1- name : " Gen: Create Spec"
2- run-name : " Create Spec: ${{ github.event.issue.title }}"
1+ name : " Gen: Create Spec / Handle Update "
2+ run-name : " ${{ contains(github.event.issue.labels.*.name, 'update') && 'Update' || ' Create Spec' }} : ${{ github.event.issue.title }}"
33
44on :
55 issues :
1919 spec_id : ${{ steps.extract_spec.outputs.spec_id }}
2020 feature_branch : ${{ steps.create_branch.outputs.feature_branch }}
2121 spec_exists : ${{ steps.check_spec.outputs.exists }}
22+ is_update : ${{ steps.check.outputs.is_update }}
23+ target_library : ${{ steps.check.outputs.target_library }}
2224
2325 permissions :
2426 contents : write
@@ -28,10 +30,13 @@ jobs:
2830 steps :
2931 - name : Check conditions
3032 id : check
33+ env :
34+ ISSUE_TITLE : ${{ github.event.issue.title }}
3135 run : |
3236 echo "=== Debug Info ==="
3337 echo "Label added: ${{ github.event.label.name }}"
3438 echo "Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}"
39+ echo "Issue title: $ISSUE_TITLE"
3540 echo "=================="
3641
3742 # Check 1: Must be "approved" label being added
@@ -49,15 +54,27 @@ jobs:
4954 exit 0
5055 fi
5156
52- # Check 3: Must NOT have "update" label (updates use existing spec)
57+ # Check 3: Detect if this is an update request
5358 HAS_UPDATE="${{ contains(github.event.issue.labels.*.name, 'update') }}"
5459 if [[ "$HAS_UPDATE" == "true" ]]; then
55- echo "::notice::Skipping: This is an update request, not a new spec"
56- echo "should_run=false" >> $GITHUB_OUTPUT
57- exit 0
60+ echo "is_update=true" >> $GITHUB_OUTPUT
61+ echo "::notice::This is an update request"
62+
63+ # Extract target library from title [update:library] or empty for all
64+ if [[ "$ISSUE_TITLE" =~ \[update:([a-z]+)\] ]]; then
65+ TARGET_LIB="${BASH_REMATCH[1]}"
66+ echo "target_library=$TARGET_LIB" >> $GITHUB_OUTPUT
67+ echo "::notice::Target library: $TARGET_LIB"
68+ else
69+ echo "target_library=" >> $GITHUB_OUTPUT
70+ echo "::notice::Target: all libraries"
71+ fi
72+ else
73+ echo "is_update=false" >> $GITHUB_OUTPUT
74+ echo "target_library=" >> $GITHUB_OUTPUT
5875 fi
5976
60- echo "::notice::All conditions met - proceeding with spec creation "
77+ echo "::notice::All conditions met - proceeding"
6178 echo "should_run=true" >> $GITHUB_OUTPUT
6279
6380 - name : Checkout repository
@@ -104,8 +121,13 @@ jobs:
104121 fi
105122
106123 # Fallback: extract from title if in brackets [spec-id]
124+ # Must be at the beginning and NOT an update marker
107125 if [ -z "$SPEC_ID" ]; then
108- SPEC_ID=$(echo "$ISSUE_TITLE" | grep -oP '\[\K[a-z0-9-]+(?=\])' | tail -1 || echo "")
126+ FIRST_BRACKET=$(echo "$ISSUE_TITLE" | grep -oP '^\[\K[a-z0-9-]+(?=\])' || echo "")
127+ # Only use if it's not an update marker
128+ if [[ -n "$FIRST_BRACKET" && ! "$FIRST_BRACKET" =~ ^update ]]; then
129+ SPEC_ID="$FIRST_BRACKET"
130+ fi
109131 fi
110132
111133 if [ -z "$SPEC_ID" ]; then
@@ -121,13 +143,19 @@ jobs:
121143 id : check_spec
122144 env :
123145 SPEC_ID : ${{ steps.extract_spec.outputs.spec_id }}
146+ IS_UPDATE : ${{ steps.check.outputs.is_update }}
124147 run : |
125148 if [ -f "specs/$SPEC_ID.md" ]; then
126149 echo "exists=true" >> $GITHUB_OUTPUT
127- echo "::notice::Spec file already exists: specs/$SPEC_ID.md"
150+ echo "::notice::Spec file exists: specs/$SPEC_ID.md"
128151 else
129152 echo "exists=false" >> $GITHUB_OUTPUT
130- echo "::notice::Spec file does not exist yet"
153+ # For updates, spec MUST exist
154+ if [[ "$IS_UPDATE" == "true" ]]; then
155+ echo "::error::Update request but spec file does not exist: specs/$SPEC_ID.md"
156+ exit 1
157+ fi
158+ echo "::notice::Spec file does not exist yet (will be created)"
131159 fi
132160
133161 - name : Check if feature branch exists
@@ -151,12 +179,21 @@ jobs:
151179 env :
152180 SPEC_ID : ${{ steps.extract_spec.outputs.spec_id }}
153181 BRANCH_EXISTS : ${{ steps.check_branch.outputs.exists }}
182+ IS_UPDATE : ${{ steps.check.outputs.is_update }}
154183 run : |
155184 BRANCH="plot/$SPEC_ID"
156185
157186 echo "feature_branch=$BRANCH" >> $GITHUB_OUTPUT
158187
159- if [[ "$BRANCH_EXISTS" == "true" ]]; then
188+ # For updates: always create fresh branch from main (old branch was deleted after merge)
189+ if [[ "$IS_UPDATE" == "true" ]]; then
190+ if [[ "$BRANCH_EXISTS" == "true" ]]; then
191+ echo "::notice::Deleting existing branch for fresh update: $BRANCH"
192+ git push origin --delete "$BRANCH" 2>/dev/null || true
193+ fi
194+ git checkout -b "$BRANCH" origin/main
195+ echo "::notice::Created fresh branch from main for update: $BRANCH"
196+ elif [[ "$BRANCH_EXISTS" == "true" ]]; then
160197 git fetch origin "$BRANCH"
161198 git checkout "$BRANCH"
162199 echo "::notice::Checked out existing branch: $BRANCH"
@@ -193,17 +230,18 @@ jobs:
193230
194231 4. Create the spec file at: `specs/${{ steps.extract_spec.outputs.spec_id }}.md`
195232 - Follow the template structure exactly
196- - Fill in all sections based on the issue description
197- - Be specific and detailed in quality criteria
198- - Include realistic use cases
233+ - Keep it simple and focused (description, data, tags, use cases)
234+ - Include example data if helpful (inline or dataset reference)
235+ - Include realistic use cases with domain context
199236
200237 5. Do NOT commit or push - just create the file
201238
202239 ### Quality Requirements
203- - All required sections must be present (Title, Description, Data Requirements)
204- - Quality criteria should be specific and measurable
240+ - All required sections: Title, Description, Data, Tags, Use Cases
241+ - Description should clearly explain what the plot visualizes
242+ - Data section should list required columns with types
205243 - Use cases should be realistic and varied
206- - The spec should be complete enough for AI to generate implementations
244+ - Keep it concise - AI uses central prompts for implementation details
207245
208246 - name : Commit and push spec file
209247 if : steps.check.outputs.should_run == 'true'
@@ -212,13 +250,20 @@ jobs:
212250 SPEC_ID : ${{ steps.extract_spec.outputs.spec_id }}
213251 BRANCH : ${{ steps.create_branch.outputs.feature_branch }}
214252 ISSUE_NUMBER : ${{ github.event.issue.number }}
253+ IS_UPDATE : ${{ steps.check.outputs.is_update }}
215254 run : |
216-
217255 # Configure git
218256 git config user.name "github-actions[bot]"
219257 git config user.email "github-actions[bot]@users.noreply.github.com"
220258
221- # Check if spec file was created
259+ # For updates, spec already exists - just push the branch
260+ if [[ "$IS_UPDATE" == "true" ]]; then
261+ git push -u origin "$BRANCH"
262+ echo "::notice::Pushed update branch: $BRANCH"
263+ exit 0
264+ fi
265+
266+ # For new specs: check if spec file was created
222267 if [ -f "specs/$SPEC_ID.md" ]; then
223268 git add "specs/$SPEC_ID.md"
224269
@@ -237,15 +282,36 @@ jobs:
237282 exit 1
238283 fi
239284
240- - name : Post comment with spec creation summary
285+ - name : Post comment with summary
241286 if : steps.check.outputs.should_run == 'true'
242287 env :
243288 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
244289 SPEC_ID : ${{ steps.extract_spec.outputs.spec_id }}
245290 BRANCH : ${{ steps.create_branch.outputs.feature_branch }}
246291 ISSUE_NUMBER : ${{ github.event.issue.number }}
292+ IS_UPDATE : ${{ steps.check.outputs.is_update }}
293+ TARGET_LIBRARY : ${{ steps.check.outputs.target_library }}
247294 run : |
248- gh issue comment "$ISSUE_NUMBER" --body "## Spec Created
295+ if [[ "$IS_UPDATE" == "true" ]]; then
296+ if [[ -n "$TARGET_LIBRARY" ]]; then
297+ SCOPE="**$TARGET_LIBRARY** only"
298+ else
299+ SCOPE="all 9 libraries"
300+ fi
301+
302+ gh issue comment "$ISSUE_NUMBER" --body "## 🔄 Update Request
303+
304+ **Spec ID:** \`$SPEC_ID\`
305+ **Branch:** \`$BRANCH\`
306+ **Scope:** $SCOPE
307+
308+ ### Next Steps
309+ Triggering code regeneration...
310+
311+ ---
312+ :robot: *[gen-create-spec workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*"
313+ else
314+ gh issue comment "$ISSUE_NUMBER" --body "## ✅ Spec Created
249315
250316 **Spec ID:** \`$SPEC_ID\`
251317 **Branch:** \`$BRANCH\`
@@ -256,6 +322,7 @@ jobs:
256322
257323 ---
258324 :robot: *[gen-create-spec workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})*"
325+ fi
259326
260327 # ============================================================================
261328 # Step 2: Trigger library generation
@@ -274,11 +341,19 @@ jobs:
274341 SPEC_ID : ${{ needs.create-spec.outputs.spec_id }}
275342 FEATURE_BRANCH : ${{ needs.create-spec.outputs.feature_branch }}
276343 ISSUE_NUMBER : ${{ github.event.issue.number }}
344+ TARGET_LIBRARY : ${{ needs.create-spec.outputs.target_library }}
277345 run : |
278- gh workflow run gen-new-plot.yml \
279- --repo ${{ github.repository }} \
280- -f spec_id="$SPEC_ID" \
281- -f feature_branch="$FEATURE_BRANCH" \
282- -f issue_number="$ISSUE_NUMBER"
346+ # Build command with optional target_library
347+ CMD="gh workflow run gen-new-plot.yml --repo ${{ github.repository }}"
348+ CMD="$CMD -f spec_id=\"$SPEC_ID\""
349+ CMD="$CMD -f feature_branch=\"$FEATURE_BRANCH\""
350+ CMD="$CMD -f issue_number=\"$ISSUE_NUMBER\""
351+
352+ if [[ -n "$TARGET_LIBRARY" ]]; then
353+ CMD="$CMD -f target_library=\"$TARGET_LIBRARY\""
354+ echo "::notice::Triggering gen-new-plot.yml for $SPEC_ID (library: $TARGET_LIBRARY)"
355+ else
356+ echo "::notice::Triggering gen-new-plot.yml for $SPEC_ID (all libraries)"
357+ fi
283358
284- echo "::notice::Triggered gen-new-plot.yml for $SPEC_ID"
359+ eval $CMD
0 commit comments