sequant 2.10.0 → 2.11.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 (71) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +6 -2
  3. package/dist/bin/cli.js +47 -2
  4. package/dist/src/commands/locks.d.ts +20 -1
  5. package/dist/src/commands/locks.js +206 -4
  6. package/dist/src/commands/ready.d.ts +6 -0
  7. package/dist/src/commands/ready.js +15 -1
  8. package/dist/src/commands/run-display.js +1 -0
  9. package/dist/src/commands/worktree.d.ts +31 -0
  10. package/dist/src/commands/worktree.js +95 -0
  11. package/dist/src/lib/cli-flags.d.ts +23 -0
  12. package/dist/src/lib/cli-flags.js +43 -0
  13. package/dist/src/lib/cli-ui/run-renderer-types.d.ts +2 -0
  14. package/dist/src/lib/cli-ui/run-renderer.js +7 -1
  15. package/dist/src/lib/locks/checkout-lock.d.ts +193 -0
  16. package/dist/src/lib/locks/checkout-lock.js +389 -0
  17. package/dist/src/lib/locks/index.d.ts +6 -3
  18. package/dist/src/lib/locks/index.js +4 -2
  19. package/dist/src/lib/locks/lock-manager.d.ts +81 -1
  20. package/dist/src/lib/locks/lock-manager.js +230 -5
  21. package/dist/src/lib/locks/types.d.ts +72 -0
  22. package/dist/src/lib/locks/types.js +28 -0
  23. package/dist/src/lib/settings.d.ts +73 -0
  24. package/dist/src/lib/settings.js +45 -0
  25. package/dist/src/lib/test-tautology-detector.d.ts +4 -3
  26. package/dist/src/lib/test-tautology-detector.js +101 -41
  27. package/dist/src/lib/workflow/batch-executor.js +78 -19
  28. package/dist/src/lib/workflow/config-resolver.d.ts +25 -0
  29. package/dist/src/lib/workflow/config-resolver.js +89 -0
  30. package/dist/src/lib/workflow/drivers/agent-driver.d.ts +15 -0
  31. package/dist/src/lib/workflow/drivers/claude-code.js +5 -0
  32. package/dist/src/lib/workflow/effort-escalation.d.ts +73 -0
  33. package/dist/src/lib/workflow/effort-escalation.js +82 -0
  34. package/dist/src/lib/workflow/error-classifier.d.ts +4 -1
  35. package/dist/src/lib/workflow/error-classifier.js +4 -0
  36. package/dist/src/lib/workflow/log-writer.d.ts +10 -1
  37. package/dist/src/lib/workflow/log-writer.js +20 -0
  38. package/dist/src/lib/workflow/metrics-schema.d.ts +49 -6
  39. package/dist/src/lib/workflow/metrics-schema.js +33 -0
  40. package/dist/src/lib/workflow/metrics-writer.d.ts +11 -0
  41. package/dist/src/lib/workflow/phase-detection.d.ts +12 -0
  42. package/dist/src/lib/workflow/phase-detection.js +5 -1
  43. package/dist/src/lib/workflow/phase-executor.js +10 -0
  44. package/dist/src/lib/workflow/ready-gate.d.ts +28 -0
  45. package/dist/src/lib/workflow/ready-gate.js +24 -3
  46. package/dist/src/lib/workflow/run-log-schema.d.ts +55 -0
  47. package/dist/src/lib/workflow/run-log-schema.js +31 -1
  48. package/dist/src/lib/workflow/run-orchestrator.js +27 -0
  49. package/dist/src/lib/workflow/spec-recommendation.d.ts +71 -0
  50. package/dist/src/lib/workflow/spec-recommendation.js +142 -0
  51. package/dist/src/lib/workflow/types.d.ts +64 -0
  52. package/dist/src/lib/workflow/worktree-manager.d.ts +8 -1
  53. package/dist/src/lib/workflow/worktree-manager.js +9 -1
  54. package/dist/src/lib/workflow/worktree-resolver.d.ts +73 -0
  55. package/dist/src/lib/workflow/worktree-resolver.js +126 -0
  56. package/package.json +3 -2
  57. package/templates/hooks/pre-tool.sh +228 -0
  58. package/templates/scripts/cleanup-worktree.sh +36 -15
  59. package/templates/scripts/new-feature.sh +25 -19
  60. package/templates/skills/_shared/references/subagent-types.md +7 -18
  61. package/templates/skills/assess/SKILL.md +5 -1
  62. package/templates/skills/exec/SKILL.md +61 -7
  63. package/templates/skills/fullsolve/SKILL.md +127 -21
  64. package/templates/skills/loop/SKILL.md +56 -11
  65. package/templates/skills/merger/SKILL.md +98 -10
  66. package/templates/skills/qa/SKILL.md +59 -6
  67. package/templates/skills/release/SKILL.md +79 -0
  68. package/templates/skills/spec/SKILL.md +31 -15
  69. package/templates/skills/spec/references/recommended-workflow.md +14 -1
  70. package/templates/skills/testgen/SKILL.md +23 -6
  71. package/templates/agents/sequant-explorer.md +0 -24
