sequant 1.17.0 → 1.19.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 (75) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +14 -2
  3. package/dist/bin/cli.js +7 -0
  4. package/dist/marketplace/external_plugins/sequant/.claude-plugin/plugin.json +21 -0
  5. package/dist/marketplace/external_plugins/sequant/README.md +38 -0
  6. package/dist/marketplace/external_plugins/sequant/hooks/post-tool.sh +292 -0
  7. package/dist/marketplace/external_plugins/sequant/hooks/pre-tool.sh +463 -0
  8. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/prompt-templates.md +350 -0
  9. package/dist/marketplace/external_plugins/sequant/skills/_shared/references/subagent-types.md +131 -0
  10. package/dist/marketplace/external_plugins/sequant/skills/assess/SKILL.md +474 -0
  11. package/dist/marketplace/external_plugins/sequant/skills/clean/SKILL.md +211 -0
  12. package/dist/marketplace/external_plugins/sequant/skills/docs/SKILL.md +337 -0
  13. package/dist/marketplace/external_plugins/sequant/skills/exec/SKILL.md +807 -0
  14. package/dist/marketplace/external_plugins/sequant/skills/fullsolve/SKILL.md +678 -0
  15. package/dist/marketplace/external_plugins/sequant/skills/improve/SKILL.md +668 -0
  16. package/dist/marketplace/external_plugins/sequant/skills/loop/SKILL.md +374 -0
  17. package/dist/marketplace/external_plugins/sequant/skills/qa/SKILL.md +570 -0
  18. package/dist/marketplace/external_plugins/sequant/skills/qa/references/code-quality-exemplars.md +107 -0
  19. package/dist/marketplace/external_plugins/sequant/skills/qa/references/code-review-checklist.md +65 -0
  20. package/dist/marketplace/external_plugins/sequant/skills/qa/references/quality-gates.md +179 -0
  21. package/dist/marketplace/external_plugins/sequant/skills/qa/references/semgrep-rules.md +207 -0
  22. package/dist/marketplace/external_plugins/sequant/skills/qa/references/testing-requirements.md +109 -0
  23. package/dist/marketplace/external_plugins/sequant/skills/qa/scripts/quality-checks.sh +622 -0
  24. package/dist/marketplace/external_plugins/sequant/skills/reflect/SKILL.md +175 -0
  25. package/dist/marketplace/external_plugins/sequant/skills/reflect/references/documentation-tiers.md +70 -0
  26. package/dist/marketplace/external_plugins/sequant/skills/reflect/references/phase-reflection.md +95 -0
  27. package/dist/marketplace/external_plugins/sequant/skills/security-review/SKILL.md +358 -0
  28. package/dist/marketplace/external_plugins/sequant/skills/security-review/references/security-checklists.md +432 -0
  29. package/dist/marketplace/external_plugins/sequant/skills/solve/SKILL.md +697 -0
  30. package/dist/marketplace/external_plugins/sequant/skills/spec/SKILL.md +754 -0
  31. package/dist/marketplace/external_plugins/sequant/skills/spec/references/parallel-groups.md +72 -0
  32. package/dist/marketplace/external_plugins/sequant/skills/spec/references/recommended-workflow.md +92 -0
  33. package/dist/marketplace/external_plugins/sequant/skills/spec/references/verification-criteria.md +104 -0
  34. package/dist/marketplace/external_plugins/sequant/skills/test/SKILL.md +600 -0
  35. package/dist/marketplace/external_plugins/sequant/skills/testgen/SKILL.md +576 -0
  36. package/dist/marketplace/external_plugins/sequant/skills/verify/SKILL.md +281 -0
  37. package/dist/src/commands/conventions.d.ts +9 -0
  38. package/dist/src/commands/conventions.js +61 -0
  39. package/dist/src/commands/init.js +12 -0
  40. package/dist/src/commands/run.d.ts +13 -280
  41. package/dist/src/commands/run.js +23 -1956
  42. package/dist/src/commands/sync.js +3 -0
  43. package/dist/src/commands/update.js +3 -0
  44. package/dist/src/lib/conventions-detector.d.ts +62 -0
  45. package/dist/src/lib/conventions-detector.js +510 -0
  46. package/dist/src/lib/plugin-version-sync.d.ts +2 -1
  47. package/dist/src/lib/plugin-version-sync.js +28 -7
  48. package/dist/src/lib/settings.d.ts +8 -0
  49. package/dist/src/lib/settings.js +1 -0
  50. package/dist/src/lib/solve-comment-parser.d.ts +26 -0
  51. package/dist/src/lib/solve-comment-parser.js +63 -7
  52. package/dist/src/lib/stacks.d.ts +4 -2
  53. package/dist/src/lib/stacks.js +43 -3
  54. package/dist/src/lib/workflow/batch-executor.d.ts +117 -0
  55. package/dist/src/lib/workflow/batch-executor.js +574 -0
  56. package/dist/src/lib/workflow/phase-executor.d.ts +40 -0
  57. package/dist/src/lib/workflow/phase-executor.js +381 -0
  58. package/dist/src/lib/workflow/phase-mapper.d.ts +65 -0
  59. package/dist/src/lib/workflow/phase-mapper.js +147 -0
  60. package/dist/src/lib/workflow/pr-operations.d.ts +86 -0
  61. package/dist/src/lib/workflow/pr-operations.js +326 -0
  62. package/dist/src/lib/workflow/pr-status.d.ts +9 -7
  63. package/dist/src/lib/workflow/pr-status.js +13 -11
  64. package/dist/src/lib/workflow/run-summary.d.ts +36 -0
  65. package/dist/src/lib/workflow/run-summary.js +142 -0
  66. package/dist/src/lib/workflow/state-schema.d.ts +5 -5
  67. package/dist/src/lib/workflow/worktree-manager.d.ts +205 -0
  68. package/dist/src/lib/workflow/worktree-manager.js +918 -0
  69. package/package.json +3 -1
  70. package/templates/skills/exec/SKILL.md +1086 -29
  71. package/templates/skills/fullsolve/SKILL.md +11 -1
  72. package/templates/skills/qa/SKILL.md +1758 -142
  73. package/templates/skills/solve/SKILL.md +86 -0
  74. package/templates/skills/spec/SKILL.md +53 -0
  75. package/templates/skills/test/SKILL.md +256 -1
