sequant 2.0.1 → 2.1.0

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 (58) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/dist/bin/cli.js +2 -1
  4. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +1 -1
  5. package/dist/marketplace/external_plugins/sequant/.mcp.json +6 -0
  6. package/dist/marketplace/external_plugins/sequant/README.md +58 -8
  7. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +19 -8
  8. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +36 -49
  9. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/subagent-types.md +158 -48
  10. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +354 -352
  11. package/dist/marketplace/external_plugins/sequant/skills/exec/SKILL.md +1155 -33
  12. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +35 -4
  13. package/dist/marketplace/external_plugins/sequant/skills/qa/SKILL.md +2157 -104
  14. package/dist/marketplace/external_plugins/sequant/skills/qa/scripts/quality-checks.sh +1 -1
  15. package/dist/marketplace/external_plugins/sequant/skills/setup/SKILL.md +386 -0
  16. package/dist/marketplace/external_plugins/sequant/skills/solve/SKILL.md +38 -664
  17. package/dist/marketplace/external_plugins/sequant/skills/spec/SKILL.md +505 -120
  18. package/dist/marketplace/external_plugins/sequant/skills/test/SKILL.md +246 -1
  19. package/dist/marketplace/external_plugins/sequant/skills/testgen/SKILL.md +138 -1
  20. package/dist/src/commands/dashboard.js +1 -1
  21. package/dist/src/commands/doctor.js +1 -1
  22. package/dist/src/commands/init.js +10 -10
  23. package/dist/src/commands/logs.js +1 -1
  24. package/dist/src/commands/run.js +49 -39
  25. package/dist/src/commands/state.js +3 -3
  26. package/dist/src/commands/status.js +5 -5
  27. package/dist/src/commands/sync.js +8 -8
  28. package/dist/src/commands/update.js +16 -16
  29. package/dist/src/lib/cli-ui.js +20 -19
  30. package/dist/src/lib/merge-check/index.js +2 -2
  31. package/dist/src/lib/settings.d.ts +8 -0
  32. package/dist/src/lib/settings.js +1 -0
  33. package/dist/src/lib/shutdown.js +1 -1
  34. package/dist/src/lib/templates.js +2 -0
  35. package/dist/src/lib/wizard.js +6 -4
  36. package/dist/src/lib/workflow/batch-executor.js +1 -1
  37. package/dist/src/lib/workflow/log-writer.js +6 -6
  38. package/dist/src/lib/workflow/metrics-writer.js +5 -3
  39. package/dist/src/lib/workflow/phase-executor.js +5 -1
  40. package/dist/src/lib/workflow/platforms/github.js +5 -1
  41. package/dist/src/lib/workflow/state-cleanup.js +1 -1
  42. package/dist/src/lib/workflow/state-manager.js +15 -13
  43. package/dist/src/lib/workflow/state-rebuild.js +2 -2
  44. package/dist/src/lib/workflow/types.d.ts +11 -0
  45. package/dist/src/lib/workflow/worktree-manager.js +40 -41
  46. package/dist/src/lib/worktree-isolation.d.ts +130 -0
  47. package/dist/src/lib/worktree-isolation.js +310 -0
  48. package/package.json +8 -8
  49. package/templates/agents/sequant-explorer.md +23 -0
  50. package/templates/agents/sequant-implementer.md +18 -0
  51. package/templates/agents/sequant-qa-checker.md +24 -0
  52. package/templates/agents/sequant-testgen.md +25 -0
  53. package/templates/scripts/cleanup-worktree.sh +18 -0
  54. package/templates/skills/_shared/references/subagent-types.md +158 -48
  55. package/templates/skills/exec/SKILL.md +72 -6
  56. package/templates/skills/qa/SKILL.md +8 -217
  57. package/templates/skills/spec/SKILL.md +446 -120
  58. package/templates/skills/testgen/SKILL.md +138 -1
@@ -13,7 +13,7 @@ allowed-tools:
13
13
  - Bash(gh label:*)
14
14
  - Bash(git worktree:*)
15
15
  - Bash(git -C:*)
16
- - Task(Explore)
16
+ - Agent(sequant-explorer)
17
17
  - AgentOutputTool
18
18
  ---
19
19
 
@@ -84,6 +84,11 @@ When called like `/spec <freeform description>`:
84
84
  - Effect: Skips the AC Quality Check step
85
85
  - Use when: AC are intentionally high-level or you want to defer linting
86
86
 
87
+ **Flag:** `--skip-scope-check`
88
+ - Usage: `/spec 123 --skip-scope-check`
89
+ - Effect: Skips the Scope Assessment step
90
+ - Use when: Issue scope is intentionally complex or you want to defer assessment
91
+
87
92
  ### AC Extraction and Storage — REQUIRED
88
93
 
89
94
  **After fetching the issue body**, extract and store acceptance criteria in workflow state:
@@ -190,6 +195,103 @@ console.log(formatACLintResults(lintResults));
190
195
  - Output: `AC Quality Check: Skipped (--skip-ac-lint flag set)`
191
196
  - Continue directly to plan generation
192
197
 
