@yagni-app/code-staging 1.2.14-staging.2213.1 → 1.2.14-staging.2244.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.
@@ -16,6 +16,7 @@
16
16
  * lives (`packages/shared/src/attempts.ts`): the two meet only at this JSON.
17
17
  */
18
18
  import type { ContinuationStage } from "./continuation.js";
19
+ import { type PlanChange } from "./planChanges.js";
19
20
  import { type VerifyCheckRun, type VerifyOutcome } from "./verify.js";
20
21
  import type { WorktreeExec } from "./worktree.js";
21
22
  import type { Finding, PipelineLane, PipelineResult, StopReason } from "./types.js";
@@ -114,6 +115,12 @@ export interface AttemptResult extends CloudIdentity {
114
115
  costMillicents: number;
115
116
  }>;
116
117
  };
118
+ /**
119
+ * The steps the build did differently than `plan.md` says, or left out
120
+ * (`planChanges.ts`, spec 2026-11-02 §4); absent when there are none. The
121
+ * host writes each into the plan as Wright's decision.
122
+ */
123
+ planChanges?: PlanChange[];
117
124
  }
118
125
  /** The findings the result reports, blocking first. */
119
126
  export declare function openFindings(findings: readonly Finding[]): OpenFinding[];
@@ -204,6 +211,12 @@ export interface CloudCompletion {
204
211
  exec: WorktreeExec;
205
212
  writeFile: (path: string, text: string) => void;
206
213
  }
