sequant 2.1.2 → 2.3.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 (146) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +73 -0
  4. package/dist/bin/cli.js +95 -9
  5. package/dist/src/commands/doctor.d.ts +25 -0
  6. package/dist/src/commands/doctor.js +36 -1
  7. package/dist/src/commands/init.d.ts +1 -0
  8. package/dist/src/commands/init.js +118 -0
  9. package/dist/src/commands/locks.d.ts +67 -0
  10. package/dist/src/commands/locks.js +290 -0
  11. package/dist/src/commands/merge.js +11 -0
  12. package/dist/src/commands/prompt.d.ts +39 -0
  13. package/dist/src/commands/prompt.js +179 -0
  14. package/dist/src/commands/run-display.d.ts +26 -0
  15. package/dist/src/commands/run-display.js +150 -0
  16. package/dist/src/commands/run-progress.d.ts +32 -0
  17. package/dist/src/commands/run-progress.js +76 -0
  18. package/dist/src/commands/run.js +83 -73
  19. package/dist/src/commands/stats.d.ts +2 -0
  20. package/dist/src/commands/stats.js +94 -8
  21. package/dist/src/commands/status.js +27 -1
  22. package/dist/src/commands/watch.d.ts +16 -0
  23. package/dist/src/commands/watch.js +147 -0
  24. package/dist/src/lib/ac-linter.d.ts +1 -1
  25. package/dist/src/lib/ac-linter.js +81 -0
  26. package/dist/src/lib/assess-collision-detect.d.ts +91 -0
  27. package/dist/src/lib/assess-collision-detect.js +217 -0
  28. package/dist/src/lib/assess-comment-parser.d.ts +59 -1
  29. package/dist/src/lib/assess-comment-parser.js +124 -2
  30. package/dist/src/lib/cli-ui/format.d.ts +19 -0
  31. package/dist/src/lib/cli-ui/format.js +34 -0
  32. package/dist/src/lib/cli-ui/run-renderer-types.d.ts +181 -0
  33. package/dist/src/lib/cli-ui/run-renderer-types.js +7 -0
  34. package/dist/src/lib/cli-ui/run-renderer.d.ts +239 -0
  35. package/dist/src/lib/cli-ui/run-renderer.js +1173 -0
  36. package/dist/src/lib/heuristics/behavior-rule-detector.d.ts +94 -0
  37. package/dist/src/lib/heuristics/behavior-rule-detector.js +467 -0
  38. package/dist/src/lib/locks/index.d.ts +7 -0
  39. package/dist/src/lib/locks/index.js +5 -0
  40. package/dist/src/lib/locks/lock-manager.d.ts +168 -0
  41. package/dist/src/lib/locks/lock-manager.js +433 -0
  42. package/dist/src/lib/locks/types.d.ts +59 -0
  43. package/dist/src/lib/locks/types.js +31 -0
  44. package/dist/src/lib/qa/markdown-only-ci.d.ts +46 -0
  45. package/dist/src/lib/qa/markdown-only-ci.js +74 -0
  46. package/dist/src/lib/relay/activation.d.ts +60 -0
  47. package/dist/src/lib/relay/activation.js +122 -0
  48. package/dist/src/lib/relay/archive.d.ts +34 -0
  49. package/dist/src/lib/relay/archive.js +106 -0
  50. package/dist/src/lib/relay/frame.d.ts +20 -0
  51. package/dist/src/lib/relay/frame.js +76 -0
  52. package/dist/src/lib/relay/index.d.ts +13 -0
  53. package/dist/src/lib/relay/index.js +13 -0
  54. package/dist/src/lib/relay/paths.d.ts +43 -0
  55. package/dist/src/lib/relay/paths.js +59 -0
  56. package/dist/src/lib/relay/pid.d.ts +34 -0
  57. package/dist/src/lib/relay/pid.js +72 -0
  58. package/dist/src/lib/relay/reader.d.ts +35 -0
  59. package/dist/src/lib/relay/reader.js +115 -0
  60. package/dist/src/lib/relay/types.d.ts +68 -0
  61. package/dist/src/lib/relay/types.js +76 -0
  62. package/dist/src/lib/relay/writer.d.ts +48 -0
  63. package/dist/src/lib/relay/writer.js +113 -0
  64. package/dist/src/lib/settings.d.ts +31 -1
  65. package/dist/src/lib/settings.js +18 -3
  66. package/dist/src/lib/skill-version.d.ts +19 -0
  67. package/dist/src/lib/skill-version.js +68 -0
  68. package/dist/src/lib/templates.d.ts +1 -0
  69. package/dist/src/lib/templates.js +1 -1
  70. package/dist/src/lib/version-check.d.ts +60 -5
  71. package/dist/src/lib/version-check.js +97 -9
  72. package/dist/src/lib/workflow/batch-executor.d.ts +20 -1
  73. package/dist/src/lib/workflow/batch-executor.js +249 -176
  74. package/dist/src/lib/workflow/config-resolver.js +4 -0
  75. package/dist/src/lib/workflow/heartbeat.d.ts +71 -0
  76. package/dist/src/lib/workflow/heartbeat.js +194 -0
  77. package/dist/src/lib/workflow/phase-executor.d.ts +88 -3
  78. package/dist/src/lib/workflow/phase-executor.js +276 -52
  79. package/dist/src/lib/workflow/phase-mapper.d.ts +3 -2
  80. package/dist/src/lib/workflow/phase-mapper.js +17 -20
  81. package/dist/src/lib/workflow/platforms/github.d.ts +1 -1
  82. package/dist/src/lib/workflow/platforms/github.js +20 -3
  83. package/dist/src/lib/workflow/pr-status.d.ts +18 -2
  84. package/dist/src/lib/workflow/pr-status.js +41 -9
  85. package/dist/src/lib/workflow/qa-stagnation.d.ts +117 -0
  86. package/dist/src/lib/workflow/qa-stagnation.js +179 -0
  87. package/dist/src/lib/workflow/run-orchestrator.d.ts +76 -0
  88. package/dist/src/lib/workflow/run-orchestrator.js +382 -29
  89. package/dist/src/lib/workflow/run-reflect.js +1 -1
  90. package/dist/src/lib/workflow/run-state.d.ts +71 -0
  91. package/dist/src/lib/workflow/run-state.js +14 -0
  92. package/dist/src/lib/workflow/state-cleanup.d.ts +13 -5
  93. package/dist/src/lib/workflow/state-cleanup.js +17 -5
  94. package/dist/src/lib/workflow/state-manager.d.ts +12 -1
  95. package/dist/src/lib/workflow/state-manager.js +37 -0
  96. package/dist/src/lib/workflow/state-schema.d.ts +62 -0
  97. package/dist/src/lib/workflow/state-schema.js +35 -1
  98. package/dist/src/lib/workflow/types.d.ts +74 -1
  99. package/dist/src/lib/workflow/worktree-manager.d.ts +12 -4
  100. package/dist/src/lib/workflow/worktree-manager.js +76 -17
  101. package/dist/src/mcp/tools/run.d.ts +44 -0
  102. package/dist/src/mcp/tools/run.js +104 -13
  103. package/dist/src/ui/tui/App.d.ts +14 -0
  104. package/dist/src/ui/tui/App.js +41 -0
  105. package/dist/src/ui/tui/ElapsedTimer.d.ts +10 -0
  106. package/dist/src/ui/tui/ElapsedTimer.js +31 -0
  107. package/dist/src/ui/tui/Header.d.ts +6 -0
  108. package/dist/src/ui/tui/Header.js +15 -0
  109. package/dist/src/ui/tui/IssueBox.d.ts +16 -0
  110. package/dist/src/ui/tui/IssueBox.js +68 -0
  111. package/dist/src/ui/tui/Spinner.d.ts +9 -0
  112. package/dist/src/ui/tui/Spinner.js +18 -0
  113. package/dist/src/ui/tui/index.d.ts +15 -0
  114. package/dist/src/ui/tui/index.js +29 -0
  115. package/dist/src/ui/tui/theme.d.ts +29 -0
  116. package/dist/src/ui/tui/theme.js +52 -0
  117. package/dist/src/ui/tui/truncate.d.ts +11 -0
  118. package/dist/src/ui/tui/truncate.js +31 -0
  119. package/package.json +10 -3
  120. package/templates/agents/sequant-explorer.md +1 -0
  121. package/templates/agents/sequant-qa-checker.md +2 -1
  122. package/templates/agents/sequant-testgen.md +1 -0
  123. package/templates/hooks/post-tool.sh +11 -0
  124. package/templates/hooks/pre-tool.sh +18 -9
  125. package/templates/hooks/relay-check.sh +107 -0
  126. package/templates/relay/frame.txt +11 -0
  127. package/templates/scripts/cleanup-worktree.sh +25 -3
  128. package/templates/scripts/new-feature.sh +6 -0
  129. package/templates/skills/_shared/references/behavior-rule-detection.md +205 -0
  130. package/templates/skills/_shared/references/subagent-types.md +21 -8
  131. package/templates/skills/assess/SKILL.md +261 -94
  132. package/templates/skills/assess/references/predicted-collision-detection.md +109 -0
  133. package/templates/skills/docs/SKILL.md +141 -22
  134. package/templates/skills/exec/SKILL.md +10 -49
  135. package/templates/skills/fullsolve/SKILL.md +80 -32
  136. package/templates/skills/loop/SKILL.md +28 -0
  137. package/templates/skills/merger/SKILL.md +621 -0
  138. package/templates/skills/qa/SKILL.md +746 -8
  139. package/templates/skills/qa/scripts/quality-checks.sh +47 -1
  140. package/templates/skills/setup/SKILL.md +6 -0
  141. package/templates/skills/spec/SKILL.md +217 -964
  142. package/templates/skills/spec/references/parallel-groups.md +7 -0
  143. package/templates/skills/spec/references/quality-checklist.md +75 -0
  144. package/templates/skills/spec/references/recommended-workflow.md +4 -2
  145. package/templates/skills/test/SKILL.md +0 -27
  146. package/templates/skills/testgen/SKILL.md +24 -44
