sequant 2.3.0 → 2.5.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 (101) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/README.md +125 -160
  4. package/dist/bin/cli.js +59 -4
  5. package/dist/dashboard/server.js +1 -0
  6. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +2 -2
  7. package/dist/marketplace/external_plugins/sequant/README.md +6 -3
  8. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +92 -0
  9. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +18 -9
  10. package/dist/marketplace/external_plugins/sequant/hooks/relay-check.sh +107 -0
  11. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/behavior-rule-detection.md +205 -0
  12. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/subagent-types.md +21 -8
  13. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +302 -86
  14. package/dist/marketplace/external_plugins/sequant/skills/assess/references/predicted-collision-detection.md +109 -0
  15. package/dist/marketplace/external_plugins/sequant/skills/docs/SKILL.md +141 -22
  16. package/dist/marketplace/external_plugins/sequant/skills/exec/SKILL.md +83 -78
  17. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +377 -137
  18. package/dist/marketplace/external_plugins/sequant/skills/loop/SKILL.md +28 -0
  19. package/dist/marketplace/external_plugins/sequant/skills/merger/SKILL.md +621 -0
  20. package/dist/marketplace/external_plugins/sequant/skills/qa/SKILL.md +741 -232
  21. package/dist/marketplace/external_plugins/sequant/skills/qa/scripts/quality-checks.sh +47 -1
  22. package/dist/marketplace/external_plugins/sequant/skills/setup/SKILL.md +12 -6
  23. package/dist/marketplace/external_plugins/sequant/skills/spec/SKILL.md +217 -964
  24. package/dist/marketplace/external_plugins/sequant/skills/spec/references/parallel-groups.md +7 -0
  25. package/dist/marketplace/external_plugins/sequant/skills/spec/references/quality-checklist.md +75 -0
  26. package/dist/marketplace/external_plugins/sequant/skills/spec/references/recommended-workflow.md +4 -2
  27. package/dist/marketplace/external_plugins/sequant/skills/test/SKILL.md +0 -27
  28. package/dist/marketplace/external_plugins/sequant/skills/testgen/SKILL.md +24 -44
  29. package/dist/src/commands/abort.d.ts +36 -0
  30. package/dist/src/commands/abort.js +138 -0
  31. package/dist/src/commands/prompt.d.ts +7 -0
  32. package/dist/src/commands/prompt.js +101 -7
  33. package/dist/src/commands/ready-tui-adapter.d.ts +59 -0
  34. package/dist/src/commands/ready-tui-adapter.js +130 -0
  35. package/dist/src/commands/ready.d.ts +49 -0
  36. package/dist/src/commands/ready.js +243 -0
  37. package/dist/src/commands/run-progress.d.ts +11 -1
  38. package/dist/src/commands/run-progress.js +20 -3
  39. package/dist/src/commands/run.js +12 -2
  40. package/dist/src/commands/status.js +4 -0
  41. package/dist/src/commands/watch.d.ts +2 -0
  42. package/dist/src/commands/watch.js +67 -3
  43. package/dist/src/lib/assess-collision-detect.js +1 -1
  44. package/dist/src/lib/cli-ui/run-renderer-types.d.ts +39 -0
  45. package/dist/src/lib/cli-ui/run-renderer.d.ts +34 -2
  46. package/dist/src/lib/cli-ui/run-renderer.js +250 -33
  47. package/dist/src/lib/cli-ui/scrollback-harness.d.ts +112 -0
  48. package/dist/src/lib/cli-ui/scrollback-harness.js +294 -0
  49. package/dist/src/lib/merge-check/types.js +1 -1
  50. package/dist/src/lib/relay/archive.js +6 -0
  51. package/dist/src/lib/relay/types.d.ts +2 -0
  52. package/dist/src/lib/relay/types.js +9 -0
  53. package/dist/src/lib/settings.d.ts +34 -0
  54. package/dist/src/lib/settings.js +23 -1
  55. package/dist/src/lib/workflow/batch-executor.js +34 -18
  56. package/dist/src/lib/workflow/drivers/agent-driver.d.ts +48 -1
  57. package/dist/src/lib/workflow/drivers/aider.d.ts +7 -1
  58. package/dist/src/lib/workflow/drivers/aider.js +9 -0
  59. package/dist/src/lib/workflow/drivers/claude-code.d.ts +17 -1
  60. package/dist/src/lib/workflow/drivers/claude-code.js +51 -2
  61. package/dist/src/lib/workflow/drivers/index.d.ts +1 -1
  62. package/dist/src/lib/workflow/event-emitter.d.ts +157 -0
  63. package/dist/src/lib/workflow/event-emitter.js +102 -0
  64. package/dist/src/lib/workflow/notice.d.ts +32 -0
  65. package/dist/src/lib/workflow/notice.js +38 -0
  66. package/dist/src/lib/workflow/phase-executor.d.ts +9 -21
  67. package/dist/src/lib/workflow/phase-executor.js +105 -117
  68. package/dist/src/lib/workflow/phase-mapper.d.ts +26 -13
  69. package/dist/src/lib/workflow/phase-mapper.js +55 -33
  70. package/dist/src/lib/workflow/phase-registry.d.ts +127 -0
  71. package/dist/src/lib/workflow/phase-registry.js +233 -0
  72. package/dist/src/lib/workflow/platforms/github.d.ts +6 -0
  73. package/dist/src/lib/workflow/platforms/github.js +17 -0
  74. package/dist/src/lib/workflow/ready-gate.d.ts +155 -0
  75. package/dist/src/lib/workflow/ready-gate.js +374 -0
  76. package/dist/src/lib/workflow/reconcile.js +6 -0
  77. package/dist/src/lib/workflow/run-log-schema.d.ts +5 -55
  78. package/dist/src/lib/workflow/run-orchestrator.d.ts +32 -2
  79. package/dist/src/lib/workflow/run-orchestrator.js +125 -11
  80. package/dist/src/lib/workflow/state-manager.d.ts +19 -1
  81. package/dist/src/lib/workflow/state-manager.js +27 -1
  82. package/dist/src/lib/workflow/state-schema.d.ts +23 -35
  83. package/dist/src/lib/workflow/state-schema.js +29 -3
  84. package/dist/src/lib/workflow/types.d.ts +74 -15
  85. package/dist/src/lib/workflow/types.js +18 -13
  86. package/dist/src/ui/tui/App.js +8 -2
  87. package/dist/src/ui/tui/IssueBox.js +3 -4
  88. package/dist/src/ui/tui/index.d.ts +13 -4
  89. package/dist/src/ui/tui/index.js +19 -5
  90. package/dist/src/ui/tui/row-cap.d.ts +51 -0
  91. package/dist/src/ui/tui/row-cap.js +76 -0
  92. package/dist/src/ui/tui/teardown.d.ts +20 -0
  93. package/dist/src/ui/tui/teardown.js +29 -0
  94. package/dist/src/ui/tui/theme.d.ts +3 -0
  95. package/dist/src/ui/tui/theme.js +3 -0
  96. package/package.json +23 -11
  97. package/templates/hooks/post-tool.sh +81 -0
  98. package/templates/skills/assess/SKILL.md +28 -28
  99. package/templates/skills/assess/references/predicted-collision-detection.md +1 -1
  100. package/templates/skills/qa/SKILL.md +5 -2
  101. package/templates/skills/setup/SKILL.md +6 -6
