sequant 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/dist/bin/cli.js +2 -1
  4. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +1 -1
  5. package/dist/marketplace/external_plugins/sequant/.mcp.json +6 -0
  6. package/dist/marketplace/external_plugins/sequant/README.md +58 -8
  7. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +19 -8
  8. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +36 -49
  9. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/subagent-types.md +158 -48
  10. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +354 -352
  11. package/dist/marketplace/external_plugins/sequant/skills/exec/SKILL.md +1155 -33
  12. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +35 -4
  13. package/dist/marketplace/external_plugins/sequant/skills/qa/SKILL.md +2157 -104
  14. package/dist/marketplace/external_plugins/sequant/skills/qa/scripts/quality-checks.sh +1 -1
  15. package/dist/marketplace/external_plugins/sequant/skills/setup/SKILL.md +386 -0
  16. package/dist/marketplace/external_plugins/sequant/skills/solve/SKILL.md +38 -664
  17. package/dist/marketplace/external_plugins/sequant/skills/spec/SKILL.md +505 -120
  18. package/dist/marketplace/external_plugins/sequant/skills/test/SKILL.md +246 -1
  19. package/dist/marketplace/external_plugins/sequant/skills/testgen/SKILL.md +138 -1
  20. package/dist/src/commands/dashboard.js +1 -1
  21. package/dist/src/commands/doctor.js +1 -1
  22. package/dist/src/commands/init.js +10 -10
  23. package/dist/src/commands/logs.js +1 -1
  24. package/dist/src/commands/run.js +49 -39
  25. package/dist/src/commands/state.js +3 -3
  26. package/dist/src/commands/status.js +5 -5
  27. package/dist/src/commands/sync.js +8 -8
  28. package/dist/src/commands/update.js +16 -16
  29. package/dist/src/lib/cli-ui.js +20 -19
  30. package/dist/src/lib/merge-check/index.js +2 -2
  31. package/dist/src/lib/settings.d.ts +8 -0
  32. package/dist/src/lib/settings.js +1 -0
  33. package/dist/src/lib/shutdown.js +1 -1
  34. package/dist/src/lib/templates.js +2 -0
  35. package/dist/src/lib/wizard.js +6 -4
  36. package/dist/src/lib/workflow/batch-executor.js +1 -1
  37. package/dist/src/lib/workflow/log-writer.js +6 -6
  38. package/dist/src/lib/workflow/metrics-writer.js +5 -3
  39. package/dist/src/lib/workflow/phase-executor.js +5 -1
  40. package/dist/src/lib/workflow/platforms/github.js +5 -1
  41. package/dist/src/lib/workflow/state-cleanup.js +1 -1
  42. package/dist/src/lib/workflow/state-manager.js +15 -13
  43. package/dist/src/lib/workflow/state-rebuild.js +2 -2
  44. package/dist/src/lib/workflow/types.d.ts +11 -0
  45. package/dist/src/lib/workflow/worktree-manager.js +40 -41
  46. package/dist/src/lib/worktree-isolation.d.ts +130 -0
  47. package/dist/src/lib/worktree-isolation.js +310 -0
  48. package/package.json +8 -8
  49. package/templates/agents/sequant-explorer.md +23 -0
  50. package/templates/agents/sequant-implementer.md +18 -0
  51. package/templates/agents/sequant-qa-checker.md +24 -0
  52. package/templates/agents/sequant-testgen.md +25 -0
  53. package/templates/scripts/cleanup-worktree.sh +18 -0
  54. package/templates/skills/_shared/references/subagent-types.md +158 -48
  55. package/templates/skills/exec/SKILL.md +72 -6
  56. package/templates/skills/qa/SKILL.md +8 -217
  57. package/templates/skills/spec/SKILL.md +446 -120
  58. package/templates/skills/testgen/SKILL.md +138 -1
@@ -1,10 +1,10 @@
1
1
  # Claude Code Subagent Types
2
2
 