198
+ ### Scope Assessment — REQUIRED (unless --skip-scope-check)
199
+
200
+ **After AC Quality Check**, run scope assessment to detect overscoped issues:
201
+
202
+ ```bash
203
+ # Run scope assessment (skip if --skip-scope-check flag is set)
204
+ npx tsx -e "
205
+ import { parseAcceptanceCriteria } from './src/lib/ac-parser.ts';
206
+ import { performScopeAssessment, formatScopeAssessment, convertSettingsToConfig } from './src/lib/scope/index.ts';
207
+ import { getSettings } from './src/lib/settings.ts';
208
+
209
+ const issueBody = \`<ISSUE_BODY_HERE>\`;
210
+ const issueTitle = '<ISSUE_TITLE>';
211
+
212
+ (async () => {
213
+ const settings = await getSettings();
214
+ const config = convertSettingsToConfig(settings.scopeAssessment);
215
+
216
+ const criteria = parseAcceptanceCriteria(issueBody);
217
+ const assessment = performScopeAssessment(criteria, issueBody, issueTitle, config);
218
+ console.log(formatScopeAssessment(assessment));
219
+ })();
220
+ "
221
+ ```
222
+
223
+ **Why this matters:**
224
+ - Bundled features (3+ distinct features) should be separate issues
225
+ - Missing non-goals lead to scope creep during implementation
226
+ - High AC counts increase complexity and error rates
227
+
228
+ **Scope Metrics:**
229
+
230
+ | Metric | Green | Yellow | Red |
231
+ |--------|-------|--------|-----|
232
+ | Feature count | 1 | 2 | 3+ |
233
+ | AC items | 1-5 | 6-8 | 9+ |
234
+ | Directory spread | 1-2 | 3-4 | 5+ |
235
+
236
+ **Non-Goals Section:**
237
+
238
+ Every `/spec` output MUST include a Non-Goals section. If the issue lacks one, output a warning:
239
+
240
+ ```markdown
241
+ ## Non-Goals
242
+
243
+ ⚠️ **Non-Goals section not found.** Consider adding scope boundaries.
244
+
245
+ Example format:
246
+ - [ ] [Adjacent feature we're deferring]
247
+ - [ ] [Scope boundary we're respecting]
248
+ - [ ] [Future work that's out of scope]
249
+ ```
250
+
251
+ **Scope Verdicts:**
252
+
253
+ | Verdict | Meaning | Action |
254
+ |---------|---------|--------|
255
+ | ✅ SCOPE_OK | Single focused feature | Proceed normally |
256
+ | ⚠️ SCOPE_WARNING | Moderate complexity | Consider narrowing; quality loop auto-enabled |
257
+ | ❌ SCOPE_SPLIT_RECOMMENDED | Multiple features bundled | Strongly recommend splitting |
258
+
259
+ **Quality Loop Auto-Enable:**
260
+
261
+ If scope verdict is SCOPE_WARNING or SCOPE_SPLIT_RECOMMENDED:
262
+ - Quality loop is automatically enabled
263
+ - Include note in Recommended Workflow section:
264
+ ```markdown
265
+ **Quality Loop:** enabled (auto-enabled due to scope concerns)
266
+ ```
267
+
268
+ **If `--skip-scope-check` flag is set:**
269
+ - Output: `Scope Assessment: Skipped (--skip-scope-check flag set)`
270
+ - Continue to plan generation
271
+
272
+ **Store in State:**
273
+
274
+ After assessment, store results in workflow state for analytics:
275
+
276
+ ```bash
277
+ npx tsx -e "
278
+ import { StateManager } from './src/lib/workflow/state-manager.ts';
279
+ import { performScopeAssessment, convertSettingsToConfig } from './src/lib/scope/index.ts';
280
+ import { getSettings } from './src/lib/settings.ts';
281
+
282
+ (async () => {
283
+ const settings = await getSettings();
284
+ const config = convertSettingsToConfig(settings.scopeAssessment);
285
+
286
+ // ... perform assessment with config ...
287
+ // const assessment = performScopeAssessment(criteria, issueBody, issueTitle, config);
288
+
289
+ const manager = new StateManager();
290
+ await manager.updateScopeAssessment(issueNumber, assessment);
291
+ })();
292
+ "
293
+ ```
294
+
193
295
  ### Feature Worktree Workflow
194
296
 
195
297
  **Planning Phase:** No worktree needed. Planning happens in the main repository directory. The worktree will be created during the execution phase (`/exec`).
@@ -209,21 +311,21 @@ Read(file_path=".sequant/settings.json")
209
311
 
210
312
  **Spawn ALL THREE agents in a SINGLE message:**
211
313
 
