sequant 1.11.0 → 1.13.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 (66) hide show
  1. package/README.md +93 -7
  2. package/dist/bin/cli.js +12 -9
  3. package/dist/src/commands/doctor.js +25 -20
  4. package/dist/src/commands/init.js +152 -65
  5. package/dist/src/commands/logs.js +7 -6
  6. package/dist/src/commands/run.d.ts +13 -1
  7. package/dist/src/commands/run.js +75 -12
  8. package/dist/src/commands/stats.js +67 -48
  9. package/dist/src/commands/status.js +30 -12
  10. package/dist/src/index.d.ts +6 -0
  11. package/dist/src/index.js +4 -0
  12. package/dist/src/lib/ac-linter.d.ts +116 -0
  13. package/dist/src/lib/ac-linter.js +304 -0
  14. package/dist/src/lib/cli-ui.d.ts +196 -0
  15. package/dist/src/lib/cli-ui.js +544 -0
  16. package/dist/src/lib/content-analyzer.d.ts +89 -0
  17. package/dist/src/lib/content-analyzer.js +437 -0
  18. package/dist/src/lib/phase-signal.d.ts +94 -0
  19. package/dist/src/lib/phase-signal.js +171 -0
  20. package/dist/src/lib/plugin-version-sync.d.ts +26 -0
  21. package/dist/src/lib/plugin-version-sync.js +91 -0
  22. package/dist/src/lib/project-name.d.ts +40 -0
  23. package/dist/src/lib/project-name.js +191 -0
  24. package/dist/src/lib/semgrep.d.ts +136 -0
  25. package/dist/src/lib/semgrep.js +406 -0
  26. package/dist/src/lib/solve-comment-parser.d.ts +84 -0
  27. package/dist/src/lib/solve-comment-parser.js +200 -0
  28. package/dist/src/lib/stack-config.d.ts +51 -0
  29. package/dist/src/lib/stack-config.js +77 -0
  30. package/dist/src/lib/stacks.d.ts +66 -0
  31. package/dist/src/lib/stacks.js +332 -0
  32. package/dist/src/lib/templates.d.ts +2 -0
  33. package/dist/src/lib/templates.js +12 -3
  34. package/dist/src/lib/upstream/assessment.d.ts +70 -0
  35. package/dist/src/lib/upstream/assessment.js +385 -0
  36. package/dist/src/lib/upstream/index.d.ts +11 -0
  37. package/dist/src/lib/upstream/index.js +14 -0
  38. package/dist/src/lib/upstream/issues.d.ts +38 -0
  39. package/dist/src/lib/upstream/issues.js +267 -0
  40. package/dist/src/lib/upstream/relevance.d.ts +50 -0
  41. package/dist/src/lib/upstream/relevance.js +209 -0
  42. package/dist/src/lib/upstream/report.d.ts +29 -0
  43. package/dist/src/lib/upstream/report.js +391 -0
  44. package/dist/src/lib/upstream/types.d.ts +207 -0
  45. package/dist/src/lib/upstream/types.js +5 -0
  46. package/dist/src/lib/workflow/log-writer.d.ts +1 -1
  47. package/dist/src/lib/workflow/metrics-schema.d.ts +3 -3
  48. package/dist/src/lib/workflow/qa-cache.d.ts +199 -0
  49. package/dist/src/lib/workflow/qa-cache.js +440 -0
  50. package/dist/src/lib/workflow/run-log-schema.d.ts +34 -6
  51. package/dist/src/lib/workflow/run-log-schema.js +12 -1
  52. package/dist/src/lib/workflow/state-schema.d.ts +4 -4
  53. package/dist/src/lib/workflow/types.d.ts +4 -0
  54. package/package.json +6 -1
  55. package/templates/hooks/pre-tool.sh +6 -0
  56. package/templates/memory/constitution.md +1 -5
  57. package/templates/skills/_shared/references/prompt-templates.md +350 -0
  58. package/templates/skills/_shared/references/subagent-types.md +131 -0
  59. package/templates/skills/exec/SKILL.md +82 -0
  60. package/templates/skills/fullsolve/SKILL.md +19 -2
  61. package/templates/skills/loop/SKILL.md +3 -1
  62. package/templates/skills/qa/SKILL.md +79 -9
  63. package/templates/skills/qa/references/quality-gates.md +85 -1
  64. package/templates/skills/qa/references/semgrep-rules.md +207 -0
  65. package/templates/skills/qa/scripts/quality-checks.sh +525 -15
  66. package/templates/skills/spec/SKILL.md +322 -9
