@yagni-app/code-staging 0.0.0 → 0.1.0-staging.998.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.
- package/LICENSE.md +55 -0
- package/README.md +166 -0
- package/dist/branding.d.ts +25 -0
- package/dist/branding.js +27 -0
- package/dist/claudeCompat.d.ts +78 -0
- package/dist/claudeCompat.js +198 -0
- package/dist/cli.d.ts +55 -0
- package/dist/cli.js +326 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +28 -0
- package/dist/credentials.d.ts +41 -0
- package/dist/credentials.js +75 -0
- package/dist/distribution.d.ts +15 -0
- package/dist/distribution.js +45 -0
- package/dist/doctor.d.ts +94 -0
- package/dist/doctor.js +343 -0
- package/dist/extension/advisor.d.ts +84 -0
- package/dist/extension/advisor.js +101 -0
- package/dist/extension/askAdvisorTool.d.ts +83 -0
- package/dist/extension/askAdvisorTool.js +188 -0
- package/dist/extension/askYagniTool.d.ts +39 -0
- package/dist/extension/askYagniTool.js +63 -0
- package/dist/extension/bless.d.ts +45 -0
- package/dist/extension/bless.js +74 -0
- package/dist/extension/branding.d.ts +48 -0
- package/dist/extension/branding.js +119 -0
- package/dist/extension/chipEditor.d.ts +117 -0
- package/dist/extension/chipEditor.js +369 -0
- package/dist/extension/config.d.ts +112 -0
- package/dist/extension/config.js +108 -0
- package/dist/extension/costHud.d.ts +73 -0
- package/dist/extension/costHud.js +123 -0
- package/dist/extension/decisionCapture.d.ts +52 -0
- package/dist/extension/decisionCapture.js +66 -0
- package/dist/extension/decisions.d.ts +83 -0
- package/dist/extension/decisions.js +200 -0
- package/dist/extension/diagnostics.d.ts +41 -0
- package/dist/extension/diagnostics.js +110 -0
- package/dist/extension/index.d.ts +116 -0
- package/dist/extension/index.js +388 -0
- package/dist/extension/initDone.d.ts +28 -0
- package/dist/extension/initDone.js +66 -0
- package/dist/extension/initPass.d.ts +152 -0
- package/dist/extension/initPass.js +394 -0
- package/dist/extension/nextWorkTool.d.ts +51 -0
- package/dist/extension/nextWorkTool.js +80 -0
- package/dist/extension/permission.d.ts +91 -0
- package/dist/extension/permission.js +236 -0
- package/dist/extension/pipeline/activity.d.ts +37 -0
- package/dist/extension/pipeline/activity.js +151 -0
- package/dist/extension/pipeline/activityFeed.d.ts +59 -0
- package/dist/extension/pipeline/activityFeed.js +175 -0
- package/dist/extension/pipeline/budget.d.ts +48 -0
- package/dist/extension/pipeline/budget.js +68 -0
- package/dist/extension/pipeline/checkpoint.d.ts +31 -0
- package/dist/extension/pipeline/checkpoint.js +176 -0
- package/dist/extension/pipeline/eval.d.ts +168 -0
- package/dist/extension/pipeline/eval.js +182 -0
- package/dist/extension/pipeline/events.d.ts +56 -0
- package/dist/extension/pipeline/events.js +147 -0
- package/dist/extension/pipeline/findings.d.ts +42 -0
- package/dist/extension/pipeline/findings.js +144 -0
- package/dist/extension/pipeline/finish.d.ts +128 -0
- package/dist/extension/pipeline/finish.js +307 -0
- package/dist/extension/pipeline/goCommand.d.ts +128 -0
- package/dist/extension/pipeline/goCommand.js +972 -0
- package/dist/extension/pipeline/goCompareCommand.d.ts +48 -0
- package/dist/extension/pipeline/goCompareCommand.js +184 -0
- package/dist/extension/pipeline/goFlags.d.ts +40 -0
- package/dist/extension/pipeline/goFlags.js +46 -0
- package/dist/extension/pipeline/goStatusCommands.d.ts +59 -0
- package/dist/extension/pipeline/goStatusCommands.js +188 -0
- package/dist/extension/pipeline/invocation.d.ts +45 -0
- package/dist/extension/pipeline/invocation.js +64 -0
- package/dist/extension/pipeline/orchestrator.d.ts +131 -0
- package/dist/extension/pipeline/orchestrator.js +636 -0
- package/dist/extension/pipeline/personas.d.ts +44 -0
- package/dist/extension/pipeline/personas.js +248 -0
- package/dist/extension/pipeline/resilience.d.ts +85 -0
- package/dist/extension/pipeline/resilience.js +166 -0
- package/dist/extension/pipeline/resume.d.ts +18 -0
- package/dist/extension/pipeline/resume.js +106 -0
- package/dist/extension/pipeline/runRegistry.d.ts +112 -0
- package/dist/extension/pipeline/runRegistry.js +202 -0
- package/dist/extension/pipeline/runSession.d.ts +152 -0
- package/dist/extension/pipeline/runSession.js +167 -0
- package/dist/extension/pipeline/runState.d.ts +158 -0
- package/dist/extension/pipeline/runState.js +264 -0
- package/dist/extension/pipeline/runner.d.ts +79 -0
- package/dist/extension/pipeline/runner.js +298 -0
- package/dist/extension/pipeline/scrubSecrets.d.ts +15 -0
- package/dist/extension/pipeline/scrubSecrets.js +32 -0
- package/dist/extension/pipeline/stages.d.ts +51 -0
- package/dist/extension/pipeline/stages.js +113 -0
- package/dist/extension/pipeline/ticketResolution.d.ts +34 -0
- package/dist/extension/pipeline/ticketResolution.js +75 -0
- package/dist/extension/pipeline/types.d.ts +436 -0
- package/dist/extension/pipeline/types.js +48 -0
- package/dist/extension/pipeline/verify.d.ts +277 -0
- package/dist/extension/pipeline/verify.js +758 -0
- package/dist/extension/pipeline/workspace.d.ts +32 -0
- package/dist/extension/pipeline/workspace.js +73 -0
- package/dist/extension/pipeline/worktree.d.ts +107 -0
- package/dist/extension/pipeline/worktree.js +200 -0
- package/dist/extension/provider.d.ts +11 -0
- package/dist/extension/provider.js +26 -0
- package/dist/extension/recall.d.ts +93 -0
- package/dist/extension/recall.js +187 -0
- package/dist/extension/recordContextTool.d.ts +38 -0
- package/dist/extension/recordContextTool.js +85 -0
- package/dist/extension/recordDecisionTool.d.ts +52 -0
- package/dist/extension/recordDecisionTool.js +102 -0
- package/dist/extension/repoDocs.d.ts +81 -0
- package/dist/extension/repoDocs.js +260 -0
- package/dist/extension/resilientFetch.d.ts +60 -0
- package/dist/extension/resilientFetch.js +133 -0
- package/dist/extension/reviewTool.d.ts +34 -0
- package/dist/extension/reviewTool.js +81 -0
- package/dist/extension/spool.d.ts +92 -0
- package/dist/extension/spool.js +266 -0
- package/dist/extension/stateHome.d.ts +2 -0
- package/dist/extension/stateHome.js +6 -0
- package/dist/extension/subagents.d.ts +135 -0
- package/dist/extension/subagents.js +281 -0
- package/dist/extension/surface.d.ts +10 -0
- package/dist/extension/surface.js +12 -0
- package/dist/extension/todos.d.ts +110 -0
- package/dist/extension/todos.js +217 -0
- package/dist/extension/tokenProvider.d.ts +93 -0
- package/dist/extension/tokenProvider.js +234 -0
- package/dist/launch.d.ts +76 -0
- package/dist/launch.js +111 -0
- package/dist/login.d.ts +45 -0
- package/dist/login.js +142 -0
- package/dist/logout.d.ts +14 -0
- package/dist/logout.js +34 -0
- package/dist/paths.d.ts +31 -0
- package/dist/paths.js +87 -0
- package/dist/piPackage.d.ts +33 -0
- package/dist/piPackage.js +71 -0
- package/dist/profiles.d.ts +80 -0
- package/dist/profiles.js +222 -0
- package/dist/refresh.d.ts +70 -0
- package/dist/refresh.js +117 -0
- package/dist/upgrade.d.ts +97 -0
- package/dist/upgrade.js +284 -0
- package/package.json +39 -3
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the /go pipeline's data shapes + tuning constants.
|
|
3
|
+
*
|
|
4
|
+
* Pure types and constants only — no logic. Every other pipeline module imports
|
|
5
|
+
* from here so the orchestrator's correctness lives in typed data rather than in
|
|
6
|
+
* scattered string literals. The stage list is a declarative contract (spec
|
|
7
|
+
* §7.2) so future complexity-lanes select a subset, never a rewrite.
|
|
8
|
+
*/
|
|
9
|
+
import type { RunUsage } from "./budget.js";
|
|
10
|
+
/**
|
|
11
|
+
* Opaque per-stage model tier. These map to models server-side under the `yagni`
|
|
12
|
+
* provider — never a model id in the pipeline config. The pipeline uses `peak`
|
|
13
|
+
* for judgment (plan/review), `standard` for execution (map/implement/fix), and
|
|
14
|
+
* `efficient` for the format-recovery re-ask; `advanced` is not wired into a
|
|
15
|
+
* stage but is the Balanced session's driver tier, so it stays valid here.
|
|
16
|
+
*
|
|
17
|
+
* `balanced` is deliberately NOT a member: it is a session strategy the picker
|
|
18
|
+
* offers, not something a pipeline stage can request. A stage names the tier it
|
|
19
|
+
* actually runs on.
|
|
20
|
+
*/
|
|
21
|
+
export type ModelTier = "peak" | "advanced" | "standard" | "efficient";
|
|
22
|
+
/** The fixed v1 pipeline stages, in order. */
|
|
23
|
+
export type StageId = "map" | "plan" | "implement" | "review" | "fix";
|
|
24
|
+
/**
|
|
25
|
+
* The stage vocabulary of the live feed + progress signals: the LLM pipeline
|
|
26
|
+
* stages plus the deterministic post-loop FINISH stage (spec §3c — commit /
|
|
27
|
+
* push / PR). FINISH is deliberately NOT a {@link StageId}: it is never run
|
|
28
|
+
* through the stage runner or `selectStages` — the /go handler drives it
|
|
29
|
+
* directly after a `clean` stop — but the feed still paints it as a stage row.
|
|
30
|
+
*/
|
|
31
|
+
export type FeedStageId = StageId | "finish";
|
|
32
|
+
/** The three adversarial review angles (spec §3). */
|
|
33
|
+
export type ReviewLens = "correctness" | "business_fit" | "does_it_hold";
|
|
34
|
+
/** Finding severities; only `critical` + `high` block the review→fix loop. */
|
|
35
|
+
export type Severity = "critical" | "high" | "medium" | "low";
|
|
36
|
+
/**
|
|
37
|
+
* One declarative stage. `model` + `tools` are the tuning surface; `taskTemplate`
|
|
38
|
+
* carries `{ticket}` / `{previous}` placeholders the invocation builder fills.
|
|
39
|
+
*/
|
|
40
|
+
export interface PipelineStage {
|
|
41
|
+
id: StageId;
|
|
42
|
+
agent: string;
|
|
43
|
+
model: ModelTier;
|
|
44
|
+
tools: string[];
|
|
45
|
+
taskTemplate: string;
|
|
46
|
+
/** Only set when the stage is fanned out per review lens. */
|
|
47
|
+
lens?: ReviewLens;
|
|
48
|
+
}
|
|
49
|
+
/** A single structured review finding parsed from a reviewer's output. */
|
|
50
|
+
export interface Finding {
|
|
51
|
+
severity: Severity;
|
|
52
|
+
lens: ReviewLens;
|
|
53
|
+
message: string;
|
|
54
|
+
file?: string;
|
|
55
|
+
line?: number;
|
|
56
|
+
}
|
|
57
|
+
/** Token/cost accounting aggregated across a stage's assistant turns. */
|
|
58
|
+
export interface StageUsage {
|
|
59
|
+
input: number;
|
|
60
|
+
output: number;
|
|
61
|
+
cacheRead: number;
|
|
62
|
+
cacheWrite: number;
|
|
63
|
+
cost: number;
|
|
64
|
+
turns: number;
|
|
65
|
+
}
|
|
66
|
+
/** The outcome of running one grounded child stage. */
|
|
67
|
+
export interface StageResult {
|
|
68
|
+
stageId: StageId;
|
|
69
|
+
agent: string;
|
|
70
|
+
exitCode: number;
|
|
71
|
+
finalOutput: string;
|
|
72
|
+
usage: StageUsage;
|
|
73
|
+
stopReason?: string;
|
|
74
|
+
errorMessage?: string;
|
|
75
|
+
stderr: string;
|
|
76
|
+
/**
|
|
77
|
+
* Tool-call health for this stage (R3-a). `toolCalls` is how many tools the
|
|
78
|
+
* child actually executed (`tool_execution_end` events); `toolErrors` is how
|
|
79
|
+
* many of those returned an error. The orchestrator folds the ratio into the
|
|
80
|
+
* write-stage health check so an implement / fix stage that exits 0 with a
|
|
81
|
+
* clean-looking summary while most of its edits failed is caught rather than
|
|
82
|
+
* trusted. Both default to 0 (no tools observed), which is below
|
|
83
|
+
* MIN_TOOL_CALLS_FOR_HEALTH and so never trips the guard.
|
|
84
|
+
*/
|
|
85
|
+
toolCalls: number;
|
|
86
|
+
toolErrors: number;
|
|
87
|
+
/**
|
|
88
|
+
* How many stdout lines this stage discarded for exceeding the max line size
|
|
89
|
+
* (`RunStageDeps.maxLineBytes`). A pathologically long single NDJSON line (a
|
|
90
|
+
* runaway assistant turn or an enormous tool payload) is dropped rather than
|
|
91
|
+
* accumulated — the reader stays O(n) and bounded instead of OOM-crashing the
|
|
92
|
+
* whole pipeline. Absent/undefined when nothing was dropped (the normal case).
|
|
93
|
+
*/
|
|
94
|
+
overlongLinesDropped?: number;
|
|
95
|
+
}
|
|
96
|
+
/** One round of the bounded review→fix loop. */
|
|
97
|
+
export interface ReviewRound {
|
|
98
|
+
round: number;
|
|
99
|
+
lensResults: StageResult[];
|
|
100
|
+
findings: Finding[];
|
|
101
|
+
/**
|
|
102
|
+
* Review lenses that could not fully carry this round, surfaced in the /go
|
|
103
|
+
* handoff so a narrowed review is never silent. Two flavors (hence string,
|
|
104
|
+
* not ReviewLens — spec §3e): a bare lens name means its child FAILED and was
|
|
105
|
+
* skipped (R2 partial-failure tolerance; a failed REQUIRED lens fails the
|
|
106
|
+
* round instead); `<lens> (unparseable)` means the child was healthy but its
|
|
107
|
+
* non-empty output never yielded a findings block, even after the one §3e
|
|
108
|
+
* re-ask, so the round proceeded treating it as zero findings. Absent when
|
|
109
|
+
* every lens was healthy and parseable.
|
|
110
|
+
*/
|
|
111
|
+
degradedLenses?: string[];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Why the pipeline ended. `clean` / `round_cap` are the two healthy review
|
|
115
|
+
* outcomes; `aborted` (a user/signal cancel) and `failed` (a crashed review or
|
|
116
|
+
* fix child) are surfaced honestly rather than mis-reported as `clean` (spec
|
|
117
|
+
* §7.3 — no silent truncation). `no_changes` is the same honesty applied one
|
|
118
|
+
* stage earlier: the build half produced no diff, so there was nothing to
|
|
119
|
+
* review — reporting that as `clean` would be a false "reviewed and clean".
|
|
120
|
+
* `partial` is the same honesty applied to a WRITE stage (implement/fix) that
|
|
121
|
+
* fails AFTER it has begun editing (a timeout or transient blip the R1 wrapper
|
|
122
|
+
* cannot retry without risking a double-apply): the diff it produced is real and
|
|
123
|
+
* sits in the working tree, so the run is reported as a preserved partial rather
|
|
124
|
+
* than a bare `failed` that discards the work.
|
|
125
|
+
*/
|
|
126
|
+
export type StopReason = "clean" | "round_cap" | "aborted" | "failed" | "no_changes" | "budget_exceeded" | "partial";
|
|
127
|
+
/**
|
|
128
|
+
* A point-in-time signature of the repo working tree, used to detect whether the
|
|
129
|
+
* build half actually produced a change. `tracked` is false when the cwd is not
|
|
130
|
+
* a git work tree (or git is unavailable) — the no-op guard fails OPEN in that
|
|
131
|
+
* case (assumes a change) rather than mis-firing `no_changes`. `head` is the
|
|
132
|
+
* current commit (so a stage that COMMITS its work still counts as a change) and
|
|
133
|
+
* `status` is the porcelain working-tree state (so an uncommitted edit counts).
|
|
134
|
+
*/
|
|
135
|
+
export interface WorkspaceSnapshot {
|
|
136
|
+
tracked: boolean;
|
|
137
|
+
head: string;
|
|
138
|
+
status: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* What the FINISH stage (spec §3c) actually landed: the commit on the run
|
|
142
|
+
* branch (and the optional pushed PR). Present ONLY when a commit really
|
|
143
|
+
* happened — a FINISH that skipped or failed leaves this absent and carries an
|
|
144
|
+
* honest note instead (§0.1: never fake a commit that didn't happen).
|
|
145
|
+
*/
|
|
146
|
+
export interface FinishInfo {
|
|
147
|
+
branch?: string;
|
|
148
|
+
commitSha: string;
|
|
149
|
+
prUrl?: string;
|
|
150
|
+
prNumber?: number;
|
|
151
|
+
}
|
|
152
|
+
/** The full pipeline outcome handed back to the /go command. */
|
|
153
|
+
export interface PipelineResult {
|
|
154
|
+
stages: StageResult[];
|
|
155
|
+
rounds: ReviewRound[];
|
|
156
|
+
stopReason: StopReason;
|
|
157
|
+
findings: Finding[];
|
|
158
|
+
/**
|
|
159
|
+
* P4 honest note when the deterministic verify gate did NOT produce a verdict
|
|
160
|
+
* (no command detected, unrunnable, or timed out, so the loop fell open to the
|
|
161
|
+
* LLM-only review). Absent when verify ran and gave a clean/blocking verdict, so
|
|
162
|
+
* a /go that silently skipped the build check is never reported as fully gated.
|
|
163
|
+
*/
|
|
164
|
+
verifyNote?: string;
|
|
165
|
+
/**
|
|
166
|
+
* The FINAL round's verify command label(s) when the gate actually RAN (e.g.
|
|
167
|
+
* "typecheck" or "typecheck, lint"). Feeds the commit trailer's
|
|
168
|
+
* `YAGNI-Verify: passed (<cmds>)` honestly; absent whenever the final verify
|
|
169
|
+
* was skipped (see {@link PipelineResult.verifyNote}).
|
|
170
|
+
*/
|
|
171
|
+
verifyCommand?: string;
|
|
172
|
+
/**
|
|
173
|
+
* How many `record_decision` tool calls completed WITHOUT error during this
|
|
174
|
+
* run, counted off the NDJSON `tool_execution_end` tap (spec §3c). COUNT only:
|
|
175
|
+
* decision ids are not observable without widening {@link JsonEvent}. Feeds
|
|
176
|
+
* the commit trailer's `YAGNI-Decisions` line.
|
|
177
|
+
*/
|
|
178
|
+
decisionsRecorded?: number;
|
|
179
|
+
/**
|
|
180
|
+
* FINISH-stage outcome, attached by the /go handler after a `clean` stop (the
|
|
181
|
+
* orchestrator never sets it — commit/push live outside the LLM pipeline).
|
|
182
|
+
*/
|
|
183
|
+
finish?: FinishInfo;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The append-only resilience journal (spec: 2026-06-29-yagni-code-go-resilience).
|
|
187
|
+
* One record per completed pipeline boundary, written through the fail-soft
|
|
188
|
+
* {@link CheckpointStore} seam so a /go interrupted mid-run can be resumed (or
|
|
189
|
+
* honestly reported) by a LATER session instead of rediscovering everything.
|
|
190
|
+
*
|
|
191
|
+
* - `run_start` : opened the run; `snapshot` = the pre-build baseline.
|
|
192
|
+
* - `build_done` : map→plan→implement all finished; `snapshot` = post-build tree,
|
|
193
|
+
* `reviewInput` = implement output (the round-1 review handoff).
|
|
194
|
+
* - `round_done` : a full review→fix round completed AND the loop will continue;
|
|
195
|
+
* `round` = that round, `reviewInput` = fix output (next round's
|
|
196
|
+
* handoff), `findings` = that round's union, `snapshot` = post-fix.
|
|
197
|
+
* - `finish_done`: the FINISH stage (spec §3c) completed after a clean stop;
|
|
198
|
+
* carries `commitSha`/`prUrl` when a commit/PR actually landed.
|
|
199
|
+
* Purely informational for later sessions — planResume ignores it.
|
|
200
|
+
* - `run_finish` : the run reached a terminal stopReason — makes the key NOT
|
|
201
|
+
* resumable (a completed run, even `round_cap`, is not "interrupted").
|
|
202
|
+
*/
|
|
203
|
+
export type CheckpointKind = "run_start" | "build_done" | "round_done" | "finish_done" | "run_finish";
|
|
204
|
+
/** One append-only journal record. Latest-applicable record wins on resume. */
|
|
205
|
+
export interface CheckpointRecord {
|
|
206
|
+
v: 1;
|
|
207
|
+
kind: CheckpointKind;
|
|
208
|
+
/** Identifies a resumable run: sanitized ticket + cwd + repo + branch. */
|
|
209
|
+
sessionKey: string;
|
|
210
|
+
ts: number;
|
|
211
|
+
ticket: string;
|
|
212
|
+
/** Backend run handle, present once the run was tracked (for session.bind on resume). */
|
|
213
|
+
runId?: string;
|
|
214
|
+
workItemId?: string;
|
|
215
|
+
repo?: string;
|
|
216
|
+
branch?: string;
|
|
217
|
+
/**
|
|
218
|
+
* The git working-tree signature at this boundary (the resume consistency key).
|
|
219
|
+
* Always set on run_start/build_done/round_done; omitted on run_finish (which is
|
|
220
|
+
* a terminal marker — planResume reads it before ever inspecting a snapshot).
|
|
221
|
+
*/
|
|
222
|
+
snapshot?: WorkspaceSnapshot;
|
|
223
|
+
/** build_done: implement output. round_done: fix output. (The next review handoff.) */
|
|
224
|
+
reviewInput?: string;
|
|
225
|
+
/** round_done: the round that just fully completed (review + fix). */
|
|
226
|
+
round?: number;
|
|
227
|
+
/** round_done: the findings union for that round (for an honest final count). */
|
|
228
|
+
findings?: Finding[];
|
|
229
|
+
/** run_finish: the terminal stop reason. */
|
|
230
|
+
stopReason?: StopReason;
|
|
231
|
+
/** finish_done: the FINISH commit that landed (absent when the commit was skipped). */
|
|
232
|
+
commitSha?: string;
|
|
233
|
+
/** finish_done: the PR opened by --pr (absent when none was). */
|
|
234
|
+
prUrl?: string;
|
|
235
|
+
/** Cumulative run usage through this completed boundary. */
|
|
236
|
+
usage?: RunUsage;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* The injectable, fail-soft journal seam (mirrors the optional `onStage` seam).
|
|
240
|
+
* Every method swallows its own errors — a checkpoint failure must NEVER break
|
|
241
|
+
* /go. `load` returns `[]` on any error (absent/corrupt file → fresh run).
|
|
242
|
+
*/
|
|
243
|
+
export interface CheckpointStore {
|
|
244
|
+
/** Append one record. Never throws. */
|
|
245
|
+
record(rec: CheckpointRecord): void;
|
|
246
|
+
/** All records for this run's key, in write order. Never throws (→ []). */
|
|
247
|
+
load(): CheckpointRecord[];
|
|
248
|
+
/** Best-effort close/delete for this key (called on every terminal outcome). */
|
|
249
|
+
clear(): void;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* The PURE resume decision (the analogue of {@link shouldStop}). Folds the
|
|
253
|
+
* journal + a live workspace snapshot into one verdict:
|
|
254
|
+
* - `fresh` : nothing to resume (no journal, completed run, or unknowable tree).
|
|
255
|
+
* - `resume_loop` : the build half completed and the live tree still matches the
|
|
256
|
+
* checkpoint — re-enter the review→fix loop at `round`.
|
|
257
|
+
* - `warn_partial` : the run was interrupted mid-build, or the tree diverged —
|
|
258
|
+
* auto-replay would risk double-applying edits, so warn + run fresh.
|
|
259
|
+
*/
|
|
260
|
+
export type ResumePlan = {
|
|
261
|
+
mode: "fresh";
|
|
262
|
+
} | {
|
|
263
|
+
mode: "warn_partial";
|
|
264
|
+
reason: "build_interrupted" | "tree_diverged";
|
|
265
|
+
ticket: string;
|
|
266
|
+
} | {
|
|
267
|
+
mode: "resume_loop";
|
|
268
|
+
/** The round to (re)enter the while-loop at (continues counting toward the cap). */
|
|
269
|
+
round: number;
|
|
270
|
+
/** The diff handoff text for that round (post-cap, byte-identical to the live run). */
|
|
271
|
+
reviewInput: string;
|
|
272
|
+
/** Prior rounds reconstructed from the journal (round# + findings) for an honest result. */
|
|
273
|
+
priorRounds: ReviewRound[];
|
|
274
|
+
/** Cumulative usage reconstructed from the last completed checkpoint. */
|
|
275
|
+
priorUsage?: RunUsage;
|
|
276
|
+
runId?: string;
|
|
277
|
+
workItemId?: string;
|
|
278
|
+
ticket: string;
|
|
279
|
+
};
|
|
280
|
+
/** Usage block as it appears on a pi `message_end` assistant message. */
|
|
281
|
+
export interface JsonEventUsage {
|
|
282
|
+
input?: number;
|
|
283
|
+
output?: number;
|
|
284
|
+
cacheRead?: number;
|
|
285
|
+
cacheWrite?: number;
|
|
286
|
+
cost?: {
|
|
287
|
+
total?: number;
|
|
288
|
+
};
|
|
289
|
+
totalTokens?: number;
|
|
290
|
+
}
|
|
291
|
+
/** A content part of a pi message (text or tool call). */
|
|
292
|
+
export interface JsonEventMessagePart {
|
|
293
|
+
type: string;
|
|
294
|
+
text?: string;
|
|
295
|
+
name?: string;
|
|
296
|
+
arguments?: Record<string, unknown>;
|
|
297
|
+
}
|
|
298
|
+
/** A pi message carried on a `message_end` event. */
|
|
299
|
+
export interface JsonEventMessage {
|
|
300
|
+
role: string;
|
|
301
|
+
content: JsonEventMessagePart[];
|
|
302
|
+
usage?: JsonEventUsage;
|
|
303
|
+
model?: string;
|
|
304
|
+
stopReason?: string;
|
|
305
|
+
errorMessage?: string;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Minimal structural shape of an event off the `--mode json` NDJSON stream.
|
|
309
|
+
* Covers `message_end` (assistant text + usage), `tool_execution_end` (the real
|
|
310
|
+
* tool-result event; the example's `tool_result_end` is dead/never-emitted),
|
|
311
|
+
* `agent_end`, and the leading session header line. The runner only line-buffers
|
|
312
|
+
* + `JSON.parse`s; the events reducers narrow on `type`.
|
|
313
|
+
*/
|
|
314
|
+
export interface JsonEvent {
|
|
315
|
+
type: string;
|
|
316
|
+
message?: JsonEventMessage;
|
|
317
|
+
toolName?: string;
|
|
318
|
+
isError?: boolean;
|
|
319
|
+
/** Correlates a `tool_execution_start` with its `tool_execution_end`. */
|
|
320
|
+
toolCallId?: string;
|
|
321
|
+
/** Tool arguments carried on a `tool_execution_start` (label-only; never executed). */
|
|
322
|
+
args?: Record<string, unknown>;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* One line surfaced into the live `/go` activity feed (spec §2). Produced PURELY
|
|
326
|
+
* by `activity.ts#eventToLine` from a single NDJSON event; the stateful
|
|
327
|
+
* `ActivityFeed` then folds these into the rendered panel.
|
|
328
|
+
*/
|
|
329
|
+
export interface ActivityLine {
|
|
330
|
+
kind: "narration" | "action";
|
|
331
|
+
/** For actions: stable id to resolve a running start against its done/error end. */
|
|
332
|
+
toolCallId?: string;
|
|
333
|
+
/** Display text, already trimmed/labelled (empty for a resolving end event). */
|
|
334
|
+
text: string;
|
|
335
|
+
/** Action lifecycle; narration is always "done". */
|
|
336
|
+
state: "running" | "done" | "error";
|
|
337
|
+
}
|
|
338
|
+
/** Which stage (and review lens / round) a tapped event belongs to (spec §5). */
|
|
339
|
+
export interface StageTag {
|
|
340
|
+
stageId: StageId;
|
|
341
|
+
lens?: ReviewLens;
|
|
342
|
+
round?: number;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Structured progress signal (replaces the bare `onProgress(string)`); the feed
|
|
346
|
+
* folds these into stage glyph transitions, the round/findings header, and the
|
|
347
|
+
* final outcome (spec §2 + §5). Stage transitions speak {@link FeedStageId} so
|
|
348
|
+
* the /go handler can drive the post-loop FINISH row through the same channel
|
|
349
|
+
* (the orchestrator itself only ever emits real {@link StageId}s).
|
|
350
|
+
*/
|
|
351
|
+
export type PipelineProgress = {
|
|
352
|
+
kind: "stage_start";
|
|
353
|
+
stageId: FeedStageId;
|
|
354
|
+
lens?: ReviewLens;
|
|
355
|
+
round?: number;
|
|
356
|
+
} | {
|
|
357
|
+
kind: "stage_done";
|
|
358
|
+
stageId: FeedStageId;
|
|
359
|
+
lens?: ReviewLens;
|
|
360
|
+
round?: number;
|
|
361
|
+
/**
|
|
362
|
+
* Per-lens finding counts. Attached only on the SECOND `stage_done` a lens
|
|
363
|
+
* receives: the first fires when its child process returns, the second when
|
|
364
|
+
* the round's parse loop resolves its output. A count is never reported
|
|
365
|
+
* before it exists.
|
|
366
|
+
*/
|
|
367
|
+
findings?: number;
|
|
368
|
+
blocking?: number;
|
|
369
|
+
/**
|
|
370
|
+
* Why this lens could not fully carry the round (spec §3e): `failed` = the
|
|
371
|
+
* child failed and was skipped; `unparseable` = healthy but its output never
|
|
372
|
+
* yielded a findings block, even after the one re-ask.
|
|
373
|
+
*/
|
|
374
|
+
degraded?: "failed" | "unparseable";
|
|
375
|
+
} | {
|
|
376
|
+
kind: "findings";
|
|
377
|
+
round: number;
|
|
378
|
+
total: number;
|
|
379
|
+
blocking: number;
|
|
380
|
+
} | {
|
|
381
|
+
kind: "done";
|
|
382
|
+
stopReason: StopReason;
|
|
383
|
+
};
|
|
384
|
+
/** Stop the review→fix loop after at most this many rounds (spec §7.3). */
|
|
385
|
+
export declare const MAX_REVIEW_ROUNDS = 3;
|
|
386
|
+
/**
|
|
387
|
+
* R1 in-loop resilience policy: the tuning surface for {@link withResilience},
|
|
388
|
+
* the HOF that wraps every per-stage child spawn with idle + wall-clock timeouts
|
|
389
|
+
* and bounded, transient-only retry. Pure data so a lane (or a dev composing the
|
|
390
|
+
* `runStage` seam) can swap the policy without touching the wrapper logic.
|
|
391
|
+
*/
|
|
392
|
+
export interface ResiliencePolicy {
|
|
393
|
+
/** Abort a stage that emits no NDJSON event for this many ms (a stalled child). */
|
|
394
|
+
idleTimeoutMs: number;
|
|
395
|
+
/** Abort a stage whose total wall-clock run exceeds this many ms. */
|
|
396
|
+
wallTimeoutMs: number;
|
|
397
|
+
/** Total attempts INCLUDING the first (so 1 = no retry). */
|
|
398
|
+
maxAttempts: number;
|
|
399
|
+
/** Exponential backoff base: delay = backoffBaseMs * 2^(attempt-1), capped. */
|
|
400
|
+
backoffBaseMs: number;
|
|
401
|
+
/** Upper bound on a single backoff delay before jitter. */
|
|
402
|
+
backoffMaxMs: number;
|
|
403
|
+
/** Jitter as a fraction of the computed delay, applied as +/- (0 = none). */
|
|
404
|
+
jitterRatio: number;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Default resilience policy. Generous timeouts so a legitimately long but live
|
|
408
|
+
* stage is never killed (the idle window sits well under the 5-min run heartbeat,
|
|
409
|
+
* and the wall window bounds a truly wedged child); three attempts with short,
|
|
410
|
+
* jittered backoff so a single transient blip across the up-to-8 child spawns no
|
|
411
|
+
* longer terminates the whole run.
|
|
412
|
+
*/
|
|
413
|
+
export declare const DEFAULT_RESILIENCE_POLICY: ResiliencePolicy;
|
|
414
|
+
/**
|
|
415
|
+
* R3-a tool-failure health gate. A WRITE stage (implement / fix) that exits 0 is
|
|
416
|
+
* still a failure when most of its tool calls errored: the prose summary reads
|
|
417
|
+
* fine while the edits never landed (the recorded silent-partial-implement
|
|
418
|
+
* landmine). Conservative by design — BOTH guards must hold before a stage is
|
|
419
|
+
* failed for tool errors, so a couple of expected misses never trip it:
|
|
420
|
+
* - `TOOL_ERROR_FAIL_RATE`: the error rate must EXCEED this clear majority, so a
|
|
421
|
+
* grep that finds nothing or one transient error among many calls is fine.
|
|
422
|
+
* - `MIN_TOOL_CALLS_FOR_HEALTH`: require a meaningful sample first, so a stage
|
|
423
|
+
* that made only one or two tool calls is never failed on a tiny ratio.
|
|
424
|
+
* Tunable per lane if a future stage needs a stricter or looser bar.
|
|
425
|
+
*/
|
|
426
|
+
export declare const TOOL_ERROR_FAIL_RATE = 0.6;
|
|
427
|
+
export declare const MIN_TOOL_CALLS_FOR_HEALTH = 4;
|
|
428
|
+
/** Bound on parallel review-lens children per round (mirrors the subagent example). */
|
|
429
|
+
export declare const MAX_CONCURRENCY = 4;
|
|
430
|
+
/** Per-stage final-output byte cap when handed forward as `{previous}`. */
|
|
431
|
+
export declare const PER_TASK_OUTPUT_CAP: number;
|
|
432
|
+
/** Max length of a narration headline surfaced into the feed (spec §3). */
|
|
433
|
+
export declare const NARRATION_MAX = 80;
|
|
434
|
+
/** Bound on the active stage's rolling action ring buffer (spec §4). */
|
|
435
|
+
export declare const FEED_WINDOW = 8;
|
|
436
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single source of truth for the /go pipeline's data shapes + tuning constants.
|
|
3
|
+
*
|
|
4
|
+
* Pure types and constants only — no logic. Every other pipeline module imports
|
|
5
|
+
* from here so the orchestrator's correctness lives in typed data rather than in
|
|
6
|
+
* scattered string literals. The stage list is a declarative contract (spec
|
|
7
|
+
* §7.2) so future complexity-lanes select a subset, never a rewrite.
|
|
8
|
+
*/
|
|
9
|
+
/** Stop the review→fix loop after at most this many rounds (spec §7.3). */
|
|
10
|
+
export const MAX_REVIEW_ROUNDS = 3;
|
|
11
|
+
/**
|
|
12
|
+
* Default resilience policy. Generous timeouts so a legitimately long but live
|
|
13
|
+
* stage is never killed (the idle window sits well under the 5-min run heartbeat,
|
|
14
|
+
* and the wall window bounds a truly wedged child); three attempts with short,
|
|
15
|
+
* jittered backoff so a single transient blip across the up-to-8 child spawns no
|
|
16
|
+
* longer terminates the whole run.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_RESILIENCE_POLICY = {
|
|
19
|
+
idleTimeoutMs: 4 * 60_000,
|
|
20
|
+
wallTimeoutMs: 20 * 60_000,
|
|
21
|
+
maxAttempts: 3,
|
|
22
|
+
backoffBaseMs: 1_000,
|
|
23
|
+
backoffMaxMs: 30_000,
|
|
24
|
+
jitterRatio: 0.25,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* R3-a tool-failure health gate. A WRITE stage (implement / fix) that exits 0 is
|
|
28
|
+
* still a failure when most of its tool calls errored: the prose summary reads
|
|
29
|
+
* fine while the edits never landed (the recorded silent-partial-implement
|
|
30
|
+
* landmine). Conservative by design — BOTH guards must hold before a stage is
|
|
31
|
+
* failed for tool errors, so a couple of expected misses never trip it:
|
|
32
|
+
* - `TOOL_ERROR_FAIL_RATE`: the error rate must EXCEED this clear majority, so a
|
|
33
|
+
* grep that finds nothing or one transient error among many calls is fine.
|
|
34
|
+
* - `MIN_TOOL_CALLS_FOR_HEALTH`: require a meaningful sample first, so a stage
|
|
35
|
+
* that made only one or two tool calls is never failed on a tiny ratio.
|
|
36
|
+
* Tunable per lane if a future stage needs a stricter or looser bar.
|
|
37
|
+
*/
|
|
38
|
+
export const TOOL_ERROR_FAIL_RATE = 0.6;
|
|
39
|
+
export const MIN_TOOL_CALLS_FOR_HEALTH = 4;
|
|
40
|
+
/** Bound on parallel review-lens children per round (mirrors the subagent example). */
|
|
41
|
+
export const MAX_CONCURRENCY = 4;
|
|
42
|
+
/** Per-stage final-output byte cap when handed forward as `{previous}`. */
|
|
43
|
+
export const PER_TASK_OUTPUT_CAP = 50 * 1024;
|
|
44
|
+
/** Max length of a narration headline surfaced into the feed (spec §3). */
|
|
45
|
+
export const NARRATION_MAX = 80;
|
|
46
|
+
/** Bound on the active stage's rolling action ring buffer (spec §4). */
|
|
47
|
+
export const FEED_WINDOW = 8;
|
|
48
|
+
//# sourceMappingURL=types.js.map
|