212
- 1. `Task(subagent_type="Explore", model="haiku", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
314
+ 1. `Agent(subagent_type="sequant-explorer", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
213
315
 
214
- 2. `Task(subagent_type="Explore", model="haiku", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
316
+ 2. `Agent(subagent_type="sequant-explorer", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
215
317
 
216
- 3. `Task(subagent_type="Explore", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
318
+ 3. `Agent(subagent_type="sequant-explorer", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
217
319
 
218
320
  #### If sequential mode (default):
219
321
 
220
322
  **Spawn each agent ONE AT A TIME, waiting for each to complete:**
221
323
 
222
- 1. **First:** `Task(subagent_type="Explore", model="haiku", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
324
+ 1. **First:** `Agent(subagent_type="sequant-explorer", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
223
325
 
224
- 2. **After #1 completes:** `Task(subagent_type="Explore", model="haiku", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
326
+ 2. **After #1 completes:** `Agent(subagent_type="sequant-explorer", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
225
327
 
226
- 3. **After #2 completes:** `Task(subagent_type="Explore", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
328
+ 3. **After #2 completes:** `Agent(subagent_type="sequant-explorer", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
227
329
 
228
330
  ### Feature Branch Context Detection
229
331
 
@@ -348,9 +450,9 @@ Before creating the implementation plan, scan for potential conflicts with in-fl
348
450
 
349
451
  ## Output Structure
350
452
 
351
- ### 1. AC Checklist with Verification Criteria
453
+ ### 1. AC Checklist with Verification Criteria (REQUIRED)
352
454
 
353
- Restate AC as a checklist with verification for each:
455
+ **Every AC MUST have an explicit Verification Method.** Restate AC as a checklist with verification for each:
354
456
 
355
457
  ```markdown
356
458
  ### AC-1: [Description]
@@ -369,6 +471,64 @@ Restate AC as a checklist with verification for each:
369
471
  - [ ] [Assumption that must be true]
370
472
  ```
371
473
 
474
+ #### Verification Method Decision Framework
475
+
476
+ **REQUIRED:** Choose the most appropriate verification method for each AC:
477
+
478
+ | AC Type | Verification Method | When to Use |
479
+ |---------|---------------------|-------------|
480
+ | Pure logic/calculation | **Unit Test** | Functions with clear input/output, no side effects |
481
+ | API endpoint | **Integration Test** | HTTP handlers, database queries, external service calls |
482
+ | User workflow | **Browser Test** | Multi-step UI interactions, form submissions |
483
+ | Visual appearance | **Manual Test** | Styling, layout, animations (hard to automate) |
484
+ | CLI command | **Integration Test** | Script execution, file operations, stdout verification |
485
+ | Error handling | **Unit Test** + **Integration Test** | Both isolated behavior and realistic scenarios |
486
+ | Performance | **Manual Test** + **Integration Test** | Timing thresholds, load testing |
487
+
488
+ #### Verification Method Examples
489
+
490
+ **Good (specific and testable):**
491
+ ```markdown
492
+ **AC-1:** User can submit the registration form
493
+ **Verification Method:** Browser Test
494
+ **Test Scenario:**
495
+ - Given: User on /register page
496
+ - When: Fill form fields, click Submit
497
+ - Then: Redirect to /dashboard, success toast appears
498
+ ```
499
+
500
+ **Bad (vague, no clear verification):**
501
+ ```markdown
502
+ **AC-1:** Registration should work properly
503
+ **Verification Method:** ??? (cannot determine)
504
+ ```
505
+
506
+ #### Flags for Missing Verification Methods
507
+
508
+ If you cannot determine a verification method for an AC:
509
+
510
+ 1. **Flag the AC as unclear:**
511
+ ```markdown
512
+ **AC-3:** System handles errors gracefully
513
+ **Verification Method:** ⚠️ UNCLEAR - needs specific error scenarios
514
+ **Suggested Refinement:** List specific error types and expected responses
515
+ ```
516
+
517
+ 2. **Include in Open Questions:**
518
+ ```markdown
519
+ ## Open Questions
520
+
521
+ 1. **AC-3 verification method unclear**
522
+ - Question: What specific error scenarios should be tested?
523
+ - Recommendation: Define 3-5 error types with expected behavior
524
+ - Impact: Without this, QA cannot objectively validate
525
+ ```
526
+
527
+ **Why this matters:** AC without verification methods:
528
+ - Cannot be objectively validated in `/qa`
529
+ - Lead to subjective "does it work?" assessments
530
+ - Cause rework when expectations don't match implementation
531
+
372
532
  See [verification-criteria.md](references/verification-criteria.md) for detailed examples including the #452 hooks failure case.
373
533
 
374
534
  ### 2. Implementation Plan
@@ -391,142 +551,222 @@ For each major decision:
391
551
 
392
552
  See [parallel-groups.md](references/parallel-groups.md) for parallelization format.
393
553
 
394
- ### 3. Plan Review
554
+ ### 2.5. Design Review (REQUIRED)
395
555
 
396
- Ask the user to confirm or adjust:
397
- - The AC checklist (with verification criteria)
398
- - The implementation plan
399
- - The assumptions to validate
400
-
401
- **Do NOT start implementation** - this is planning-only.
556
+ **Purpose:** Make design decisions explicit before implementation starts. This forces evaluation of *how* to build, not just *what* to build — catching wrong-layer, over-engineered, or pattern-mismatched approaches before code is written.
402
557
 
403
- ### 4. Content Analysis (AC-1, AC-2, AC-3, AC-4)
558
+ **Why this matters:** Repeated pattern across issues: implementation passes QA functionally but uses the wrong design — wrong layer, hacky shortcut, over-engineered approach. The fix cycle is expensive. Making design explicit here prevents it.
404
559
 
405
- **Before** determining the recommended workflow, analyze the issue content for phase-relevant signals:
560
+ **Complexity Scaling:**
561
+ - **Simple issues** (`simple-fix`, `typo`, `docs-only` labels): Abbreviated — answer Q1 and Q3 only
562
+ - **Standard issues**: Answer all 4 questions
563
+ - **Complex issues** (`complex`, `refactor`, `breaking` labels): Answer all 4 questions with detailed rationale
406
564
 
407
- #### Step 1: Check for Solve Comment (AC-4)
565
+ **Answer these questions:**
408
566
 
409
- First, check if a `/solve` comment already exists for this issue:
567
+ 1. **Where does this logic belong?** Which module/layer owns this change? Name the specific directory, file, or abstraction layer. If it spans layers, explain why.
410
568
 
411
- ```bash
412
- # Check issue comments for solve workflow
413
- gh issue view <issue-number> --json comments --jq '.comments[].body' | grep -l "## Solve Workflow for Issues:" || true
414
- ```
569
+ 2. **What's the simplest correct approach?** — Actively reject over-engineering. What's the minimum implementation that satisfies all AC? What alternatives did you consider and reject?
415
570
 
416
- **If solve comment found:**
417
- - Extract phases from the solve workflow (e.g., `spec → exec → test → qa`)
418
- - Use solve recommendations as the primary source (after labels)
419
- - Skip content analysis for phases (solve already analyzed)
420
- - Include in output: `"Solve comment found - using /solve workflow recommendations"`
571
+ 3. **What existing pattern does this follow?** — Name the specific pattern in the codebase. Confirm it fits this use case. If no existing pattern fits, explain why a new approach is needed.
421
572
 
422
- #### Step 2: Analyze Title for Keywords (AC-1)
573
+ 4. **What would a senior reviewer challenge?** — Anticipate design pushback. What's the most likely "why didn't you just...?" or "this should be in X instead" feedback?
423
574
 
424
- If no solve comment, analyze the issue title for phase-relevant keywords:
575
+ **Example (standard issue):**
425
576
 
426
- | Pattern | Detection | Suggested Phase |
427
- |---------|-----------|-----------------|
428
- | `extract`, `component` | UI work | Add `/test` |
429
- | `refactor.*ui`, `ui refactor` | UI work | Add `/test` |
430
- | `frontend`, `dashboard` | UI work | Add `/test` |
431
- | `auth`, `permission`, `security` | Security-sensitive | Add `/security-review` |
432
- | `password`, `credential`, `token` | Security-sensitive | Add `/security-review` |
433
- | `refactor`, `migration`, `restructure` | Complex work | Enable quality loop |
434
- | `breaking change` | Complex work | Enable quality loop |
577
+ ```markdown
578
+ ## Design Review
435
579
 
436
- #### Step 3: Analyze Body for Patterns (AC-2)
580
+ 1. **Where does this logic belong?** Spec skill's SKILL.md prompt files — purely prompt engineering, not TypeScript. Same layer as Feature Quality Planning and AC Checklist sections.
437
581
 
438
- Analyze the issue body for file references and keywords:
582
+ 2. **What's the simplest correct approach?** Add markdown prompt text to SKILL.md. Reuse the existing complexity scaling pattern from Feature Quality Planning. No code, no new files, no abstractions.
439
583
 
440
- | Pattern | Detection | Suggested Phase |
441
- |---------|-----------|-----------------|
442
- | References `.tsx` or `.jsx` files | UI work likely | Add `/test` |
443
- | References `components/` directory | UI work | Add `/test` |
444
- | References `scripts/` or `bin/` | CLI work | May need `/verify` |
445
- | References `auth/` directory | Security-sensitive | Add `/security-review` |
446
- | References `middleware.ts` | May be auth-related | Consider `/security-review` |
447
- | Contains "breaking change" | Complex work | Enable quality loop |
584
+ 3. **What existing pattern does this follow?** Mirrors Feature Quality Planning exactly: required section, purpose statement, complexity scaling table, question format.
448
585
 
449
- #### Step 3a: Browser Testing Label Suggestion
586
+ 4. **What would a senior reviewer challenge?** (1) "Why after Implementation Plan, not before?" — Design review needs the plan as input to evaluate. (2) "Won't this bloat output?" — Adds ~15 lines for standard, ~5 for simple-fix.
587
+ ```
450
588
 
451
- **When `.tsx` or `.jsx` file references are detected** in the issue body AND the issue does NOT have `ui`, `frontend`, or `admin` labels, include this warning in the spec output:
589
+ **Example (simple-fix issue, abbreviated):**
452
590
 
453
591
  ```markdown
454
- > **Component files detected** — Issue body references `.tsx`/`.jsx` files or `components/` directory, but no `ui`/`frontend`/`admin` label is present.
455
- > - To enable browser testing: add the `ui` label → `gh issue edit <N> --add-label ui`
456
- > - To explicitly skip browser testing: add `no-browser-test` label → `gh issue edit <N> --add-label no-browser-test`
457
- > - Without either label, QA will note the missing browser test coverage.
458
- ```
592
+ ## Design Review
459
593
 
460
- **When NOT to show this warning:**
461
- - Issue already has `ui`, `frontend`, or `admin` label (browser testing already enabled)
462
- - Issue has `no-browser-test` label (explicit opt-out)
463
- - No `.tsx`/`.jsx`/`components/` references detected
594
+ 1. **Where does this logic belong?** `src/lib/utils.ts` — utility function, same layer as existing helpers.
595
+
596
+ 3. **What existing pattern does this follow?** Same pattern as `formatDuration()` in the same file — pure function, no side effects, single responsibility.
597
+ ```
464
598
 
465
- #### Step 4: Merge Signals (AC-3)
599
+ ### 3. Feature Quality Planning (REQUIRED)
466
600
 
467
- Content analysis **supplements** label detection - it can only ADD phases, never remove them.
601
+ **Purpose:** Systematically consider professional implementation requirements beyond the minimum AC. This prevents gaps that slip through exec and QA because they were never planned.
468
602
 
469
- **Priority order (highest first):**
470
- 1. **Labels** (explicit, highest priority)
471
- 2. **Solve comment** (if exists)
472
- 3. **Title keywords**
473
- 4. **Body patterns** (lowest priority)
603
+ **Why this matters:** Spec currently plans the "minimum to satisfy AC" rather than "complete professional implementation." Gaps found in manual review are omissions from incomplete planning, not failures.
474
604
 
475
- **Output format:**
605
+ **Complexity Scaling:**
606
+ - **Simple issues** (`simple-fix`, `typo`, `docs-only` labels): Use abbreviated checklist (Completeness + one relevant section)
607
+ - **Standard issues**: Complete all applicable sections
608
+ - **Complex issues** (`complex`, `refactor`, `breaking` labels): Complete all sections with detailed items
476
609
 
477
610
  ```markdown
478
- ## Content Analysis
611
+ ## Feature Quality Planning
612
+
613
+ ### Completeness Check
614
+ - [ ] All AC items have corresponding implementation steps
615
+ - [ ] Integration points with existing features identified
616
+ - [ ] No partial implementations or TODOs planned
617
+ - [ ] State management considered (if applicable)
618
+ - [ ] Data flow is complete end-to-end
619
+
620
+ ### Error Handling
621
+ - [ ] Invalid input scenarios identified
622
+ - [ ] API/external service failures handled
623
+ - [ ] Edge cases documented (empty, null, max values)
624
+ - [ ] Error messages are user-friendly
625
+ - [ ] Graceful degradation planned
626
+
627
+ ### Code Quality
628
+ - [ ] Types fully defined (no `any` planned)
629
+ - [ ] Follows existing patterns in codebase
630
+ - [ ] Error boundaries where needed
631
+ - [ ] No magic strings/numbers
632
+ - [ ] Consistent naming conventions
633
+
634
+ ### Test Coverage Plan
635
+ - [ ] Unit tests for business logic
636
+ - [ ] Integration tests for data flow
637
+ - [ ] Edge case tests identified
638
+ - [ ] Mocking strategy appropriate
639
+ - [ ] Critical paths have test coverage
640
+
641
+ ### Best Practices
642
+ - [ ] Logging for debugging/observability
643
+ - [ ] Accessibility considerations (if UI)
644
+ - [ ] Performance implications considered
645
+ - [ ] Security reviewed (auth, validation, sanitization)
646
+ - [ ] Documentation updated (if behavior changes)
647
+
648
+ ### Polish (UI features only)
649
+ - [ ] Loading states planned
650
+ - [ ] Error states have UI
651
+ - [ ] Empty states handled
652
+ - [ ] Responsive design considered
653
+ - [ ] Keyboard navigation works
654
+
655
+ ### Derived ACs
656
+
657
+ Based on quality planning, identify additional ACs needed:
658
+
659
+ | Source | Derived AC | Priority |
660
+ |--------|-----------|----------|
661
+ | Error Handling | AC-N: Handle [specific error] with [specific response] | High/Medium/Low |
662
+ | Test Coverage | AC-N+1: Add tests for [specific scenario] | High/Medium/Low |
663
+ | Best Practices | AC-N+2: Add logging for [specific operation] | High/Medium/Low |
664
+
665
+ **Note:** Derived ACs are numbered sequentially after original ACs and follow the same format.
666
+ ```
479
667
 
480
- ### Signal Sources
668
+ **Section Applicability:**
481
669
 
482
- | Phase | Source | Confidence | Reason |
483
- |-------|--------|------------|--------|
484
- | /test | title | high | "Extract component" detected |
485
- | /security-review | body | medium | References auth/ directory |
670
+ | Issue Type | Sections Required |
671
+ |------------|-------------------|
672
+ | Bug fix | Completeness, Error Handling, Test Coverage |
673
+ | New feature | All sections |
674
+ | Refactor | Completeness, Code Quality, Test Coverage |
675
+ | UI change | All sections including Polish |
676
+ | Backend/API | Completeness, Error Handling, Code Quality, Test Coverage, Best Practices |
677
+ | CLI/Script | Completeness, Error Handling, Test Coverage, Best Practices |
678
+ | Docs only | Completeness only |
486
679
 
487
- ### Merged Recommendations
680
+ **Example (API endpoint feature):**
488
681
 
489
- **From labels:** /test (ui label)
490
- **From content:** /security-review (added)
491
- **Final phases:** spec → exec → test → security-review → qa
682
+ ```markdown
683
+ ## Feature Quality Planning
684
+
685
+ ### Completeness Check
686
+ - [x] All AC items have corresponding implementation steps
687
+ - [x] Integration points: Auth middleware, database queries, response serializer
688
+ - [x] No partial implementations planned
689
+ - [ ] State management: N/A (stateless API)
690
+ - [x] Data flow: Request → Validate → Query → Transform → Response
691
+
692
+ ### Error Handling
693
+ - [x] Invalid input: Return 400 with validation errors
694
+ - [x] Auth failure: Return 401 with "Unauthorized" message
695
+ - [x] Not found: Return 404 with resource ID
696
+ - [x] Server error: Return 500, log full error, return generic message
697
+ - [x] Rate limit: Return 429 with retry-after header
698
+
699
+ ### Code Quality
700
+ - [x] Types: Define RequestDTO, ResponseDTO, ErrorResponse
701
+ - [x] Patterns: Follow existing controller pattern in `src/api/`
702
+ - [ ] Error boundaries: N/A (API, not UI)
703
+ - [x] No magic strings: Use constants for error messages
704
+
705
+ ### Test Coverage Plan
706
+ - [x] Unit: Validation logic, data transformation
707
+ - [x] Integration: Full request/response cycle
708
+ - [x] Edge cases: Empty results, max pagination, invalid IDs
709
+ - [x] Mocking: Mock database, not HTTP layer
710
+
711
+ ### Best Practices
712
+ - [x] Logging: Log request ID, duration, status code
713
+ - [ ] Accessibility: N/A (API)
714
+ - [x] Performance: Add database index for query field
715
+ - [x] Security: Validate input, sanitize output, check auth
716
+
717
+ ### Derived ACs
718
+
719
+ | Source | Derived AC | Priority |
720
+ |--------|-----------|----------|
721
+ | Error Handling | AC-6: Return 429 with retry-after header on rate limit | Medium |
722
+ | Best Practices | AC-7: Log request ID and duration for observability | High |
723
+ | Test Coverage | AC-8: Add integration test for auth failure path | High |
492
724
  ```
493
725
 
494
- ### 4.5. Solve Comment Detection (AC-4, AC-5)
726
+ ### 4. Plan Review
495
727
 
496
- **Before making your own phase recommendation**, check if `/solve` has already posted an analysis comment to this issue:
728
+ Ask the user to confirm or adjust:
729
+ - The AC checklist (with verification criteria)
730
+ - The implementation plan
731
+ - The assumptions to validate
732
+
733
+ **Do NOT start implementation** - this is planning-only.
734
+
735
+ ### 4.5. Assess Comment Detection (AC-4, AC-5)
736
+
737
+ **Before making your own phase recommendation**, check if `/assess` has already posted an analysis comment to this issue:
497
738
 
498
739
  ```bash
499
- # Check for solve analysis comment on the issue
500
- solve_comment=$(gh issue view <issue-number> --json comments \
501
- --jq '[.comments[].body | select(test("## Solve Analysis|<!-- solve:phases="))] | last // empty')
740
+ # Check for assess analysis comment on the issue (includes legacy /solve format for backward compat)
741
+ assess_comment=$(gh issue view <issue-number> --json comments \
742
+ --jq '[.comments[].body | select(test("## Assess Analysis|## Solve Analysis|<!-- assess:phases=|<!-- solve:phases="))] | last // empty')
502
743
  ```
503
744
 
504
- **If a solve analysis comment exists:**
745
+ **If an assess analysis comment exists:**
505
746
 
506
747
  1. Parse the HTML comment markers to extract the recommended phases:
507
748
  ```
508
- <!-- solve:phases=exec,qa --> → phases: ["exec", "qa"]
509
- <!-- solve:skip-spec=true --> skip spec phase
510
- <!-- solve:browser-test=false --> no browser testing needed
511
- <!-- solve:quality-loop=true --> → enable quality loop
749
+ <!-- assess:phases=exec,qa --> → phases: ["exec", "qa"] (spec not included = skip spec)
750
+ <!-- assess:browser-test=false --> no browser testing needed
751
+ <!-- assess:quality-loop=true --> enable quality loop
512
752
  ```
513
753
 
514
- 2. **Use the solve recommendation as your starting point** for the phase recommendation in step 5.
754
+ 2. **Use the assess recommendation as your starting point** for the phase recommendation in step 5.
515
755
 
516
- 3. **You may override the solve recommendation**, but you MUST document why:
756
+ 3. **You may override the assess recommendation**, but you MUST document why:
517
757
  ```markdown
518
758
  ## Recommended Workflow
519
759
 
520
760
  **Phases:** spec → exec → test → qa
521
761
  **Quality Loop:** enabled
522
- **Reasoning:** Solve recommended `exec → qa`, but codebase analysis reveals UI components
762
+ **Reasoning:** Assess recommended `exec → qa`, but codebase analysis reveals UI components
523
763
  are affected (found `.tsx` files in change scope), so browser testing is needed.
524
- Overriding solve recommendation with explanation.
764
+ Overriding assess recommendation with explanation.
525
765
  ```
526
766
 
527
- 4. If the solve comment recommends `skip-spec=true`, acknowledge this in your output but proceed with spec since `/spec` was explicitly invoked.
767
+ 4. If the assess comment recommends phases that don't include `spec` (e.g., `phases=exec,qa`), acknowledge this in your output but proceed with spec since `/spec` was explicitly invoked.
528
768
 
529
- **If no solve analysis comment exists:** Proceed with your own analysis as normal (step 5).
769
+ **If no assess analysis comment exists:** Proceed with your own analysis as normal (step 5).
530
770
 
531
771
  ### 5. Recommended Workflow
532
772
 
@@ -537,20 +777,90 @@ Analyze the issue and recommend the optimal workflow phases:
537
777
 
538
778
  **Phases:** spec → exec → qa
539
779
  **Quality Loop:** disabled
540
- **Signal Sources:** [labels | solve | content]
541
780
  **Reasoning:** [Brief explanation of why these phases were chosen]
542
781
  ```
543
782
 
544
783
  **Phase Selection Logic:**
545
784
  - **UI/Frontend changes** → Add `test` phase (browser testing)
785
+ - **`no-browser-test` label** → Skip `test` phase (explicit opt-out, overrides UI labels)
546
786
  - **Bug fixes** → Skip `spec` if already well-defined
547
787
  - **Complex refactors** → Enable quality loop
548
788
  - **Security-sensitive** → Add `security-review` phase
549
789
  - **Documentation only** → Skip `spec`, just `exec → qa`
790
+ - **New features with testable ACs** → Add `testgen` phase after spec
791
+ - **Refactors needing regression tests** → Add `testgen` phase
792
+
793
+ #### Browser Testing Label Suggestion
794
+
795
+ **When `.tsx` or `.jsx` file references are detected** in the issue body AND the issue does NOT have `ui`, `frontend`, or `admin` labels, include this warning in the spec output:
796
+
797
+ ```markdown
798
+ > **Component files detected** — Issue body references `.tsx`/`.jsx` files or `components/` directory, but no `ui`/`frontend`/`admin` label is present.
799
+ > - To enable browser testing: add the `ui` label → `gh issue edit <N> --add-label ui`
800
+ > - To explicitly skip browser testing: add `no-browser-test` label → `gh issue edit <N> --add-label no-browser-test`
801
+ > - Without either label, QA will note the missing browser test coverage.
802
+ ```
803
+
804
+ **When NOT to show this warning:**
805
+ - Issue already has `ui`, `frontend`, or `admin` label (browser testing already enabled)
806
+ - Issue has `no-browser-test` label (explicit opt-out)
807
+ - No `.tsx`/`.jsx`/`components/` references detected
808
+
809
+ #### Testgen Phase Auto-Detection
810
+
811
+ **When to recommend `testgen` phase:**
812
+
813
+ | Condition | Recommend testgen? | Reasoning |
814
+ |-----------|-------------------|-----------|
815
+ | ACs have "Unit Test" verification method | ✅ Yes | Tests should be stubbed before implementation |
816
+ | ACs have "Integration Test" verification method | ✅ Yes | Complex integration tests benefit from early structure |
817
+ | Issue is a new feature (not bug fix) with >2 AC items | ✅ Yes | Features need test coverage |
818
+ | Issue has `enhancement` or `feature` label | ✅ Yes | New functionality needs tests |
819
+ | Project has test framework (Jest, Vitest, etc.) | ✅ Yes | Infrastructure exists to run tests |
820
+ | Issue is a simple bug fix (`bug` label only) | ❌ No | Bug fixes typically have targeted tests |
821
+ | Issue is docs-only (`docs` label) | ❌ No | Documentation doesn't need unit tests |
822
+ | All ACs have "Manual Test" or "Browser Test" verification | ❌ No | These don't generate code stubs |
823
+
824
+ **Detection Logic:**
825
+
826
+ 1. **Check verification methods in AC items:**
827
+ - Count ACs with "Unit Test" → If >0, recommend testgen
828
+ - Count ACs with "Integration Test" → If >0, recommend testgen
829
+
830
+ 2. **Check issue labels:**
831
+ ```bash
832
+ gh issue view <issue> --json labels --jq '.labels[].name'
833
+ ```
834
+ - If `bug` or `fix` is the ONLY label → Skip testgen
835
+ - If `docs` is present → Skip testgen
836
+ - If `enhancement`, `feature`, `refactor` → Consider testgen
837
+
838
+ 3. **Check project test infrastructure:**
839
+ ```bash
840
+ # Check for test framework in package.json
841
+ grep -E "jest|vitest|mocha" package.json || true
842
+ ```
843
+ - If no test framework detected → Skip testgen (no infrastructure)
844
+
845
+ **Example output when testgen is recommended:**
846
+
847
+ ```markdown
848
+ ## Recommended Workflow
849
+
850
+ **Phases:** spec → testgen → exec → qa
851
+ **Quality Loop:** disabled
852
+ **Reasoning:** ACs include Unit Test verification methods; testgen will create stubs before implementation
853
+ ```
854
+
855
+ **Example output when testgen is NOT recommended:**
856
+
857
+ ```markdown
858
+ ## Recommended Workflow
550
859
 
551
- **Content Analysis Integration:**
552
- - Include content-detected phases in the workflow
553
- - Note signal source in reasoning (e.g., "Added /test based on title keyword 'extract component'")
860
+ **Phases:** spec → exec → qa
861
+ **Quality Loop:** disabled
862
+ **Reasoning:** Bug fix with targeted scope; existing tests sufficient
863
+ ```
554
864
 
555
865
  ### 6. Label Review
556
866
 
@@ -650,16 +960,26 @@ npx tsx scripts/state/update.ts fail <issue-number> spec "Error description"
650
960
  **Before responding, verify your output includes ALL of these:**
651
961
 
652
962
  - [ ] **AC Quality Check** - Lint results (or "Skipped" if --skip-ac-lint)
963
+ - [ ] **Scope Assessment** - Verdict and metrics (or "Skipped" if --skip-scope-check)
964
+ - [ ] **Non-Goals Section** - Listed or warning if missing
653
965
  - [ ] **AC Checklist** - Numbered AC items (AC-1, AC-2, etc.) with descriptions
654
- - [ ] **Verification Criteria** - Each AC has Verification Method and Test Scenario
966
+ - [ ] **Verification Criteria (REQUIRED)** - Each AC MUST have:
967
+ - Explicit Verification Method (Unit Test, Integration Test, Browser Test, or Manual Test)
968
+ - Test Scenario with Given/When/Then format
969
+ - If unclear, flag as "⚠️ UNCLEAR" and add to Open Questions
655
970
  - [ ] **Conflict Risk Analysis** - Check for in-flight work, include if conflicts found
656
971
  - [ ] **Implementation Plan** - 3-7 concrete steps with codebase references
657
- - [ ] **Content Analysis** - Title/body analysis results (or "Solve comment found" if using /solve)
658
- - [ ] **Recommended Workflow** - Phases, Quality Loop setting, Signal Sources, and Reasoning
972
+ - [ ] **Design Review** - All 4 questions answered (abbreviated to Q1+Q3 for simple-fix/typo/docs-only labels)
973
+ - [ ] **Feature Quality Planning** - Quality dimensions checklist completed (abbreviated for simple-fix/typo/docs-only labels)
974
+ - [ ] **Recommended Workflow** - Phases, Quality Loop setting, and Reasoning (auto-enable quality loop if scope is yellow/red)
659
975
  - [ ] **Label Review** - Current vs recommended labels based on plan analysis
660
- - [ ] **Open Questions** - Any ambiguities with recommended defaults
976
+ - [ ] **Open Questions** - Any ambiguities with recommended defaults (including unclear verification methods)
661
977
  - [ ] **Issue Comment Draft** - Formatted for GitHub posting
662
978
 
979
+ **CRITICAL:** Do NOT output AC items without verification methods. Either:
980
+ 1. Assign a verification method from the decision framework, or
981
+ 2. Flag as "⚠️ UNCLEAR" and include in Open Questions
982
+
663
983
  **DO NOT respond until all items are verified.**
664
984
 
665
985
  ## Output Template
@@ -673,6 +993,26 @@ You MUST include these sections in order:
673
993
 
674
994
  ---
675
995
 
996
+ ## Scope Assessment
997
+
998
+ ### Non-Goals (Required)
999
+
1000
+ [List non-goals from issue, or warning if missing]
1001
+
1002
+ ### Scope Metrics
1003
+
1004
+ | Metric | Value | Status |
1005
+ |--------|-------|--------|
1006
+ | Feature count | [N] | [✅/⚠️/❌] |
1007
+ | AC items | [N] | [✅/⚠️/❌] |
1008
+ | Directory spread | [N] | [✅/⚠️/❌] |
1009
+
1010
+ ### Scope Verdict
1011
+
1012
+ [✅/⚠️/❌] **[SCOPE_OK/SCOPE_WARNING/SCOPE_SPLIT_RECOMMENDED]** - [Recommendation]
1013
+
1014
+ ---
1015
+
676
1016
  ## Acceptance Criteria
677
1017
 
678
1018
  ### AC-1: [Description]
@@ -685,6 +1025,20 @@ You MUST include these sections in order:
685
1025
  - Then: [Expected outcome]
686
1026
 
687
1027
  ### AC-2: [Description]
1028
+
1029
+ **Verification Method:** [Choose from decision framework]
1030
+
1031
+ **Test Scenario:**
1032
+ - Given: [Initial state]
1033
+ - When: [Action]
1034
+ - Then: [Expected outcome]
1035
+
1036
+ ### AC-N: [Unclear AC example]
1037
+
1038
+ **Verification Method:** ⚠️ UNCLEAR - [reason why verification is unclear]
1039
+
1040
+ **Suggested Refinement:** [How to make this AC testable]
1041
+
688
1042
  <!-- Continue for all AC items -->
689
1043
 
690
1044
  ---
@@ -700,31 +1054,63 @@ You MUST include these sections in order:
700
1054
 
701
1055
  ---
702
1056
 
703
- ## Open Questions
1057
+ ## Design Review
704
1058
 
705
- 1. **[Question]**
706
- - Recommendation: [Default choice]
707
- - Impact: [What happens if wrong]
1059
+ 1. **Where does this logic belong?** [Module/layer that owns this change]
1060
+
1061
+ 2. **What's the simplest correct approach?** [Minimum implementation, rejected alternatives]
1062
+
1063
+ 3. **What existing pattern does this follow?** [Named pattern, confirmation it fits]
1064
+
1065
+ 4. **What would a senior reviewer challenge?** [Anticipated pushback]
1066
+
1067
+ <!-- For simple-fix/typo/docs-only: only Q1 and Q3 required -->
708
1068
 
709
1069
  ---
710
1070
 
711
- ## Content Analysis
1071
+ ## Feature Quality Planning
712
1072
 
713
- <!-- If solve comment found: -->
714
- **Source:** Solve comment found - using /solve workflow recommendations
1073
+ ### Completeness Check
1074
+ - [ ] All AC items have corresponding implementation steps
1075
+ - [ ] Integration points identified
1076
+ - [ ] No partial implementations planned
715
1077
 
716
- <!-- If no solve comment, show analysis: -->
717
- ### Signal Sources
1078
+ ### Error Handling
1079
+ - [ ] Invalid input scenarios identified
1080
+ - [ ] External service failures handled
1081
+ - [ ] Edge cases documented
718
1082
 
719
- | Phase | Source | Confidence | Reason |
720
- |-------|--------|------------|--------|
721
- | /test | title | high | "[matched keyword]" detected |
722
- | /security-review | body | medium | References [pattern] |
1083
+ ### Code Quality
1084
+ - [ ] Types fully defined (no `any`)
1085
+ - [ ] Follows existing patterns
1086
+ - [ ] No magic strings/numbers
723
1087
 
724
- ### Merged Recommendations
1088
+ ### Test Coverage Plan
1089
+ - [ ] Unit tests for business logic
1090
+ - [ ] Edge case tests identified
1091
+ - [ ] Critical paths covered
725
1092
 
726
- **From labels:** [label-detected phases]
727
- **From content:** [content-detected phases]
1093
+ ### Best Practices
1094
+ - [ ] Logging for observability
1095
+ - [ ] Security reviewed
1096
+ - [ ] Documentation updated
1097
+
1098
+ ### Polish (UI only)
1099
+ - [ ] Loading/error/empty states
1100
+ - [ ] Responsive design
1101
+
1102
+ ### Derived ACs
1103
+ | Source | Derived AC | Priority |
1104
+ |--------|-----------|----------|
1105
+ | [Section] | AC-N: [Description] | High/Medium/Low |
1106
+
1107
+ ---
1108
+
1109
+ ## Open Questions
1110
+
1111
+ 1. **[Question]**
1112
+ - Recommendation: [Default choice]
1113
+ - Impact: [What happens if wrong]
728
1114
 
729
1115
  ---
730
1116
 
@@ -732,7 +1118,6 @@ You MUST include these sections in order:
732
1118
 
733
1119
  **Phases:** exec → qa
734
1120
  **Quality Loop:** disabled
735
- **Signal Sources:** [labels | solve | content]
736
1121
  **Reasoning:** [Why these phases based on issue analysis]
737
1122
 
738
1123
  ---