@@ -0,0 +1,281 @@
1
+ ---
2
+ name: verify
3
+ description: Execution verification for CLI/script features — runs commands and captures output for human review. Use after /exec for script changes.
4
+ license: MIT
5
+ metadata:
6
+ author: sequant
7
+ version: "1.0"
8
+ allowed-tools:
9
+ - Bash(*)
10
+ - Read
11
+ - Glob
12
+ - Grep
13
+ - AskUserQuestion
14
+ - Bash(gh issue view:*)
15
+ - Bash(gh issue comment:*)
16
+ ---
17
+
18
+ # Execution Verification
19
+
20
+ You are the "Execution Verification Agent" for the current repository.
21
+
22
+ ## Purpose
23
+
24
+ When invoked as `/verify`, your job is to:
25
+
26
+ 1. Run the specified command for a CLI/script feature.
27
+ 2. Capture and display the command output (stdout/stderr).
28
+ 3. Prompt for human confirmation that output matches expected behavior.
29
+ 4. Post verification evidence to the GitHub issue.
30
+
31
+ This is the CLI equivalent of `/test` (which handles UI features via browser testing).
32
+
33
+ ## When to Use
34
+
35
+ Use `/verify` for:
36
+ - New scripts in `scripts/`
37
+ - CLI tool changes
38
+ - Automation features
39
+ - Anything with terminal output as primary interface
40
+
41
+ ## Invocation
42
+
43
+ ```bash
44
+ # With explicit command
45
+ /verify 559 --command "npx tsx scripts/migrate.ts --dry-run"
46
+
47
+ # With issue only (will prompt for command)
48
+ /verify 559
49
+ ```
50
+
51
+ ## Behavior
52
+
53
+ ### 1. Parse Arguments
54
+
55
+ Extract from the invocation:
56
+ - **Issue number:** The GitHub issue being verified
57
+ - **Command:** The command to execute (from `--command` flag or prompted)
58
+
59
+ If no command provided:
60
+ ```
61
+ Ask: "What command should I run to verify this feature?"
62
+ ```
63
+
64
+ ### 2. Verify Issue Context
65
+
66
+ ```bash
67
+ # Get issue details
68
+ gh issue view <issue-number> --json title,body,labels
69
+ ```
70
+
71
+ Confirm this is a CLI/script feature by checking:
72
+ - Issue title/body mentions scripts, CLI, automation
73
+ - Files changed include `scripts/` directory
74
+ - Not a UI-only feature
75
+
76
+ ### 3. Execute Command
77
+
78
+ Run the specified command with a timeout:
79
+
80
+ ```bash
81
+ # Run with 2-minute timeout, capture both stdout and stderr
82
+ timeout 120 <command> 2>&1
83
+ ```
84
+
85
+ **Timeout handling:**
86
+ - Default: 2 minutes (120 seconds)
87
+ - If command exceeds timeout, capture partial output and note timeout
88
+
89
+ **Output capture:**
90
+ - Capture both stdout and stderr
91
+ - Truncate at 500 lines to prevent oversized GitHub comments
92
+ - Preserve formatting (colors stripped for readability)
93
+
94
+ ### 4. Display Output
95
+
96
+ Present the captured output to the user:
97
+
98
+ ```markdown
99
+ ## Execution Output
100
+
101
+ **Command:** `<command>`
102
+ **Exit code:** <0 or error code>
103
+ **Duration:** <X seconds>
104
+
105
+ <details>
106
+ <summary>Output (X lines)</summary>
107
+
108
+ ```
109
+ [captured output here]
110
+ ```
111
+
112
+ </details>
113
+ ```
114
+
115
+ ### 5. Prompt for Confirmation
116
+
117
+ Use AskUserQuestion to get human confirmation:
118
+
119
+ ```
120
+ Question: Does this output match expected behavior for the feature?
121
+
122
+ Options:
123
+ - Yes, looks correct
124
+ - Partially - some issues but acceptable
125
+ - No, something is wrong
126
+ ```
127
+
128
+ ### 6. Handle Confirmation Response
129
+
130
+ **If "Yes" or "Partially":**
131
+ - Prepare verification evidence comment for GitHub
132
+ - Include: command, exit code, output summary, human confirmation
133
+
134
+ **If "No":**
135
+ - Ask for details about what's wrong
136
+ - Do NOT post verification (feature needs fixes)
137
+ - Suggest running `/exec` to address issues
138
+
139
+ ### 7. Post Verification to GitHub Issue
140
+
141
+ Post a comment with verification evidence:
142
+
143
+ ```markdown
144
+ ## Execution Verification
145
+
146
+ **Command:** `<command>`
147
+ **Result:** Verified by human review
148
+
149
+ <details>
150
+ <summary>Execution Output (click to expand)</summary>
151
+
152
+ **Exit code:** <code>
153
+ **Duration:** <duration>
154
+
155
+ ```
156
+ [truncated output - first 100 lines]
157
+ ```
158
+
159
+ [Output truncated at 100 lines - X total lines captured]
160
+
161
+ </details>
162
+
163
+ **Human Confirmation:**
164
+ > <confirmation response and any notes>
165
+
166
+ ---
167
+ *Verified by `/verify` command*
168
+ ```
169
+
170
+ ### 8. Exit Code Handling
171
+
172
+ Handle non-zero exit codes gracefully:
173
+
174
+ | Exit Code | Interpretation |
175
+ |-----------|----------------|
176
+ | 0 | Success |
177
+ | 1-125 | Command failed (show error output) |
178
+ | 124 | Timeout (command exceeded 2 minutes) |
179
+ | 126 | Permission denied |
180
+ | 127 | Command not found |
181
+
182
+ For non-zero exits:
183
+ - Still display output
184
+ - Still ask for confirmation (failure might be expected for testing error paths)
185
+ - Note the failure in the verification comment
186
+
187
+ ## Output Truncation
188
+
189
+ To prevent oversized GitHub comments (64KB limit):
190
+
191
+ 1. Capture full output to temp file
192
+ 2. Count lines
193
+ 3. If > 500 lines:
194
+ - Show first 100 lines in comment
195
+ - Note: "[Output truncated at 100 lines - X total lines captured]"
196
+ 4. Preserve full output locally for reference
197
+
198
+ ## Examples
199
+
200
+ ### Example 1: Successful Verification
201
+
202
+ ```bash
203
+ /verify 558 --command "npx tsx scripts/migrate.ts --dry-run"
204
+ ```
205
+
206
+ Output:
207
+ ```
208
+ Starting migration (dry run)...
209
+ Checking tables...
210
+ Migration plan: 3 tables, 5 columns
211
+ ...
212
+ Completed successfully
213
+ ```
214
+
215
+ Human confirms: "Yes, looks correct"
216
+
217
+ -> Posts verification evidence to issue #558
218
+
219
+ ### Example 2: Command Failure (Expected)
220
+
221
+ ```bash
222
+ /verify 559 --command "npx tsx scripts/dev/test-error-handling.ts --trigger-error"
223
+ ```
224
+
225
+ Output:
226
+ ```
227
+ Triggering intentional error...
228
+ Error: Test error triggered as expected
229
+ Exit code: 1
230
+ ```
231
+
232
+ Human confirms: "Yes, this error was expected - testing error handling"
233
+
234
+ -> Posts verification evidence noting expected failure
235
+
236
+ ### Example 3: No Command Provided
237
+
238
+ ```bash
239
+ /verify 560
240
+ ```
241
+
242
+ Agent prompts: "What command should I run to verify this feature?"
243
+
244
+ User provides: "npx tsx scripts/audit/check-coverage.ts nashville"
245
+
246
+ -> Proceeds with verification
247
+
248
+ ## Integration with /qa
249
+
250
+ The `/qa` skill will:
251
+ 1. Detect when `scripts/` files are modified
252
+ 2. Prompt to run `/verify` before `READY_FOR_MERGE`
253
+ 3. Check for "Execution Verification" section in issue comments
254
+
255
+ This ensures CLI/script features are actually tested, not just code-reviewed.
256
+
257
+ ## Error Recovery
258
+
259
+ If verification fails due to infrastructure issues:
260
+
261
+ 1. **Network timeout:** Retry once, then note as infrastructure issue
262
+ 2. **Missing dependencies:** Run `npm install` and retry
263
+ 3. **Environment issues:** Check for `.env.local` and required vars
264
+ 4. **File not found:** Verify worktree is correct, check file paths
265
+
266
+ Report infrastructure issues separately from feature issues.
267
+
268
+ ---
269
+
270
+ ## Output Verification
271
+
272
+ **Before responding, verify your output includes ALL of these:**
273
+
274
+ - [ ] **Command Executed** - The exact command that was run
275
+ - [ ] **Exit Code** - Success (0) or error code
276
+ - [ ] **Duration** - How long the command took
277
+ - [ ] **Output Sample** - Captured stdout/stderr (truncated if needed)
278
+ - [ ] **Human Confirmation** - User's verification response recorded
279
+ - [ ] **GitHub Comment** - Verification evidence posted to issue
280
+
281
+ **DO NOT respond until all items are verified.**
@@ -0,0 +1,9 @@
1
+ /**
2
+ * sequant conventions - View and manage codebase conventions
3
+ */
4
+ interface ConventionsOptions {
5
+ detect?: boolean;
6
+ reset?: boolean;
7
+ }
8
+ export declare function conventionsCommand(options: ConventionsOptions): Promise<void>;
9
+ export {};
@@ -0,0 +1,61 @@
1
+ /**
2
+ * sequant conventions - View and manage codebase conventions
3
+ */
4
+ import chalk from "chalk";
5
+ import { detectAndSaveConventions, loadConventions, formatConventions, CONVENTIONS_PATH, } from "../lib/conventions-detector.js";
6
+ import { fileExists, writeFile } from "../lib/fs.js";
7
+ export async function conventionsCommand(options) {
8
+ if (options.reset) {
9
+ await handleReset();
10
+ return;
11
+ }
12
+ if (options.detect) {
13
+ await handleDetect();
14
+ return;
15
+ }
16
+ // Default: show current conventions
17
+ await handleShow();
18
+ }
19
+ async function handleDetect() {
20
+ console.log(chalk.blue("Detecting codebase conventions..."));
21
+ const result = await detectAndSaveConventions(process.cwd());
22
+ const count = Object.keys(result.detected).length;
23
+ console.log(chalk.green(`\nDetected ${count} conventions:`));
24
+ console.log(formatConventions(result));
25
+ console.log(chalk.gray(`\nSaved to ${CONVENTIONS_PATH}`));
26
+ }
27
+ async function handleReset() {
28
+ const existing = await loadConventions();
29
+ if (!existing) {
30
+ console.log(chalk.yellow("No conventions file found. Nothing to reset."));
31
+ return;
32
+ }
33
+ // Keep manual entries, clear detected
34
+ const reset = {
35
+ detected: {},
36
+ manual: existing.manual,
37
+ detectedAt: "",
38
+ };
39
+ await writeFile(CONVENTIONS_PATH, JSON.stringify(reset, null, 2));
40
+ console.log(chalk.green("Detected conventions cleared. Manual entries preserved."));
41
+ if (Object.keys(existing.manual).length > 0) {
42
+ console.log(chalk.gray("\nManual entries kept:"));
43
+ for (const [key, value] of Object.entries(existing.manual)) {
44
+ console.log(chalk.gray(` ${key}: ${value}`));
45
+ }
46
+ }
47
+ }
48
+ async function handleShow() {
49
+ if (!(await fileExists(CONVENTIONS_PATH))) {
50
+ console.log(chalk.yellow("No conventions detected yet."));
51
+ console.log(chalk.gray("Run 'sequant conventions --detect' or 'sequant init' to detect conventions."));
52
+ return;
53
+ }
54
+ const conventions = await loadConventions();
55
+ if (!conventions) {
56
+ console.log(chalk.yellow("Could not read conventions file."));
57
+ return;
58
+ }
59
+ console.log(formatConventions(conventions));
60
+ console.log(chalk.gray(`\nEdit ${CONVENTIONS_PATH} to add manual overrides.`));
61
+ }
@@ -9,6 +9,7 @@ import { copyTemplates } from "../lib/templates.js";
9
9
  import { createManifest } from "../lib/manifest.js";