214
+ /**
215
+ * The changes to the plan the session's implement stage reported: the last
216
+ * implement summary that carries a plan-changes block. None when no implement
217
+ * stage ran, or none reported a change.
218
+ */
219
+ export declare function implementPlanChanges(stages: readonly Pick<PipelineResult["stages"][number], "stageId" | "finalOutput">[]): PlanChange[];
207
220
  /**
208
221
  * The cloud session's last act. A plan execution writes `plan.md` and
209
222
  * `plan.json`. Any other runs the secret and binary scan on what it added,
@@ -19,6 +19,7 @@ import { createHash } from "node:crypto";
19
19
  import { join } from "node:path";
20
20
  import { isBlockingFinding } from "./findings.js";
21
21
  import { planTitle, runFinish, verifyTrailerValue } from "./finish.js";
22
+ import { extractPlanChanges, planChangeNote } from "./planChanges.js";
22
23
  import { buildPlanFile, planMarkdown } from "./planOutput.js";
23
24
  import { cloudLane } from "./stages.js";
24
25
  import { applyStageTiers, parseStageTiers, STAGE_TIERS_ENV } from "./tierCap.js";
@@ -290,6 +291,22 @@ export function cannotRunNote(checks) {
290
291
  function findingKey(finding) {
291
292
  return `${finding.file ?? ""}:${finding.line ?? ""}:${finding.message}`;
292
293
  }
294
+ /**
295
+ * The changes to the plan the session's implement stage reported: the last
296
+ * implement summary that carries a plan-changes block. None when no implement
297
+ * stage ran, or none reported a change.
298
+ */
299
+ export function implementPlanChanges(stages) {
300
+ let found = [];
301
+ for (const stage of stages) {
302
+ if (stage.stageId !== "implement")
303
+ continue;
304
+ const changes = extractPlanChanges(stage.finalOutput ?? "");
305
+ if (changes.length > 0)
306
+ found = changes;
307
+ }
308
+ return found;
309
+ }
293
310
  /**
294
311
  * The cloud session's last act. A plan execution writes `plan.md` and
295
312
  * `plan.json`. Any other runs the secret and binary scan on what it added,
@@ -316,6 +333,11 @@ export async function completeCloudSession(c, ran) {
316
333
  }
317
334
  };
318
335
  const result = "result" in ran ? ran.result : undefined;
336
+ // What the implement stage did differently than the plan says, from the
337
+ // plan-changes block its summary ends with (`cloudLane`, spec 2026-11-02 §4).
338
+ const planChanges = c.stage === "plan"
339
+ ? []
340
+ : implementPlanChanges(result?.stages ?? ("partial" in ran ? ran.partial : []));
319
341
  let stop = result?.stopReason ?? "failed";
320
342
  if (stop === "partial")
321
343
  notes.push("A build stage stopped partway; its change is committed as it was left.");
@@ -398,6 +420,7 @@ export async function completeCloudSession(c, ran) {
398
420
  }
399
421
  const facts = await gitFacts(c.cwd, c.exec, c.baseSha);
400
422
  notes.push(...facts.notes);
423
+ notes.push(...planChanges.map(planChangeNote));
401
424
  let delivered = outputsWritten;
402
425
  if (c.stage !== "plan") {
403
426
  // A commit past the base is this execution's work, whoever wrote it.
@@ -435,6 +458,7 @@ export async function completeCloudSession(c, ran) {
435
458
  notes,
436
459
  blockingKey: blockingFindingsKey(findings),
437
460
  usage: resultUsage(result ?? { stages: "partial" in ran ? ran.partial : [], rounds: [] }),
461
+ ...(planChanges.length > 0 ? { planChanges } : {}),
438
462
  };
439
463
  const resultWritten = writeOut(RESULT_FILE_NAME, `${JSON.stringify(attempt, null, 2)}\n`);
440
464
  return { attempt, ok: resultWritten && attempt.stopReason === "clean" && delivered };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The steps a build session did differently than `plan.md` says, or left out
3
+ * (spec 2026-11-02 "The plan a person approves is the only contract", §4),
4
+ * as `result.json` carries them in `planChanges`. The host writes each into
5
+ * the plan as Wright's decision, in a version of the build's own, which
6
+ * Proctor checks. Without one, Proctor reads a step done another way as a
7
+ * step skipped.
8
+ *
9
+ * The session lane's model reports them in `session-report.json`; the
10
+ * one-attempt lane's implement stage ends its summary with a fenced
11
+ * `plan-changes` block. Both read through {@link parsePlanChanges}, the rule
12
+ * the host reads `result.json` with. This package does not depend on
13
+ * `@yagni/shared`, so the region between the markers below is a byte-for-byte
14
+ * copy of the same region of `packages/shared/src/attempts.ts`;
15
+ * `test/pipeline/planChanges.test.ts` fails when the two differ. Change the
16
+ * shared file and copy the region here.
17
+ */
18
+ /** One step done differently, or left out, in the session's own words. */
19
+ export interface AttemptPlanChange {
20
+ /** The step's number in `plan.md`, from 1; null for a change to the plan as a whole. */
21
+ step: number | null;
22
+ instead: string;
23
+ why: string;
24
+ }
25
+ /** The most plan changes a report carries, and the longest each one's words. */
26
+ export declare const MAX_PLAN_CHANGES = 20;
27
+ export declare const MAX_PLAN_CHANGE_CHARS = 600;
28
+ /** The report's plan changes: each with what was done instead, the rest dropped. */
29
+ export declare function parsePlanChanges(value: unknown): AttemptPlanChange[];
30
+ /** The extension's name for one change, as `cloud.ts` and the session lane use it. */
31
+ export type PlanChange = AttemptPlanChange;
32
+ /** What a build is told about reporting a change to the plan, in either lane. */
33
+ export declare const PLAN_CHANGES_RULE: string;
34
+ /**
35
+ * The changes an implement stage's summary ends with, in its ```plan-changes
36
+ * block: the last block that parses, or none. A summary with no block
37
+ * changed nothing in the plan.
38
+ */
39
+ export declare function extractPlanChanges(text: string): PlanChange[];
40
+ /** The line a change adds to the result's notes, which the stream shows. */
41
+ export declare function planChangeNote(change: PlanChange): string;
42
+ //# sourceMappingURL=planChanges.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * The steps a build session did differently than `plan.md` says, or left out
3
+ * (spec 2026-11-02 "The plan a person approves is the only contract", §4),
4
+ * as `result.json` carries them in `planChanges`. The host writes each into
5
+ * the plan as Wright's decision, in a version of the build's own, which
6
+ * Proctor checks. Without one, Proctor reads a step done another way as a
7
+ * step skipped.
8
+ *
9
+ * The session lane's model reports them in `session-report.json`; the
10
+ * one-attempt lane's implement stage ends its summary with a fenced
11
+ * `plan-changes` block. Both read through {@link parsePlanChanges}, the rule
12
+ * the host reads `result.json` with. This package does not depend on
13
+ * `@yagni/shared`, so the region between the markers below is a byte-for-byte
14
+ * copy of the same region of `packages/shared/src/attempts.ts`;
15
+ * `test/pipeline/planChanges.test.ts` fails when the two differ. Change the
16
+ * shared file and copy the region here.
17
+ */
18
+ /** The most plan changes a report carries, and the longest each one's words. */
19
+ export const MAX_PLAN_CHANGES = 20;
20
+ export const MAX_PLAN_CHANGE_CHARS = 600;
21
+ /** A change's words on one line, clipped; null for none. */
22
+ function planChangeWords(value) {
23
+ if (typeof value !== "string")
24
+ return null;
25
+ const words = value.replace(/\s+/g, " ").trim();
26
+ return words ? words.slice(0, MAX_PLAN_CHANGE_CHARS) : null;
27
+ }
28
+ /** The report's plan changes: each with what was done instead, the rest dropped. */
29
+ export function parsePlanChanges(value) {
30
+ if (!Array.isArray(value))
31
+ return [];
32
+ const changes = [];
33
+ for (const entry of value) {
34
+ if (changes.length >= MAX_PLAN_CHANGES)
35
+ break;
36
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
37
+ continue;
38
+ const raw = entry;
39
+ const instead = planChangeWords(raw.instead);
40
+ const step = raw.step;
41
+ const numbered = typeof step === "number" && Number.isInteger(step) && step > 0;
42
+ if (!instead || !(numbered || step === null || step === undefined))
43
+ continue;
44
+ changes.push({ step: numbered ? step : null, instead, why: planChangeWords(raw.why) ?? "" });
45
+ }
46
+ return changes;
47
+ }
48
+ /** What a build is told about reporting a change to the plan, in either lane. */
49
+ export const PLAN_CHANGES_RULE = "The steps are guidance. When you do a step differently than plan.md says, or leave one out, " +
50
+ "add it to planChanges in your report: the step's number, what you did instead, and why. " +
51
+ "Leave out choices the plan left to you.";
52
+ const PLAN_CHANGES_BLOCK = /```plan-changes[^\n]*\n([\s\S]*?)```/gi;
53
+ /**
54
+ * The changes an implement stage's summary ends with, in its ```plan-changes
55
+ * block: the last block that parses, or none. A summary with no block
56
+ * changed nothing in the plan.
57
+ */
58
+ export function extractPlanChanges(text) {
59
+ let found = [];
60
+ for (const match of text.matchAll(PLAN_CHANGES_BLOCK)) {
61
+ try {
62
+ found = parsePlanChanges(JSON.parse(match[1] ?? ""));
63
+ }
64
+ catch {
65
+ // A block that does not parse is skipped; an earlier or later one may.
66
+ }
67
+ }
68
+ return found;
69
+ }
70
+ /** The line a change adds to the result's notes, which the stream shows. */
71
+ export function planChangeNote(change) {
72
+ const where = change.step ? `step ${change.step}` : "the plan";
73
+ return `Changed ${where}: ${change.instead}${change.why ? `, because ${change.why}` : ""}`;
74
+ }
75
+ //# sourceMappingURL=planChanges.js.map
@@ -29,7 +29,8 @@
29
29
  * process then runs what the cloud lane's finish runs (the secret and
