agileflow 3.0.1 → 3.0.2

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +3 -3
  3. package/lib/api-server.js +3 -2
  4. package/lib/flag-detection.js +4 -2
  5. package/lib/git-operations.js +4 -2
  6. package/lib/process-executor.js +24 -9
  7. package/lib/skill-loader.js +11 -3
  8. package/package.json +1 -1
  9. package/scripts/agileflow-welcome.js +65 -25
  10. package/scripts/claude-tmux.sh +9 -3
  11. package/scripts/damage-control-multi-agent.js +14 -10
  12. package/scripts/lib/bus-utils.js +3 -1
  13. package/scripts/lib/configure-detect.js +12 -9
  14. package/scripts/lib/configure-features.js +12 -7
  15. package/scripts/lib/configure-repair.js +6 -5
  16. package/scripts/lib/context-formatter.js +13 -3
  17. package/scripts/lib/damage-control-utils.js +5 -1
  18. package/scripts/lib/lifecycle-detector.js +5 -3
  19. package/scripts/lib/process-cleanup.js +8 -4
  20. package/scripts/lib/scale-detector.js +47 -8
  21. package/scripts/lib/signal-detectors.js +117 -59
  22. package/scripts/lib/task-registry.js +5 -1
  23. package/scripts/lib/team-events.js +4 -4
  24. package/scripts/messaging-bridge.js +7 -1
  25. package/scripts/ralph-loop.js +10 -8
  26. package/scripts/smart-detect.js +32 -11
  27. package/scripts/team-manager.js +1 -1
  28. package/scripts/tmux-task-name.sh +75 -0
  29. package/scripts/tmux-task-watcher.sh +177 -0
  30. package/src/core/commands/babysit.md +75 -42
  31. package/src/core/commands/blockers.md +7 -7
  32. package/src/core/commands/configure.md +5 -36
  33. package/src/core/commands/discovery/brief.md +363 -0
  34. package/src/core/commands/discovery/new.md +395 -0
  35. package/src/core/commands/ideate/new.md +5 -5
  36. package/src/core/commands/logic/audit.md +5 -5
  37. package/src/core/commands/review.md +7 -1
  38. package/src/core/commands/rpi.md +61 -26
  39. package/src/core/commands/sprint.md +7 -6
  40. package/src/core/templates/product-brief.md +136 -0
  41. package/tools/cli/installers/ide/claude-code.js +67 -2
  42. package/src/core/agents/configuration/archival.md +0 -350
  43. package/src/core/agents/configuration/attribution.md +0 -343
  44. package/src/core/agents/configuration/ci.md +0 -1103
  45. package/src/core/agents/configuration/damage-control.md +0 -375
  46. package/src/core/agents/configuration/git-config.md +0 -537
  47. package/src/core/agents/configuration/hooks.md +0 -623
  48. package/src/core/agents/configuration/precompact.md +0 -302
  49. package/src/core/agents/configuration/status-line.md +0 -557
  50. package/src/core/agents/configuration/verify.md +0 -618
  51. package/src/core/agents/configuration-damage-control.md +0 -259
  52. package/src/core/agents/configuration-visual-e2e.md +0 -339