@@ -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:
@@ -1507,13 +1497,47 @@ Look in the issue comments (especially from `/spec`) for:
1507
1497
 
1508
1498
  **If Parallel Groups exist:**
1509
1499
 
1500
+ 0. **Check isolation mode (AC-20):**
1501
+ ```bash
1502
+ # Check env var first (set by --isolate-parallel CLI flag via phase-executor),
1503
+ # then fall back to settings.json
1504
+ ISOLATE="${SEQUANT_ISOLATE_PARALLEL:-}"
1505
+ if [ -z "$ISOLATE" ]; then
1506
+ ISOLATE=$(cat .sequant/settings.json 2>/dev/null | grep -o '"isolateParallel":[^,}]*' | grep -o 'true\|false' || echo "false")
1507
+ fi
1508
+ echo "Parallel isolation mode: ${ISOLATE}"
1509
+ ```
1510
+
1511
+ **If isolation is enabled (`isolateParallel: true` or `--isolate-parallel`):**
1512
+ - Create sub-worktrees BEFORE spawning agents (see step 1b below)
1513
+ - Each agent gets its own working directory
1514
+ - After agents complete, merge changes back (see step 5b below)
1515
+
1516
+ **If isolation is disabled (default):**
1517
+ - All agents share the issue worktree (current behavior)
1518
+ - Skip steps 1b and 5b
1519
+
1510
1520
  1. **Create group marker before spawning agents:**
1511
1521
  ```bash
1512
1522
  touch /tmp/claude-parallel-group-1.marker
1513
1523
  ```
1514
1524
 