@@ -0,0 +1,109 @@
1
+ # Predicted file-collision detection
2
+
3
+ `/assess` Step 5 inspects two sources of overlap between PROCEED issues:
4
+
5
+ 1. **Active-worktree overlap.** For each running worktree, `git diff --name-only main...HEAD` is intersected with the assessed issues' likely-touched files. Catches in-flight work.
6
+ 2. **Predicted file-collision (this document).** For each pair of unstarted PROCEED issues, the detector reads issue bodies and predicts which pairs will modify the same file once both run in parallel worktrees.
7
+
8
+ This document is the tunable surface for the predicted-collision heuristic. The skill prose in `SKILL.md` names the detection functions; the patterns and the exclusion list live here so they can change without skill edits.
9
+
10
+ ## Trigger
11
+
12
+ The detector runs automatically during Step 5 whenever ≥2 PROCEED issues are present in the assessment. Single-issue assessments skip it.
13
+
14
+ ## Path-extraction heuristics
15
+
16
+ For each issue body, paths are extracted in this order:
17
+
18
+ ### 1. Strip code blocks and HTML comments
19
+
20
+ Fenced code blocks (```` ``` … ``` ````) and HTML comments (`<!-- … -->`) are removed before any path matching. This is the **AC-5 false-positive guard**: paths quoted as code in prose count, paths inside a code block don't.
21
+
22
+ ### 2. Backtick-quoted source paths (PATH_REGEX)
23
+
24
+ Backtick-quoted paths starting with one of the tracked roots and ending in a known source extension are extracted verbatim:
25
+
26
+ ```
27
+ `(.claude|templates|skills|src|bin|docs)/<path-segment>+\.(md|ts|tsx|json|sh)`
28
+ ```
29
+
30
+ Examples that match:
31
+
32
+ - `` `.claude/skills/assess/SKILL.md` ``
33
+ - `` `src/lib/foo.ts` ``
34
+ - `` `templates/scripts/dev/foo.sh` ``
35
+
36
+ Examples that **don't** match:
37
+
38
+ - `` `phase-mapper.ts` `` — no directory prefix; too generic to disambiguate
39
+ - `` `.claude/skills/**/*.md` `` — glob, not a literal path
40
+ - `` `references/foo.md` `` — `references` is not a tracked root (it lives under `skills/<name>/`)
41
+
42
+ ### 3. Canonical bare form for skill files
43
+
44
+ Skill files have three byte-identical mirrors at `.claude/skills/<name>/...`, `templates/skills/<name>/...`, `skills/<name>/...`. Treating the mirrors as separate paths would produce 3× the `Order:` lines and 6× the warnings for one logical conflict.
45
+
46
+ The detector normalizes all three mirror prefixes to the bare subpath at extraction time:
47
+
48
+ | Input (in issue body) | Canonical |
49
+ |-----------------------|-----------|
50
+ | `` `.claude/skills/qa/SKILL.md` `` | `qa/SKILL.md` |
51
+ | `` `templates/skills/qa/SKILL.md` `` | `qa/SKILL.md` |
52
+ | `` `skills/qa/SKILL.md` `` | `qa/SKILL.md` |
53
+ | `` `qa/SKILL.md` `` (under 3-dir sync) | `qa/SKILL.md` |
54
+
55
+ This is the form that appears in `Order:` lines and `⚠` warnings.
56
+
57
+ ### 4. Bare `<name>/SKILL.md` references (gated on 3-dir sync)
58
+
59
+ When the body also signals "3-dir sync" (regex below), bare skill-file mentions like `` `qa/SKILL.md` `` and `` `spec/SKILL.md` `` are added to the path set in canonical form. The 3-dir-sync gate prevents over-extraction from incidental skill-file references in prose.
60
+
61
+ 3-dir-sync language is matched by:
62
+
63
+ ```
64
+ /3[- ]dir(?:ectory)?\s+sync|across\s+all\s+three\s+skill\s+directories|across\s+(?:the\s+)?three\s+skill\s+directories/i
65
+ ```
66
+
67
+ ### 5. Slash-command-skill derivation (gated on 3-dir sync)
68
+
69
+ When the body signals 3-dir sync, every `/<skill>` slash-command mention is also added as `<skill>/SKILL.md` (canonical bare form) — provided `<skill>` matches a known skill name. This catches issues that describe section changes via `/qa Section 6c`-style notation rather than naming the file path.
70
+
71
+ The known-skill-name list lives in `KNOWN_SKILL_NAMES` in `src/lib/assess-collision-detect.ts`. Keep it in sync with the actual skill set under `skills/`. Adding a new skill? Append its name here.
72
+
73
+ Slash-command derivation requires the same fenced-code-block / HTML-comment stripping — `/qa` mentioned only inside a code block does **not** trigger derivation.
74
+
75
+ ## False-positive guards
76
+
77
+ ### Globally excluded paths
78
+
79
+ These paths are stripped from every issue's path set before pairwise intersection. They are paths that virtually every PROCEED issue tends to touch — including them would flag every batch as colliding and train users to ignore the warning.
80
+
81
+ - `CHANGELOG.md` — every PROCEED issue updates the unreleased section
82
+ - `package-lock.json` — alphabetically merged in practice; collisions are rare in practice
83
+ - `yarn.lock`
84
+ - `pnpm-lock.yaml`
85
+
86
+ `EXCLUDED_PATHS` in `src/lib/assess-collision-detect.ts` is the canonical list. To add or remove an entry, edit that constant; this document and the skill prose pick up the change automatically.
87
+
88
+ ### Code block / HTML comment stripping
89
+
90
+ Step 1 of the extraction (above) removes all fenced code blocks and HTML comments before path matching. A path mentioned **only** inside one of those will not contribute to the issue's path set.
91
+
92
+ ### Path-shape constraints
93
+
94
+ The PATH_REGEX requires a directory prefix (one of the six tracked roots) and a known source extension. Bare filenames in prose (e.g. "phase-mapper.ts behavior") and glob patterns (`**/*.md`) are not extracted.
95
+
96
+ ## Tuning notes
97
+
98
+ - **Proximity weighting** is not implemented. The original feature design proposed weighting paths inside `- [ ] **AC-N:**` bullets higher than paths in "Motivation" or "Additional context". Adding it is a follow-up if the false-positive rate becomes a problem in practice; leave it out until evidence demands it.
99
+ - **Cost.** For 13 issues (the realistic batch ceiling), pairwise comparison is 78 pairs — cheap, no real performance concern. Don't optimize prematurely.
100
+
101
+ ## Output rules
102
+
103
+ The detector returns `CollisionResult[]` from `detectFileCollisions`. The formatter (`formatCollisionAnnotations`) renders annotations in the dashboard format:
104
+
105
+ - `Order: A → B (path)` per pair (or `Order: A → B → C (path)` for 3+ on the same file). `path` is the canonical bare form (e.g. `qa/SKILL.md`).
106
+ - `⚠ #N Modifies <path> (overlaps #M); land sequentially` per affected issue.
107
+ - `Chain: npx sequant run A B C --chain --qa-gate -q # alternative — N issues modify <path> (chain length≥3 historically 1/6 = 17%; see docs/reference/chain-mode-analysis-2026-05.md)` only when ≥3 issues collide on the same file (suggest-only). The historical-rate annotation comes from the #604 forensic write-up; users see the suggestion alongside the parallel default and can weigh the trade-off.
108
+
109
+ The bare-filename `Order:` exception (defined in the skill's "Annotation Rules") applies here — predicted collisions are file-collision reasons by definition, so the filename in parentheses is the reason verbatim.
@@ -55,13 +55,63 @@ gh pr list --search "head:feature/<issue-number>" --json number,headRefName
55
55
  **Step 3:** Analyze the implementation diff:
56
56
  ```bash
57
57
  # If PR exists:
58
- gh pr diff <pr-number>
58
+ gh pr diff <pr-number>
59
59
 
60
60
  # If no PR, use git diff from feature branch:
61
61
  git diff main...HEAD --name-only
62
62
  git diff main...HEAD
63
63
  ```
64
64
 
65
+ **Step 4:** Detect documentation-only changes:
66
+ ```bash
67
+ # Count non-documentation files changed
68
+ non_doc_files=$(git diff main...HEAD --name-only | grep -vE '\.(md|mdx)$|^docs/' | wc -l | xargs || true)
69
+ ```
70
+
71
+ **Decision Logic:**
72
+ ```
73
+ IF non_doc_files == 0 THEN
74
+ # Documentation-only issue detected
75
+ # Skip template generation, post confirmation comment instead
76
+ # See Section 2a: Documentation-Only Early Exit
77
+ ELSE
78
+ # Continue with normal documentation generation
79
+ END IF
80
+ ```
81
+
82
+ ### 2a. Documentation-Only Early Exit
83
+
84
+ When only documentation files (`.md`, `.mdx`, or files in `docs/`) were modified, skip template generation and post a confirmation comment instead.
85
+
86
+ **Detection criteria - ALL of these must be true:**
87
+ - `git diff main...HEAD --name-only` returns files
88
+ - All changed files match: `*.md`, `*.mdx`, or `docs/*`
89
+
90
+ **Early exit action:**
91
+
92
+ 1. **Post confirmation comment to GitHub issue:**
93
+ ```bash
94
+ gh issue comment <issue-number> --body "$(cat <<'EOF'
95
+ ## Documentation Review Complete
96
+
97
+ This issue contains **documentation-only changes**. No additional documentation generation required.
98
+
99
+ ### Files Modified:
100
+ [List of changed .md/.mdx/docs/ files]
101
+
102
+ ### Status:
103
+ ✅ Documentation changes are ready for review and merge.
104
+
105
+ ---
106
+ Ready to merge!
107
+ EOF
108
+ )"
109
+ ```
110
+
111
+ 2. **Exit without generating template documentation.**
112
+
113
+ **Skip to end of workflow** - do not proceed to Section 2 (Auto-Detect Documentation Type) or beyond.
114
+
65
115
  ### 2. Auto-Detect Documentation Type
66
116
 
67
117
  Determine documentation type based on changed files:
@@ -72,25 +122,45 @@ Determine documentation type based on changed files:
72
122
  - Files in `lib/admin/`
73
123
  - Admin-related API routes
74
124
 
75
- **User-Facing Documentation** (`docs/features/`):
76
- - Files in `app/[city]/`
77
- - Files in `components/` (non-admin)
78
- - Public-facing pages or features
125
+ **Developer Tool Documentation** (`docs/features/`):
126
+ - Files in `src/commands/`, `bin/`, `src/mcp/`
127
+ - CLI commands, MCP tools, scripts
128
+ - Configuration options, SDK integrations
129
+
130
+ **Infra / Scaffold Documentation** (`docs/features/`):
131
+ - Root config files (`package.json`, `*.config.{ts,js,mjs,cts,cjs,mts}`)
132
+ - TypeScript / JavaScript project config (`tsconfig.json`, `jsconfig.json`)
133
+ - Environment templates (`.env.example`)
134
+ - Next.js layout/page files (`src/app/**/layout.tsx`, `src/app/**/page.tsx`)
135
+ - Middleware (`src/middleware.ts`)
136
+ - Framework config (`payload.config.*`, `drizzle.config.*`, `next.config.*`, `vite.config.*`, `vitest.config.*`)
137
+
138
+ Everything else (user-facing pages, non-admin components, public-facing features) falls through to the default `developer-tool` template.
79
139
 
80
140
  **Decision Logic:**
81
141
  ```
82
142
  IF any file path contains "/admin/" THEN
83
143
  type = "admin"
84
144
  output_dir = "docs/admin/"
145
+ template = "admin" (Section 3a)
146
+ ELSE IF any file path matches "src/commands/|bin/|src/mcp/|scripts/" THEN
147
+ type = "developer-tool"
148
+ output_dir = "docs/features/"
149
+ template = "developer-tool" (Section 3b)
150
+ ELSE IF any file path matches "package\.json$|.*\.config\.(ts|js|mjs|cts|cjs|mts)$|(ts|js)config\.json$|\.env\.example$|^src/app/.*(layout|page)\.tsx$|^src/middleware\.ts$|^(payload|drizzle|next|vite|vitest)\.config\." THEN
151
+ type = "developer-tool"
152
+ output_dir = "docs/features/"
153
+ template = "developer-tool" (Section 3b)
85
154
  ELSE
86
- type = "feature"
155
+ type = "developer-tool"
87
156
  output_dir = "docs/features/"
157
+ template = "developer-tool" (Section 3b)
88
158
  END IF
89
159
  ```
90
160
 
91
- ### 3. Documentation Template
161
+ ### 3a. Admin/UI Documentation Template
92
162
 
93
- Generate documentation using this template:
163
+ Use this template for admin pages and UI features:
94
164
 
95
165
  ```markdown
96
166
  # [Feature Name]
@@ -130,11 +200,6 @@ Generate documentation using this template:
130
200
  2. [Step 2]
131
201
  3. [Step 3]
132
202
 
133
- ### [Workflow 2: e.g., "Bulk Edit Multiple Items"]
134
-
135
- 1. [Step 1]
136
- 2. [Step 2]
137
-
138
203
  ## Troubleshooting
139
204
 
140
205
  ### [Common Issue 1]
@@ -143,20 +208,69 @@ Generate documentation using this template:
143
208
 
144
209
  **Solution:** [How to fix it]
145
210
 
146
- ### [Common Issue 2]
211
+ ---
147
212
 
148
- **Symptoms:** [What the user sees]
213
+ *Generated for Issue #[number] on [date]*
214
+ ```
149
215
 
150
- **Solution:** [How to fix it]
216
+ ### 3b. Developer Tool Documentation Template
217
+
218
+ Use this template for CLI commands, MCP tools, scripts, and developer-facing features. Structure around the user's journey, not the API surface.
219
+
220
+ ```markdown
221
+ # [Feature Name]
222
+
223
+ [1-2 sentence summary: what it does and why you'd use it.]
224
+
225
+ ## Prerequisites
226
+
227
+ [Everything needed before this works. Be exhaustive — list tools, auth, config. Include verification commands.]
228
+
229
+ 1. **[Requirement 1]** — `verification command`
230
+ 2. **[Requirement 2]** — `verification command`
231
+
232
+ ## Setup
233
+
234
+ [Step-by-step to go from zero to working. If setup differs per environment/client/platform, show each separately with clear labels.]
235
+
236
+ ## What You Can Do
237
+
238
+ [Real examples of usage in natural language or command form. Show the most common actions first.]
239
+
240
+ ## What to Expect
241
+
242
+ [Set expectations: how long things take, what output looks like, where results go. Address "it looks like nothing is happening" if applicable.]
243
+
244
+ ## [Command/Tool] Reference
245
+
246
+ [Parameter tables, flags, options. Put this AFTER the narrative sections — users need context before reference.]
247
+
248
+ | Parameter | Type | Required | Default | Description |
249
+ |-----------|------|----------|---------|-------------|
250
+
251
+ ## Troubleshooting
252
+
253
+ [Real failure scenarios users will hit. Lead with what they see, then the fix.]
254
+
255
+ ### [Problem user sees]
256
+
257
+ [Cause and solution]
151
258
 
152
259
  ---
153
260
 
154
261
  *Generated for Issue #[number] on [date]*
155
262
  ```
156
263
 
264
+ **Key differences from admin template:**
265
+ - No "Access / URL / Menu / Permissions" section (not applicable to CLI tools)
266
+ - Prerequisites section is mandatory (CLI tools have more dependencies)
267
+ - "What to Expect" section addresses timing, output location, async behavior
268
+ - Setup may vary per environment — show each variant
269
+ - Reference tables come after narrative, not before
270
+
157
271
  ### 4. Content Guidelines
158
272
 
159
- **Focus on operational usage, not technical implementation:**
273
+ **For admin/UI features — focus on operational usage:**
160
274
 
161
275
  - "Click the 'Approve' button to publish the item"
162
276
  - NOT: "The `approveItem` function updates the database"
@@ -164,16 +278,19 @@ Generate documentation using this template:
164
278
  - "Wait for the green success message"
165
279
  - NOT: "The API returns a 200 status code"
166
280
 
281
+ **For developer tools — focus on the user's journey:**
282
+
283
+ - "Run `sequant serve` to start the MCP server"
284
+ - NOT: "The `serveCommand` function creates an MCP server instance"
285
+
286
+ - "This takes 10–20 minutes. Your editor will appear idle — that's normal."
287
+ - NOT: "The tool uses `spawnSync` with a 30-minute timeout"
288
+
167
289
  **Be specific and actionable:**
168
290
 
169
291
  - "Navigate to Admin → Items → Review Queue"
170
292
  - NOT: "Go to the review page"
171
293
 
172
- **Include visual cues when relevant:**
173
-
174
- - "Look for the blue 'Edit' icon next to each row"
175
- - NOT: "Click the edit button"
176
-
177
294
  **Document common workflows end-to-end:**
178
295
 
179
296
  - "To approve an item: 1. Open Review Queue, 2. Click item name, 3. Review details, 4. Click Approve"
@@ -239,6 +356,8 @@ Before completing, verify:
239
356
  - [ ] Correct folder (`docs/admin/` vs `docs/features/`)
240
357
  - [ ] Summary comment posted to issue
241
358
 
359
+ **Note:** For documentation-only issues (detected in Step 4), skip this checklist and use the simplified confirmation comment from Section 2a instead.
360
+
242
361
  ## Workflow Integration
243
362
 
244
363
  The `/docs` command is the final step before merging:
@@ -27,8 +27,8 @@ allowed-tools:
27
27
  - Bash(git push:*)
28
28
  - Bash(git worktree:*)
29
29
  # Worktree management
30
- - Bash(./scripts/dev/new-feature.sh:*)
31
- - Bash(./scripts/dev/cleanup-worktree.sh:*)
30
+ - Bash(./scripts/new-feature.sh:*)
31
+ - Bash(./scripts/cleanup-worktree.sh:*)
32
32
  # GitHub CLI
33
33
  - Bash(gh issue view:*)
34
34
  - Bash(gh issue comment:*)
@@ -273,7 +273,7 @@ When worktree creation is needed (standalone mode, no existing worktree):
273
273
  1. **Start worktree creation as background task:**
274
274
  ```bash
275
275
  # From main repo, start worktree creation in background
276
- ./scripts/dev/new-feature.sh <issue-number> &
276
+ ./scripts/new-feature.sh <issue-number> &
277
277
  WORKTREE_PID=$!
278
278
  echo "Worktree creation started (PID: $WORKTREE_PID)"
279
279
  ```
@@ -461,8 +461,8 @@ echo "Current branch: $CURRENT_BRANCH"
461
461
 
462
462
  **If on main/master branch:**
463
463
  1. **STOP** - Do not implement directly on main
464
- 2. Create a feature worktree first: `./scripts/dev/new-feature.sh <issue-number>`
465
- - For custom base branch: `./scripts/dev/new-feature.sh <issue-number> --base <branch>`
464
+ 2. Create a feature worktree first: `./scripts/new-feature.sh <issue-number>`
465
+ - For custom base branch: `./scripts/new-feature.sh <issue-number> --base <branch>`
466
466
  3. Navigate to the worktree before making any changes
467
467
 
468
468
  **Why this matters:** Work done directly on main can be lost during sync operations (git reset, git pull --rebase, etc.). Worktrees provide isolation and safe recovery through branches.
@@ -484,9 +484,9 @@ echo "Current branch: $CURRENT_BRANCH"
484
484
  ```bash
485
485
  # Step 1: Start worktree creation in background
486
486
  # For default (main) base:
487
- ./scripts/dev/new-feature.sh <issue-number> &
487
+ ./scripts/new-feature.sh <issue-number> &
488
488
  # For custom base branch (e.g., feature integration branch):
489
- ./scripts/dev/new-feature.sh <issue-number> --base feature/dashboard &
489
+ ./scripts/new-feature.sh <issue-number> --base feature/dashboard &
490
490
  WORKTREE_PID=$!
491
491
 
492
492
  # Step 2: Gather context while worktree creates (see Section 2)
@@ -517,7 +517,7 @@ echo "Current branch: $CURRENT_BRANCH"
517
517
  4. **After implementation is complete:**
518
518
  - Push the branch: `git push -u origin feature/<branch-name>`
519
519
  - Create PR (manually or via script)
520
- - The worktree will be cleaned up after PR merge using `./scripts/dev/cleanup-worktree.sh <branch-name>`
520
+ - The worktree will be cleaned up after PR merge using `./scripts/cleanup-worktree.sh <branch-name>`
521
521
 
522
522
  **Important:** Always work in the worktree directory, not the main repository, once the worktree is created.
523
523
 
@@ -806,16 +806,6 @@ After implementation is complete and all checks pass, create and verify the PR:
806
806
  - If PR exists: Record the URL from `gh pr view` output
807
807
  - If PR creation failed: Record the error and include manual creation instructions
808
808
 
809
- 6. **Record PR info in workflow state:**
810
- ```bash
811
- # Extract PR number and URL from gh pr view output, then update state
812
- PR_INFO=$(gh pr view --json number,url)
813
- PR_NUMBER=$(echo "$PR_INFO" | jq -r '.number')
814
- PR_URL=$(echo "$PR_INFO" | jq -r '.url')
815
- npx tsx scripts/state/update.ts pr <issue-number> "$PR_NUMBER" "$PR_URL"
816
- ```
817
- This enables `--cleanup` to detect merged PRs and auto-remove state entries.
818
-
819
809
  **PR Verification Failure Handling:**
820
810
 
821
811
  If `gh pr view` fails after retry:
@@ -1546,6 +1536,8 @@ Look in the issue comments (especially from `/spec`) for:
1546
1536
 
1547
1537
  2. **Determine model for each task:**
1548
1538
 
1539
+ <!-- Note: model param inert per anthropics/claude-code#43869; the parsing
1540
+ logic below reactivates automatically when the upstream fix ships. -->
1549
1541
  Check for model annotations in the task line: `[model: haiku]` or `[model: sonnet]`
1550
1542
 
1551
1543
  **Model Selection Priority:**
@@ -1924,37 +1916,6 @@ You may be invoked multiple times for the same issue. Each time, re-establish co
1924
1916
 
1925
1917
  ---
1926
1918
 
1927
- ## State Tracking
1928
-
1929
- **IMPORTANT:** Update workflow state when running standalone (not orchestrated).
1930
-
1931
- ### Check Orchestration Mode
1932
-
1933
- The orchestration check happens automatically when you run the state update script - it exits silently if `SEQUANT_ORCHESTRATOR` is set.
1934
-
1935
- ### State Updates (Standalone Only)
1936
-
1937
- When NOT orchestrated (`SEQUANT_ORCHESTRATOR` is not set):
1938
-
1939
- **At skill start:**
1940
- ```bash
1941
- npx tsx scripts/state/update.ts start <issue-number> exec
1942
- ```
1943
-
1944
- **On successful completion:**
1945
- ```bash
1946
- npx tsx scripts/state/update.ts complete <issue-number> exec
1947
- ```
1948
-
1949
- **On failure:**
1950
- ```bash
1951
- npx tsx scripts/state/update.ts fail <issue-number> exec "Error description"
1952
- ```
1953
-
1954
- **Why this matters:** State tracking enables dashboard visibility, resume capability, and workflow orchestration. Skills update state when standalone; orchestrators handle state when running workflows.
1955
-
1956
- ---
1957
-
1958
1919
  ## Output Verification
1959
1920
 
1960
1921
  **Before responding, verify your output includes ALL of these:**
@@ -34,6 +34,9 @@ allowed-tools:
34
34
  - Bash(git push:*)
35
35
  - Bash(git worktree:*)
36
36
  - Bash(./scripts/dev/*:*)
37
+ - Bash(./scripts/cleanup-worktree.sh:*)
38
+ - Bash(./scripts/new-feature.sh:*)
39
+ - Bash(./scripts/list-worktrees.sh:*)
37
40
  ---
38
41
 
39
42
  # Full Solve Command
@@ -244,6 +247,29 @@ Before creating any files, check if they already exist:
244
247
 
245
248
  **If work already exists:** Skip to the appropriate phase (e.g., if implementation is done, go to Phase 3 or 4).
246
249
 
250
+ ### 0.3 Acquire Concurrency Lock (#625)
251
+
252
+ **Before invoking `/spec`**, claim the per-issue concurrency lock. This prevents a second session (another `/fullsolve`, an `npx sequant run`, or another `/fullsolve` in a different window) from racing on the same issue and producing zero-diff exec failures.
253
+
254
+ ```bash
255
+ # Acquire lock for this issue. --skip-pid-check is required: the shell that
256
+ # runs this command exits immediately, so the lock's PID is dead by the time
257
+ # the next check runs. Stale recovery falls back to age-only (2h).
258
+ if ! npx sequant locks acquire <issue-number> \
259
+ --command="/fullsolve <issue-number>" \
260
+ --skip-pid-check; then
261
+ echo "❌ Another session is working on #<issue-number>. Run 'npx sequant locks list' for details."
262
+ echo " If you're sure the holder is dead, run: npx sequant locks clear <issue-number>"
263
+ exit 1
264
+ fi
265
+ ```
266
+
267
+ **Release contract:** Phase 5.5 releases the lock on the happy path. On ANY halt/abort branch (spec failure, exec exhausted, qa loop exhausted with AC_NOT_MET, unrecoverable error, stagnation halt), you MUST run `npx sequant locks release <issue-number> || true` **before** printing the halt message. The explicit release calls below cover the known branches; if you add a new abort path, add a release call there too.
268
+
269
+ **Backstop:** If a release is somehow missed, stale recovery clears the lock after 6h on the same host (`SEQUANT_SKILL_LOCK_TTL_MS` overrides). The user can also force-clear via `npx sequant locks clear <issue-number>`.
270
+
271
+ **Orchestrator/MCP mode:** When `SEQUANT_ORCHESTRATOR` is set, `locks acquire` and `locks release` are no-ops (exit 0, no file touched). Safe to call unconditionally.
272
+
247
273
  ## Phase 1: Planning (SPEC)
248
274
 
249
275
  **Invoke the `/spec` skill** to plan implementation and extract acceptance criteria.
@@ -284,8 +310,14 @@ After `/spec` completes, extract and store:
284
310
  If `/spec` fails:
285
311
  - Check if issue exists and is readable
286
312
  - Verify GitHub CLI authentication
313
+ - **Release the lock acquired in Phase 0.3** (so the user can retry without hitting the orphan window)
287
314
  - Report failure and exit workflow
288
315
 
316
+ ```bash
317
+ # Release before halting — see Phase 0.3 release contract.
318
+ npx sequant locks release <issue-number> || true
319
+ ```
320
+
289
321
  ```markdown
290
322
  ## Spec Failed
291
323
 
@@ -355,6 +387,11 @@ while exec_iteration < MAX_EXEC_ITERATIONS:
355
387
  ```
356
388
 
357
389
  **If all iterations exhausted:**
390
+ ```bash
391
+ # Release before halting — see Phase 0.3 release contract.
392
+ npx sequant locks release <issue-number> || true
393
+ ```
394
+
358
395
  ```markdown
359
396
  ## Exec Failed
360
397
 
@@ -446,7 +483,7 @@ while test_iteration < MAX_TEST_ITERATIONS:
446
483
  break
447
484
 
448
485
  # Use /loop to fix failures
449
- Skill(skill: "loop", args: "<issue-number> --phase test")
486
+ Skill(skill: "sequant:loop", args: "<issue-number> --phase test")
450
487
  test_iteration += 1
451
488
  ```
452
489
 
@@ -504,11 +541,29 @@ When `/qa` detects `SEQUANT_ORCHESTRATOR`, it:
504
541
 
505
542
  ### 4.3 QA Loop (Max 2 iterations)
506
543
 
507
- If verdict is not `READY_FOR_MERGE`, invoke `/loop` to fix and re-run QA:
544
+ If verdict is not `READY_FOR_MERGE`, invoke `/loop` to fix and re-run QA.
545
+
546
+ **Stagnation gate (issue #581):** Before each `/qa` re-invocation after iteration 1, run the stagnation detector. If it reports `stagnant: true` with reason `SAME_SHA_NO_PROGRESS`, the prior `/loop` made no commit and produced no diff — re-running `/qa` would yield the same verdict. Halt the loop and surface a hard blocker instead of wasting another cycle.
547
+
548
+ ```bash
549
+ # Run before each /qa call after iteration 0 (skip on first call):
550
+ npx tsx scripts/qa-stagnation.ts detect <issue-number>
551
+ # Output (JSON): {"stagnant": true|false, "reason"?: "SAME_SHA_NO_PROGRESS", "message": "...", ...}
552
+ # When stagnant === true: record telemetry, then halt — do NOT call /qa again.
553
+ npx tsx scripts/qa-stagnation.ts record <issue-number> <iteration> SAME_SHA_NO_PROGRESS --verdict=AC_NOT_MET
554
+ ```
508
555
 
509
556
  ```
510
557
  qa_iteration = 0
511
558
  while qa_iteration < MAX_QA_ITERATIONS:
559
+ if qa_iteration > 0:
560
+ # Stagnation gate — same-SHA same-verdict cycles are wasted.
561
+ decision = `npx tsx scripts/qa-stagnation.ts detect <issue-number>`
562
+ if decision.stagnant == true:
563
+ `npx tsx scripts/qa-stagnation.ts record <issue-number> {qa_iteration} SAME_SHA_NO_PROGRESS --verdict=AC_NOT_MET`
564
+ # Halt — no progress since last QA. Skip to 4.4 with stagnation note.
565
+ break
566
+
512
567
  result = Skill(skill: "qa", args: "<issue-number>")
513
568
 
514
569
  if result.verdict == "READY_FOR_MERGE":
@@ -524,7 +579,7 @@ while qa_iteration < MAX_QA_ITERATIONS:
524
579
  break
525
580
 
526
581
  # Use /loop to fix issues (AC_NOT_MET)
527
- Skill(skill: "loop", args: "<issue-number> --phase qa")
582
+ Skill(skill: "sequant:loop", args: "<issue-number> --phase qa")
528
583
  qa_iteration += 1
529
584
  ```
530
585
 
@@ -615,7 +670,7 @@ Post completion comment to issue with:
615
670
  gh pr merge <N> --squash
616
671
 
617
672
  # 2. Clean up worktree (removes local worktree + branch)
618
- ./scripts/dev/cleanup-worktree.sh feature/<issue-number>-*
673
+ ./scripts/cleanup-worktree.sh feature/<issue-number>-*
619
674
 
620
675
  # 3. Issue auto-closes if commit message contains "Fixes #N"
621
676
  ```
@@ -639,6 +694,16 @@ npx sequant doctor
639
694
 
640
695
  If any command fails, fix immediately on main before continuing. This catches issues like ESM compatibility bugs that unit tests may miss.
641
696
 
697
+ ### 5.5 Release Concurrency Lock (#625)
698
+
699
+ After the PR is created (or earlier if the workflow exits gracefully), release the lock so other sessions can claim it:
700
+
701
+ ```bash
702
+ npx sequant locks release <issue-number> || true
703
+ ```
704
+
705
+ `|| true` is intentional — release is idempotent; the lock may already have been cleared (orchestrator mode, age-based recovery, or manual `locks clear`). The exit code is informational only.
706
+
642
707
  ## Iteration Tracking
643
708
 
644
709
  Track iterations to prevent infinite loops:
@@ -737,15 +802,24 @@ Ready for human review and merge.
737
802
 
738
803
  ## Error Recovery
739
804
 
805
+ **Concurrency lock cleanup (#625, applies to every abort path below):**
806
+
807
+ ```bash
808
+ npx sequant locks release <issue-number> || true
809
+ ```
810
+
811
+ Run this BEFORE printing the halt/exit message in any of the branches below. The release call is idempotent (no-op when nothing is held, no-op in orchestrator mode), so calling it unconditionally on every error path is safe.
812
+
740
813
  **If spec fails:**
741
814
  - Check issue exists and is readable
742
815
  - Verify GitHub CLI authentication
816
+ - Release lock (see top of section)
743
817
  - Exit with clear error
744
818
 
745
819
  **If exec fails (build/test):**
746
820
  - Check error logs
747
821
  - Attempt targeted fix
748
- - If persistent, document and exit
822
+ - If persistent: release lock, document, and exit
749
823
 
750
824
  **If test loop exhausted:**
751
825
  - Document remaining failures
@@ -854,33 +928,7 @@ As an orchestrator, `/fullsolve` must:
854
928
  export SEQUANT_WORKTREE=<worktree-path>
855
929
  ```
856
930
 
857
- 2. **Initialize issue state at workflow start:**
858
- ```bash
859
- npx tsx scripts/state/update.ts init <issue-number> "<issue-title>"
860
- ```
861
-
862
- 3. **Update phase status** at each transition:
863
- ```bash
864
- # Before invoking child skill
865
- npx tsx scripts/state/update.ts start <issue-number> <phase>
866
-
867
- # After child skill completes
868
- npx tsx scripts/state/update.ts complete <issue-number> <phase>
869
-
870
- # If child skill fails
871
- npx tsx scripts/state/update.ts fail <issue-number> <phase> "Error"
872
- ```
873
-
874
- 4. **Update final status** after workflow completes:
875
- ```bash
876
- # On READY_FOR_MERGE
877
- npx tsx scripts/state/update.ts status <issue-number> ready_for_merge
878
-
879
- # On failure
880
- npx tsx scripts/state/update.ts status <issue-number> blocked
881
- ```
882
-
883
- **Why child skills skip state updates:** When `SEQUANT_ORCHESTRATOR` is set, child skills defer state management to the orchestrator to avoid duplicate updates.
931
+ 2. **State tracking** is handled automatically by the orchestrator runtime when `SEQUANT_ORCHESTRATOR` is set. Child skills defer state management to the orchestrator to avoid duplicate updates.
884
932
 
885
933
  ---
886
934