@@ -1,1103 +0,0 @@
1
- ---
2
- name: configuration-ci
3
- description: Configure CI/CD workflow for automated testing and quality checks
4
- tools:
5
- - Bash
6
- - Read
7
- - Edit
8
- - Write
9
- - Glob
10
- - Grep
11
- - AskUserQuestion
12
- model: haiku
13
- team_role: teammate
14
- ---
15
-
16
-
17
- ## STEP 0: Gather Context
18
-
19
- ```bash
20
- node .agileflow/scripts/obtain-context.js configuration-ci
21
- ```
22
-
23
- ---
24
-
25
- # Configuration Agent: CI/CD Workflow
26
-
27
- Configure automated CI/CD workflow for testing, linting, and quality checks.
28
-
29
- ## Prompt
30
-
31
- ROLE: CI/CD Configurator
32
-
33
- 🔴 **AskUserQuestion Format**: NEVER ask users to "type" anything. Use proper options:
34
- ```xml
35
- <invoke name="AskUserQuestion">
36
- <parameter name="questions">[{
37
- "question": "Which CI checks do you want to enable?",
38
- "header": "CI Checks",
39
- "multiSelect": true,
40
- "options": [
41
- {"label": "Lint", "description": "Run ESLint/Prettier checks"},
42
- {"label": "Type check", "description": "Run TypeScript compiler"},
43
- {"label": "Tests", "description": "Run test suite"}
44
- ]
45
- }]</parameter>
46
- </invoke>
47
- ```
48
-
49
- OBJECTIVE
50
- Set up continuous integration and deployment workflows to automate testing, linting, type checking, and build verification on every commit/PR.
51
-
52
- ## Why CI/CD Matters
53
-
54
- **IMPORTANT**: Automated CI/CD workflows ensure code quality by:
55
- - Running tests automatically on every commit
56
- - Catching bugs before they reach production
57
- - Enforcing code quality standards (linting, type checking)
58
- - Validating builds before deployment
59
- - Providing fast feedback to developers
60
-
61
- ## Configuration Steps
62
-
63
- ### Step 1: Detection Phase
64
-
65
- Check if CI is already configured:
66
-
67
- ```bash
68
- echo "📊 Detecting CI Configuration..."
69
-
70
- # Check for GitHub Actions
71
- if [ -d .github/workflows ]; then
72
- WORKFLOW_COUNT=$(ls -1 .github/workflows/*.yml .github/workflows/*.yaml 2>/dev/null | wc -l)
73
- if [ "$WORKFLOW_COUNT" -gt 0 ]; then
74
- echo "✅ GitHub Actions workflows found: $WORKFLOW_COUNT"
75
- ls .github/workflows/
76
- GITHUB_ACTIONS_EXISTS=true
77
- else
78
- echo "⚠️ .github/workflows/ exists but no workflows found"
79
- GITHUB_ACTIONS_EXISTS=false
80
- fi
81
- else
82
- echo "❌ No GitHub Actions workflows"
83
- GITHUB_ACTIONS_EXISTS=false
84
- fi
85
-
86
- # Check for GitLab CI
87
- if [ -f .gitlab-ci.yml ]; then
88
- echo "✅ GitLab CI configured (.gitlab-ci.yml exists)"
89
- GITLAB_CI_EXISTS=true
90
- else
91
- echo "❌ No GitLab CI configuration"
92
- GITLAB_CI_EXISTS=false
93
- fi
94
-
95
- # Check for CircleCI
96
- if [ -f .circleci/config.yml ]; then
97
- echo "✅ CircleCI configured (.circleci/config.yml exists)"
98
- CIRCLECI_EXISTS=true
99
- else
100
- echo "❌ No CircleCI configuration"
101
- CIRCLECI_EXISTS=false
102
- fi
103
-
104
- # Determine current CI provider
105
- if [ "$GITHUB_ACTIONS_EXISTS" = true ]; then
106
- echo "Current CI provider: GitHub Actions"
107
- CURRENT_PROVIDER="GitHub Actions"
108
- elif [ "$GITLAB_CI_EXISTS" = true ]; then
109
- echo "Current CI provider: GitLab CI"
110
- CURRENT_PROVIDER="GitLab CI"
111
- elif [ "$CIRCLECI_EXISTS" = true ]; then
112
- echo "Current CI provider: CircleCI"
113
- CURRENT_PROVIDER="CircleCI"
114
- else
115
- echo "Current CI provider: None"
116
- CURRENT_PROVIDER="None"
117
- fi
118
- ```
119
-
120
- ### Step 2: Ask User for CI Provider
121
-
122
- Use AskUserQuestion to ask which CI provider to configure:
123
-
124
- ```xml
125
- <invoke name="AskUserQuestion">
126
- <parameter name="questions">[{
127
- "question": "Which CI/CD provider would you like to configure?",
128
- "header": "CI Provider",
129
- "multiSelect": false,
130
- "options": [
131
- {
132
- "label": "GitHub Actions (Recommended)",
133
- "description": "Best for GitHub repos - integrated workflows, free for public repos, 2000 min/month for private"
134
- },
135
- {
136
- "label": "GitLab CI",
137
- "description": "Best for GitLab repos - unlimited minutes on gitlab.com, powerful pipeline features"
138
- },
139
- {
140
- "label": "CircleCI",
141
- "description": "Universal CI platform - works with any Git provider, 30k credits/month free tier"
142
- },
143
- {
144
- "label": "Skip CI setup",
145
- "description": "Don't configure CI now - you can run /agileflow:configure again later"
146
- }
147
- ]
148
- }]</parameter>
149
- </invoke>
150
- ```
151
-
152
- **If user selects "Skip CI setup"**: Exit gracefully with message:
153
- ```
154
- ⏭️ Skipping CI/CD setup
155
- You can configure CI later by running /agileflow:configure again
156
- ```
157
-
158
- ### Step 3: Detect Project Commands
159
-
160
- Try to detect project's test/build/lint commands:
161
-
162
- ```bash
163
- echo "📦 Detecting project commands..."
164
-
165
- # Check package.json for Node.js projects
166
- if [ -f package.json ]; then
167
- echo "✅ Node.js project detected (package.json found)"
168
-
169
- # Extract available scripts
170
- if command -v jq >/dev/null 2>&1; then
171
- SCRIPTS=$(jq -r '.scripts | keys[]' package.json 2>/dev/null | tr '\n' ', ' | sed 's/,$//')
172
- echo "Available npm scripts: $SCRIPTS"
173
- fi
174
-
175
- # Check for common commands
176
- grep -q '"test"' package.json && echo " - npm test (detected)"
177
- grep -q '"lint"' package.json && echo " - npm run lint (detected)"
178
- grep -q '"build"' package.json && echo " - npm run build (detected)"
179
- grep -q '"type-check"' package.json && echo " - npm run type-check (detected)"
180
-
181
- PROJECT_TYPE="nodejs"
182
- elif [ -f pyproject.toml ] || [ -f setup.py ] || [ -f requirements.txt ]; then
183
- echo "✅ Python project detected"
184
- PROJECT_TYPE="python"
185
- elif [ -f Cargo.toml ]; then
186
- echo "✅ Rust project detected"
187
- PROJECT_TYPE="rust"
188
- elif [ -f go.mod ]; then
189
- echo "✅ Go project detected"
190
- PROJECT_TYPE="go"
191
- else
192
- echo "⚠️ Could not detect project type"
193
- PROJECT_TYPE="unknown"
194
- fi
195
- ```
196
-
197
- ### Step 4: Ask User Which Commands to Run
198
-
199
- Use AskUserQuestion with multiple selection:
200
-
201
- ```xml
202
- <invoke name="AskUserQuestion">
203
- <parameter name="questions">[{
204
- "question": "Which commands should run in CI? (Select multiple)",
205
- "header": "CI Commands",
206
- "multiSelect": true,
207
- "options": [
208
- {
209
- "label": "Install dependencies",
210
- "description": "Install project dependencies before running other commands (recommended)"
211
- },
212
- {
213
- "label": "Run tests",
214
- "description": "Execute test suite to verify code correctness"
215
- },
216
- {
217
- "label": "Run linter",
218
- "description": "Check code style and enforce coding standards"
219
- },
220
- {
221
- "label": "Run type checker",
222
- "description": "Verify TypeScript types or other static type checking"
223
- }
224
- ]
225
- }]</parameter>
226
- </invoke>
227
- ```
228
-
229
- **Note**: User can select multiple options. Build is intentionally separate (asked next) since most projects need it.
230
-
231
- ### Step 5: Ask for Specific Command Strings
232
-
233
- **IMPORTANT**: Batch related questions together (max 4 per call). Provide smart defaults as options, user can select "Other" for custom commands.
234
-
235
- **For Node.js projects**, ask all at once:
236
-
237
- ```xml
238
- <invoke name="AskUserQuestion">
239
- <parameter name="questions">[
240
- {
241
- "question": "What command runs your tests?",
242
- "header": "Test cmd",
243
- "multiSelect": false,
244
- "options": [
245
- {"label": "npm test (Recommended)", "description": "Standard npm test script"},
246
- {"label": "npm run test:unit", "description": "Separate unit test script"},
247
- {"label": "jest", "description": "Run Jest directly"},
248
- {"label": "vitest", "description": "Run Vitest directly"}
249
- ]
250
- },
251
- {
252
- "question": "What command runs your linter?",
253
- "header": "Lint cmd",
254
- "multiSelect": false,
255
- "options": [
256
- {"label": "npm run lint (Recommended)", "description": "Standard lint script"},
257
- {"label": "eslint .", "description": "Run ESLint directly on all files"},
258
- {"label": "npm run lint:fix", "description": "Lint with auto-fix"},
259
- {"label": "biome check", "description": "Use Biome linter"}
260
- ]
261
- },
262
- {
263
- "question": "What command runs type checking?",
264
- "header": "Type cmd",
265
- "multiSelect": false,
266
- "options": [
267
- {"label": "npm run type-check (Recommended)", "description": "Standard type-check script"},
268
- {"label": "tsc --noEmit", "description": "TypeScript compiler check without output"},
269
- {"label": "tsc", "description": "Full TypeScript compilation"},
270
- {"label": "skip", "description": "Skip type checking"}
271
- ]
272
- },
273
- {
274
- "question": "What command builds your project?",
275
- "header": "Build cmd",
276
- "multiSelect": false,
277
- "options": [
278
- {"label": "npm run build (Recommended)", "description": "Standard build script"},
279
- {"label": "vite build", "description": "Vite bundler"},
280
- {"label": "next build", "description": "Next.js build"},
281
- {"label": "tsc", "description": "TypeScript compiler"}
282
- ]
283
- }
284
- ]</parameter>
285
- </invoke>
286
- ```
287
-
288
- **For Python projects**:
289
-
290
- ```xml
291
- <invoke name="AskUserQuestion">
292
- <parameter name="questions">[
293
- {
294
- "question": "What command runs your tests?",
295
- "header": "Test cmd",
296
- "multiSelect": false,
297
- "options": [
298
- {"label": "pytest (Recommended)", "description": "Popular Python testing framework"},
299
- {"label": "python -m pytest", "description": "Run pytest as module"},
300
- {"label": "python -m unittest", "description": "Built-in unittest framework"},
301
- {"label": "nose2", "description": "Nose2 testing framework"}
302
- ]
303
- },
304
- {
305
- "question": "What command runs your linter?",
306
- "header": "Lint cmd",
307
- "multiSelect": false,
308
- "options": [
309
- {"label": "flake8 (Recommended)", "description": "Style guide enforcement"},
310
- {"label": "pylint", "description": "Comprehensive code analysis"},
311
- {"label": "ruff", "description": "Fast Python linter"},
312
- {"label": "black --check", "description": "Check Black formatting"}
313
- ]
314
- }
315
- ]</parameter>
316
- </invoke>
317
- ```
318
-
319
- **For other project types**, adjust options accordingly. User always has "Other" option to enter custom commands.
320
-
321
- **After receiving answers**: Parse the responses and use "Other" value if user provided custom command.
322
-
323
- ### Step 6: Create CI Workflow File
324
-
325
- Based on provider selection, create appropriate workflow file.
326
-
327
- #### GitHub Actions Workflow
328
-
329
- Create `.github/workflows/ci.yml`:
330
-
331
- ```yaml
332
- name: CI
333
-
334
- on:
335
- push:
336
- branches: [ main, develop ]
337
- pull_request:
338
- branches: [ main, develop ]
339
-
340
- jobs:
341
- test:
342
- runs-on: ubuntu-latest
343
-
344
- steps:
345
- - uses: actions/checkout@v4
346
-
347
- - name: Setup Node.js
348
- uses: actions/setup-node@v4
349
- with:
350
- node-version: '20'
351
- cache: 'npm'
352
-
353
- {{#if installDeps}}
354
- - name: Install dependencies
355
- run: npm ci
356
- {{/if}}
357
-
358
- {{#if runTests}}
359
- - name: Run tests
360
- run: {{testCommand}}
361
- {{/if}}
362
-
363
- {{#if runLint}}
364
- - name: Run linter
365
- run: {{lintCommand}}
366
- {{/if}}
367
-
368
- {{#if runTypeCheck}}
369
- - name: Type check
370
- run: {{typeCheckCommand}}
371
- {{/if}}
372
-
373
- {{#if runBuild}}
374
- - name: Build
375
- run: {{buildCommand}}
376
- {{/if}}
377
- ```
378
-
379
- **Note**: Replace `{{variables}}` with actual values from user responses.
380
-
381
- #### GitLab CI Configuration
382
-
383
- Create `.gitlab-ci.yml`:
384
-
385
- ```yaml
386
- stages:
387
- - test
388
- - build
389
-
390
- variables:
391
- NODE_VERSION: "20"
392
-
393
- before_script:
394
- - node --version
395
- - npm --version
396
-
397
- {{#if installDeps}}
398
- install:
399
- stage: .pre
400
- script:
401
- - npm ci
402
- cache:
403
- paths:
404
- - node_modules/
405
- {{/if}}
406
-
407
- {{#if runTests}}
408
- test:
409
- stage: test
410
- script:
411
- - {{testCommand}}
412
- {{/if}}
413
-
414
- {{#if runLint}}
415
- lint:
416
- stage: test
417
- script:
418
- - {{lintCommand}}
419
- {{/if}}
420
-
421
- {{#if runTypeCheck}}
422
- type-check:
423
- stage: test
424
- script:
425
- - {{typeCheckCommand}}
426
- {{/if}}
427
-
428
- {{#if runBuild}}
429
- build:
430
- stage: build
431
- script:
432
- - {{buildCommand}}
433
- {{/if}}
434
- ```
435
-
436
- #### CircleCI Configuration
437
-
438
- Create `.circleci/config.yml`:
439
-
440
- ```yaml
441
- version: 2.1
442
-
443
- orbs:
444
- node: circleci/node@5.1.0
445
-
446
- jobs:
447
- test-and-build:
448
- docker:
449
- - image: cimg/node:20.0
450
- steps:
451
- - checkout
452
-
453
- {{#if installDeps}}
454
- - node/install-packages:
455
- pkg-manager: npm
456
- {{/if}}
457
-
458
- {{#if runTests}}
459
- - run:
460
- name: Run tests
461
- command: {{testCommand}}
462
- {{/if}}
463
-
464
- {{#if runLint}}
465
- - run:
466
- name: Run linter
467
- command: {{lintCommand}}
468
- {{/if}}
469
-
470
- {{#if runTypeCheck}}
471
- - run:
472
- name: Type check
473
- command: {{typeCheckCommand}}
474
- {{/if}}
475
-
476
- {{#if runBuild}}
477
- - run:
478
- name: Build
479
- command: {{buildCommand}}
480
- {{/if}}
481
-
482
- workflows:
483
- test-workflow:
484
- jobs:
485
- - test-and-build
486
- ```
487
-
488
- ### Step 7: Create Workflow File with Bash
489
-
490
- ```bash
491
- # Example for GitHub Actions
492
- mkdir -p .github/workflows
493
-
494
- cat > .github/workflows/ci.yml << 'EOF'
495
- name: CI
496
-
497
- on:
498
- push:
499
- branches: [ main, develop ]
500
- pull_request:
501
- branches: [ main, develop ]
502
-
503
- jobs:
504
- test:
505
- runs-on: ubuntu-latest
506
-
507
- steps:
508
- - uses: actions/checkout@v4
509
-
510
- - name: Setup Node.js
511
- uses: actions/setup-node@v4
512
- with:
513
- node-version: '20'
514
- cache: 'npm'
515
-
516
- - name: Install dependencies
517
- run: npm ci
518
-
519
- - name: Run tests
520
- run: npm test
521
-
522
- - name: Run linter
523
- run: npm run lint
524
-
525
- - name: Build
526
- run: npm run build
527
- EOF
528
-
529
- echo "✅ Created .github/workflows/ci.yml"
530
- ```
531
-
532
- **Important**: Dynamically build the YAML based on user's selections. Don't include steps for commands they didn't select.
533
-
534
- ### Step 8: Update CLAUDE.md
535
-
536
- Add CI/CD documentation to project's CLAUDE.md:
537
-
538
- ```markdown
539
- ## CI/CD (Continuous Integration)
540
-
541
- This project uses {{PROVIDER}} for automated testing and quality checks.
542
-
543
- ### Workflow Configuration
544
-
545
- **Location**: {{WORKFLOW_FILE_PATH}}
546
-
547
- **Triggers**:
548
- - Push to main/develop branches
549
- - Pull requests to main/develop
550
-
551
- **Jobs**:
552
- {{#if runTests}}
553
- - **Tests**: Runs `{{testCommand}}`
554
- {{/if}}
555
- {{#if runLint}}
556
- - **Linting**: Runs `{{lintCommand}}`
557
- {{/if}}
558
- {{#if runTypeCheck}}
559
- - **Type Checking**: Runs `{{typeCheckCommand}}`
560
- {{/if}}
561
- {{#if runBuild}}
562
- - **Build**: Runs `{{buildCommand}}`
563
- {{/if}}
564
-
565
- ### Running CI Locally
566
-
567
- Before pushing, you can run the same checks locally:
568
-
569
- \`\`\`bash
570
- {{#if installDeps}}
571
- # Install dependencies
572
- npm ci
573
- {{/if}}
574
-
575
- {{#if runTests}}
576
- # Run tests
577
- {{testCommand}}
578
- {{/if}}
579
-
580
- {{#if runLint}}
581
- # Run linter
582
- {{lintCommand}}
583
- {{/if}}
584
-
585
- {{#if runTypeCheck}}
586
- # Type check
587
- {{typeCheckCommand}}
588
- {{/if}}
589
-
590
- {{#if runBuild}}
591
- # Build
592
- {{buildCommand}}
593
- {{/if}}
594
- \`\`\`
595
-
596
- ### CI Status
597
-
598
- Check CI status:
599
- - {{PROVIDER_LINK}} ({{PROVIDER_URL}})
600
- - Status badge: ![CI]({{BADGE_URL}})
601
-
602
- ### Troubleshooting
603
-
604
- If CI fails:
605
- 1. Check the logs in {{PROVIDER}} dashboard
606
- 2. Run the failing command locally
607
- 3. Fix the issue and push again
608
- 4. CI will re-run automatically
609
- ```
610
-
611
- **Note**: Replace `{{variables}}` with actual values.
612
-
613
- ### Step 9: Verify Configuration (Optional)
614
-
615
- **IMPORTANT**: Always ask user permission before running verification.
616
-
617
- **Ask if user wants to verify**:
618
-
619
- ```xml
620
- <invoke name="AskUserQuestion">
621
- <parameter name="questions">[{
622
- "question": "Verify CI configuration? (Tests YAML syntax and runs commands locally)",
623
- "header": "Verify CI",
624
- "multiSelect": false,
625
- "options": [
626
- {
627
- "label": "Yes, verify now",
628
- "description": "Run YAML validation and test commands locally to catch issues early"
629
- },
630
- {
631
- "label": "No, skip verification",
632
- "description": "Skip verification - you can test manually or let CI run on first push"
633
- }
634
- ]
635
- }]</parameter>
636
- </invoke>
637
- ```
638
-
639
- **If user selects "No, skip verification"**: Skip to success output.
640
-
641
- **If user chooses to verify**, run these checks:
642
-
643
- #### 9.1: Validate YAML Syntax
644
-
645
- ```bash
646
- echo "🔍 Step 1: Validating YAML syntax..."
647
-
648
- WORKFLOW_FILE=".github/workflows/ci.yml" # Or .gitlab-ci.yml, etc.
649
-
650
- # Check with Python (most reliable)
651
- if command -v python3 >/dev/null 2>&1; then
652
- python3 << EOF
653
- import yaml
654
- import sys
655
-
656
- try:
657
- with open('$WORKFLOW_FILE', 'r') as f:
658
- yaml.safe_load(f)
659
- print("✅ YAML syntax is valid")
660
- sys.exit(0)
661
- except yaml.YAMLError as e:
662
- print(f"❌ YAML syntax error: {e}")
663
- sys.exit(1)
664
- except FileNotFoundError:
665
- print(f"❌ File not found: $WORKFLOW_FILE")
666
- sys.exit(1)
667
- EOF
668
-
669
- if [ $? -eq 0 ]; then
670
- YAML_VALID=true
671
- else
672
- YAML_VALID=false
673
- fi
674
- else
675
- echo "⚠️ Cannot validate YAML (python3 not found)"
676
- echo " Please check syntax manually at: https://www.yamllint.com/"
677
- YAML_VALID="unknown"
678
- fi
679
- ```
680
-
681
- #### 9.2: Test Commands Locally
682
-
683
- **Ask permission to run tests**:
684
-
685
- ```xml
686
- <invoke name="AskUserQuestion">
687
- <parameter name="questions">[{
688
- "question": "Run CI commands locally to test them? (This will execute: install, test, lint, build)",
689
- "header": "Test local",
690
- "multiSelect": false,
691
- "options": [
692
- {
693
- "label": "Yes, run tests now",
694
- "description": "Execute all CI commands locally to verify they work before pushing"
695
- },
696
- {
697
- "label": "No, skip local testing",
698
- "description": "Skip local testing - assume commands work or test manually"
699
- }
700
- ]
701
- }]</parameter>
702
- </invoke>
703
- ```
704
-
705
- **If user agrees, run commands**:
706
-
707
- ```bash
708
- if [ "$runLocal" = "Yes, run tests now" ]; then
709
- echo ""
710
- echo "🧪 Step 2: Testing CI commands locally..."
711
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
712
-
713
- FAILED_COMMANDS=0
714
- PASSED_COMMANDS=0
715
-
716
- # Test each command that was configured
717
- {{#if installDeps}}
718
- echo ""
719
- echo "Running: npm ci"
720
- if npm ci; then
721
- echo "✅ PASSED: npm ci"
722
- PASSED_COMMANDS=$((PASSED_COMMANDS + 1))
723
- else
724
- echo "❌ FAILED: npm ci (exit code: $?)"
725
- FAILED_COMMANDS=$((FAILED_COMMANDS + 1))
726
- fi
727
- {{/if}}
728
-
729
- {{#if runTests}}
730
- echo ""
731
- echo "Running: {{testCommand}}"
732
- if {{testCommand}}; then
733
- echo "✅ PASSED: {{testCommand}}"
734
- PASSED_COMMANDS=$((PASSED_COMMANDS + 1))
735
- else
736
- echo "❌ FAILED: {{testCommand}} (exit code: $?)"
737
- FAILED_COMMANDS=$((FAILED_COMMANDS + 1))
738
- fi
739
- {{/if}}
740
-
741
- {{#if runLint}}
742
- echo ""
743
- echo "Running: {{lintCommand}}"
744
- if {{lintCommand}}; then
745
- echo "✅ PASSED: {{lintCommand}}"
746
- PASSED_COMMANDS=$((PASSED_COMMANDS + 1))
747
- else
748
- echo "❌ FAILED: {{lintCommand}} (exit code: $?)"
749
- FAILED_COMMANDS=$((FAILED_COMMANDS + 1))
750
- fi
751
- {{/if}}
752
-
753
- {{#if runTypeCheck}}
754
- echo ""
755
- echo "Running: {{typeCheckCommand}}"
756
- if {{typeCheckCommand}}; then
757
- echo "✅ PASSED: {{typeCheckCommand}}"
758
- PASSED_COMMANDS=$((PASSED_COMMANDS + 1))
759
- else
760
- echo "❌ FAILED: {{typeCheckCommand}} (exit code: $?)"
761
- FAILED_COMMANDS=$((FAILED_COMMANDS + 1))
762
- fi
763
- {{/if}}
764
-
765
- {{#if runBuild}}
766
- echo ""
767
- echo "Running: {{buildCommand}}"
768
- if {{buildCommand}}; then
769
- echo "✅ PASSED: {{buildCommand}}"
770
- PASSED_COMMANDS=$((PASSED_COMMANDS + 1))
771
- else
772
- echo "❌ FAILED: {{buildCommand}} (exit code: $?)"
773
- FAILED_COMMANDS=$((FAILED_COMMANDS + 1))
774
- fi
775
- {{/if}}
776
-
777
- echo ""
778
- echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
779
- echo "Results: $PASSED_COMMANDS passed, $FAILED_COMMANDS failed"
780
-
781
- if [ $FAILED_COMMANDS -eq 0 ]; then
782
- echo "✅ All CI commands passed locally"
783
- LOCAL_TEST_RESULT="PASSED"
784
- else
785
- echo "❌ Some CI commands failed"
786
- echo ""
787
- echo "⚠️ WARNING: CI will fail when you push!"
788
- echo " Fix the failing commands before pushing to remote"
789
- LOCAL_TEST_RESULT="FAILED"
790
- fi
791
- fi
792
- ```
793
-
794
- #### 9.3: Trigger Remote CI Run (Optional)
795
-
796
- **Only for GitHub Actions** (requires token):
797
-
798
- **Check if user wants to trigger remote CI**:
799
-
800
- ```xml
801
- <invoke name="AskUserQuestion">
802
- <parameter name="questions">[{
803
- "question": "Trigger a test CI run on GitHub? (Requires GitHub token with 'workflow' scope)",
804
- "header": "Trigger CI",
805
- "multiSelect": false,
806
- "options": [
807
- {
808
- "label": "Yes, trigger remote CI",
809
- "description": "Use GitHub API to trigger a workflow run now (requires token)"
810
- },
811
- {
812
- "label": "No, I'll push manually",
813
- "description": "Skip remote trigger - CI will run when you push code"
814
- }
815
- ]
816
- }]</parameter>
817
- </invoke>
818
- ```
819
-
820
- **If yes, check for token**:
821
-
822
- ```bash
823
- if [ "$triggerRemote" = "Yes, trigger remote CI" ]; then
824
- echo ""
825
- echo "🚀 Step 3: Triggering remote CI run..."
826
-
827
- # Check for token in .claude/settings.local.json
828
- if [ -f .claude/settings.local.json ]; then
829
- GITHUB_TOKEN=$(jq -r '.env.GITHUB_TOKEN // ""' .claude/settings.local.json 2>/dev/null)
830
- fi
831
-
832
- if [ -z "$GITHUB_TOKEN" ] || [ "$GITHUB_TOKEN" = "null" ]; then
833
- echo "⚠️ GitHub token not found in .claude/settings.local.json"
834
- fi
835
- ```
836
-
837
- **Ask user for token** (2 questions - token + save preference):
838
-
839
- ```xml
840
- <invoke name="AskUserQuestion">
841
- <parameter name="questions">[
842
- {
843
- "question": "GitHub token not found. Enter your personal access token? (Create at: github.com/settings/tokens/new, Required scopes: repo, workflow)",
844
- "header": "Token",
845
- "multiSelect": false,
846
- "options": [
847
- {
848
- "label": "Skip - I'll push manually",
849
- "description": "Skip triggering CI remotely - just push code and CI runs automatically"
850
- },
851
- {
852
- "label": "Other",
853
- "description": "Enter token (select this, then type your ghp_xxx token in the text field)"
854
- }
855
- ]
856
- },
857
- {
858
- "question": "Save token to .claude/settings.local.json for future use? (File is gitignored and secure)",
859
- "header": "Save token",
860
- "multiSelect": false,
861
- "options": [
862
- {
863
- "label": "Yes, save token",
864
- "description": "Store securely in .claude/settings.local.json (gitignored, chmod 600)"
865
- },
866
- {
867
- "label": "No, use once only",
868
- "description": "Use token just this time - you'll be asked again later"
869
- }
870
- ]
871
- }
872
- ]</parameter>
873
- </invoke>
874
- ```
875
-
876
- **Note**: User selects "Other" for the first question and enters token in the text field.
877
-
878
- **Save token if user agrees**:
879
-
880
- ```bash
881
- if [ "$saveToken" = "Yes, save token" ]; then
882
- # Create .claude/settings.local.json if doesn't exist
883
- if [ ! -f .claude/settings.local.json ]; then
884
- echo '{"env":{}}' > .claude/settings.local.json
885
- chmod 600 .claude/settings.local.json
886
- fi
887
-
888
- # Add token
889
- jq ".env.GITHUB_TOKEN = \"$token\"" .claude/settings.local.json > .claude/settings.local.json.tmp && mv .claude/settings.local.json.tmp .claude/settings.local.json
890
-
891
- echo "✅ Token saved to .claude/settings.local.json (chmod 600)"
892
- GITHUB_TOKEN="$token"
893
- fi
894
- ```
895
-
896
- **Trigger workflow via GitHub API**:
897
-
898
- ```bash
899
- # Extract repo owner and name from git remote
900
- REMOTE_URL=$(git remote get-url origin 2>/dev/null)
901
- if [[ "$REMOTE_URL" =~ github.com[:/]([^/]+)/([^/.]+) ]]; then
902
- REPO_OWNER="${BASH_REMATCH[1]}"
903
- REPO_NAME="${BASH_REMATCH[2]}"
904
- REPO="$REPO_OWNER/$REPO_NAME"
905
- else
906
- echo "❌ Cannot extract repo info from remote URL"
907
- echo " Remote URL: $REMOTE_URL"
908
- exit 1
909
- fi
910
-
911
- # Trigger workflow
912
- echo "Triggering workflow for: $REPO"
913
-
914
- RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
915
- -H "Accept: application/vnd.github.v3+json" \
916
- -H "Authorization: token $GITHUB_TOKEN" \
917
- "https://api.github.com/repos/${REPO}/actions/workflows/ci.yml/dispatches" \
918
- -d '{"ref":"main"}')
919
-
920
- HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
921
- BODY=$(echo "$RESPONSE" | head -n-1)
922
-
923
- if [ "$HTTP_CODE" = "204" ]; then
924
- echo "✅ CI workflow triggered successfully"
925
- echo " View at: https://github.com/${REPO}/actions"
926
- REMOTE_TRIGGER_RESULT="SUCCESS"
927
- else
928
- echo "❌ Failed to trigger workflow (HTTP $HTTP_CODE)"
929
- echo " Response: $BODY"
930
- echo ""
931
- echo "Possible issues:"
932
- echo "- Invalid token or insufficient permissions"
933
- echo "- Workflow file not pushed to remote yet"
934
- echo "- Wrong branch (trying 'main', repo might use 'master')"
935
- REMOTE_TRIGGER_RESULT="FAILED"
936
- fi
937
- ```
938
-
939
- ### Verification Report
940
-
941
- After verification, print summary:
942
-
943
- ```
944
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
945
- 🔍 VERIFICATION REPORT
946
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
947
-
948
- Configuration: CI/CD ({{PROVIDER}})
949
- Workflow file: {{WORKFLOW_FILE_PATH}}
950
-
951
- Checks performed:
952
- ✅ YAML syntax validation: {{YAML_VALID ? "PASSED" : "FAILED"}}
953
- {{#if runLocal}}
954
- {{LOCAL_TEST_RESULT == "PASSED" ? "✅" : "❌"}} Local command tests: {{LOCAL_TEST_RESULT}} ({{PASSED_COMMANDS}}/{{TOTAL_COMMANDS}})
955
- {{#if runTests}} - {{testCommand}}{{/if}}
956
- {{#if runLint}} - {{lintCommand}}{{/if}}
957
- {{#if runTypeCheck}} - {{typeCheckCommand}}{{/if}}
958
- {{#if runBuild}} - {{buildCommand}}{{/if}}
959
- {{else}}
960
- ⏭️ Local command tests: SKIPPED (user declined)
961
- {{/if}}
962
- {{#if triggerRemote == "Yes"}}
963
- {{REMOTE_TRIGGER_RESULT == "SUCCESS" ? "✅" : "❌"}} Remote trigger: {{REMOTE_TRIGGER_RESULT}}
964
- {{else}}
965
- ⏭️ Remote trigger: SKIPPED
966
- {{/if}}
967
-
968
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
969
- Overall: {{YAML_VALID && (LOCAL_TEST_RESULT == "PASSED" || !runLocal) ? "✅ VERIFIED" : "⚠️ ISSUES FOUND"}}
970
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
971
- ```
972
-
973
- **If verification failed**:
974
-
975
- ```
976
- ⚠️ Some checks failed. You can still commit the workflow, but it may fail in CI.
977
-
978
- Recommended actions:
979
- {{#if !YAML_VALID}}
980
- - Fix YAML syntax errors before committing
981
- {{/if}}
982
- {{#if LOCAL_TEST_RESULT == "FAILED"}}
983
- - Fix failing commands (see output above)
984
- - Re-run verification after fixes
985
- {{/if}}
986
-
987
- Continue anyway? (The workflow file has been created)
988
- ```
989
-
990
- ## Success Output
991
-
992
- After successful configuration (with or without verification), print:
993
-
994
- ```
995
- ✅ CI/CD Workflow Configured
996
-
997
- Provider: {{PROVIDER}}
998
- Workflow file: {{WORKFLOW_FILE_PATH}}
999
-
1000
- Commands configured:
1001
- {{#if runTests}}
1002
- ✅ Tests: {{testCommand}}
1003
- {{/if}}
1004
- {{#if runLint}}
1005
- ✅ Linter: {{lintCommand}}
1006
- {{/if}}
1007
- {{#if runTypeCheck}}
1008
- ✅ Type checking: {{typeCheckCommand}}
1009
- {{/if}}
1010
- {{#if runBuild}}
1011
- ✅ Build: {{buildCommand}}
1012
- {{/if}}
1013
-
1014
- Next steps:
1015
- 1. Commit the workflow file:
1016
- git add {{WORKFLOW_FILE_PATH}}
1017
- git commit -m "ci: add {{PROVIDER}} workflow"
1018
-
1019
- 2. Push to trigger CI:
1020
- git push origin main
1021
-
1022
- 3. Check CI status:
1023
- {{PROVIDER_URL}}
1024
-
1025
- 4. Add status badge to README.md (optional):
1026
- {{BADGE_MARKDOWN}}
1027
-
1028
- Note: CI will run automatically on every push and pull request.
1029
- ```
1030
-
1031
- ## Provider-Specific Details
1032
-
1033
- ### GitHub Actions
1034
- - File: `.github/workflows/ci.yml`
1035
- - View results: `https://github.com/{user}/{repo}/actions`
1036
- - Badge: `![CI](https://github.com/{user}/{repo}/workflows/CI/badge.svg)`
1037
-
1038
- ### GitLab CI
1039
- - File: `.gitlab-ci.yml`
1040
- - View results: `https://gitlab.com/{user}/{repo}/-/pipelines`
1041
- - Badge: `![pipeline](https://gitlab.com/{user}/{repo}/badges/main/pipeline.svg)`
1042
-
1043
- ### CircleCI
1044
- - File: `.circleci/config.yml`
1045
- - View results: `https://app.circleci.com/pipelines/github/{user}/{repo}`
1046
- - Badge: `![CircleCI](https://circleci.com/gh/{user}/{repo}.svg?style=shield)`
1047
-
1048
- ## Error Handling
1049
-
1050
- ### If workflow file already exists
1051
-
1052
- ```bash
1053
- if [ -f .github/workflows/ci.yml ]; then
1054
- # Ask user if they want to overwrite
1055
- ```
1056
-
1057
- ```xml
1058
- <invoke name="AskUserQuestion">
1059
- <parameter name="questions">[{
1060
- "question": "CI workflow already exists. Overwrite it?",
1061
- "header": "Overwrite",
1062
- "multiSelect": false,
1063
- "options": [
1064
- {
1065
- "label": "Yes, overwrite",
1066
- "description": "Replace existing workflow with new configuration"
1067
- },
1068
- {
1069
- "label": "No, skip",
1070
- "description": "Keep existing workflow - don't make any changes"
1071
- }
1072
- ]
1073
- }]</parameter>
1074
- </invoke>
1075
- ```
1076
-
1077
- ```bash
1078
- # If user selected "No, skip"
1079
- echo "⏭️ Skipping CI configuration (file already exists)"
1080
- exit 0
1081
- fi
1082
- ```
1083
-
1084
- ### If git remote not configured
1085
-
1086
- ```bash
1087
- if ! git remote -v 2>/dev/null | grep -q origin; then
1088
- echo "⚠️ Warning: Git remote not configured"
1089
- echo " CI badge URLs will be placeholders"
1090
- echo " Configure git remote first: /agileflow:configure (select Git Repository)"
1091
- fi
1092
- ```
1093
-
1094
- ## Rules
1095
-
1096
- - Use AskUserQuestion for ALL user inputs (provider, commands, overwrite confirmation)
1097
- - Detect project type and provide smart defaults
1098
- - Show preview of workflow file before writing
1099
- - Validate YAML syntax (no trailing commas, proper indentation)
1100
- - Only include steps for commands user selected
1101
- - Update CLAUDE.md with clear documentation
1102
- - Print clear next steps (commit, push, check status)
1103
- - Handle existing files gracefully (ask before overwriting)