1525
+ 1b. **Create sub-worktrees (isolation mode only):**
1526
+ ```bash
1527
+ # Uses the tested TypeScript API via CLI wrapper.
1528
+ # Creates sub-worktree, symlinks node_modules, copies env files from .worktreeinclude.
1529
+ WORKTREE_PATH="[issue worktree path]"
1530
+ for i in 0 1 2; do # adjust for number of agents
1531
+ result=$(npx tsx scripts/worktree-isolation.ts create "${WORKTREE_PATH}" $i)
1532
+ AGENT_PATH=$(echo "$result" | jq -r '.path')
1533
+ echo "Agent ${i}: ${AGENT_PATH}"
1534
+ done
1535
+ ```
1536
+
1515
1537
  2. **Determine model for each task:**
1516
1538
 
1539
+ <!-- Note: model param inert per anthropics/claude-code#43869; the parsing
1540
+ logic below reactivates automatically when the upstream fix ships. -->
1517
1541
  Check for model annotations in the task line: `[model: haiku]` or `[model: sonnet]`
1518
1542
 
1519
1543
  **Model Selection Priority:**
@@ -1524,15 +1548,22 @@ Look in the issue comments (especially from `/spec`) for:
1524
1548
  3. **Spawn parallel agents with the appropriate model in a SINGLE message:**
1525
1549
  Note: `sequant-implementer` intentionally omits `model` in its agent definition
1526
1550
  so the skill can override per-invocation (e.g., `model="haiku"` for subtasks).
1551
+
1552
+ **Working directory:** Use the sub-worktree path when isolation is enabled,
1553
+ otherwise use the issue worktree path.
1554
+
1527
1555
  ```
1528
1556
  Agent(subagent_type="sequant-implementer",
1529
1557
  model="haiku",
1530
1558
  run_in_background=true,
1531
1559
  prompt="Implement: Create types/metrics.ts with MetricEvent interface.
1532
- Working directory: [worktree path]
1533
- After completion, report what files were created/modified.")
1560
+ Working directory: [sub-worktree path or issue worktree path]
1561
+ After completion, commit your changes and report what files were created/modified.")
1534
1562
  ```
1535
1563
 
1564
+ **Important (isolation mode):** Tell agents to commit their changes in the
1565
+ sub-worktree. This is required for merge-back to work.
1566
+
1536
1567
  4. **Wait for all agents to complete:**
1537
1568
  ```
1538
1569
  TaskOutput(task_id="...", block=true)
@@ -1544,6 +1575,31 @@ Look in the issue comments (especially from `/spec`) for:
1544
1575
  npx prettier --write [files modified by agents]
1545
1576
  ```
1546
1577
 
1578
+ 5b. **Merge back and clean up sub-worktrees (isolation mode only):**
1579
+ ```bash
1580
+ WORKTREE_PATH="[issue worktree path]"
1581
+
1582
+ # Merge all agent branches back into the issue branch.
1583
+ # Uses the tested TypeScript API — handles conflict detection,
1584
+ # partial merges, and structured error reporting.
1585
+ MERGE_RESULT=$(npx tsx scripts/worktree-isolation.ts merge-all "${WORKTREE_PATH}")
1586
+ MERGED=$(echo "$MERGE_RESULT" | jq -r '.merged')
1587
+ CONFLICTS=$(echo "$MERGE_RESULT" | jq -r '.conflicts')
1588
+ echo "Merge-back: ${MERGED} merged, ${CONFLICTS} conflicts"
1589
+
1590
+ if [ "$CONFLICTS" -gt 0 ]; then
1591
+ echo "⚠️ Conflicts detected — flagged for next iteration:"
1592
+ echo "$MERGE_RESULT" | jq -r '.results[] | select(.success == false) | " Agent \(.agentIndex): \(.error)"'
1593
+ fi
1594
+
1595
+ # Clean up sub-worktrees and orphaned branches
1596
+ npx tsx scripts/worktree-isolation.ts cleanup "${WORKTREE_PATH}"
1597
+ ```
1598
+
1599
+ **If all merges succeed:** Proceed normally.
1600
+ **If conflicts occur:** Report conflicting files. The next `/exec` iteration
1601
+ can resolve them. Non-conflicting agents' changes are preserved.
1602
+
1547
1603
  6. **Proceed to next group or sequential tasks**
1548
1604
 
1549
1605
  **If no Parallel Groups section exists:**
@@ -1773,40 +1829,20 @@ When in doubt, choose:
1773
1829
 
