sequant 2.1.2 → 2.3.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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +73 -0
- package/dist/bin/cli.js +95 -9
- package/dist/src/commands/doctor.d.ts +25 -0
- package/dist/src/commands/doctor.js +36 -1
- package/dist/src/commands/init.d.ts +1 -0
- package/dist/src/commands/init.js +118 -0
- package/dist/src/commands/locks.d.ts +67 -0
- package/dist/src/commands/locks.js +290 -0
- package/dist/src/commands/merge.js +11 -0
- package/dist/src/commands/prompt.d.ts +39 -0
- package/dist/src/commands/prompt.js +179 -0
- package/dist/src/commands/run-display.d.ts +26 -0
- package/dist/src/commands/run-display.js +150 -0
- package/dist/src/commands/run-progress.d.ts +32 -0
- package/dist/src/commands/run-progress.js +76 -0
- package/dist/src/commands/run.js +83 -73
- package/dist/src/commands/stats.d.ts +2 -0
- package/dist/src/commands/stats.js +94 -8
- package/dist/src/commands/status.js +27 -1
- package/dist/src/commands/watch.d.ts +16 -0
- package/dist/src/commands/watch.js +147 -0
- package/dist/src/lib/ac-linter.d.ts +1 -1
- package/dist/src/lib/ac-linter.js +81 -0
- package/dist/src/lib/assess-collision-detect.d.ts +91 -0
- package/dist/src/lib/assess-collision-detect.js +217 -0
- package/dist/src/lib/assess-comment-parser.d.ts +59 -1
- package/dist/src/lib/assess-comment-parser.js +124 -2
- package/dist/src/lib/cli-ui/format.d.ts +19 -0
- package/dist/src/lib/cli-ui/format.js +34 -0
- package/dist/src/lib/cli-ui/run-renderer-types.d.ts +181 -0
- package/dist/src/lib/cli-ui/run-renderer-types.js +7 -0
- package/dist/src/lib/cli-ui/run-renderer.d.ts +239 -0
- package/dist/src/lib/cli-ui/run-renderer.js +1173 -0
- package/dist/src/lib/heuristics/behavior-rule-detector.d.ts +94 -0
- package/dist/src/lib/heuristics/behavior-rule-detector.js +467 -0
- package/dist/src/lib/locks/index.d.ts +7 -0
- package/dist/src/lib/locks/index.js +5 -0
- package/dist/src/lib/locks/lock-manager.d.ts +168 -0
- package/dist/src/lib/locks/lock-manager.js +433 -0
- package/dist/src/lib/locks/types.d.ts +59 -0
- package/dist/src/lib/locks/types.js +31 -0
- package/dist/src/lib/qa/markdown-only-ci.d.ts +46 -0
- package/dist/src/lib/qa/markdown-only-ci.js +74 -0
- package/dist/src/lib/relay/activation.d.ts +60 -0
- package/dist/src/lib/relay/activation.js +122 -0
- package/dist/src/lib/relay/archive.d.ts +34 -0
- package/dist/src/lib/relay/archive.js +106 -0
- package/dist/src/lib/relay/frame.d.ts +20 -0
- package/dist/src/lib/relay/frame.js +76 -0
- package/dist/src/lib/relay/index.d.ts +13 -0
- package/dist/src/lib/relay/index.js +13 -0
- package/dist/src/lib/relay/paths.d.ts +43 -0
- package/dist/src/lib/relay/paths.js +59 -0
- package/dist/src/lib/relay/pid.d.ts +34 -0
- package/dist/src/lib/relay/pid.js +72 -0
- package/dist/src/lib/relay/reader.d.ts +35 -0
- package/dist/src/lib/relay/reader.js +115 -0
- package/dist/src/lib/relay/types.d.ts +68 -0
- package/dist/src/lib/relay/types.js +76 -0
- package/dist/src/lib/relay/writer.d.ts +48 -0
- package/dist/src/lib/relay/writer.js +113 -0
- package/dist/src/lib/settings.d.ts +31 -1
- package/dist/src/lib/settings.js +18 -3
- package/dist/src/lib/skill-version.d.ts +19 -0
- package/dist/src/lib/skill-version.js +68 -0
- package/dist/src/lib/templates.d.ts +1 -0
- package/dist/src/lib/templates.js +1 -1
- package/dist/src/lib/version-check.d.ts +60 -5
- package/dist/src/lib/version-check.js +97 -9
- package/dist/src/lib/workflow/batch-executor.d.ts +20 -1
- package/dist/src/lib/workflow/batch-executor.js +249 -176
- package/dist/src/lib/workflow/config-resolver.js +4 -0
- package/dist/src/lib/workflow/heartbeat.d.ts +71 -0
- package/dist/src/lib/workflow/heartbeat.js +194 -0
- package/dist/src/lib/workflow/phase-executor.d.ts +88 -3
- package/dist/src/lib/workflow/phase-executor.js +276 -52
- package/dist/src/lib/workflow/phase-mapper.d.ts +3 -2
- package/dist/src/lib/workflow/phase-mapper.js +17 -20
- package/dist/src/lib/workflow/platforms/github.d.ts +1 -1
- package/dist/src/lib/workflow/platforms/github.js +20 -3
- package/dist/src/lib/workflow/pr-status.d.ts +18 -2
- package/dist/src/lib/workflow/pr-status.js +41 -9
- package/dist/src/lib/workflow/qa-stagnation.d.ts +117 -0
- package/dist/src/lib/workflow/qa-stagnation.js +179 -0
- package/dist/src/lib/workflow/run-orchestrator.d.ts +76 -0
- package/dist/src/lib/workflow/run-orchestrator.js +382 -29
- package/dist/src/lib/workflow/run-reflect.js +1 -1
- package/dist/src/lib/workflow/run-state.d.ts +71 -0
- package/dist/src/lib/workflow/run-state.js +14 -0
- package/dist/src/lib/workflow/state-cleanup.d.ts +13 -5
- package/dist/src/lib/workflow/state-cleanup.js +17 -5
- package/dist/src/lib/workflow/state-manager.d.ts +12 -1
- package/dist/src/lib/workflow/state-manager.js +37 -0
- package/dist/src/lib/workflow/state-schema.d.ts +62 -0
- package/dist/src/lib/workflow/state-schema.js +35 -1
- package/dist/src/lib/workflow/types.d.ts +74 -1
- package/dist/src/lib/workflow/worktree-manager.d.ts +12 -4
- package/dist/src/lib/workflow/worktree-manager.js +76 -17
- package/dist/src/mcp/tools/run.d.ts +44 -0
- package/dist/src/mcp/tools/run.js +104 -13
- package/dist/src/ui/tui/App.d.ts +14 -0
- package/dist/src/ui/tui/App.js +41 -0
- package/dist/src/ui/tui/ElapsedTimer.d.ts +10 -0
- package/dist/src/ui/tui/ElapsedTimer.js +31 -0
- package/dist/src/ui/tui/Header.d.ts +6 -0
- package/dist/src/ui/tui/Header.js +15 -0
- package/dist/src/ui/tui/IssueBox.d.ts +16 -0
- package/dist/src/ui/tui/IssueBox.js +68 -0
- package/dist/src/ui/tui/Spinner.d.ts +9 -0
- package/dist/src/ui/tui/Spinner.js +18 -0
- package/dist/src/ui/tui/index.d.ts +15 -0
- package/dist/src/ui/tui/index.js +29 -0
- package/dist/src/ui/tui/theme.d.ts +29 -0
- package/dist/src/ui/tui/theme.js +52 -0
- package/dist/src/ui/tui/truncate.d.ts +11 -0
- package/dist/src/ui/tui/truncate.js +31 -0
- package/package.json +10 -3
- package/templates/agents/sequant-explorer.md +1 -0
- package/templates/agents/sequant-qa-checker.md +2 -1
- package/templates/agents/sequant-testgen.md +1 -0
- package/templates/hooks/post-tool.sh +11 -0
- package/templates/hooks/pre-tool.sh +18 -9
- package/templates/hooks/relay-check.sh +107 -0
- package/templates/relay/frame.txt +11 -0
- package/templates/scripts/cleanup-worktree.sh +25 -3
- package/templates/scripts/new-feature.sh +6 -0
- package/templates/skills/_shared/references/behavior-rule-detection.md +205 -0
- package/templates/skills/_shared/references/subagent-types.md +21 -8
- package/templates/skills/assess/SKILL.md +261 -94
- package/templates/skills/assess/references/predicted-collision-detection.md +109 -0
- package/templates/skills/docs/SKILL.md +141 -22
- package/templates/skills/exec/SKILL.md +10 -49
- package/templates/skills/fullsolve/SKILL.md +80 -32
- package/templates/skills/loop/SKILL.md +28 -0
- package/templates/skills/merger/SKILL.md +621 -0
- package/templates/skills/qa/SKILL.md +746 -8
- package/templates/skills/qa/scripts/quality-checks.sh +47 -1
- package/templates/skills/setup/SKILL.md +6 -0
- package/templates/skills/spec/SKILL.md +217 -964
- package/templates/skills/spec/references/parallel-groups.md +7 -0
- package/templates/skills/spec/references/quality-checklist.md +75 -0
- package/templates/skills/spec/references/recommended-workflow.md +4 -2
- package/templates/skills/test/SKILL.md +0 -27
- package/templates/skills/testgen/SKILL.md +24 -44
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QA stagnation detection — early-exit guard for fullsolve's QA loop.
|
|
3
|
+
*
|
|
4
|
+
* Background (issue #581): when fullsolve's QA loop sees an `AC_NOT_MET`
|
|
5
|
+
* verdict it invokes `/loop` to apply fixes, then re-runs `/qa`. If `/loop`
|
|
6
|
+
* silently no-ops (no diff, no commit), the re-run produces the same verdict
|
|
7
|
+
* at the same SHA — wasting iterations without adding signal.
|
|
8
|
+
*
|
|
9
|
+
* This module exposes:
|
|
10
|
+
*
|
|
11
|
+
* - `detectStagnation()` — pure decision function. Given the latest qa marker,
|
|
12
|
+
* the current HEAD SHA, and whether the worktree is dirty, returns whether
|
|
13
|
+
* the next QA invocation would be wasted.
|
|
14
|
+
* - `recordStagnation()` — appends a stagnation entry to the per-issue
|
|
15
|
+
* record in `.sequant/state.json` so successive fullsolve runs can see
|
|
16
|
+
* the history.
|
|
17
|
+
*
|
|
18
|
+
* The fullsolve and loop SKILL.md files invoke a thin CLI shim that wraps
|
|
19
|
+
* these functions so the same code paths are exercised by tests and the
|
|
20
|
+
* orchestrated runtime.
|
|
21
|
+
*/
|
|
22
|
+
import { type StateManagerOptions } from "./state-manager.js";
|
|
23
|
+
import type { PhaseMarker } from "./state-schema.js";
|
|
24
|
+
/**
|
|
25
|
+
* Reason codes for halting the QA loop.
|
|
26
|
+
*/
|
|
27
|
+
export type StagnationReason = "SAME_SHA_NO_PROGRESS" | "LOOP_NO_DIFF";
|
|
28
|
+
/**
|
|
29
|
+
* Decision returned by `detectStagnation`.
|
|
30
|
+
*
|
|
31
|
+
* `stagnant === true` means the orchestrator should NOT re-invoke `/qa` at
|
|
32
|
+
* the current state — either escalate or hand off to `/loop` for one more
|
|
33
|
+
* fix attempt.
|
|
34
|
+
*/
|
|
35
|
+
export interface StagnationDecision {
|
|
36
|
+
stagnant: boolean;
|
|
37
|
+
reason?: StagnationReason;
|
|
38
|
+
/** Human-readable explanation suitable for logs / GitHub comments. */
|
|
39
|
+
message: string;
|
|
40
|
+
/** SHA the prior QA was recorded at, if any. */
|
|
41
|
+
priorSha?: string;
|
|
42
|
+
/** Verdict from the prior QA, if any. */
|
|
43
|
+
priorVerdict?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface DetectStagnationInput {
|
|
46
|
+
/** Current `git rev-parse HEAD` for the worktree. */
|
|
47
|
+
currentSha: string;
|
|
48
|
+
/** Whether `git status --porcelain` is non-empty. */
|
|
49
|
+
isDirty: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Most recent qa phase marker (any status). Pass `null` when no marker has
|
|
52
|
+
* been recorded yet — that always means "fresh, run qa".
|
|
53
|
+
*/
|
|
54
|
+
lastMarker: PhaseMarker | null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Pure detection function: would invoking `/qa` again be a wasted cycle?
|
|
58
|
+
*
|
|
59
|
+
* The contract from issue #581 AC-1: if the prior qa marker is `failed`,
|
|
60
|
+
* its `commitSHA` matches HEAD, AND the worktree is clean, the next `/qa`
|
|
61
|
+
* call will produce the same verdict — so the orchestrator should escalate
|
|
62
|
+
* (or run `/loop` once) instead.
|
|
63
|
+
*/
|
|
64
|
+
export declare function detectStagnation(input: DetectStagnationInput): StagnationDecision;
|
|
65
|
+
/**
|
|
66
|
+
* Append a stagnation entry to the per-issue record. Schema-additive — older
|
|
67
|
+
* state files without the field will simply gain it on next write.
|
|
68
|
+
*/
|
|
69
|
+
export declare function recordStagnation(issueNumber: number, entry: {
|
|
70
|
+
sha: string;
|
|
71
|
+
verdict: string;
|
|
72
|
+
iteration: number;
|
|
73
|
+
reason: StagnationReason;
|
|
74
|
+
}, options?: StateManagerOptions): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Inputs required for the CLI shim. Loaded from git + GitHub at the call site.
|
|
77
|
+
*/
|
|
78
|
+
export interface CLIDetectInput {
|
|
79
|
+
currentSha: string;
|
|
80
|
+
isDirty: boolean;
|
|
81
|
+
lastMarker: PhaseMarker | null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Read the worktree's HEAD SHA. Pure wrapper around `git rev-parse HEAD`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function readHeadSha(cwd?: string): string;
|
|
87
|
+
/**
|
|
88
|
+
* Returns true when `git status --porcelain` reports any uncommitted change.
|
|
89
|
+
*/
|
|
90
|
+
export declare function readIsDirty(cwd?: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Snapshot a worktree's HEAD SHA and dirty bit. Used by `/loop` to detect
|
|
93
|
+
* whether a fix attempt actually produced a diff. We deliberately exclude
|
|
94
|
+
* `.sequant/state.json` writes from the dirty check — the helper itself
|
|
95
|
+
* writes there, and per issue #581 those writes do NOT count as progress.
|
|
96
|
+
*/
|
|
97
|
+
export interface LoopProgressSnapshot {
|
|
98
|
+
sha: string;
|
|
99
|
+
/** Path-relative dirty entries, excluding `.sequant/` state writes. */
|
|
100
|
+
dirty: string[];
|
|
101
|
+
}
|
|
102
|
+
export declare function snapshotLoopProgress(cwd?: string): LoopProgressSnapshot;
|
|
103
|
+
export interface LoopProgressDecision {
|
|
104
|
+
/** True when the snapshot pair shows a real diff (commit or working-tree change). */
|
|
105
|
+
progressed: boolean;
|
|
106
|
+
reason?: "LOOP_NO_DIFF";
|
|
107
|
+
message: string;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Compare two `LoopProgressSnapshot`s. Returns `progressed: false` ONLY when
|
|
111
|
+
* both the SHA and the (state-excluded) dirty set are unchanged.
|
|
112
|
+
*
|
|
113
|
+
* State-file / settings writes are excluded from the dirty comparison per
|
|
114
|
+
* issue #581's open question — `/loop` may legitimately touch
|
|
115
|
+
* `.sequant/state.json` without that counting as a fix.
|
|
116
|
+
*/
|
|
117
|
+
export declare function compareLoopProgress(before: LoopProgressSnapshot, after: LoopProgressSnapshot): LoopProgressDecision;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QA stagnation detection — early-exit guard for fullsolve's QA loop.
|
|
3
|
+
*
|
|
4
|
+
* Background (issue #581): when fullsolve's QA loop sees an `AC_NOT_MET`
|
|
5
|
+
* verdict it invokes `/loop` to apply fixes, then re-runs `/qa`. If `/loop`
|
|
6
|
+
* silently no-ops (no diff, no commit), the re-run produces the same verdict
|
|
7
|
+
* at the same SHA — wasting iterations without adding signal.
|
|
8
|
+
*
|
|
9
|
+
* This module exposes:
|
|
10
|
+
*
|
|
11
|
+
* - `detectStagnation()` — pure decision function. Given the latest qa marker,
|
|
12
|
+
* the current HEAD SHA, and whether the worktree is dirty, returns whether
|
|
13
|
+
* the next QA invocation would be wasted.
|
|
14
|
+
* - `recordStagnation()` — appends a stagnation entry to the per-issue
|
|
15
|
+
* record in `.sequant/state.json` so successive fullsolve runs can see
|
|
16
|
+
* the history.
|
|
17
|
+
*
|
|
18
|
+
* The fullsolve and loop SKILL.md files invoke a thin CLI shim that wraps
|
|
19
|
+
* these functions so the same code paths are exercised by tests and the
|
|
20
|
+
* orchestrated runtime.
|
|
21
|
+
*/
|
|
22
|
+
import { execSync } from "child_process";
|
|
23
|
+
import { StateManager, getStateManager, } from "./state-manager.js";
|
|
24
|
+
/**
|
|
25
|
+
* Pure detection function: would invoking `/qa` again be a wasted cycle?
|
|
26
|
+
*
|
|
27
|
+
* The contract from issue #581 AC-1: if the prior qa marker is `failed`,
|
|
28
|
+
* its `commitSHA` matches HEAD, AND the worktree is clean, the next `/qa`
|
|
29
|
+
* call will produce the same verdict — so the orchestrator should escalate
|
|
30
|
+
* (or run `/loop` once) instead.
|
|
31
|
+
*/
|
|
32
|
+
export function detectStagnation(input) {
|
|
33
|
+
const { currentSha, isDirty, lastMarker } = input;
|
|
34
|
+
if (!lastMarker) {
|
|
35
|
+
return { stagnant: false, message: "No prior qa marker — fresh run." };
|
|
36
|
+
}
|
|
37
|
+
if (lastMarker.phase !== "qa") {
|
|
38
|
+
return {
|
|
39
|
+
stagnant: false,
|
|
40
|
+
message: `Latest marker is for phase '${lastMarker.phase}', not qa.`,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (lastMarker.status !== "failed") {
|
|
44
|
+
return {
|
|
45
|
+
stagnant: false,
|
|
46
|
+
message: `Prior qa marker status is '${lastMarker.status}', not 'failed'.`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (!lastMarker.commitSHA) {
|
|
50
|
+
return {
|
|
51
|
+
stagnant: false,
|
|
52
|
+
message: "Prior qa marker has no commitSHA — cannot compare; fall through.",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (lastMarker.commitSHA !== currentSha) {
|
|
56
|
+
return {
|
|
57
|
+
stagnant: false,
|
|
58
|
+
message: `Prior qa SHA ${lastMarker.commitSHA} ≠ HEAD ${currentSha}; new commits since last run.`,
|
|
59
|
+
priorSha: lastMarker.commitSHA,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (isDirty) {
|
|
63
|
+
return {
|
|
64
|
+
stagnant: false,
|
|
65
|
+
message: "Worktree dirty since last qa — uncommitted changes will produce different output.",
|
|
66
|
+
priorSha: lastMarker.commitSHA,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
stagnant: true,
|
|
71
|
+
reason: "SAME_SHA_NO_PROGRESS",
|
|
72
|
+
message: `Prior qa failed at HEAD ${currentSha} and worktree is clean — ` +
|
|
73
|
+
`re-running /qa would produce the same verdict.`,
|
|
74
|
+
priorSha: lastMarker.commitSHA,
|
|
75
|
+
priorVerdict: lastMarker.error,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Append a stagnation entry to the per-issue record. Schema-additive — older
|
|
80
|
+
* state files without the field will simply gain it on next write.
|
|
81
|
+
*/
|
|
82
|
+
export async function recordStagnation(issueNumber, entry, options = {}) {
|
|
83
|
+
const manager = options.statePath !== undefined
|
|
84
|
+
? new StateManager(options)
|
|
85
|
+
: getStateManager(options);
|
|
86
|
+
await manager.withLock(async () => {
|
|
87
|
+
const state = await manager.getState();
|
|
88
|
+
const issueState = state.issues[String(issueNumber)];
|
|
89
|
+
if (!issueState) {
|
|
90
|
+
throw new Error(`Cannot record stagnation: issue #${issueNumber} not found in state`);
|
|
91
|
+
}
|
|
92
|
+
const existing = issueState.qaStagnation ?? [];
|
|
93
|
+
existing.push({
|
|
94
|
+
sha: entry.sha,
|
|
95
|
+
verdict: entry.verdict,
|
|
96
|
+
iteration: entry.iteration,
|
|
97
|
+
reason: entry.reason,
|
|
98
|
+
detectedAt: new Date().toISOString(),
|
|
99
|
+
});
|
|
100
|
+
issueState.qaStagnation = existing;
|
|
101
|
+
issueState.lastActivity = new Date().toISOString();
|
|
102
|
+
await manager.saveState(state);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Read the worktree's HEAD SHA. Pure wrapper around `git rev-parse HEAD`.
|
|
107
|
+
*/
|
|
108
|
+
export function readHeadSha(cwd = process.cwd()) {
|
|
109
|
+
return execSync("git rev-parse HEAD", { cwd, encoding: "utf-8" }).trim();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns true when `git status --porcelain` reports any uncommitted change.
|
|
113
|
+
*/
|
|
114
|
+
export function readIsDirty(cwd = process.cwd()) {
|
|
115
|
+
return (execSync("git status --porcelain", { cwd, encoding: "utf-8" }).trim()
|
|
116
|
+
.length > 0);
|
|
117
|
+
}
|
|
118
|
+
const STATE_DIR_PREFIX = ".sequant/";
|
|
119
|
+
function readDirtyExcludingState(cwd = process.cwd()) {
|
|
120
|
+
// `git status --porcelain` (v1) always prefixes each line with exactly
|
|
121
|
+
// `XY ` (two status bytes + a space) before the path. We must slice on the
|
|
122
|
+
// RAW line — trimming first strips the leading space of unstaged-only
|
|
123
|
+
// entries (` M file.ts`) and a subsequent `.{1,3}` regex would chop real
|
|
124
|
+
// path bytes. See issue #581 QA review.
|
|
125
|
+
const out = execSync("git status --porcelain", {
|
|
126
|
+
cwd,
|
|
127
|
+
encoding: "utf-8",
|
|
128
|
+
});
|
|
129
|
+
return out
|
|
130
|
+
.split("\n")
|
|
131
|
+
.filter((line) => line.length > 0)
|
|
132
|
+
.map((line) => {
|
|
133
|
+
// Renamed entries use `R old -> new`; we only care about the new path.
|
|
134
|
+
const path = line.slice(3);
|
|
135
|
+
const arrow = path.indexOf(" -> ");
|
|
136
|
+
return arrow >= 0 ? path.slice(arrow + 4) : path;
|
|
137
|
+
})
|
|
138
|
+
.filter((path) => !path.startsWith(STATE_DIR_PREFIX));
|
|
139
|
+
}
|
|
140
|
+
export function snapshotLoopProgress(cwd = process.cwd()) {
|
|
141
|
+
return { sha: readHeadSha(cwd), dirty: readDirtyExcludingState(cwd) };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Compare two `LoopProgressSnapshot`s. Returns `progressed: false` ONLY when
|
|
145
|
+
* both the SHA and the (state-excluded) dirty set are unchanged.
|
|
146
|
+
*
|
|
147
|
+
* State-file / settings writes are excluded from the dirty comparison per
|
|
148
|
+
* issue #581's open question — `/loop` may legitimately touch
|
|
149
|
+
* `.sequant/state.json` without that counting as a fix.
|
|
150
|
+
*/
|
|
151
|
+
export function compareLoopProgress(before, after) {
|
|
152
|
+
if (before.sha !== after.sha) {
|
|
153
|
+
return {
|
|
154
|
+
progressed: true,
|
|
155
|
+
message: `HEAD advanced ${before.sha} → ${after.sha}.`,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const beforeSet = new Set(before.dirty);
|
|
159
|
+
const afterSet = new Set(after.dirty);
|
|
160
|
+
if (beforeSet.size !== afterSet.size) {
|
|
161
|
+
return {
|
|
162
|
+
progressed: true,
|
|
163
|
+
message: `Working-tree dirty count changed (${beforeSet.size} → ${afterSet.size}).`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
for (const path of afterSet) {
|
|
167
|
+
if (!beforeSet.has(path)) {
|
|
168
|
+
return {
|
|
169
|
+
progressed: true,
|
|
170
|
+
message: `New dirty path detected: ${path}.`,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
progressed: false,
|
|
176
|
+
reason: "LOOP_NO_DIFF",
|
|
177
|
+
message: "/loop made no commit and no working-tree changes (excluding .sequant/ state writes) — manual intervention required.",
|
|
178
|
+
};
|
|
179
|
+
}
|
|
@@ -7,11 +7,22 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
import type { ExecutionConfig, IssueResult, RunOptions, ProgressCallback } from "./types.js";
|
|
10
|
+
import type { RunSnapshot } from "./run-state.js";
|
|
10
11
|
import type { WorktreeInfo } from "./worktree-manager.js";
|
|
11
12
|
import { LogWriter } from "./log-writer.js";
|
|
12
13
|
import { StateManager } from "./state-manager.js";
|
|
13
14
|
import { ShutdownManager } from "../shutdown.js";
|
|
15
|
+
import type { LockFile } from "../locks/index.js";
|
|
14
16
|
import type { SequantSettings } from "../settings.js";
|
|
17
|
+
/**
|
|
18
|
+
* Build the stack-manifest line emitted into PR bodies under --stacked.
|
|
19
|
+
*
|
|
20
|
+
* Example for issues `[100, 101, 102]` at `currentIndex=1`:
|
|
21
|
+
* `Part of stack: #100 → #101 (this) → #102`
|
|
22
|
+
*
|
|
23
|
+
* @internal Exported for testing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildStackManifest(issueNumbers: number[], currentIndex: number): string;
|
|
15
26
|
/**
|
|
16
27
|
* Injectable services for RunOrchestrator.
|
|
17
28
|
* All optional — orchestrator degrades gracefully when services are absent.
|
|
@@ -64,6 +75,39 @@ export interface RunInit {
|
|
|
64
75
|
baseBranch?: string;
|
|
65
76
|
/** Per-phase progress callback */
|
|
66
77
|
onProgress?: ProgressCallback;
|
|
78
|
+
/**
|
|
79
|
+
* Invoked once the orchestrator is constructed but before execution begins.
|
|
80
|
+
* Used by the experimental TUI to attach a snapshot poller to the active
|
|
81
|
+
* orchestrator instance created inside `run()`.
|
|
82
|
+
*/
|
|
83
|
+
onOrchestratorReady?: (orchestrator: RunOrchestrator) => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Pure result of config resolution — no side effects, no services.
|
|
87
|
+
* Produced by `RunOrchestrator.resolveConfig()` and consumed by both
|
|
88
|
+
* `run()` (internally) and the CLI (for pre-run display).
|
|
89
|
+
*/
|
|
90
|
+
export interface ResolvedRun {
|
|
91
|
+
/** Post-merge run options (defaults < settings < env < explicit) */
|
|
92
|
+
mergedOptions: RunOptions;
|
|
93
|
+
/** Execution config derived from mergedOptions */
|
|
94
|
+
config: ExecutionConfig;
|
|
95
|
+
/** Parsed + dep-sorted issue numbers (pre-state-guard) */
|
|
96
|
+
issueNumbers: number[];
|
|
97
|
+
/** Resolved batches if --batch specified, else null */
|
|
98
|
+
batches: number[][] | null;
|
|
99
|
+
/** Resolved base branch (CLI → settings → auto-detect → "main") */
|
|
100
|
+
baseBranch: string;
|
|
101
|
+
/** Stack from manifest */
|
|
102
|
+
stack: string;
|
|
103
|
+
/** True when phases will be auto-detected from issue labels */
|
|
104
|
+
autoDetectPhases: boolean;
|
|
105
|
+
/** True when worktree isolation is enabled */
|
|
106
|
+
worktreeIsolationEnabled: boolean;
|
|
107
|
+
/** True when JSON logging will be initialized */
|
|
108
|
+
logEnabled: boolean;
|
|
109
|
+
/** True when state tracking will be enabled */
|
|
110
|
+
stateEnabled: boolean;
|
|
67
111
|
}
|
|
68
112
|
/**
|
|
69
113
|
* Structured result of a full orchestrator run.
|
|
@@ -100,7 +144,34 @@ export interface RunResult {
|
|
|
100
144
|
*/
|
|
101
145
|
export declare class RunOrchestrator {
|
|
102
146
|
private readonly cfg;
|
|
147
|
+
private readonly issueStates;
|
|
148
|
+
private readonly phaseStartTimes;
|
|
149
|
+
private done;
|
|
103
150
|
constructor(config: OrchestratorConfig);
|
|
151
|
+
/**
|
|
152
|
+
* Point-in-time view of the entire run.
|
|
153
|
+
*
|
|
154
|
+
* Safe under concurrent reads: the returned object contains only freshly
|
|
155
|
+
* allocated arrays and plain records; no internal Map or mutable state
|
|
156
|
+
* reference is leaked. Callers may hold snapshots across awaits without
|
|
157
|
+
* observing torn writes.
|
|
158
|
+
*/
|
|
159
|
+
getSnapshot(): RunSnapshot;
|
|
160
|
+
/** Mark the run as completed so the dashboard can unmount. */
|
|
161
|
+
markDone(): void;
|
|
162
|
+
private initIssueStates;
|
|
163
|
+
private wrapProgress;
|
|
164
|
+
private applyProgressEvent;
|
|
165
|
+
/**
|
|
166
|
+
* Pure config resolution — no side effects.
|
|
167
|
+
*
|
|
168
|
+
* Produces a `ResolvedRun` containing merged options, execution config,
|
|
169
|
+
* parsed/sorted issue numbers, base branch, and display-only flags. Safe
|
|
170
|
+
* to call for preview purposes (e.g. CLI config display before run).
|
|
171
|
+
*
|
|
172
|
+
* `run()` uses this internally to avoid duplicating resolution logic.
|
|
173
|
+
*/
|
|
174
|
+
static resolveConfig(init: RunInit, issueArgs: string[], batches?: number[][] | null): ResolvedRun;
|
|
104
175
|
/**
|
|
105
176
|
* Full lifecycle execution — the primary entry point for programmatic use.
|
|
106
177
|
*
|
|
@@ -120,5 +191,10 @@ export declare class RunOrchestrator {
|
|
|
120
191
|
private executeOneIssue;
|
|
121
192
|
private static recordMetrics;
|
|
122
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Build the synthetic `IssueResult` returned for an issue that was skipped
|
|
196
|
+
* because another sequant session holds its lock (#625).
|
|
197
|
+
*/
|
|
198
|
+
export declare function buildLockedResult(issueNumber: number, holder: LockFile): IssueResult;
|
|
123
199
|
/** Log a non-fatal warning: one-line summary always, detail in verbose. */
|
|
124
200
|
export declare function logNonFatalWarning(message: string, error: unknown, verbose: boolean): void;
|