30
30
  * binary scan, a commit of anything left, the git facts) and writes
31
31
  * `result.json` with the model's checks, what it could not verify and
32
- * where it departed from the plan folded in.
32
+ * where it departed from the plan folded in, each departure in
33
+ * `planChanges` for the host to write into the plan (`planChanges.ts`).
33
34
  *
34
35
  * Kept from the cloud lane: the run's clock (`YAGNI_PIPELINE_TIME_LEFT_MS`,
35
36
  * the turn's tools refused once it is nearly spent), the tool-failure health
@@ -39,6 +40,7 @@
39
40
  */
40
41
  import { type AttemptResult, type CloudIdentity, type CloudStage } from "./cloud.js";
41
42
  import type { ContinuationInputs } from "./continuation.js";
43
+ import { type PlanChange } from "./planChanges.js";
42
44
  import { type RunStageDeps } from "./runner.js";
43
45
  import { type ModelTier, type PipelineStage, type StageResult, type StopReason } from "./types.js";
44
46
  import { type VerifyCheckRun } from "./verify.js";
@@ -65,13 +67,6 @@ export declare function sessionPaths(home: string, attemptId: string): {
65
67
  sessionFile: string;
66
68
  skillFile: string;
67
69
  };
68
- /** One plan answer as `plan-answers.json` carries it. */
69
- interface PlanAnswer {
70
- answer: string;
71
- question?: string;
72
- }
73
- /** The answers in `plan-answers.json`, or none when it is missing or does not read. */
74
- export declare function readPlanAnswers(text: string | null): PlanAnswer[];
75
70
  /** What a turn's message is built from. */