3
- Reference for valid subagent types when spawning agents via the `Task` tool.
3
+ Reference for valid subagent types when spawning agents via the `Agent` tool.
4
4
 
5
- ## Valid Types
5
+ ## Built-in Types
6
6
 
7
- Claude Code supports exactly **4 subagent types**:
7
+ Claude Code supports exactly **4 built-in subagent types**:
8
8
 
9
9
  | Type | Purpose | Tools Available |
10
10
  |------|---------|-----------------|
@@ -13,55 +13,122 @@ Claude Code supports exactly **4 subagent types**:
13
13
  | `Explore` | Codebase exploration, file search, pattern finding | Read-only tools |
14
14
  | `Plan` | Architecture planning, implementation design | Read-only tools |
15
15
 
16
- ## When to Use Each
16
+ ## Custom Agents (Sequant)
17
17
 
18
- ### `Bash`
19
- Best for: Single command execution, git operations, build commands
18
+ Sequant defines **4 custom agents** in `.claude/agents/`. These centralize model, permissions, effort, and tool restrictions that were previously duplicated inline.
19
+
20
+ | Agent Name | Based On | Model | Permission Mode | Used By |
21
+ |------------|----------|-------|-----------------|---------|
22
+ | `sequant-explorer` | Explore | haiku | (default) | `/spec` |
23
+ | `sequant-qa-checker` | general-purpose | haiku | bypassPermissions | `/qa` |
24
+ | `sequant-implementer` | general-purpose | (inherits) | bypassPermissions | `/exec` |
25
+ | `sequant-testgen` | general-purpose | haiku | (default) | `/testgen` |
26
+
27
+ ### sequant-explorer
28
+
29
+ Read-only codebase exploration for the `/spec` phase. No Bash, Edit, or Write access.
20
30
 
21
31
  ```
22
- Task(subagent_type="Bash", prompt="Run npm test and report results")
32
+ Agent(subagent_type="sequant-explorer",
33
+ prompt="Find similar features in components/. Report patterns.")
23
34
  ```
24
35
 
25
- ### `general-purpose`
26
- Best for: Implementation tasks, quality checks, multi-file operations
36
+ ### sequant-qa-checker
37
+
38
+ Quality check agent for the `/qa` phase. Has `bypassPermissions` for Bash access (git diff, npm test). Effort: low.
27
39
 
28
40
  ```
29
- Task(subagent_type="general-purpose",
41
+ Agent(subagent_type="sequant-qa-checker",
30
42
  prompt="Run type safety checks on the diff. Report: type issues, verdict.")
31
43
  ```
32
44
 
33
- **Use cases:**
34
- - Quality checks (type safety, security scan, scope analysis)
35
- - Implementation tasks requiring edits
36
- - Tasks needing both file reading and command execution
45
+ ### sequant-implementer
46
+
47
+ Implementation agent for `/exec` parallel groups. Inherits model from parent (user-configurable). Has `bypassPermissions` for full tool access.
48
+
49
+ ```
50
+ Agent(subagent_type="sequant-implementer",
51
+ prompt="Implement the UserCard component in components/admin/...")
52
+ ```
53
+
54
+ ### sequant-testgen
37
55
 
38
- ### `Explore`
39
- Best for: Codebase search, pattern discovery, schema inspection
56
+ Test stub generator for the `/testgen` phase. Has Write access but no Bash access.
40
57
 
