spets 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,248 +0,0 @@
1
- # Spets GitHub Action
2
- # Handles workflow start from Issue creation and commands from comments
3
-
4
- name: Spets Workflow
5
-
6
- on:
7
- issues:
8
- types: [opened, closed]
9
- issue_comment:
10
- types: [created]
11
- pull_request:
12
- types: [closed]
13
-
14
- permissions:
15
- contents: write
16
- issues: write
17
- pull-requests: write
18
-
19
- jobs:
20
- # Start workflow when a spets Issue is created
21
- start-workflow:
22
- if: github.event.action == 'opened' && contains(github.event.issue.labels.*.name, 'spets')
23
- runs-on: ubuntu-latest
24
-
25
- steps:
26
- - name: Checkout
27
- uses: actions/checkout@v4
28
- with:
29
- fetch-depth: 1
30
- persist-credentials: false
31
-
32
- - name: Parse Issue body
33
- id: parse
34
- env:
35
- ISSUE_BODY: ${{ github.event.issue.body }}
36
- ISSUE_NUMBER: ${{ github.event.issue.number }}
37
- run: |
38
- # Parse requirements (multi-line support)
39
- TASK=$(echo "$ISSUE_BODY" | sed -n '/### Requirements/,/###/{/###/!p;}' | sed '/^$/d')
40
- echo "task<<EOF" >> $GITHUB_OUTPUT
41
- echo "$TASK" >> $GITHUB_OUTPUT
42
- echo "EOF" >> $GITHUB_OUTPUT
43
-
44
- # Parse branch name (optional)
45
- BRANCH=$(echo "$ISSUE_BODY" | sed -n '/### Branch Name/,/###/{/###/!p;}' | sed '/^$/d' | head -1)
46
- if [ -z "$BRANCH" ]; then
47
- BRANCH="spets/$ISSUE_NUMBER"
48
- fi
49
- echo "branch=$BRANCH" >> $GITHUB_OUTPUT
50
-
51
- - name: Create and checkout branch
52
- run: |
53
- git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
54
- git checkout -b ${{ steps.parse.outputs.branch }}
55
- git push -u origin ${{ steps.parse.outputs.branch }}
56
-
57
- - name: Setup Node.js
58
- uses: actions/setup-node@v4
59
- with:
60
- node-version: '20'
61
-
62
- - name: Cache Claude Code & Spets
63
- uses: actions/cache@v4
64
- with:
65
- path: |
66
- /usr/local/lib/node_modules/@anthropic-ai/claude-code
67
- /usr/local/lib/node_modules/spets
68
- key: spets-tools-${{ runner.os }}-v1
69
-
70
- - name: Install Claude Code & Spets
71
- run: npm install -g @anthropic-ai/claude-code spets
72
-
73
- - name: Start Spets workflow
74
- run: |
75
- spets start "$TASK" --github --issue ${{ github.event.issue.number }}
76
- env:
77
- TASK: ${{ steps.parse.outputs.task }}
78
- CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
79
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80
-
81
- - name: Push changes
82
- run: |
83
- git config user.name "github-actions[bot]"
84
- git config user.email "github-actions[bot]@users.noreply.github.com"
85
- git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
86
- git add -A
87
- git diff --staged --quiet || git commit -m "Spets: Start workflow for #${{ github.event.issue.number }}"
88
- git push
89
-
90
- # Handle commands from Issue/PR comments
91
- handle-command:
92
- if: |
93
- github.event.action == 'created' && (
94
- contains(github.event.comment.body, '/approve') ||
95
- contains(github.event.comment.body, '/revise') ||
96
- contains(github.event.comment.body, '/reject') ||
97
- contains(github.event.comment.body, '/answer') ||
98
- contains(github.event.comment.body, '/decide')
99
- )
100
- runs-on: ubuntu-latest
101
-
102
- steps:
103
- - name: Find branch from Issue or PR
104
- id: branch
105
- env:
106
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107
- run: |
108
- # Check if this is a PR (has pull_request field)
109
- PR_BRANCH=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.pull_request.url // empty' 2>/dev/null)
110
-
111
- if [ -n "$PR_BRANCH" ]; then
112
- # It's a PR - get head branch directly
113
- BRANCH=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.issue.number }} --jq '.head.ref')
114
- echo "Found PR head branch: $BRANCH"
115
- else
116
- # It's an Issue - try to parse branch name from body
117
- ISSUE_BODY=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.body')
118
- CUSTOM_BRANCH=$(echo "$ISSUE_BODY" | sed -n '/### Branch Name/,/###/{/###/!p;}' | sed '/^$/d' | head -1)
119
-
120
- if [ -n "$CUSTOM_BRANCH" ]; then
121
- BRANCH="$CUSTOM_BRANCH"
122
- else
123
- BRANCH="spets/${{ github.event.issue.number }}"
124
- fi
125
- fi
126
-
127
- echo "Checking for branch: $BRANCH"
128
-
129
- # Check if branch exists on remote using gh api
130
- if gh api "repos/${{ github.repository }}/branches/$BRANCH" --silent 2>/dev/null; then
131
- echo "name=$BRANCH" >> $GITHUB_OUTPUT
132
- echo "exists=true" >> $GITHUB_OUTPUT
133
- echo "Branch $BRANCH found!"
134
- else
135
- echo "exists=false" >> $GITHUB_OUTPUT
136
- echo "expected=$BRANCH" >> $GITHUB_OUTPUT
137
- echo "::error::Branch $BRANCH not found. Start workflow first by creating an Issue with 'spets' label."
138
- fi
139
-
140
- - name: Post error comment
141
- if: steps.branch.outputs.exists == 'false'
142
- run: |
143
- gh issue comment ${{ github.event.issue.number }} \
144
- -R "${{ github.repository }}" \
145
- --body "❌ **Spets Error**: Branch \`${{ steps.branch.outputs.expected }}\` not found.
146
-
147
- Please make sure the workflow was started properly. You can:
148
- 1. Add the \`spets\` label to this issue to trigger the start workflow
149
- 2. Or manually create the branch and run \`spets start\`"
150
- env:
151
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152
-
153
- - name: Exit if branch not found
154
- if: steps.branch.outputs.exists == 'false'
155
- run: exit 1
156
-
157
- - name: Checkout
158
- uses: actions/checkout@v4
159
- with:
160
- ref: ${{ steps.branch.outputs.name }}
161
- fetch-depth: 1
162
- persist-credentials: false
163
-
164
- - name: Setup Node.js
165
- uses: actions/setup-node@v4
166
- with:
167
- node-version: '20'
168
-
169
- - name: Cache Claude Code & Spets
170
- uses: actions/cache@v4
171
- with:
172
- path: |
173
- /usr/local/lib/node_modules/@anthropic-ai/claude-code
174
- /usr/local/lib/node_modules/spets
175
- key: spets-tools-${{ runner.os }}-v1
176
-
177
- - name: Install Claude Code & Spets
178
- run: npm install -g @anthropic-ai/claude-code spets
179
-
180
- - name: Run Spets command
181
- run: |
182
- spets github --issue ${{ github.event.issue.number }} --comment "$COMMENT"
183
- env:
184
- COMMENT: ${{ github.event.comment.body }}
185
- CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
186
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187
-
188
- - name: Push changes
189
- run: |
190
- git config user.name "$COMMENT_AUTHOR"
191
- git config user.email "$COMMENT_AUTHOR@users.noreply.github.com"
192
- git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
193
- git add -A
194
- git diff --staged --quiet || git commit -m "Spets: Update from #${{ github.event.issue.number }}"
195
- git push
196
- env:
197
- COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
198
-
199
- # Cleanup branch when Issue is closed
200
- cleanup-branch-on-issue-close:
201
- if: github.event.action == 'closed' && github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'spets')
202
- runs-on: ubuntu-latest
203
-
204
- steps:
205
- - name: Find and delete branch
206
- env:
207
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
208
- run: |
209
- # Parse branch name from Issue body (same logic as start-workflow)
210
- ISSUE_BODY=$(gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }} --jq '.body')
211
- CUSTOM_BRANCH=$(echo "$ISSUE_BODY" | sed -n '/### Branch Name/,/###/{/###/!p;}' | sed '/^$/d' | head -1)
212
-
213
- if [ -n "$CUSTOM_BRANCH" ]; then
214
- BRANCH="$CUSTOM_BRANCH"
215
- else
216
- BRANCH="spets/${{ github.event.issue.number }}"
217
- fi
218
-
219
- echo "Attempting to delete branch: $BRANCH"
220
-
221
- # Delete branch if it exists (ignore errors if already deleted)
222
- if gh api "repos/${{ github.repository }}/branches/$BRANCH" --silent 2>/dev/null; then
223
- gh api -X DELETE "repos/${{ github.repository }}/git/refs/heads/$BRANCH" || echo "Branch already deleted or protected"
224
- echo "Branch $BRANCH deleted"
225
- else
226
- echo "Branch $BRANCH not found, skipping"
227
- fi
228
-
229
- # Cleanup branch when PR is merged
230
- cleanup-branch-on-pr-merge:
231
- if: github.event.action == 'closed' && github.event_name == 'pull_request' && github.event.pull_request.merged == true
232
- runs-on: ubuntu-latest
233
-
234
- steps:
235
- - name: Delete merged branch
236
- env:
237
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
238
- run: |
239
- BRANCH="${{ github.event.pull_request.head.ref }}"
240
- echo "Attempting to delete merged branch: $BRANCH"
241
-
242
- # Delete branch if it exists (ignore errors if already deleted)
243
- if gh api "repos/${{ github.repository }}/branches/$BRANCH" --silent 2>/dev/null; then
244
- gh api -X DELETE "repos/${{ github.repository }}/git/refs/heads/$BRANCH" || echo "Branch already deleted or protected"
245
- echo "Branch $BRANCH deleted"
246
- else
247
- echo "Branch $BRANCH not found, skipping"
248
- fi
@@ -1,37 +0,0 @@
1
- #!/bin/bash
2
- # Cleanup branch after workflow completion/rejection
3
- # This hook is called when a workflow completes or is rejected
4
-
5
- set -e
6
-
7
- BRANCH="${SPETS_BRANCH}"
8
-
9
- if [ -z "$BRANCH" ]; then
10
- echo "No branch to cleanup"
11
- exit 0
12
- fi
13
-
14
- # Skip if on protected branches
15
- if [[ "$BRANCH" == "main" || "$BRANCH" == "master" || "$BRANCH" == "develop" ]]; then
16
- echo "Skipping cleanup of protected branch: $BRANCH"
17
- exit 0
18
- fi
19
-
20
- echo "Cleaning up branch: $BRANCH"
21
-
22
- # Switch to main/master before deleting
23
- git checkout main 2>/dev/null || git checkout master 2>/dev/null || {
24
- echo "Warning: Could not switch to main/master branch"
25
- }
26
-
27
- # Delete local branch
28
- git branch -D "$BRANCH" 2>/dev/null || {
29
- echo "Warning: Could not delete local branch $BRANCH"
30
- }
31
-
32
- # Delete remote branch (optional - uncomment if needed)
33
- # git push origin --delete "$BRANCH" 2>/dev/null || {
34
- # echo "Warning: Could not delete remote branch $BRANCH"
35
- # }
36
-
37
- echo "Branch cleanup completed"