10
10
  import { saveConfig } from "../lib/config.js";
11
11
  import { createDefaultSettings } from "../lib/settings.js";
12
+ import { detectAndSaveConventions } from "../lib/conventions-detector.js";
12
13
  import { fileExists, ensureDir, readFile, writeFile } from "../lib/fs.js";
13
14
  import { commandExists, isGhAuthenticated, getInstallHint, } from "../lib/system.js";
14
15
  import { shouldUseInteractiveMode, getNonInteractiveReason, } from "../lib/tty.js";
@@ -347,6 +348,17 @@ export async function initCommand(options) {
347
348
  settingsSpinner.start();
348
349
  await createDefaultSettings();
349
350
  settingsSpinner.succeed("Created default settings");
351
+ // Detect codebase conventions
352
+ const conventionsSpinner = ui.spinner("Detecting codebase conventions...");
353
+ conventionsSpinner.start();
354
+ try {
355
+ const conventions = await detectAndSaveConventions(process.cwd());
356
+ const count = Object.keys(conventions.detected).length;
357
+ conventionsSpinner.succeed(`Detected ${count} codebase conventions`);
358
+ }
359
+ catch {
360
+ conventionsSpinner.warn("Could not detect conventions (non-blocking)");
361
+ }
350
362
  // Copy templates (with symlinks for scripts unless --no-symlinks)
351
363
  const templatesSpinner = ui.spinner("Copying templates...");
352
364
  templatesSpinner.start();
@@ -1,287 +1,20 @@
1
1
  /**
2
2
  * sequant run - Execute workflow for GitHub issues
3
3
  *
4
- * Runs the Sequant workflow (/spec /exec → /qa) for one or more issues
5
- * using the Claude Agent SDK for proper skill invocation.
6
- */
7
- import { Phase, ExecutionConfig, PhaseResult, QaVerdict } from "../lib/workflow/types.js";
8
- import { ShutdownManager } from "../lib/shutdown.js";
9
- import { PhaseSpinner } from "../lib/phase-spinner.js";
10
- /**
11
- * Parse QA verdict from phase output
12
- *
13
- * Looks for verdict patterns in the QA output:
14
- * - "### Verdict: READY_FOR_MERGE"
15
- * - "**Verdict:** AC_NOT_MET"
16
- * - "Verdict: AC_MET_BUT_NOT_A_PLUS"
17
- *
18
- * @param output - The captured output from QA phase
19
- * @returns The parsed verdict or null if not found
20
- */
21
- export declare function parseQaVerdict(output: string): QaVerdict | null;
22
- /**
23
- * Result of worktree freshness check
24
- */
25
- interface WorktreeFreshnessResult {
26
- /** True if worktree is stale (significantly behind main) */
27
- isStale: boolean;
28
- /** Number of commits behind origin/main */
29
- commitsBehind: number;
30
- /** True if worktree has uncommitted changes */
31
- hasUncommittedChanges: boolean;
32
- /** True if worktree has unpushed commits */
33
- hasUnpushedCommits: boolean;
34
- }
35
- /**
36
- * Check if a worktree is stale (behind origin/main) and should be recreated
37
- *
38
- * @param worktreePath - Path to the worktree
39
- * @param verbose - Enable verbose output
40
- * @returns Freshness check result
41
- */
42
- export declare function checkWorktreeFreshness(worktreePath: string, verbose: boolean): WorktreeFreshnessResult;
43
- /**
44
- * Remove and recreate a stale worktree
45
- *
46
- * @param existingPath - Path to existing worktree
47
- * @param branch - Branch name
48
- * @param verbose - Enable verbose output
49
- * @returns true if worktree was removed
50
- */
51
- export declare function removeStaleWorktree(existingPath: string, branch: string, verbose: boolean): boolean;
52
- /**
53
- * List all active worktrees with their branches
54
- */
55
- export declare function listWorktrees(): Array<{
56
- path: string;
57
- branch: string;
58
- issue: number | null;
59
- }>;
60
- /**
61
- * Get changed files in a worktree compared to main
62
- */
63
- export declare function getWorktreeChangedFiles(worktreePath: string): string[];
64
- /**
65
- * Get diff stats for a worktree (files changed, lines added)
66
- * Returns aggregate metrics only - no file paths to preserve privacy
67
- */
68
- export declare function getWorktreeDiffStats(worktreePath: string): {
69
- filesChanged: number;
70
- linesAdded: number;
71
- };
72
- /**
73
- * Filter phases based on resume status.
74
- *
75
- * When `resume` is true, calls `getResumablePhasesForIssue` to determine
76
- * which phases have already completed (via GitHub issue comment markers)
77
- * and removes them from the execution list.
78
- *
79
- * @param issueNumber - GitHub issue number
80
- * @param phases - The phases to potentially filter
81
- * @param resume - Whether the --resume flag is set
82
- * @returns Object with filtered phases and any skipped phases
83
- */
84
- export declare function filterResumedPhases(issueNumber: number, phases: Phase[], resume: boolean): {
85
- phases: Phase[];
86
- skipped: Phase[];
87
- };
88
- /**
89
- * Create a checkpoint commit in the worktree after QA passes
90
- * This allows recovery in case later issues in the chain fail
91
- * @internal Exported for testing
92
- */
93
- export declare function createCheckpointCommit(worktreePath: string, issueNumber: number, verbose: boolean): boolean;
94
- /**
95
- * Check if any lockfile changed during a rebase and re-run install if needed.
96
- * This prevents dependency drift when the lockfile was updated on main.
97
- * @param worktreePath Path to the worktree
98
- * @param packageManager Package manager to use for install
99
- * @param verbose Whether to show verbose output
100
- * @param preRebaseRef Git ref pointing to pre-rebase HEAD (defaults to ORIG_HEAD,
101
- * which git sets automatically after rebase). Using ORIG_HEAD captures all
102
- * lockfile changes across multi-commit rebases, unlike HEAD~1 which only
103
- * checks the last commit.
104
- * @returns true if reinstall was performed, false otherwise
105
- * @internal Exported for testing
106
- */
107
- export declare function reinstallIfLockfileChanged(worktreePath: string, packageManager: string | undefined, verbose: boolean, preRebaseRef?: string): boolean;
108
- /**
109
- * Result of a pre-PR rebase operation
110
- */
111
- export interface RebaseResult {
112
- /** Whether the rebase was performed */
113
- performed: boolean;
114
- /** Whether the rebase succeeded */
115
- success: boolean;
116
- /** Whether dependencies were reinstalled */
117
- reinstalled: boolean;
118
- /** Error message if rebase failed */
119
- error?: string;
120
- }
121
- /**
122
- * Rebase the worktree branch onto origin/main before PR creation.
123
- * This ensures the branch is up-to-date and prevents lockfile drift.
124
- *
125
- * @param worktreePath Path to the worktree
126
- * @param issueNumber Issue number (for logging)
127
- * @param packageManager Package manager to use if reinstall needed
128
- * @param verbose Whether to show verbose output
129
- * @returns RebaseResult indicating success/failure and whether reinstall was performed
130
- * @internal Exported for testing
131
- */
132
- export declare function rebaseBeforePR(worktreePath: string, issueNumber: number, packageManager: string | undefined, verbose: boolean): RebaseResult;
133
- /**
134
- * Result of PR creation
135
- */
136
- export interface PRCreationResult {
137
- /** Whether PR creation was attempted */
138
- attempted: boolean;
139
- /** Whether PR was created successfully (or already existed) */
140
- success: boolean;
141
- /** PR number */
142
- prNumber?: number;
143
- /** PR URL */
144
- prUrl?: string;
145
- /** Error message if failed */
146
- error?: string;
147
- }
148
- /**
149
- * Push branch and create a PR after successful QA.
150
- *
151
- * Handles both fresh PR creation and detection of existing PRs.
152
- * Failures are warnings — they don't fail the run.
153
- *
154
- * @param worktreePath Path to the worktree
155
- * @param issueNumber Issue number
156
- * @param issueTitle Issue title (for PR title)
157
- * @param branch Branch name
158
- * @param verbose Whether to show verbose output
159
- * @returns PRCreationResult with PR info or error
160
- * @internal Exported for testing
161
- */
162
- export declare function createPR(worktreePath: string, issueNumber: number, issueTitle: string, branch: string, verbose: boolean, labels?: string[]): PRCreationResult;
163
- /**
164
- * Detect phases based on issue labels (like /solve logic)
165
- */
166
- export declare function detectPhasesFromLabels(labels: string[]): {
167
- phases: Phase[];
168
- qualityLoop: boolean;
169
- };
170
- /**
171
- * Parse recommended workflow from /spec output
172
- *
173
- * Looks for:
174
- * ## Recommended Workflow
175
- * **Phases:** exec → qa
176
- * **Quality Loop:** enabled|disabled
177
- */
178
- export declare function parseRecommendedWorkflow(output: string): {
179
- phases: Phase[];
180
- qualityLoop: boolean;
181
- } | null;
182
- interface RunOptions {
183
- phases?: string;
184
- sequential?: boolean;
185
- dryRun?: boolean;
186
- verbose?: boolean;
187
- timeout?: number;
188
- logJson?: boolean;
189
- noLog?: boolean;
190
- logPath?: string;
191
- qualityLoop?: boolean;
192
- maxIterations?: number;
193
- batch?: string[];
194
- smartTests?: boolean;
195
- noSmartTests?: boolean;
196
- testgen?: boolean;
197
- autoDetectPhases?: boolean;
198
- /** Enable automatic worktree creation for issue isolation */
199
- worktreeIsolation?: boolean;
200
- /** Reuse existing worktrees instead of creating new ones */
201
- reuseWorktrees?: boolean;
202
- /** Suppress version warnings and non-essential output */
203
- quiet?: boolean;
204
- /** Chain issues: each branches from previous (requires --sequential) */
205
- chain?: boolean;
206
- /**
207
- * Wait for QA pass before starting next issue in chain mode.
208
- * When enabled, the chain pauses if QA fails, preventing downstream issues
209
- * from building on potentially broken code.
210
- */
211
- qaGate?: boolean;
212
- /**
213
- * Base branch for worktree creation.
214
- * Resolution priority: this CLI flag → settings.run.defaultBase → 'main'
215
- */
216
- base?: string;
217
- /**
218
- * Disable MCP servers in headless mode.
219
- * When true, MCPs are not passed to the SDK (faster/cheaper runs).
220
- * Resolution priority: this CLI flag → settings.run.mcp → default (true)
221
- */
222
- noMcp?: boolean;
223
- /**
224
- * Resume from last completed phase.
225
- * Reads phase markers from GitHub issue comments and skips completed phases.
226
- */
227
- resume?: boolean;
228
- /**
229
- * Disable automatic retry with MCP fallback.
230
- * When true, no retry attempts are made on phase failure.
231
- * Useful for debugging to see the actual failure without retry masking it.
232
- */
233
- noRetry?: boolean;
234
- /**
235
- * Skip pre-PR rebase onto origin/main.
236
- * When true, branches are not rebased before creating the PR.
237
- * Use when you want to preserve branch state or handle rebasing manually.
238
- */
239
- noRebase?: boolean;
240
- /**
241
- * Skip PR creation after successful QA.
242
- * When true, branches are pushed but no PR is created.
243
- * Useful for manual workflows where PRs are created separately.
244
- */
245
- noPr?: boolean;
246
- /**
247
- * Force re-execution of issues even if they have completed status.
248
- * Bypasses the pre-flight state guard that skips ready_for_merge/merged issues.
249
- */
250
- force?: boolean;
251
- /**
252
- * Analyze run results and suggest workflow improvements.
253
- * Displays observations about timing patterns, phase mismatches, and
254
- * actionable suggestions after the summary output.
255
- */
256
- reflect?: boolean;
257
- }
258
- /**
259
- * Execute a single phase for an issue using Claude Agent SDK
260
- */
261
- declare function executePhase(issueNumber: number, phase: Phase, config: ExecutionConfig, sessionId?: string, worktreePath?: string, shutdownManager?: ShutdownManager, spinner?: PhaseSpinner): Promise<PhaseResult & {
262
- sessionId?: string;
263
- }>;
264
- /**
265
- * Execute a phase with automatic retry for cold-start failures and MCP fallback.
266
- *
267
- * Retry strategy:
268
- * 1. If phase fails within COLD_START_THRESHOLD_SECONDS, retry up to COLD_START_MAX_RETRIES times
269
- * 2. If still failing and MCP is enabled, retry once with MCP disabled (npx-based MCP servers
270
- * can fail on first run due to cold-cache issues)
271
- *
272
- * The MCP fallback is safe because MCP servers are optional enhancements, not required
273
- * for core functionality.
274
- */
275
- /**
276
- * @internal Exported for testing only
277
- */
278
- export declare function executePhaseWithRetry(issueNumber: number, phase: Phase, config: ExecutionConfig, sessionId?: string, worktreePath?: string, shutdownManager?: ShutdownManager, spinner?: PhaseSpinner,
279
- /** @internal Injected for testing — defaults to module-level executePhase */
280
- executePhaseFn?: typeof executePhase): Promise<PhaseResult & {
281
- sessionId?: string;
282
- }>;
4
+ * Orchestrator module that composes focused workflow modules:
5
+ * - worktree-manager: Worktree lifecycle (ensure, list, cleanup, changed files)
6
+ * - phase-executor: Phase execution with retry and failure handling
7
+ * - phase-mapper: Label-to-phase detection and workflow parsing
8
+ * - batch-executor: Batch execution, dependency sorting, issue logging
9
+ */
10
+ import type { RunOptions } from "../lib/workflow/batch-executor.js";
11
+ export { parseQaVerdict, formatDuration, executePhaseWithRetry, } from "../lib/workflow/phase-executor.js";
12
+ export { detectDefaultBranch, checkWorktreeFreshness, removeStaleWorktree, listWorktrees, getWorktreeChangedFiles, getWorktreeDiffStats, readCacheMetrics, filterResumedPhases, ensureWorktree, createCheckpointCommit, reinstallIfLockfileChanged, rebaseBeforePR, createPR, } from "../lib/workflow/worktree-manager.js";
13
+ export type { WorktreeInfo, RebaseResult, PRCreationResult, } from "../lib/workflow/worktree-manager.js";
14
+ export { detectPhasesFromLabels, parseRecommendedWorkflow, determinePhasesForIssue, } from "../lib/workflow/phase-mapper.js";
15
+ export { getIssueInfo, sortByDependencies, parseBatches, getEnvConfig, executeBatch, runIssueWithLogging, } from "../lib/workflow/batch-executor.js";
16
+ export type { RunOptions } from "../lib/workflow/batch-executor.js";
283
17
  /**
284
18
  * Main run command
285
19
  */
286
20
  export declare function runCommand(issues: string[], options: RunOptions): Promise<void>;
287
- export {};