@@ -41,6 +41,116 @@ When called like `/spec <freeform description>`:
41
41
  1. Treat the text as the problem/AC source.
42
42
  2. Ask clarifying questions if AC are ambiguous or conflicting.
43
43
 
44
+ **Flag:** `--skip-ac-lint`
45
+ - Usage: `/spec 123 --skip-ac-lint`
46
+ - Effect: Skips the AC Quality Check step
47
+ - Use when: AC are intentionally high-level or you want to defer linting
48
+
49
+ ### AC Extraction and Storage — REQUIRED
50
+
51
+ **After fetching the issue body**, extract and store acceptance criteria in workflow state:
52
+
53
+ ```bash
54
+ # Extract AC from issue body and store in state
55
+ npx tsx -e "
56
+ import { extractAcceptanceCriteria } from './src/lib/ac-parser.js';
57
+ import { StateManager } from './src/lib/workflow/state-manager.js';
58
+
59
+ const issueBody = \`<ISSUE_BODY_HERE>\`;
60
+ const issueNumber = <ISSUE_NUMBER>;
61
+ const issueTitle = '<ISSUE_TITLE>';
62
+
63
+ const ac = extractAcceptanceCriteria(issueBody);
64
+ console.log('Extracted AC:', JSON.stringify(ac, null, 2));
65
+
66
+ if (ac.items.length > 0) {
67
+ const manager = new StateManager();
68
+ // Initialize issue if not exists
69
+ const existing = await manager.getIssueState(issueNumber);
70
+ if (!existing) {
71
+ await manager.initializeIssue(issueNumber, issueTitle);
72
+ }
73
+ await manager.updateAcceptanceCriteria(issueNumber, ac);
74
+ console.log('AC stored in state for issue #' + issueNumber);
75
+ }
76
+ "
77
+ ```
78
+
79
+ **Why this matters:** Storing AC in state enables:
80
+ - Dashboard visibility of AC progress per issue
81
+ - `/qa` skill to update AC status during review
82
+ - Cross-skill AC tracking throughout the workflow
83
+
84
+ **AC Format Detection:**
85
+ The parser supports multiple formats:
86
+ - `- [ ] **AC-1:** Description` (bold with hyphen)
87
+ - `- [ ] **B2:** Description` (letter + number)
88
+ - `- [ ] AC-1: Description` (no bold)
89
+
90
+ **If no AC found:**
91
+ - Log a warning but continue with planning
92
+ - The plan output should note that AC will need to be defined
93
+
94
+ ### AC Quality Check — REQUIRED (unless --skip-ac-lint)
95
+
96
+ **After extracting AC**, run the AC linter to flag vague, untestable, or incomplete requirements:
97
+
98
+ ```bash
99
+ # Lint AC for quality issues (skip if --skip-ac-lint flag is set)
100
+ npx tsx -e "
101
+ import { parseAcceptanceCriteria } from './src/lib/ac-parser.js';
102
+ import { lintAcceptanceCriteria, formatACLintResults } from './src/lib/ac-linter.js';
103
+
104
+ const issueBody = \`<ISSUE_BODY_HERE>\`;
105
+
106
+ const criteria = parseAcceptanceCriteria(issueBody);
107
+ const lintResults = lintAcceptanceCriteria(criteria);
108
+ console.log(formatACLintResults(lintResults));
109
+ "
110
+ ```
111
+
112
+ **Why this matters:** Vague AC lead to:
113
+ - Ambiguous implementations that don't match expectations
114
+ - Subjective /qa verdicts ("does it work properly?")
115
+ - Wasted iteration cycles when requirements are clarified late
116
+
117
+ **Pattern Detection:**
118
+
119
+ | Pattern Type | Examples | Issue |
120
+ |--------------|----------|-------|
121
+ | Vague | "should work", "properly", "correctly" | Subjective, no measurable outcome |
122
+ | Unmeasurable | "fast", "performant", "responsive" | No threshold defined |
123
+ | Incomplete | "handle errors", "edge cases" | Specific scenarios not enumerated |
124
+ | Open-ended | "etc.", "and more", "such as" | Scope is undefined |
125
+
126
+ **Example Output:**
127
+
128
+ ```markdown
129
+ ## AC Quality Check
130
+
131
+ ⚠️ **AC-2:** "System should handle errors gracefully"
132
+ → Incomplete: error types not specified
133
+ → Suggest: List specific error types and expected responses (e.g., 400 for invalid input, 503 for service unavailable)
134
+
135
+ ⚠️ **AC-4:** "Page loads quickly"
136
+ → Unmeasurable: "quickly" has no threshold
137
+ → Suggest: Specify time limit (e.g., completes in <5 seconds)
138
+
139
+ ✅ AC-1, AC-3, AC-5: Clear and testable
140
+
141
+ **Summary:** 2/5 AC items flagged for review
142
+ ```
143
+
144
+ **Behavior:**
145
+ - **Warning-only**: AC Quality Check does NOT block planning
146
+ - Issues are surfaced in the output but plan generation continues
147
+ - Include flagged AC in the issue comment draft with suggestions
148
+ - Recommend refining vague AC before implementation
149
+
150
+ **If `--skip-ac-lint` flag is set:**
151
+ - Output: `AC Quality Check: Skipped (--skip-ac-lint flag set)`
152
+ - Continue directly to plan generation
153
+
44
154
  ### Feature Worktree Workflow
