sequant 1.20.3 → 2.0.1

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 (137) hide show
  1. package/.claude-plugin/marketplace.json +2 -4
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.md +36 -15
  4. package/dist/bin/cli.js +25 -2
  5. package/dist/src/commands/doctor.js +42 -9
  6. package/dist/src/commands/init.d.ts +1 -0
  7. package/dist/src/commands/init.js +52 -0
  8. package/dist/src/commands/logs.d.ts +1 -0
  9. package/dist/src/commands/logs.js +18 -2
  10. package/dist/src/commands/run.d.ts +7 -0
  11. package/dist/src/commands/run.js +235 -68
  12. package/dist/src/commands/serve.d.ts +13 -0
  13. package/dist/src/commands/serve.js +131 -0
  14. package/dist/src/commands/stats.d.ts +1 -0
  15. package/dist/src/commands/stats.js +185 -26
  16. package/dist/src/commands/status.d.ts +2 -0
  17. package/dist/src/commands/status.js +99 -50
  18. package/dist/src/index.d.ts +2 -2
  19. package/dist/src/index.js +4 -1
  20. package/dist/src/lib/ac-parser.d.ts +2 -0
  21. package/dist/src/lib/ac-parser.js +12 -2
  22. package/dist/src/lib/assess-comment-parser.d.ts +137 -0
  23. package/dist/src/lib/assess-comment-parser.js +344 -0
  24. package/dist/src/lib/ci/config.d.ts +22 -0
  25. package/dist/src/lib/ci/config.js +134 -0
  26. package/dist/src/lib/ci/index.d.ts +12 -0
  27. package/dist/src/lib/ci/index.js +10 -0
  28. package/dist/src/lib/ci/inputs.d.ts +29 -0
  29. package/dist/src/lib/ci/inputs.js +103 -0
  30. package/dist/src/lib/ci/labels.d.ts +34 -0
  31. package/dist/src/lib/ci/labels.js +101 -0
  32. package/dist/src/lib/ci/outputs.d.ts +25 -0
  33. package/dist/src/lib/ci/outputs.js +84 -0
  34. package/dist/src/lib/ci/triggers.d.ts +9 -0
  35. package/dist/src/lib/ci/triggers.js +86 -0
  36. package/dist/src/lib/ci/types.d.ts +131 -0
  37. package/dist/src/lib/ci/types.js +47 -0
  38. package/dist/src/lib/mcp-config.d.ts +54 -0
  39. package/dist/src/lib/mcp-config.js +172 -0
  40. package/dist/src/lib/merge-check/index.js +6 -12
  41. package/dist/src/lib/merge-check/types.d.ts +20 -7
  42. package/dist/src/lib/merge-check/types.js +11 -0
  43. package/dist/src/lib/phase-signal.d.ts +3 -3
  44. package/dist/src/lib/phase-signal.js +5 -3
  45. package/dist/src/lib/settings.d.ts +52 -0
  46. package/dist/src/lib/settings.js +41 -0
  47. package/dist/src/lib/shutdown.d.ts +16 -5
  48. package/dist/src/lib/shutdown.js +32 -12
  49. package/dist/src/lib/solve-comment-parser.d.ts +9 -102
  50. package/dist/src/lib/solve-comment-parser.js +13 -248
  51. package/dist/src/lib/stacks.d.ts +8 -0
  52. package/dist/src/lib/stacks.js +34 -0
  53. package/dist/src/lib/system.js +3 -7
  54. package/dist/src/lib/test-tautology-detector.d.ts +10 -0
  55. package/dist/src/lib/test-tautology-detector.js +43 -4
  56. package/dist/src/lib/upstream/assessment.js +9 -59
  57. package/dist/src/lib/upstream/issues.js +12 -75
  58. package/dist/src/lib/version-check.d.ts +2 -2
  59. package/dist/src/lib/version-check.js +6 -3
  60. package/dist/src/lib/version.d.ts +4 -0
  61. package/dist/src/lib/version.js +25 -0
  62. package/dist/src/lib/workflow/batch-executor.d.ts +26 -86
  63. package/dist/src/lib/workflow/batch-executor.js +269 -55
  64. package/dist/src/lib/workflow/drivers/agent-driver.d.ts +56 -0
  65. package/dist/src/lib/workflow/drivers/agent-driver.js +8 -0
  66. package/dist/src/lib/workflow/drivers/aider.d.ts +18 -0
  67. package/dist/src/lib/workflow/drivers/aider.js +160 -0
  68. package/dist/src/lib/workflow/drivers/claude-code.d.ts +17 -0
  69. package/dist/src/lib/workflow/drivers/claude-code.js +165 -0
  70. package/dist/src/lib/workflow/drivers/index.d.ts +20 -0
  71. package/dist/src/lib/workflow/drivers/index.js +27 -0
  72. package/dist/src/lib/workflow/error-classifier.d.ts +16 -0
  73. package/dist/src/lib/workflow/error-classifier.js +90 -0
  74. package/dist/src/lib/workflow/log-writer.d.ts +6 -3
  75. package/dist/src/lib/workflow/log-writer.js +57 -27
  76. package/dist/src/lib/workflow/metrics-schema.d.ts +9 -9
  77. package/dist/src/lib/workflow/phase-detection.d.ts +23 -0
  78. package/dist/src/lib/workflow/phase-detection.js +45 -29
  79. package/dist/src/lib/workflow/phase-executor.d.ts +42 -3
  80. package/dist/src/lib/workflow/phase-executor.js +375 -229
  81. package/dist/src/lib/workflow/phase-mapper.d.ts +1 -1
  82. package/dist/src/lib/workflow/phase-mapper.js +7 -7
  83. package/dist/src/lib/workflow/platforms/github.d.ts +157 -0
  84. package/dist/src/lib/workflow/platforms/github.js +466 -0
  85. package/dist/src/lib/workflow/platforms/index.d.ts +17 -0
  86. package/dist/src/lib/workflow/platforms/index.js +25 -0
  87. package/dist/src/lib/workflow/platforms/platform-provider.d.ts +67 -0
  88. package/dist/src/lib/workflow/platforms/platform-provider.js +8 -0
  89. package/dist/src/lib/workflow/pr-status.d.ts +2 -4
  90. package/dist/src/lib/workflow/pr-status.js +3 -16
  91. package/dist/src/lib/workflow/qa-cache.d.ts +58 -0
  92. package/dist/src/lib/workflow/qa-cache.js +88 -0
  93. package/dist/src/lib/workflow/reconcile.d.ts +69 -0
  94. package/dist/src/lib/workflow/reconcile.js +290 -0
  95. package/dist/src/lib/workflow/ring-buffer.d.ts +17 -0
  96. package/dist/src/lib/workflow/ring-buffer.js +37 -0
  97. package/dist/src/lib/workflow/run-log-schema.d.ts +115 -24
  98. package/dist/src/lib/workflow/run-log-schema.js +47 -12
  99. package/dist/src/lib/workflow/run-reflect.js +1 -1
  100. package/dist/src/lib/workflow/state-cleanup.js +21 -0
  101. package/dist/src/lib/workflow/state-manager.d.ts +34 -3
  102. package/dist/src/lib/workflow/state-manager.js +278 -126
  103. package/dist/src/lib/workflow/state-schema.d.ts +34 -30
  104. package/dist/src/lib/workflow/state-schema.js +35 -25
  105. package/dist/src/lib/workflow/state-utils.d.ts +3 -1
  106. package/dist/src/lib/workflow/state-utils.js +1 -0
  107. package/dist/src/lib/workflow/types.d.ts +224 -6
  108. package/dist/src/lib/workflow/types.js +20 -1
  109. package/dist/src/lib/workflow/worktree-discovery.d.ts +1 -1
  110. package/dist/src/lib/workflow/worktree-discovery.js +6 -14
  111. package/dist/src/lib/workflow/worktree-manager.js +33 -51
  112. package/dist/src/mcp/index.d.ts +4 -0
  113. package/dist/src/mcp/index.js +4 -0
  114. package/dist/src/mcp/resources.d.ts +7 -0
  115. package/dist/src/mcp/resources.js +111 -0
  116. package/dist/src/mcp/run-registry.d.ts +34 -0
  117. package/dist/src/mcp/run-registry.js +42 -0
  118. package/dist/src/mcp/server.d.ts +12 -0
  119. package/dist/src/mcp/server.js +50 -0
  120. package/dist/src/mcp/tools/logs.d.ts +7 -0
  121. package/dist/src/mcp/tools/logs.js +149 -0
  122. package/dist/src/mcp/tools/run.d.ts +121 -0
  123. package/dist/src/mcp/tools/run.js +591 -0
  124. package/dist/src/mcp/tools/status.d.ts +7 -0
  125. package/dist/src/mcp/tools/status.js +127 -0
  126. package/package.json +26 -7
  127. package/templates/hooks/post-tool.sh +19 -8
  128. package/templates/hooks/pre-tool.sh +36 -49
  129. package/templates/mcp.json +6 -0
  130. package/templates/skills/assess/SKILL.md +354 -352
  131. package/templates/skills/exec/SKILL.md +64 -1
  132. package/templates/skills/fullsolve/SKILL.md +35 -4
  133. package/templates/skills/qa/SKILL.md +486 -9
  134. package/templates/skills/qa/scripts/quality-checks.sh +1 -1
  135. package/templates/skills/setup/SKILL.md +386 -0
  136. package/templates/skills/solve/SKILL.md +38 -664
  137. package/templates/skills/spec/SKILL.md +90 -31