1774
1830
  The goal is to satisfy AC with the smallest, safest change possible.
1775
1831
 
1776
- ### 5. Adversarial Self-Evaluation (REQUIRED)
1832
+ ### 5. Pre-PR Confidence Check (REQUIRED)
1777
1833
 
1778
- **Before outputting your final summary**, you MUST complete this adversarial self-evaluation to catch issues that automated checks miss.
1779
-
1780
- **Why this matters:** Sessions show that honest self-questioning consistently catches real issues:
1781
- - Tests that pass but don't cover the actual changes
1782
- - Features that build but don't work as expected
1783
- - AC items marked "done" but with weak implementation
1784
-
1785
- **Answer these questions honestly:**
1786
- 1. "Did anything not work as expected during implementation?"
1787
- 2. "If this feature broke tomorrow, would the current tests catch it?"
1788
- 3. "What's the weakest part of this implementation?"
1789
- 4. "Am I reporting success metrics without honest self-evaluation?"
1790
- 5. "For each changed source file, does a corresponding test file exist? If not, why is that acceptable?"
1791
- 6. "Did I run `npm run lint` and fix all errors, or am I hoping CI will pass?"
1834
+ **Before creating a PR**, state your confidence in 2-3 sentences.
1792
1835
 
1793
1836
  **Include this section in your output:**
1794
1837
 
1795
1838
  ```markdown
1796
- ### Self-Evaluation
1839
+ ### Pre-PR Confidence Check
1797
1840
 
1798
- - **Worked as expected:** [Yes/No - if No, explain what didn't work]
1799
- - **Test coverage confidence:** [High/Medium/Low - explain why]
1800
- - **Weakest part:** [Identify the weakest aspect of the implementation]
1801
- - **Honest assessment:** [Any concerns or caveats?]
1841
+ - **Weakest part:** [What's the most fragile aspect of this implementation?]
1842
+ - **Coverage gaps:** [Which changed files lack corresponding tests, and why is that acceptable?]
1802
1843
  ```
1803
1844
 
1804
- **If any answer reveals concerns:**
1805
- - Address the issues before proceeding
1806
- - Re-run relevant checks (`npm test`, `npm run build`)
1807
- - Update the self-evaluation after fixes
1808
-
1809
- **Do NOT skip this self-evaluation.** Honest reflection catches issues that automated checks miss.
1845
+ **If either field reveals concerns**, address them before creating the PR. Re-run `npm test` and `npm run build` after fixes.
1810
1846
 
1811
1847
  ---
1812
1848
 
@@ -1880,42 +1916,11 @@ You may be invoked multiple times for the same issue. Each time, re-establish co
1880
1916
 
1881
1917
  ---
1882
1918
 
1883
- ## State Tracking
1884
-
1885
- **IMPORTANT:** Update workflow state when running standalone (not orchestrated).
1886
-
1887
- ### Check Orchestration Mode
1888
-
1889
- The orchestration check happens automatically when you run the state update script - it exits silently if `SEQUANT_ORCHESTRATOR` is set.
1890
-
1891
- ### State Updates (Standalone Only)
1892
-
1893
- When NOT orchestrated (`SEQUANT_ORCHESTRATOR` is not set):
1894
-
1895
- **At skill start:**
1896
- ```bash
1897
- npx tsx scripts/state/update.ts start <issue-number> exec
1898
- ```
1899
-
1900
- **On successful completion:**
1901
- ```bash
1902
- npx tsx scripts/state/update.ts complete <issue-number> exec
1903
- ```
1904
-
1905
- **On failure:**
1906
- ```bash
1907
- npx tsx scripts/state/update.ts fail <issue-number> exec "Error description"
1908
- ```
1909
-
1910
- **Why this matters:** State tracking enables dashboard visibility, resume capability, and workflow orchestration. Skills update state when standalone; orchestrators handle state when running workflows.
1911
-
1912
- ---
1913
-
1914
1919
  ## Output Verification
1915
1920
 
1916
1921
  **Before responding, verify your output includes ALL of these:**
1917
1922
 
1918
- - [ ] **Self-Evaluation Completed** - Adversarial self-evaluation section included in output
1923
+ - [ ] **Pre-PR Confidence Check** - Weakest part and coverage gaps stated
1919
1924
  - [ ] **AC Progress Summary** - Which AC items are satisfied, partially met, or blocked
1920
1925
  - [ ] **Files Changed** - List of key files modified
1921
1926
  - [ ] **Test/Build/Lint Results** - Output from `npm run build`, `npm run lint`, and `npm test`