41
58
  ```
42
- Task(subagent_type="Explore",
43
- prompt="Find similar components in components/admin/. Report patterns.")
59
+ Agent(subagent_type="sequant-testgen",
60
+ prompt="Generate test stubs for AC-1: User authentication...")
61
+ ```
62
+
63
+ ### Agent Definition Location
64
+
65
+ Custom agents are defined in `.claude/agents/*.md` with YAML frontmatter:
66
+
67
+ ```markdown
68
+ ---
69
+ name: sequant-qa-checker
70
+ description: Quality check agent for sequant QA phase.
71
+ model: haiku
72
+ permissionMode: bypassPermissions
73
+ effort: low
74
+ maxTurns: 15
75
+ tools:
76
+ - Read
77
+ - Grep
78
+ - Glob
79
+ - Bash
80
+ - Edit
81
+ ---
82
+
83
+ [Agent behavioral instructions here]
84
+ ```
85
+
86
+ ### Agent Resolution Priority
87
+
88
+ Claude Code resolves agent names in this order:
89
+ 1. Managed settings
90
+ 2. `--agents` CLI flag
91
+ 3. `.claude/agents/` (project-level) — sequant's agents live here
92
+ 4. `~/.claude/agents/` (user-level) — users can override here
93
+ 5. Plugin agents
94
+
95
+ ## When to Use Each
96
+
97
+ ### Built-in `Bash`
98
+ Best for: Single command execution, git operations, build commands
99
+
100
+ ```
101
+ Agent(subagent_type="Bash", prompt="Run npm test and report results")
102
+ ```
103
+
104
+ ### Built-in `general-purpose`
105
+ Best for: Custom tasks that don't fit a sequant agent profile
106
+
107
+ ```
108
+ Agent(subagent_type="general-purpose",
109
+ prompt="Analyze the error logs and suggest fixes.")
44
110
  ```
45
111
 
46
112
  **Use cases:**
47
- - Finding existing patterns before implementing new features
48
- - Searching for file locations
49
- - Understanding codebase structure
50
- - Schema and database inspection
113
+ - One-off tasks outside the sequant workflow
114
+ - Tasks needing a specific model/permission combination
51
115
 
52
- ### `Plan`
116
+ ### Built-in `Explore`
117
+ Best for: Ad-hoc codebase search outside the `/spec` workflow
118
+
119
+ ```
120
+ Agent(subagent_type="Explore",
121
+ prompt="Find all API routes in the project.")
122
+ ```
123
+
124
+ ### Built-in `Plan`
53
125
  Best for: Designing implementation approaches, architectural decisions
54
126
 
55
127
  ```
56
- Task(subagent_type="Plan",
128
+ Agent(subagent_type="Plan",
57
129
  prompt="Design the implementation approach for adding user auth.")
58
130
  ```
59
131
 
60
- **Use cases:**
61
- - Creating implementation plans
62
- - Evaluating architectural trade-offs
63
- - Breaking down complex features
64
-
65
132
  ## Model Selection
66
133
 
67
134
  | Model | When to Use | Cost |