76
71
  export interface TurnFacts {
77
72
  stage: CloudStage;
@@ -79,7 +74,6 @@ export interface TurnFacts {
79
74
  resumed: boolean;
80
75
  inputDir: string;
81
76
  outDir: string;
82
- answers: readonly PlanAnswer[];
83
77
  continuation?: ContinuationInputs;
84
78
  /** The input folder has `hand-off-answer.md`: a person answered a stop. */
85
79
  handOffAnswer: boolean;
@@ -102,11 +96,8 @@ export interface SessionReport {
102
96
  summary: string | null;
103
97
  checks: VerifyCheckRun[];
104
98
  notVerified: string[];
105
- departures: Array<{
106
- from: string;
107
- what: string;
108
- why: string;
109
- }>;
99
+ /** The steps it did differently than plan.md says, or left out (spec 2026-11-02 §4). */
100
+ planChanges: PlanChange[];
110
101
  }
111
102
  /**
112
103
  * `session-report.json` as this process folds it, or null when it is missing
@@ -176,5 +167,4 @@ export interface SessionTurnOutcome {
176
167
  }
177
168
  /** Run one turn of the run's session and write what the host reads. Never throws for the model's sake. */
178
169
  export declare function runSessionTurn(input: SessionTurnInput, deps?: SessionTurnDeps): Promise<SessionTurnOutcome>;
179
- export {};
180
170
  //# sourceMappingURL=sessionLane.d.ts.map
@@ -29,7 +29,8 @@
29
29
  * process then runs what the cloud lane's finish runs (the secret and
30
30
  * binary scan, a commit of anything left, the git facts) and writes
31
31
  * `result.json` with the model's checks, what it could not verify and
32
- * where it departed from the plan folded in.
32
+ * where it departed from the plan folded in, each departure in
33
+ * `planChanges` for the host to write into the plan (`planChanges.ts`).
33
34
  *
34
35
  * Kept from the cloud lane: the run's clock (`YAGNI_PIPELINE_TIME_LEFT_MS`,
35
36
  * the turn's tools refused once it is nearly spent), the tool-failure health
@@ -47,6 +48,7 @@ import { MISSION_CHECKS_FILE_NAME, readMissionChecksFile } from "./missionChecks
47
48
  import { creditExhaustionReason } from "./orchestrator.js";
48
49
  import { WORK_A_TICKET_SKILL } from "./personas.js";
49
50
  import { extractPlanJson } from "./planOutput.js";
51
+ import { PLAN_CHANGES_RULE, parsePlanChanges, planChangeNote, } from "./planChanges.js";
50
52
  import { runStage as defaultRunStage } from "./runner.js";
51
53
  import { scrubSecrets } from "./scrubSecrets.js";
52
54
  import { DECISIONS_READ_TOOL, PLAN_JSON_CONTRACT } from "./stages.js";
@@ -110,34 +112,6 @@ function feedStage(stage) {
110
112
  return "fix";
111
113
  return "implement";
112
114
  }
113
- /** The answers in `plan-answers.json`, or none when it is missing or does not read. */
114
- export function readPlanAnswers(text) {
115
- if (!text)
116
- return [];
117
- try {
118
- const data = JSON.parse(text);
119
- if (!Array.isArray(data.answers))
120
- return [];
121
- return data.answers.flatMap((entry) => {
122
- if (!entry || typeof entry !== "object")
123
- return [];
124
- const { answer, question } = entry;
125
- if (typeof answer !== "string" || !answer.trim())
126
- return [];
127
- return [
128
- {
129
- answer: answer.trim().slice(0, 1_000),
130
- ...(typeof question === "string" && question.trim()
131
- ? { question: question.trim().slice(0, 500) }
132
- : {}),
133
- },
134
- ];
135
- });
136
- }
137
- catch {
138
- return [];
139
- }
140
- }
141
115
  /** The file the host writes a person's note for the next step to (`attempts/inputs.ts`). */
142
116
  export const NEXT_STEP_NOTE_FILE_NAME = "next-step-note.md";
143
117
  const REPORT_CONTRACT = (outDir) => `Last, write ${join(outDir, SESSION_REPORT_FILE_NAME)} as JSON, honestly: ` +
@@ -145,10 +119,12 @@ const REPORT_CONTRACT = (outDir) => `Last, write ${join(outDir, SESSION_REPORT_F
145
119
  '"checks": [{"name": "lint", "command": "pnpm lint", "cwd": ".", "exitCode": 0, "durationMs": 41000, ' +
146
120
  '"baseline": "runnable | fails_on_base | cannot_run"}], ' +
147
121
  '"notVerified": ["<what you could not verify, and why>"], ' +
148
- '"departures": [{"from": "<the plan step>", "what": "<what you did instead>", "why": "<why>"}]}. ' +
122
+ '"planChanges": [{"step": <the step\'s number in plan.md, or null for the plan as a whole>, ' +
123
+ '"instead": "<what you did instead>", "why": "<why>"}]}. ' +
149
124
  "List every check you ran on the final tree with its real exit code; a check you did not run is " +
150
125
  'not a pass, and goes in "notVerified". "baseline" is "fails_on_base" only when the check already ' +
151
- "failed on the unchanged code. Then end your turn.";
126
+ 'failed on the unchanged code. "planChanges" lists only a step you did differently than plan.md ' +
127
+ "says, or left out, never a choice the plan left to you. Then end your turn.";
152
128
  const BUILD_RULES = (outDir) => [
153
129
  "Write tools are on now. Work as your playbook says:",
154
130
  "- Prefer the smallest change that meets the ticket.",
@@ -195,17 +171,10 @@ export function turnMessage(facts) {
195
171
  parts.push(PLAN_RULES);
196
172
  return parts.join("\n\n");
197
173
  }
198
- const answers = facts.answers.length > 0
199
- ? [
200
- "Their answers:",
201
- ...facts.answers.map((entry) => entry.question ? `- ${entry.question}: ${entry.answer}` : `- ${entry.answer}`),
202
- ].join("\n")
203
- : "";
204
174
  if (facts.stage === "implement" && facts.resumed && !facts.continuation) {
205
- parts.push(`The person approved your plan. The plan as approved is ${at("plan.md")}, and their answers are in ${at("plan-answers.json")}; ${at("ticket.md")} lists any answer that changes the plan.`);
206
- if (answers)
207
- parts.push(answers);
208
- parts.push(`The option they picked is binding. If it is not the one you recommended, re-plan in place first: write the plan you will build to ${join(facts.outDir, "plan.md")}, then build that. The steps are guidance; record every departure from them and why.`);
175
+ // Spec 2026-11-02: every answer is in the plan before Approve, so the
176
+ // plan as approved is the whole contract and nothing rides beside it.
177
+ parts.push(`The person approved the plan. The plan as approved is ${at("plan.md")}: their answers are already in it, under Decisions and Not doing, and it supersedes the draft you wrote earlier in this session. Build that plan. Leave out everything under Not doing. ${PLAN_CHANGES_RULE}`);
209
178
  }
210
179
  else if (facts.stage === "fix" && facts.review) {
211
180
  parts.push(`A review or the CI on this attempt's pull request asks for changes. They are in ${at("ticket.md")}, under "Review on this attempt's pull request", each with its id; the branch may hold a person's commits since your last turn, so read the code as it is now. Address every item with the smallest change that does it, write the outcomes file that section names, and commit.`);
@@ -218,10 +187,8 @@ export function turnMessage(facts) {
218
187
  ? `Pick up the attempt where it stands on this branch.${why}`
219
188
  : `You are building an approved plan for this ticket, on a branch that holds whatever this attempt committed so far.${why}`);
220
189
  if (!facts.resumed) {
221
- parts.push(INPUTS(facts.inputDir), `- plan.md: the plan a person approved, and plan-answers.json, their answers. The option they picked is binding; the steps are guidance.`);
190
+ parts.push(INPUTS(facts.inputDir), `- plan.md: the plan a person approved, with their answers in it under Decisions and Not doing. The steps are guidance.`);
222
191
  }
223
- if (answers && !facts.resumed)
224
- parts.push(answers);
225
192
  if (facts.stage === "verify") {
226
193
  parts.push("Check the work on this branch against the plan: run the checks, fix only what this change broke, and commit any fix.");
227
194
  }
@@ -301,18 +268,8 @@ export function parseSessionReport(text, known = new Map()) {
301
268
  .map((entry) => line(entry))
302
269
  .filter((entry) => entry !== null)
303
270
  .slice(0, MAX_REPORT_LINES);
304
- const departures = list(data.departures)
305
- .flatMap((entry) => {
306
- if (!entry || typeof entry !== "object")
307
- return [];
308
- const record = entry;
309
- const what = line(record.what);
310
- if (!what)
311
- return [];
312
- return [{ from: line(record.from, 200) ?? "the plan", what, why: line(record.why) ?? "" }];
313
- })
314
- .slice(0, MAX_REPORT_LINES);
315
- return { summary: line(data.summary, 1_500), checks, notVerified, departures };
271
+ const planChanges = parsePlanChanges(data.planChanges);
272
+ return { summary: line(data.summary, 1_500), checks, notVerified, planChanges };
316
273
  }
317
274
  /** The checks the host named in `checks.json`, by their command, with how each stands on the base. */
318
275
  function knownBaselines(inputDir, readFile) {
@@ -334,12 +291,13 @@ export function withReport(attempt, report) {
334
291
  ...(report.summary ? [report.summary] : []),
335
292
  ...attempt.notes,
336
293
  ...report.notVerified.map((entry) => `Not verified: ${entry}`),
337
- ...report.departures.map((entry) => `Departed from ${entry.from}: ${entry.what}${entry.why ? `, because ${entry.why}` : ""}`),
294
+ ...report.planChanges.map(planChangeNote),
338
295
  ];
339
296
  return {
340
297
  ...attempt,
341
298
  checks: report.checks.length > 0 ? report.checks : attempt.checks,
342
299
  notes,
300
+ ...(report.planChanges.length > 0 ? { planChanges: report.planChanges } : {}),
343
301
  };
344
302
  }
345
303
  /** The most of a child's stderr a failed turn's note carries. */
@@ -474,7 +432,6 @@ export async function runSessionTurn(input, deps = {}) {
474
432
  resumed,
475
433
  inputDir: input.inputDir,
476
434
  outDir: input.outDir,
477
- answers: readPlanAnswers(readOrNull(join(input.inputDir, "plan-answers.json"))),
478
435
  ...(input.continuation ? { continuation: input.continuation } : {}),
479
436
  handOffAnswer: exists(join(input.inputDir, "hand-off-answer.md")),
480
437
  review: exists(join(input.inputDir, "fix-round.json")),
@@ -98,6 +98,12 @@ export declare const PLAN_JSON_CONTRACT: string;
98
98
  * ends its own run: implement starts in a later run, on the approved plan.
99
99
  */
100
100
  export declare function cloudLane(inputDir: string): PipelineLane;
101
+ /**
102
+ * The cloud implement stage's report of what it did differently than the
103
+ * plan says (spec 2026-11-02 §4): a fenced block its summary ends with, which
104
+ * the session writes into `result.json` (`cloud.ts` `implementPlanChanges`).
105
+ */
106
+ export declare const CLOUD_PLAN_CHANGES_RULE: string;
101
107
  /**
102
108
  * The plan contract re-ask: the same cheap format-recovery pass the review
103
109
  * lenses get, pointed at the ```plan-json block. One attempt only.
@@ -291,6 +291,7 @@ export function cloudLane(inputDir) {
291
291
  const fix = PIPELINE_V1.find((s) => s.id === "fix");
292
292
  if (!fix)
293
293
  throw new Error("PIPELINE_V1 is missing the fix stage");
294
+ const implement = implementStage();
294
295
  return {
295
296
  stages: [
296
297
  {
@@ -301,7 +302,11 @@ export function cloudLane(inputDir) {
301
302
  taskTemplate: cloudPlanTask(inputDir),
302
303
  timeBudgetMs: CLOUD_PLAN_MINUTES * 60_000,
303
304
  },
304
- { ...implementStage(), model: "advanced" },
305
+ {
306
+ ...implement,
307
+ model: "advanced",
308
+ taskTemplate: withPlanChangesRule(implement.taskTemplate),
309
+ },
305
310
  reviewStage(),
306
311
  { ...fix, model: "advanced" },
307
312
  ],
@@ -312,6 +317,22 @@ export function cloudLane(inputDir) {
312
317
  skillsEveryStage: true,
313
318
  };
314
319
  }
320
+ /**
321
+ * The cloud implement stage's report of what it did differently than the
322
+ * plan says (spec 2026-11-02 §4): a fenced block its summary ends with, which
323
+ * the session writes into `result.json` (`cloud.ts` `implementPlanChanges`).
324
+ */
325
+ export const CLOUD_PLAN_CHANGES_RULE = "The steps are guidance. When you do a step differently than the plan says, or leave one out, " +
326
+ "end your summary with a ```plan-changes block: a JSON list with one entry per change, " +
327
+ '{"step": <the step\'s number in the plan, or null for the plan as a whole>, ' +
328
+ '"instead": "<what you did instead>", "why": "<why>"}. Leave out choices the plan left to you.';
329
+ /** The implement task with the rule just before the plan it builds. */
330
+ function withPlanChangesRule(taskTemplate) {
331
+ const at = taskTemplate.lastIndexOf("Plan:\n{previous}");
332
+ if (at < 0)
333
+ throw new Error("the implement stage's task no longer ends with its plan");
334
+ return `${taskTemplate.slice(0, at)}${CLOUD_PLAN_CHANGES_RULE}\n\n${taskTemplate.slice(at)}`;
335
+ }
315
336
  /**
316
337
  * The plan contract re-ask: the same cheap format-recovery pass the review
317
338
  * lenses get, pointed at the ```plan-json block. One attempt only.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2213.1",
3
+ "version": "1.2.14-staging.2244.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -58,5 +58,5 @@
58
58
  "turndown": "^7.2.4",
59
59
  "typebox": "^1.3.15"
60
60
  },
61
- "yagniSourceSha": "4cc9f6388171d4967fbf78689819f238baa1f5f8"
61
+ "yagniSourceSha": "026d28b72cc0909a00e49bab55ae11643a3a89be"
62
62
  }