@@ -588,6 +588,51 @@ echo "Current branch: $CURRENT_BRANCH"
588
588
  - Documents intentional deferrals
589
589
  - Enables better QA in `/qa` phase
590
590
 
591
+ ### 3e2. Simulate QA Before PR (REQUIRED)
592
+
593
+ **Purpose:** Prevent first-pass QA failures by simulating the QA reviewer's perspective before creating a PR. Root cause analysis of multi-attempt QA issues (#448) found that the majority of first-pass failures stem from gaps exec could have caught with deliberate self-verification.
594
+
595
+ **Top failure patterns exec must check for (from analysis of 6 multi-attempt issues):**
596
+
597
+ | Pattern | Frequency | What to check |
598
+ |---------|-----------|---------------|
599
+ | Test coverage gaps | 50% (3/6 issues) | Changed files have corresponding tests |
600
+ | Incomplete self-verification | 17% (1/6 issues) | Each AC verified against literal wording, not just spirit |
601
+ | Lint/build not run pre-PR | 17% (1/6 issues) | `npm run lint` + `npm run build` pass locally |
602
+
603
+ *Note: Remaining 33% were QA detection issues, addressed separately in QA skill.*
604
+
605
+ **Simulate QA Checklist (answer each before creating PR):**
606
+
607
+ 1. **Test-to-Change Alignment:** For each source file you modified:
608
+ ```bash
609
+ # List changed source files (excluding tests)
610
+ changed=$(git diff main...HEAD --name-only | grep -E '\.(ts|tsx|js|jsx)$' | grep -v -E '\.(test|spec)\.' || true)
611
+
612
+ # For each, verify a corresponding test exists and covers the change
613
+ for file in $changed; do
614
+ base=$(basename "$file" | sed 's/\.[^.]*$//')
615
+ test_exists=$(find . -name "${base}.test.*" -o -name "${base}.spec.*" 2>/dev/null | head -1 || true)
616
+ if [[ -z "$test_exists" ]]; then
617
+ echo "WARNING NO TEST: $file"
618
+ fi
619
+ done
620
+ ```
621
+ - If critical files lack tests, add tests before PR creation
622
+ - If tests exist but don't cover the specific change, note as known gap
623
+
624
+ 2. **QA Reviewer Perspective:** Ask yourself:
625
+ - "If I were reviewing this PR for the first time, what would I flag?"
626
+ - "Are there any 'I'll fix it later' shortcuts that QA will catch?"
627
+ - "Did I actually run the feature, or just verify it compiles?"
628
+
629
+ **If any check reveals a gap:**
630
+ - Fix the gap before creating the PR
631
+ - Re-run build/lint/tests after fixing
632
+ - Update the AC verification table
633
+
634
+ **Do NOT skip this step.** This single checkpoint addresses the most common first-pass QA failure patterns.
635
+
591
636
  ### 3f. CHANGELOG Update (REQUIRED for user-facing changes)