@@ -112,6 +112,62 @@ gh auth status || { echo "Not logged in - run: gh auth login"; exit 1; }
112
112
 
113
113
  ## Release Steps
114
114
 
115
+ ### Step 0: Acquire the Checkout Lock (REQUIRED)
116
+
117
+ Everything from here on mutates the **main checkout**: the version bump and its
118
+ commit, tag, and push (Steps 4–7), plus the rollback verbs (`git reset --soft`,
119
+ `git checkout -- …`) if a step fails. `git commit`/`tag`/`push` are not guarded
120
+ by `pre-tool.sh`, but the `git reset` in rollback is — and, more importantly,
121
+ holding the checkout lock (#901) is what stops a session on another issue from
122
+ interleaving a `git checkout` between the bump and the commit and landing the
123
+ release commit on the wrong HEAD. So claim the tree now, before the first
124
+ interactive approval pause (Step 2's release-notes review), exactly as
125
+ `/fullsolve` does in its Phase 0.3.
126
+
127
+ `/release` has no issue of its own, and the checkout lock proves ownership by a
128
+ **positive integer** — the `pre-tool.sh` guard and `sequant locks checkout` both
129
+ key on `--issue=<N>`. So `/release` claims the tree under a reserved sentinel
130
+ issue id, **`999999999`** (a number that will never be a real issue), and uses it
131
+ on the acquire and on every release below. `locks list` and the CLI's
132
+ release-refusal render this sentinel as `/release (sentinel)` so it does not
133
+ read as a real issue. A symbolic holder (e.g. `--label=release`) would avoid
134
+ the reserved-number scheme entirely, but it would require changing the
135
+ lock-file schema, the CLI, *and* the numeric-only `pre-tool.sh` guard — out of
136
+ scope for #911 (tracked there as a follow-up).
137
+
138
+ ```bash
139
+ # Claim the shared working tree before the first mutation / approval pause.
140
+ # Skip for --dry-run: it previews only and mutates nothing, so it needs no lock.
141
+ npx sequant locks checkout acquire \
142
+ --issue=999999999 \
143
+ --command="/release" \
144
+ --skip-pid-check || true
145
+ export SEQUANT_ISSUE=999999999
146
+ ```
147
+
148
+ Acquire **after** the read-only pre-flight checks above, not before: those checks
149
+ (`git status`/`fetch`, `npm test`/`build`, `npm whoami`, `gh auth`) mutate
150
+ nothing, so a pre-flight abort holds no lock and needs no release. That is why the
151
+ pre-flight `exit 1` branches carry no release call — you cannot release a lock you
152
+ have not taken.
153
+
154
+ **`--issue=999999999` is mandatory on release** (#906): it is what proves you are
155
+ the holder once the acquiring shell's PID is gone (`--skip-pid-check`). Stale
156
+ recovery is age-based only (the 6h `SEQUANT_SKILL_LOCK_TTL_MS` and the 24h
157
+ `SEQUANT_MAX_LOCK_AGE_MS` ceiling), not same-host dead-PID recovery.
158
+
159
+ **Release contract:** release the checkout lock —
160
+ `npx sequant locks checkout release --issue=999999999 || true` — on **every**
161
+ path that exits after this acquire: happy-path completion (Post-Release
162
+ Verification), any mid-release error (Error Handling), and the Rollback
163
+ Procedures. Releasing an already-released lock is a harmless no-op, so a failure
164
+ that both errors and rolls back may run two of these — that is safe.
165
+
166
+ **Orchestrator/MCP mode:** when `SEQUANT_ORCHESTRATOR` is set, every `locks
167
+ checkout` action is a no-op (exit 0, no file touched) and the `pre-tool.sh`
168
+ checkout guard stands down, so the acquire/release calls are safe to run
169
+ unconditionally.
170
+
115
171
  ### Step 1: Determine Version
116
172
 
117
173
  If version type not provided as argument, ask the user:
@@ -493,6 +549,13 @@ gh release view "v${new_version}"
493
549
  npx sequant@${new_version} --version
494
550
  ```
495
551
 
552
+ The release is complete — hand the working tree back (#901). This is the
553
+ counterpart to the acquire in Step 0.
554
+
555
+ ```bash
556
+ npx sequant locks checkout release --issue=999999999 || true
557
+ ```
558
+
496
559
  ## Output Summary
497
560
 
498
561
  ```
@@ -575,6 +638,11 @@ git reset --soft HEAD~1
575
638
 
576
639
  # Delete local tag
577
640
  git tag -d v{version}
641
+
642
+ # Rollback aborts the release — hand the working tree back (#901/#906).
643
+ # The git reset above is a guarded verb; it runs unrefused only because Step 0
644
+ # made this session the checkout holder.
645
+ npx sequant locks checkout release --issue=999999999 || true
578
646
  ```
579
647
 
580
648
  ### After git push, before npm publish
@@ -589,6 +657,9 @@ gh release delete v{version} --yes
589
657
  # Revert commit
590
658
  git revert HEAD
591
659
  git push origin main
660
+
661
+ # Rollback aborts the release — hand the working tree back (#901/#906).
662
+ npx sequant locks checkout release --issue=999999999 || true
592
663
  ```
593
664
 
594
665
  ### After npm publish
@@ -601,6 +672,14 @@ Instead:
601
672
 
602
673
  ## Error Handling
603
674
 
675
+ **If a release step fails and you halt without completing, release the checkout
676
+ lock first** (#901/#906) — Step 0 acquired it and every abort after that must hand
677
+ the working tree back before stopping:
678
+
679
+ ```bash
680
+ npx sequant locks checkout release --issue=999999999 || true
681
+ ```
682
+
604
683
  | Error | Cause | Resolution |
605
684
  |-------|-------|------------|
606
685
  | "Not on main" | Wrong branch | `git checkout main` |
@@ -13,7 +13,7 @@ allowed-tools:
13
13
  - Bash(gh label:*)
14
14
  - Bash(git worktree:*)
15
15
  - Bash(git -C:*)
16
- - Agent(sequant-explorer)
16
+ - Agent(Explore)
17
17
  - AgentOutputTool
18
18
  ---
19
19
 
@@ -24,6 +24,22 @@ allowed-tools:
24
24
 
25
25
  Phase 1 "Planning Agent." Understands the issue and AC, reviews or synthesizes a plan, identifies gaps and risks, and drafts a GitHub issue comment.
26
26
 
27
+ ## Worktree Contract
28
+
29
+ <!-- BEGIN: spec-worktree-contract (#899) -->
30
+
31
+ **No worktree needed. Planning happens in the main repository directory.** The
32
+ worktree is created later — by the orchestrator (`/fullsolve` Phase 1.5, or
33
+ `sequant run`) when one is driving, otherwise by `/exec` itself.
34
+
35
+ This skill only ever *reads* `git worktree list`, for in-flight collision
36
+ detection. **Do not create a worktree here, and do not describe one as
37
+ existing after `/spec`** — downstream skills that trust such a claim end up
38
+ implementing in the main checkout (#899, and the line this restores was
39
+ dropped by #515).
40
+
41
+ <!-- END: spec-worktree-contract (#899) -->
42
+
27
43
  ## Platform Detection — Run First
28
44
 
29
45
  ```bash
@@ -114,22 +130,11 @@ ls -d src/ app/ lib/ components/ pages/ routes/ docs/ 2>/dev/null || true
114
130
 
115
131
  Use discovered paths in all agent prompts and search commands.
116
132
 
117
- ### Agent Spawn Rules
133
+ ### Context-Gathering Strategy
118
134
 
119
- Determine agent count from issue contentdo NOT always spawn 3:
135
+ Default to targeted inline `Read`/`Grep` against the paths the issue names or the ones discovered above this is what actually resolves most issues and avoids paying subagent overhead for context you can fetch directly. Escalate to a single `Explore` agent only for genuinely open-ended discovery (e.g. "where does X live?" with no named files or an unfamiliar area of the codebase). Don't spawn more than one `Explore` agent per `/spec` run — if the issue needs more context than that, narrow the search instead of fanning out.
120
136
 
121
- | Issue Content | Agents | What to Spawn |
122
- |---------------|--------|---------------|
123
- | Database/SQL/migration keywords in AC or labels | 3 | Similar features + Codebase area + Database schema |
124
- | UI/frontend (`.tsx`/`.jsx`/`components/` references) | 2 | Similar features + Codebase area |
125
- | CLI/script changes | 2 | Similar features + Codebase area |
126
- | Docs/config/`simple-fix` label | 1 | General context only |
127
-
128
- **Execution mode:** Read `.sequant/settings.json` → `agents.parallel` (default: false).
129
- - **Parallel:** Spawn all agents in a SINGLE message
130
- - **Sequential:** Spawn one at a time, waiting for each to complete
131
-
132
- Agent prompts MUST reference discovered paths from the step above, not hardcoded ones like `components/admin/` or `lib/queries/`.
137
+ Whichever path you take, reference discovered paths from the step above in searches, not hardcoded ones like `components/admin/` or `lib/queries/`.
133
138
 
134
139
  ### In-Flight Work Analysis
135
140
 
@@ -319,6 +324,8 @@ See [verification-criteria.md](references/verification-criteria.md) for detailed
319
324
  **Quality Loop:** [enabled/disabled]
320
325
  **Reasoning:** [Brief explanation]
321
326
 
327
+ <!-- SEQUANT_SPEC: {"phases":["exec","qa"],"qualityLoop":false} -->
328
+
322
329
  <!-- Decision logic:
323
330
  - UI/frontend → add `test` phase
324
331
  - `no-browser-test` label → skip `test` (overrides UI labels)
@@ -327,6 +334,15 @@ See [verification-criteria.md](references/verification-criteria.md) for detailed
327
334
  - New features with Unit/Integration Test verification ACs → add `testgen` phase
328
335
  - Docs-only → skip spec, just exec → qa -->
329
336
 
337
+ **Emit the `SEQUANT_SPEC` marker with the real resolved values** — `phases`
338
+ is the same list shown in `**Phases:**` above, minus `spec` (it already
339
+ ran); `qualityLoop` mirrors `**Quality Loop:**`. This is the durable
340
+ resolution channel `sequant run` reads first (#921) — `**Phases:**` prose
341
+ and spec's own chat output are both fallbacks for when this marker is
342
+ missing or fails validation, so an omitted or stale marker silently
343
+ downgrades which phases actually run. It MUST be included in the comment
344
+ actually posted via `gh issue comment`, not just shown in this response.
345
+
330
346
  ---
331
347
 
332
348
  ## Label Review
@@ -1,6 +1,17 @@
1
1
  # Recommended Workflow Format
2
2
 
3
- This document shows the expected output format for the `## Recommended Workflow` section in `/spec` output. The `parseRecommendedWorkflow()` function parses this format to determine which phases to execute.
3
+ This document shows the expected output format for the `## Recommended Workflow` section in `/spec` output.
4
+
5
+ ## Resolution chain (#921)
6
+
7
+ `sequant run` resolves phases through an ordered chain, not `parseRecommendedWorkflow()` alone:
8
+
9
+ 1. **`SEQUANT_SPEC` marker** — a structured HTML comment in the posted plan comment, e.g. `<!-- SEQUANT_SPEC: {"phases":["testgen","exec","qa"],"qualityLoop":true} -->`. This is the primary, durable channel — always emit it alongside the prose section below.
10
+ 2. **Comment prose** — `parseRecommendedWorkflow()` applied to the plan comment body (same format as this doc).
11
+ 3. **Chat text** — the same parser applied to the spec agent's chat output. Nondeterministic: only present if the agent happens to restate the section in chat rather than posting via a body file (#814).
12
+ 4. **Label fallback** — `detectPhasesFromLabels()`. Can never produce `testgen` or `security-review`.
13
+
14
+ The marker's `phases` array excludes `spec` (it already ran) and must name only registered phases — an unknown phase name invalidates the whole marker and falls through to step 2.
4
15
 
5
16
  ## Format
6
17
 
@@ -10,6 +21,8 @@ This document shows the expected output format for the `## Recommended Workflow`
10
21
  **Phases:** spec → exec → qa
11
22
  **Quality Loop:** disabled
12
23
  **Reasoning:** Brief explanation of why this workflow was chosen.
24
+
25
+ <!-- SEQUANT_SPEC: {"phases":["exec","qa"],"qualityLoop":false} -->
13
26
  ```
14
27
 
15
28
  ## Examples
@@ -6,6 +6,7 @@ metadata:
6
6
  author: sequant
7
7
  version: "1.0"
8
8
  allowed-tools:
9
+ - Bash(npx sequant worktree:*)
9
10
  - Read
10
11
  - Write
11
12
  - Edit
@@ -530,17 +531,33 @@ If an AC has verification method "N/A - Trivial", skip test generation and note
530
531
 
531
532
  ### Step 4: Locate Feature Worktree
532
533
 
533
- If generating file-based tests (Unit Test, Integration Test), find the worktree:
534
+ If generating file-based tests (Unit Test, Integration Test), find the worktree.
534
535
 
535
- ```bash
536
- git worktree list | grep -E "feature.*<issue-number>" || true
537
- ```
536
+ <!-- BEGIN: worktree-standalone-lookup (#899) -->
537
+
538
+ Resolve it through git, not the filesystem:
538
539
 
539
- Or check:
540
540
  ```bash
541
- ls ../worktrees/feature/<issue-number>-*/
541
+ WORKTREE="$(npx sequant worktree resolve <issue-number>)" || {
542
+ echo "❌ HALT: no worktree for #<issue-number> in this repository."
543
+ exit 1
544
+ }
545
+ cd "$WORKTREE"
542
546
  ```
543
547
 
548
+ `sequant worktree resolve` reads `git worktree list` in the current repository
549
+ — which reports only *this* repo's worktrees — and selects on the **branch**
550
+ git reports, not the directory name.
551
+
552
+ **Do not glob `../worktrees/feature/<issue-number>-*`, and do not grep
553
+ `git worktree list` for the issue number.** The first matches across sibling
554
+ repositories, which share that directory; the second matches the printed path,
555
+ so it keys on the directory slug — and a slug can drift from its own branch
556
+ after a rename. Because this skill **writes test files**, landing in the wrong
557
+ tree scatters stubs into an unrelated project.
558
+
559
+ <!-- END: worktree-standalone-lookup (#899) -->
560
+
544
561
  Create test directories if needed:
545
562
  ```bash
546
563
  mkdir -p __tests__/integration
@@ -1,24 +0,0 @@
1
- ---
2
- name: sequant-explorer
3
- description: Codebase exploration agent for sequant /spec phase. Searches for existing patterns, components, database schemas, and file structures. Use when gathering context before planning a feature implementation.
4
- # Note: per anthropics/claude-code#43869 this is currently a no-op; agent runs on parent's model
5
- model: haiku
6
- maxTurns: 15
7
- tools:
8
- - Read
9
- - Grep
10
- - Glob
11
- ---
12
-
13
- You are an exploration agent for the sequant development workflow.
14
-
15
- Your job is to search the codebase for existing patterns, components, and structures relevant to a planned feature.
16
-
17
- Rules:
18
- - Search thoroughly across relevant directories
19
- - Report findings in structured format: file paths, patterns discovered, recommendations
20
- - Do NOT modify any files
21
- - Do NOT run shell commands
22
- - Send results back via SendMessage when complete
23
- - All grep commands must use `|| true` to prevent exit code 1 on zero matches
24
- - Focus on actionable findings that inform implementation decisions