Skip to content

Commit 0ff9486

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/fairies
2 parents f92cca4 + ed5f109 commit 0ff9486

1 file changed

Lines changed: 34 additions & 26 deletions

File tree

.github/workflows/claudebox.yml

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,29 @@ jobs:
2929
repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
3030
-f content='eyes' || true
3131
32+
- name: Checkout repository
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
34+
with:
35+
sparse-checkout: .claude/scripts
36+
sparse-checkout-cone-mode: false
37+
3238
- name: Parse command
3339
id: parse
40+
env:
41+
COMMENT_BODY: ${{ github.event.comment.body }}
3442
run: |
35-
# Strip /claudebox prefix, first word = script name, rest = raw prompt
36-
BODY="${{ github.event.comment.body }}"
37-
CMD=$(echo "$BODY" | sed 's|^/claudebox[[:space:]]*||')
38-
SCRIPT_NAME=$(echo "$CMD" | awk '{print $1}')
39-
PROMPT=$(echo "$CMD" | sed "s|^$SCRIPT_NAME[[:space:]]*||")
43+
# Strip /claudebox prefix
44+
CMD=$(printf '%s' "$COMMENT_BODY" | sed 's|^/claudebox[[:space:]]*||')
45+
FIRST_WORD=$(echo "$CMD" | awk '{print $1}')
46+
47+
# If the first word matches a script, use it; otherwise use "default"
48+
if [ -f ".claude/scripts/$FIRST_WORD" ]; then
49+
SCRIPT_NAME="$FIRST_WORD"
50+
PROMPT=$(echo "$CMD" | sed "s|^$SCRIPT_NAME[[:space:]]*||")
51+
else
52+
SCRIPT_NAME="default"
53+
PROMPT="$CMD"
54+
fi
4055
4156
echo "script_name=$SCRIPT_NAME" >> "$GITHUB_OUTPUT"
4257
{
@@ -46,31 +61,17 @@ jobs:
4661
} >> "$GITHUB_OUTPUT"
4762
echo "Parsed: script=$SCRIPT_NAME prompt=$PROMPT"
4863
49-
- name: Checkout repository
50-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
51-
with:
52-
sparse-checkout: .claude/scripts
53-
sparse-checkout-cone-mode: false
54-
55-
- name: Validate script exists
56-
run: |
57-
SCRIPT=".claude/scripts/${{ steps.parse.outputs.script_name }}"
58-
if [ ! -f "$SCRIPT" ]; then
59-
echo "ERROR: Script not found: $SCRIPT"
60-
echo "Available scripts:"
61-
ls .claude/scripts/ | grep -v '\.py$' || echo " (none)"
62-
exit 1
63-
fi
64-
echo "Script validated: $SCRIPT"
65-
6664
- name: Post status comment
6765
id: status_comment
6866
env:
6967
GH_TOKEN: ${{ secrets.AZTEC_BOT_GITHUB_TOKEN }}
68+
SCRIPT_NAME: ${{ steps.parse.outputs.script_name }}
69+
PROMPT_TEXT: ${{ steps.parse.outputs.prompt }}
7070
run: |
7171
ISSUE_NUM="${{ github.event.issue.number }}"
7272
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
73-
BODY="**ClaudeBox** is running \`${{ steps.parse.outputs.script_name }}\`... [workflow run]($RUN_URL)"
73+
SHORT_PROMPT=$(printf '%.120s' "$PROMPT_TEXT")
74+
BODY="**ClaudeBox** \`${SCRIPT_NAME}\`: _${SHORT_PROMPT}_ ... [workflow run]($RUN_URL)"
7475
7576
COMMENT_ID=$(gh api \
7677
repos/${{ github.repository }}/issues/$ISSUE_NUM/comments \
@@ -91,9 +92,16 @@ jobs:
9192
env:
9293
CLAUDEBOX_HOST: ${{ vars.CLAUDEBOX_HOST }}
9394
CLAUDEBOX_USER: ${{ vars.CLAUDEBOX_USER || 'claude' }}
95+
CLAUDEBOX_PROMPT: ${{ steps.parse.outputs.prompt }}
96+
CLAUDEBOX_SCRIPT: ${{ steps.parse.outputs.script_name }}
97+
COMMENT_ID: ${{ github.event.comment.id }}
98+
RUN_COMMENT_ID: ${{ steps.status_comment.outputs.run_comment_id }}
99+
REPO: ${{ github.repository }}
100+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
101+
ISSUE_NUM: ${{ github.event.issue.number }}
102+
AUTHOR: ${{ github.event.comment.user.login }}
94103
run: |
95-
# Pipe prompt via stdin to avoid quoting issues
96-
echo '${{ steps.parse.outputs.prompt }}' | \
104+
printf '%s' "$CLAUDEBOX_PROMPT" | \
97105
ssh -o ConnectTimeout=10 -o ServerAliveInterval=30 \
98106
"${CLAUDEBOX_USER}@${CLAUDEBOX_HOST}" \
99-
"~/claudeentry.sh '${{ steps.parse.outputs.script_name }}' --comment-id=${{ github.event.comment.id }} --run-comment-id=${{ steps.status_comment.outputs.run_comment_id }} --repo=${{ github.repository }}"
107+
"~/claudeentry.sh '${CLAUDEBOX_SCRIPT}' --comment-id=${COMMENT_ID} --run-comment-id=${RUN_COMMENT_ID} --repo=${REPO} --run-url=${RUN_URL} --user=${AUTHOR}"

0 commit comments

Comments
 (0)