592
637
 
593
638
  **Purpose:** Ensure all user-facing changes are documented in the CHANGELOG before PR creation. This prevents documentation gaps and reduces release overhead.
@@ -1161,7 +1206,7 @@ for script in $shell_scripts; do
1161
1206
  # 3. Unused function detection
1162
1207
  funcs=$(grep -oE "^[a-zA-Z_]+\(\)" "$script" | sed 's/()//' || true)
1163
1208
  for func in $funcs; do
1164
- calls=$(grep -c "\b${func}\b" "$script" || echo "0")
1209
+ calls=$(grep -c "\b${func}\b" "$script" || true)
1165
1210
  if [[ $calls -lt 2 ]]; then
1166
1211
  echo "⚠️ Function '$func' defined but possibly not called"
1167
1212
  fi
@@ -1636,6 +1681,22 @@ When retrying a failed agent, use the error recovery template from [prompt-templ
1636
1681
 
1637
1682
  Before each commit, self-check against these standards:
1638
1683
 
1684
+ ### 0. Branch Verification
1685
+
1686
+ **CRITICAL:** Verify you are on the correct feature branch, not main/master.
1687
+
1688
+ ```bash
1689
+ CURRENT_BRANCH=$(git branch --show-current)
1690
+ if [[ "$CURRENT_BRANCH" == "main" || "$CURRENT_BRANCH" == "master" ]]; then
1691
+ echo "❌ ERROR: On $CURRENT_BRANCH — do NOT commit here."
1692
+ echo " Navigate to the feature worktree or create a branch first."
1693
+ exit 1
1694
+ fi
1695
+ echo "✓ On branch: $CURRENT_BRANCH"
1696
+ ```
1697
+
1698
+ **Why:** Sub-agents and shell context resets can silently switch the working directory back to main. Without this check, commits land on main instead of the feature branch.
1699
+
1639
1700
  ### 1. Scope Check
1640
1701
  Does this change directly address an AC item?
1641
1702
  - **Yes** → Proceed
@@ -1724,6 +1785,8 @@ The goal is to satisfy AC with the smallest, safest change possible.
1724
1785
  2. "If this feature broke tomorrow, would the current tests catch it?"
1725
1786
  3. "What's the weakest part of this implementation?"
1726
1787
  4. "Am I reporting success metrics without honest self-evaluation?"
1788
+ 5. "For each changed source file, does a corresponding test file exist? If not, why is that acceptable?"
1789
+ 6. "Did I run `npm run lint` and fix all errors, or am I hoping CI will pass?"
1727
1790
 
1728
1791
  **Include this section in your output:**
1729
1792
 
@@ -143,7 +143,14 @@ When posting progress comments after each phase, append the appropriate marker:
143
143
  ### 0.1 Git State Verification
144
144
 
145
145
  ```bash
146
- # Check current branch and recent commits
146
+ # Check current branch warn if on main/master
147
+ CURRENT_BRANCH=$(git branch --show-current)
148
+ echo "Current branch: $CURRENT_BRANCH"
149
+ if [[ "$CURRENT_BRANCH" == "main" || "$CURRENT_BRANCH" == "master" ]]; then
150
+ echo "⚠️ WARNING: On $CURRENT_BRANCH — will need feature branch before committing"
151
+ fi
152
+
153
+ # Check recent commits
147
154
  git log --oneline -5 --stat
148
155
 
149
156
  # Check for any existing work on this issue
@@ -412,6 +419,30 @@ while qa_iteration < 2:
412
419
 
413
420
  ## Phase 5: Pull Request (PR)
414
421
 
422
+ ### 5.0 Branch Verification Gate
423
+
424
+ **CRITICAL: Verify you are on the correct feature branch before committing or creating a PR.**
425
+
426
+ ```bash
427
+ CURRENT_BRANCH=$(git branch --show-current)
428
+ echo "Current branch: $CURRENT_BRANCH"
429
+
430
+ # HARD GATE: Must be on a feature branch, not main/master
431
+ if [[ "$CURRENT_BRANCH" == "main" || "$CURRENT_BRANCH" == "master" ]]; then
432
+ echo "❌ ERROR: On $CURRENT_BRANCH — commits must NOT land on main."
433
+ echo " Fix: git checkout feature/<issue-number>-* or create a new branch."
434
+ exit 1
435
+ fi
436
+
437
+ # Soft check: branch should match the issue number
438
+ if ! echo "$CURRENT_BRANCH" | grep -q "<issue-number>"; then
439
+ echo "⚠️ WARNING: Branch '$CURRENT_BRANCH' does not contain issue number <issue-number>."
440
+ echo " Verify this is the correct branch before continuing."
441
+ fi
442
+ ```
443
+
444
+ **Why this matters:** Sub-agents and shell context resets can silently switch the working directory back to main. Without this check, commits land on main instead of the feature branch, requiring messy recovery (cherry-picks, force pushes, re-created PRs).
445
+
415
446
  ### 5.1 Create PR (if not exists)
416
447
 
417
448
  ```bash
@@ -435,8 +466,8 @@ Post completion comment to issue with:
435
466
  **IMPORTANT:** Merge the PR first, then clean up the worktree.
436
467
 
437
468
  ```bash
438
- # 1. Merge PR (--delete-branch deletes remote; local deletion will fail but that's OK)
439
- gh pr merge <N> --squash --delete-branch
469
+ # 1. Merge PR (without --delete-branch; cleanup happens after success)
470
+ gh pr merge <N> --squash
440
471
 
441
472
  # 2. Clean up worktree (removes local worktree + branch)
442
473
  ./scripts/dev/cleanup-worktree.sh feature/<issue-number>-*
@@ -444,7 +475,7 @@ gh pr merge <N> --squash --delete-branch
444
475
  # 3. Issue auto-closes if commit message contains "Fixes #N"
445
476
  ```
446
477
 
447
- **Why this order matters:** The cleanup script checks if the PR is merged before proceeding. The `--delete-branch` flag will fail to delete the local branch (worktree conflict) but successfully deletes the remote branch. The cleanup script then handles the local branch removal.
478
+ **Why this order matters:** The cleanup script checks if the PR is merged before proceeding. Merging without `--delete-branch` avoids worktree lock conflicts. The post-tool hook and cleanup script handle branch removal after merge succeeds. If the merge fails, the worktree is preserved so work isn't lost.
448
479
 
449
480
  ### 5.4 Post-Merge Verification
450
481