45
155
 
46
156
  **Planning Phase:** No worktree needed. Planning happens in the main repository directory. The worktree will be created during the execution phase (`/exec`).
@@ -49,13 +159,62 @@ When called like `/spec <freeform description>`:
49
159
 
50
160
  **You MUST spawn sub-agents for context gathering.** Do NOT explore the codebase inline with Glob/Grep commands. Sub-agents provide parallel execution, better context isolation, and consistent reporting.
51
161
 
162
+ **Check agent execution mode first:**
163
+ ```bash
164
+ parallel=$(cat .sequant/settings.json 2>/dev/null | jq -r '.agents.parallel // false')
165
+ ```
166
+
167
+ #### If parallel mode enabled:
168
+
52
169
  **Spawn ALL THREE agents in a SINGLE message:**
53
170
 
54
- 1. `Task(subagent_type="pattern-scout", model="haiku", prompt="Find similar features for [FEATURE]. Check components/admin/, lib/queries/, docs/patterns/. Report: file paths, patterns, recommendations.")`
171
+ 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.")`
55
172
 
56
173
  2. `Task(subagent_type="Explore", model="haiku", prompt="Explore [CODEBASE AREA] for [FEATURE]. Find: main components, data flow, key files. Report structure.")`
57
174
 
58
- 3. `Task(subagent_type="schema-inspector", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
175
+ 3. `Task(subagent_type="Explore", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
176
+
177
+ #### If sequential mode (default):
178
+
179
+ **Spawn each agent ONE AT A TIME, waiting for each to complete:**
180
+
181
+ 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.")`
182
+
183
+ 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.")`
184
+
185
+ 3. **After #2 completes:** `Task(subagent_type="Explore", model="haiku", prompt="Inspect database for [FEATURE]. Check: table schema, RLS policies, existing queries. Report findings.")`
186
+
187
+ ### Feature Branch Context Detection
188
+
189
+ Before creating the implementation plan, check if a custom base branch should be recommended:
190
+
191
+ 1. **Check for feature branch references in issue body**:
192
+ ```bash
193
+ gh issue view <issue> --json body --jq '.body' | grep -iE "(feature/|branch from|based on|part of.*feature)"
194
+ ```
195
+
196
+ 2. **Check issue labels for feature context**:
197
+ ```bash
198
+ gh issue view <issue> --json labels --jq '.labels[].name' | grep -iE "(dashboard|feature-|epic-)"
199
+ ```
200
+
201
+ 3. **Check if project has defaultBase configured**:
202
+ ```bash
203
+ cat .sequant/settings.json 2>/dev/null | jq -r '.run.defaultBase // empty'
204
+ ```
205
+
206
+ 4. **If feature branch context detected**, include in plan output:
207
+ ```markdown
208
+ ## Feature Branch Context
209
+
210
+ **Detected base branch**: `feature/dashboard`
211
+ **Source**: Issue body mentions "Part of dashboard feature" / Project config / Label
212
+
213
+ **Recommended workflow**:
214
+ \`\`\`bash
215
+ npx sequant run <issue> --base feature/dashboard
216
+ \`\`\`
217
+ ```
59
218
 
60
219
  ### In-Flight Work Analysis (Conflict Detection)
61
220
 
@@ -66,9 +225,9 @@ Before creating the implementation plan, scan for potential conflicts with in-fl
66
225
  git worktree list --porcelain
67
226
  ```
68
227
 
69
- 2. **For each worktree, get changed files**:
228
+ 2. **For each worktree, get changed files** (use detected base branch or default to main):
70
229
  ```bash
71
- git -C <worktree-path> diff --name-only main...HEAD
230
+ git -C <worktree-path> diff --name-only <base-branch>...HEAD
72
231
  ```
73
232
 
74
233
  3. **Analyze this issue's likely file touches** based on:
@@ -127,6 +286,14 @@ Before creating the implementation plan, scan for potential conflicts with in-fl
127
286
  3. **Check existing dependencies**
128
287
  - Review `package.json` for libraries
129
288
  - Prefer existing dependencies over new ones
289
+ - For "solved problem" domains, recommend established packages in the plan:
290
+ | Domain | Recommended Packages |
291
+ |--------|---------------------|
292
+ | Date/time | `date-fns`, `dayjs` |
293
+ | Validation | `zod`, `yup`, `valibot` |
294
+ | HTTP with retry | `ky`, `got`, `axios` |
295
+ | Form state | `react-hook-form` |
296
+ | State management | `zustand`, `jotai` |
130
297
 
131
298
  4. **For database-heavy features**
132
299
  - Verify table schemas against TypeScript types
@@ -190,7 +357,82 @@ Ask the user to confirm or adjust:
190
357
 
191
358
  **Do NOT start implementation** - this is planning-only.
192
359
 
193
- ### 4. Recommended Workflow
360
+ ### 4. Content Analysis (AC-1, AC-2, AC-3, AC-4)
361
+
362
+ **Before** determining the recommended workflow, analyze the issue content for phase-relevant signals:
363
+
364
+ #### Step 1: Check for Solve Comment (AC-4)
365
+
366
+ First, check if a `/solve` comment already exists for this issue:
367
+
368
+ ```bash
369
+ # Check issue comments for solve workflow
370
+ gh issue view <issue-number> --json comments --jq '.comments[].body' | grep -l "## Solve Workflow for Issues:"
371
+ ```
372
+
373
+ **If solve comment found:**
374
+ - Extract phases from the solve workflow (e.g., `spec → exec → test → qa`)
375
+ - Use solve recommendations as the primary source (after labels)
376
+ - Skip content analysis for phases (solve already analyzed)
377
+ - Include in output: `"Solve comment found - using /solve workflow recommendations"`
378
+
379
+ #### Step 2: Analyze Title for Keywords (AC-1)
380
+
381
+ If no solve comment, analyze the issue title for phase-relevant keywords:
382
+
383
+ | Pattern | Detection | Suggested Phase |
384
+ |---------|-----------|-----------------|
385
+ | `extract`, `component` | UI work | Add `/test` |
386
+ | `refactor.*ui`, `ui refactor` | UI work | Add `/test` |
387
+ | `frontend`, `dashboard` | UI work | Add `/test` |
388
+ | `auth`, `permission`, `security` | Security-sensitive | Add `/security-review` |
389
+ | `password`, `credential`, `token` | Security-sensitive | Add `/security-review` |
390
+ | `refactor`, `migration`, `restructure` | Complex work | Enable quality loop |
391
+ | `breaking change` | Complex work | Enable quality loop |
392
+
393
+ #### Step 3: Analyze Body for Patterns (AC-2)
394
+
395
+ Analyze the issue body for file references and keywords:
396
+
397
+ | Pattern | Detection | Suggested Phase |
398
+ |---------|-----------|-----------------|
399
+ | References `.tsx` or `.jsx` files | UI work likely | Add `/test` |
400
+ | References `components/` directory | UI work | Add `/test` |
401
+ | References `scripts/` or `bin/` | CLI work | May need `/verify` |
402
+ | References `auth/` directory | Security-sensitive | Add `/security-review` |
403
+ | References `middleware.ts` | May be auth-related | Consider `/security-review` |
404
+ | Contains "breaking change" | Complex work | Enable quality loop |
405
+
406
+ #### Step 4: Merge Signals (AC-3)
407
+
408
+ Content analysis **supplements** label detection - it can only ADD phases, never remove them.
409
+
410
+ **Priority order (highest first):**
411
+ 1. **Labels** (explicit, highest priority)
412
+ 2. **Solve comment** (if exists)
413
+ 3. **Title keywords**
414
+ 4. **Body patterns** (lowest priority)
415
+
416
+ **Output format:**
417
+
418
+ ```markdown
419
+ ## Content Analysis
420
+
421
+ ### Signal Sources
422
+
423
+ | Phase | Source | Confidence | Reason |
424
+ |-------|--------|------------|--------|
425
+ | /test | title | high | "Extract component" detected |
426
+ | /security-review | body | medium | References auth/ directory |
427
+
428
+ ### Merged Recommendations
429
+
430
+ **From labels:** /test (ui label)
431
+ **From content:** /security-review (added)
432
+ **Final phases:** spec → exec → test → security-review → qa
433
+ ```
434
+
435
+ ### 5. Recommended Workflow
194
436
 
195
437
  Analyze the issue and recommend the optimal workflow phases:
196
438
 
@@ -199,6 +441,7 @@ Analyze the issue and recommend the optimal workflow phases:
199
441
 
200
442
  **Phases:** spec → exec → qa
201
443
  **Quality Loop:** disabled
444
+ **Signal Sources:** [labels | solve | content]
202
445
  **Reasoning:** [Brief explanation of why these phases were chosen]
203
446
  ```
204
447
 
@@ -209,7 +452,11 @@ Analyze the issue and recommend the optimal workflow phases:
209
452
  - **Security-sensitive** → Add `security-review` phase
210
453
  - **Documentation only** → Skip `spec`, just `exec → qa`
211
454
 
212
- ### 5. Label Review
455
+ **Content Analysis Integration:**
456
+ - Include content-detected phases in the workflow
457
+ - Note signal source in reasoning (e.g., "Added /test based on title keyword 'extract component'")
458
+
459
+ ### 6. Label Review
213
460
 
214
461
  Analyze current labels vs implementation plan and suggest updates:
215
462
 
@@ -239,7 +486,7 @@ Analyze current labels vs implementation plan and suggest updates:
239
486
  - Check if API contracts are changing
240
487
  - Match against quality loop trigger labels
241
488
 
242
- ### 6. Issue Comment Draft
489
+ ### 7. Issue Comment Draft
243
490
 
244
491
  Generate a Markdown snippet with:
245
492
  - AC checklist with verification criteria
@@ -255,7 +502,7 @@ Label clearly as:
255
502
  --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---
256
503
  ```
257
504
 
258
- ### 7. Update GitHub Issue
505
+ ### 8. Update GitHub Issue
259
506
 
260
507
  Post the draft comment to GitHub:
261
508
  ```bash
@@ -265,15 +512,54 @@ gh issue edit <issue-number> --add-label "planned"
265
512
 
266
513
  ---
267
514
 
515
+ ## State Tracking
516
+
517
+ **IMPORTANT:** Update workflow state when running standalone (not orchestrated).
518
+
519
+ ### Check Orchestration Mode
520
+
521
+ At the start of the skill, check if running orchestrated:
522
+ ```bash
523
+ # Check if orchestrated - if so, skip state updates
524
+ if [[ -n "$SEQUANT_ORCHESTRATOR" ]]; then
525
+ echo "Running orchestrated - state managed by orchestrator"
526
+ fi
527
+ ```
528
+
529
+ ### State Updates (Standalone Only)
530
+
531
+ When NOT orchestrated (`SEQUANT_ORCHESTRATOR` is not set):
532
+
533
+ **At skill start:**
534
+ ```bash
535
+ npx tsx scripts/state/update.ts start <issue-number> spec
536
+ ```
537
+
538
+ **On successful completion:**
539
+ ```bash
540
+ npx tsx scripts/state/update.ts complete <issue-number> spec
541
+ ```
542
+
543
+ **On failure:**
544
+ ```bash
545
+ npx tsx scripts/state/update.ts fail <issue-number> spec "Error description"
546
+ ```
547
+
548
+ **Why this matters:** State tracking enables dashboard visibility, resume capability, and workflow orchestration. Skills update state when standalone; orchestrators handle state when running workflows.
549
+
550
+ ---
551
+
268
552
  ## Output Verification
269
553
 
270
554
  **Before responding, verify your output includes ALL of these:**
271
555
 
556
+ - [ ] **AC Quality Check** - Lint results (or "Skipped" if --skip-ac-lint)
272
557
  - [ ] **AC Checklist** - Numbered AC items (AC-1, AC-2, etc.) with descriptions
273
558
  - [ ] **Verification Criteria** - Each AC has Verification Method and Test Scenario
274
559
  - [ ] **Conflict Risk Analysis** - Check for in-flight work, include if conflicts found
275
560
  - [ ] **Implementation Plan** - 3-7 concrete steps with codebase references
276
- - [ ] **Recommended Workflow** - Phases, Quality Loop setting, and Reasoning
561
+ - [ ] **Content Analysis** - Title/body analysis results (or "Solve comment found" if using /solve)
562
+ - [ ] **Recommended Workflow** - Phases, Quality Loop setting, Signal Sources, and Reasoning
277
563
  - [ ] **Label Review** - Current vs recommended labels based on plan analysis
278
564
  - [ ] **Open Questions** - Any ambiguities with recommended defaults
279
565
  - [ ] **Issue Comment Draft** - Formatted for GitHub posting
@@ -285,6 +571,12 @@ gh issue edit <issue-number> --add-label "planned"
285
571
  You MUST include these sections in order:
286
572
 
287
573
  ```markdown
574
+ ## AC Quality Check
575
+
576
+ [Output from AC linter, or "Skipped (--skip-ac-lint flag set)"]
577
+
578
+ ---
579
+
288
580
  ## Acceptance Criteria
289
581
 
290
582
  ### AC-1: [Description]
@@ -320,10 +612,31 @@ You MUST include these sections in order:
320
612
 
321
613
  ---
322
614
 
615
+ ## Content Analysis
616
+
617
+ <!-- If solve comment found: -->
618
+ **Source:** Solve comment found - using /solve workflow recommendations
619
+
620
+ <!-- If no solve comment, show analysis: -->
621
+ ### Signal Sources
622
+
623
+ | Phase | Source | Confidence | Reason |
624
+ |-------|--------|------------|--------|
625
+ | /test | title | high | "[matched keyword]" detected |
626
+ | /security-review | body | medium | References [pattern] |
627
+
628
+ ### Merged Recommendations
629
+
630
+ **From labels:** [label-detected phases]
631
+ **From content:** [content-detected phases]
632
+
633
+ ---
634
+
323
635
  ## Recommended Workflow
324
636
 
325
637
  **Phases:** exec → qa
326
638
  **Quality Loop:** disabled
639
+ **Signal Sources:** [labels | solve | content]
327
640
  **Reasoning:** [Why these phases based on issue analysis]
328
641
 
329
642
  ---