@@ -72,60 +139,103 @@ Task(subagent_type="Plan",
72
139
 
73
140
  **Default:** Use `haiku` unless the task requires deep reasoning.
74
141
 
142
+ Custom agents set their model in the agent definition, so you don't need to specify it inline:
143
+
75
144
  ```
76
- Task(subagent_type="general-purpose",
77
- model="haiku",
145
+ # Model comes from .claude/agents/sequant-qa-checker.md (haiku)
146
+ Agent(subagent_type="sequant-qa-checker",
78
147
  prompt="...")
79
148
  ```
80
149
 
81
150
  ## Common Patterns
82
151
 
83
- ### Parallel Quality Checks
152
+ ### Parallel Quality Checks (via /qa)
84
153
  ```
85
- Task(subagent_type="general-purpose", model="haiku",
154
+ Agent(subagent_type="sequant-qa-checker",
86
155
  prompt="Check type safety on diff vs main. Report issues count.")
87
156
 
88
- Task(subagent_type="general-purpose", model="haiku",
157
+ Agent(subagent_type="sequant-qa-checker",
89
158
  prompt="Check for deleted tests in diff. Report count.")
90
159
 
91
- Task(subagent_type="general-purpose", model="haiku",
160
+ Agent(subagent_type="sequant-qa-checker",
92
161
  prompt="Run security scan on changed files. Report findings.")
93
162
  ```
94
163
 
95
- ### Context Gathering (Spec Phase)
164
+ ### Context Gathering (via /spec)
96
165
  ```
97
- Task(subagent_type="Explore", model="haiku",
166
+ Agent(subagent_type="sequant-explorer",
98
167
  prompt="Find similar features in components/. Report patterns.")
99
168
 
100
- Task(subagent_type="Explore", model="haiku",
169
+ Agent(subagent_type="sequant-explorer",
101
170
  prompt="Explore database schema for user tables. Report structure.")
102
171
  ```
103
172
 
104
- ### Background Execution
173
+ ### Background Execution (via /exec)
105
174
  ```
106
- Task(subagent_type="general-purpose",
107
- model="haiku",
175
+ Agent(subagent_type="sequant-implementer",
108
176
  run_in_background=true,
109
177
  prompt="Implement the UserCard component...")
110
178
  ```
111
179
 
112
180
  Use `TaskOutput(task_id="...", block=true)` to wait for completion.
113
181
 
182
+ **IMPORTANT: Background agents and permissions**
183
+
184
+ Background agents cannot prompt for permission interactively. Custom agents with
185
+ `permissionMode: bypassPermissions` in their definition handle this automatically.
186
+ For built-in types, set `mode` explicitly when spawning background agents.
187
+
188
+ ### Permission Mode Reference
189
+
190
+ | Mode | Edit/Write | Bash | When to Use |
191
+ |------|------------|------|-------------|
192
+ | `"acceptEdits"` | ✅ Auto-approved | ❌ **Denied** (prompts) | File-editing agents that don't need Bash |
193
+ | `"bypassPermissions"` | ✅ Auto-approved | ✅ Auto-approved | **Agents that need Bash** (quality checks, git commands) |
194
+ | (omitted) | ❌ Prompts | ❌ Prompts | Only if parent already auto-approves |
195
+
196
+ **Note:** Sequant's custom agents (`sequant-qa-checker`, `sequant-implementer`) have
197
+ `permissionMode` set in their agent definitions, so you don't need to specify `mode`
198
+ inline when spawning them.
199
+
200
+ ### Choosing the Right Agent
201
+
202
+ | Task | Recommended Agent | Why |
203
+ |------|-------------------|-----|
204
+ | Quality checks (git diff, npm test) | `sequant-qa-checker` | bypassPermissions + haiku + effort:low |
205
+ | Codebase exploration | `sequant-explorer` | Read-only, haiku, focused tools |
206
+ | Implementation subtask | `sequant-implementer` | Full access, inherits model |
207
+ | Test stub generation | `sequant-testgen` | Write access, no Bash, haiku |
208
+ | One-off custom task | `general-purpose` | Flexible, specify model/mode inline |
209
+
210
+ **CRITICAL:** If your background agent runs `git diff`, `npm test`, `git status`, or any shell command, use `sequant-qa-checker` or `sequant-implementer` (both have bypassPermissions). Do NOT use `general-purpose` without `mode="bypassPermissions"` — Bash calls will silently fail.
211
+
212
+ ### Security Considerations
213
+
214
+ `bypassPermissions` is safe when:
215
+ - Agent only reads/analyzes (quality checks, security scans)
216
+ - Agent runs in an isolated worktree
217
+ - Agent output is reviewed before any further action
218
+
219
+ `bypassPermissions` requires caution when:
220
+ - Agent could write to production files
221
+ - Agent could push to remote repositories
222
+ - Agent has access to secrets or credentials
223
+
114
224
  ## Invalid Types (Do Not Use)
115
225
 
116
226
  These types do **not exist** and will cause silent failures:
117
227
 
118
- - ~~`quality-checker`~~ → Use `general-purpose`
119
- - ~~`pattern-scout`~~ → Use `Explore`
120
- - ~~`schema-inspector`~~ → Use `Explore`
121
- - ~~`code-reviewer`~~ → Use `general-purpose`
122
- - ~~`implementation`~~ → Use `general-purpose`
228
+ - ~~`quality-checker`~~ → Use `sequant-qa-checker` or `general-purpose`
229
+ - ~~`pattern-scout`~~ → Use `sequant-explorer` or `Explore`
230
+ - ~~`schema-inspector`~~ → Use `sequant-explorer` or `Explore`
231
+ - ~~`code-reviewer`~~ → Use `sequant-qa-checker` or `general-purpose`
232
+ - ~~`implementation`~~ → Use `sequant-implementer` or `general-purpose`
123
233
 
124
234
  See issue #170 for context on this fix.
125
235
 
126
236
  ## References
127
237
 
128
- - [Claude Code Task Tool Documentation](https://docs.anthropic.com/claude-code)
129
- - [Prompt Templates](./prompt-templates.md) - Task-specific prompt templates for sub-agents
238
+ - [Claude Code Custom Subagents](https://code.claude.com/docs/en/sub-agents)
239
+ - Agent definitions: `.claude/agents/*.md`
130
240
  - `/exec` skill parallel execution: `templates/skills/exec/SKILL.md`
131
241
  - `/qa` skill quality checks: `templates/skills/qa/SKILL.md`
@@ -39,7 +39,7 @@ allowed-tools:
39
39
  - mcp__context7__* # Library documentation lookup - falls back to web search if unavailable
40
40
  - mcp__sequential-thinking__* # Complex reasoning - falls back to standard analysis if unavailable
41
41
  # Task management
42
- - Task(general-purpose)
42
+ - Agent(sequant-implementer)
43
43
  - TodoWrite
44
44
  ---
45
45
 
@@ -1507,11 +1507,43 @@ Look in the issue comments (especially from `/spec`) for:
1507
1507
 
1508
1508
  **If Parallel Groups exist:**
1509
1509
 
1510
+ 0. **Check isolation mode (AC-20):**
1511
+ ```bash
1512
+ # Check env var first (set by --isolate-parallel CLI flag via phase-executor),
1513
+ # then fall back to settings.json
1514
+ ISOLATE="${SEQUANT_ISOLATE_PARALLEL:-}"
1515
+ if [ -z "$ISOLATE" ]; then
1516
+ ISOLATE=$(cat .sequant/settings.json 2>/dev/null | grep -o '"isolateParallel":[^,}]*' | grep -o 'true\|false' || echo "false")
1517
+ fi
1518
+ echo "Parallel isolation mode: ${ISOLATE}"
1519
+ ```
1520
+
1521
+ **If isolation is enabled (`isolateParallel: true` or `--isolate-parallel`):**
1522
+ - Create sub-worktrees BEFORE spawning agents (see step 1b below)
1523
+ - Each agent gets its own working directory
1524
+ - After agents complete, merge changes back (see step 5b below)
1525
+
1526
+ **If isolation is disabled (default):**
1527
+ - All agents share the issue worktree (current behavior)
1528
+ - Skip steps 1b and 5b
1529
+
1510
1530
  1. **Create group marker before spawning agents:**
1511
1531
  ```bash
1512
1532
  touch /tmp/claude-parallel-group-1.marker
1513
1533
  ```
1514
1534
 
1535
+ 1b. **Create sub-worktrees (isolation mode only):**
1536
+ ```bash
1537
+ # Uses the tested TypeScript API via CLI wrapper.
1538
+ # Creates sub-worktree, symlinks node_modules, copies env files from .worktreeinclude.
1539
+ WORKTREE_PATH="[issue worktree path]"
1540
+ for i in 0 1 2; do # adjust for number of agents
1541
+ result=$(npx tsx scripts/worktree-isolation.ts create "${WORKTREE_PATH}" $i)
1542
+ AGENT_PATH=$(echo "$result" | jq -r '.path')
1543
+ echo "Agent ${i}: ${AGENT_PATH}"
1544
+ done
1545
+ ```
1546
+
1515
1547
  2. **Determine model for each task:**
1516
1548
 
1517
1549
  Check for model annotations in the task line: `[model: haiku]` or `[model: sonnet]`
@@ -1522,15 +1554,24 @@ Look in the issue comments (especially from `/spec`) for:
1522
1554
  3. Default to `haiku` if no annotation
1523
1555
 
1524
1556
  3. **Spawn parallel agents with the appropriate model in a SINGLE message:**
1557
+ Note: `sequant-implementer` intentionally omits `model` in its agent definition
1558
+ so the skill can override per-invocation (e.g., `model="haiku"` for subtasks).
1559
+
1560
+ **Working directory:** Use the sub-worktree path when isolation is enabled,
1561
+ otherwise use the issue worktree path.
1562
+
1525
1563
  ```
1526
- Task(subagent_type="general-purpose",
1564
+ Agent(subagent_type="sequant-implementer",
1527
1565
  model="haiku",
1528
1566
  run_in_background=true,
1529
1567
  prompt="Implement: Create types/metrics.ts with MetricEvent interface.
1530
- Working directory: [worktree path]
1531
- After completion, report what files were created/modified.")
1568
+ Working directory: [sub-worktree path or issue worktree path]
1569
+ After completion, commit your changes and report what files were created/modified.")
1532
1570
  ```
1533
1571
 
1572
+ **Important (isolation mode):** Tell agents to commit their changes in the
1573
+ sub-worktree. This is required for merge-back to work.
1574
+
1534
1575
  4. **Wait for all agents to complete:**
1535
1576
  ```
1536
1577
  TaskOutput(task_id="...", block=true)
@@ -1542,6 +1583,31 @@ Look in the issue comments (especially from `/spec`) for:
1542
1583
  npx prettier --write [files modified by agents]
1543
1584
  ```
1544
1585
 
1586
+ 5b. **Merge back and clean up sub-worktrees (isolation mode only):**
1587
+ ```bash
1588
+ WORKTREE_PATH="[issue worktree path]"
1589
+
1590
+ # Merge all agent branches back into the issue branch.
1591
+ # Uses the tested TypeScript API — handles conflict detection,
1592
+ # partial merges, and structured error reporting.
1593
+ MERGE_RESULT=$(npx tsx scripts/worktree-isolation.ts merge-all "${WORKTREE_PATH}")
1594
+ MERGED=$(echo "$MERGE_RESULT" | jq -r '.merged')
1595
+ CONFLICTS=$(echo "$MERGE_RESULT" | jq -r '.conflicts')
1596
+ echo "Merge-back: ${MERGED} merged, ${CONFLICTS} conflicts"
1597
+
1598
+ if [ "$CONFLICTS" -gt 0 ]; then
1599
+ echo "⚠️ Conflicts detected — flagged for next iteration:"
1600
+ echo "$MERGE_RESULT" | jq -r '.results[] | select(.success == false) | " Agent \(.agentIndex): \(.error)"'
1601
+ fi
1602
+
1603
+ # Clean up sub-worktrees and orphaned branches
1604
+ npx tsx scripts/worktree-isolation.ts cleanup "${WORKTREE_PATH}"
1605
+ ```
1606
+
1607
+ **If all merges succeed:** Proceed normally.
1608
+ **If conflicts occur:** Report conflicting files. The next `/exec` iteration
1609
+ can resolve them. Non-conflicting agents' changes are preserved.
1610
+
1545
1611
  6. **Proceed to next group or sequential tasks**
1546
1612
 
1547
1613
  **If no Parallel Groups section exists:**
@@ -1626,14 +1692,14 @@ Use `[template: X]` annotation to force a specific template:
1626
1692
 
1627
1693
  Instead of a generic prompt:
1628
1694
  ```
1629
- Task(subagent_type="general-purpose",
1695
+ Agent(subagent_type="sequant-implementer",
1630
1696
  model="haiku",
1631
1697
  prompt="Create MetricsCard component in components/admin/")
1632
1698
  ```
1633
1699
 
1634
1700
  Use a structured template prompt:
1635
1701
  ```
1636
- Task(subagent_type="general-purpose",
1702
+ Agent(subagent_type="sequant-implementer",
1637
1703
  model="haiku",
1638
1704
  prompt="## Task: Create React Component
1639
1705