@yagni-app/code-staging 1.2.14-staging.2390.1 → 1.2.14-staging.2406.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.
@@ -24,6 +24,8 @@ export declare const MIN_REVIEW_ROUND_MS: number;
24
24
  export declare const MAX_PLAN_REVIEW_ROUNDS = 4;
25
25
  /** How the review ends when its last round still lists a major (its wording names the cap above). */
26
26
  export declare const REVIEW_CAP_ENDED = "the review reached its cap of four rounds; round 4's majors were revised but not checked again";
27
+ /** How the review ends at a cap of `cap` rounds with a major still listed; at four, {@link REVIEW_CAP_ENDED}. */
28
+ export declare function reviewCapEnded(cap: number): string;
27
29
  /** One major finding the session backed with evidence. */
28
30
  export interface PlanFinding {
29
31
  dimension: string;
@@ -46,7 +48,7 @@ export declare const REVIEW_MESSAGE_OPENING = "Review the plan you just wrote";
46
48
  * whole (its plan-json block included) so a compaction during the plan turn
47
49
  * never leaves the session reviewing a summary of its own plan.
48
50
  */
49
- export declare function reviewMessage(inputDir: string, planText: string, round: number): string;
51
+ export declare function reviewMessage(inputDir: string, planText: string, round: number, cap?: number): string;
50
52
  /** The re-ask when a review round's answer carried no verdict that reads. */
51
53
  export declare const VERDICT_REASK = "Your last message did not end with a plan-review block that reads. Send the whole plan again as your last message: the plan, then its plan-json block, then the plan-review block listing the majors you found this round (an empty list when there were none).";
52
54
  /** The text without its plan-review blocks: the verdict never reaches the gate's plan. */
@@ -86,6 +88,14 @@ export declare function selfReviewPlan(input: {
86
88
  }>;
87
89
  /** The run's time left before its turn's finish; undefined when it has no deadline. */
88
90
  timeLeftMs: () => number | undefined;
91
+ /**
92
+ * The most rounds for the plan as it stands (YAG-1306: the host sizes the
93
+ * review to the plan), read again after every round, so a review that
94
+ * changes the plan's size takes the new size's rounds. Absent, four.
95
+ */
96
+ maxRounds?: (planText: string) => number;
97
+ /** Told as each round's turn starts, with its number: the stream marks its stage rows with it. */
98
+ onRound?: (round: number) => void;
89
99
  signal?: AbortSignal;
90
100
  }): Promise<{
91
101
  run: StageResult;
@@ -94,7 +104,9 @@ export declare function selfReviewPlan(input: {
94
104
  ended: string | null;
95
105
  }>;
96
106
  /** The `## Self-review` section the host adds to the plan: how many rounds, and what each changed. */
97
- export declare function selfReviewSection(rounds: readonly ReviewRound[], ended: string | null): string;
107
+ export declare function selfReviewSection(rounds: readonly ReviewRound[], ended: string | null,
108
+ /** The plan's own size, when the host sized the review to it and it ran no round. */
109
+ unreviewedSize?: string | null): string;
98
110
  /** A path a plan cites, and whether the line that cites it says the plan creates it. */
99
111
  export interface CitedPath {
100
112
  path: string;
@@ -24,6 +24,13 @@ export const MIN_REVIEW_ROUND_MS = 10 * 60_000;
24
24
  export const MAX_PLAN_REVIEW_ROUNDS = 4;
25
25
  /** How the review ends when its last round still lists a major (its wording names the cap above). */
26
26
  export const REVIEW_CAP_ENDED = "the review reached its cap of four rounds; round 4's majors were revised but not checked again";
27
+ const ROUND_WORDS = ["no rounds", "one round", "two rounds", "three rounds", "four rounds"];
28
+ /** How the review ends at a cap of `cap` rounds with a major still listed; at four, {@link REVIEW_CAP_ENDED}. */
29
+ export function reviewCapEnded(cap) {
30
+ if (cap >= MAX_PLAN_REVIEW_ROUNDS)
31
+ return REVIEW_CAP_ENDED;
32
+ return `the review reached its cap of ${ROUND_WORDS[cap] ?? `${cap} rounds`}; round ${cap}'s majors were revised but not checked again`;
33
+ }
27
34
  const MAX_FINDINGS = 10;
28
35
  const PLAN_REVIEW_BLOCK = /```plan-review[^\n]*\n([\s\S]*?)```/gi;
29
36
  function clipped(value, max) {
@@ -40,10 +47,15 @@ export const REVIEW_MESSAGE_OPENING = "Review the plan you just wrote";
40
47
  * whole (its plan-json block included) so a compaction during the plan turn
41
48
  * never leaves the session reviewing a summary of its own plan.
42
49
  */
43
- export function reviewMessage(inputDir, planText, round) {
50
+ export function reviewMessage(inputDir, planText, round, cap = MAX_PLAN_REVIEW_ROUNDS) {
44
51
  const at = (file) => `${inputDir.replace(/\/+$/, "")}/${file}`;
52
+ // On a sized review (YAG-1306) the plan may start its build with nobody
53
+ // approving it first, so the message does not promise that a person does.
54
+ const next = cap === MAX_PLAN_REVIEW_ROUNDS
55
+ ? "A person approves it next, and the build follows it."
56
+ : "The build follows it.";
45
57
  return [
46
- `${REVIEW_MESSAGE_OPENING}, round ${round} of at most ${MAX_PLAN_REVIEW_ROUNDS}, against the ticket in ${at("ticket.md")} and the code. A person approves it next, and the build follows it. Read again what you need and run what settles a fact; change no tracked file and commit nothing.`,
58
+ `${REVIEW_MESSAGE_OPENING}, round ${round} of at most ${cap}, against the ticket in ${at("ticket.md")} and the code. ${next} Read again what you need and run what settles a fact; change no tracked file and commit nothing.`,
47
59
  [
48
60
  "Answer each of these questions against the code, not from memory:",
49
61
  '1. Ticket check: is each premise the plan relies on checked, with the command, file:line or query that shows it, or marked as not checkable? Is a premise marked checked really true? Is "Done when" written? When the plan recommends closing the ticket, check that evidence again yourself.',
@@ -156,13 +168,19 @@ export async function selfReviewPlan(input) {
156
168
  return "the attempt was stopped";
157
169
  return null;
158
170
  };
171
+ const capFor = (planText) => Math.max(0, Math.min(MAX_PLAN_REVIEW_ROUNDS, input.maxRounds?.(planText) ?? MAX_PLAN_REVIEW_ROUNDS));
159
172
  for (let round = 1;; round += 1) {
160
173
  if (input.signal?.aborted)
161
174
  return end("the attempt was stopped");
175
+ // A plan sized for no review runs none, and ends as a clean one does.
176
+ const cap = capFor(run.finalOutput);
177
+ if (round > cap)
178
+ return { run, asked, rounds, ended: null };
162
179
  const left = input.timeLeftMs();
163
180
  if (left !== undefined && left < MIN_REVIEW_ROUND_MS)
164
181
  return end("the run's time ran low");
165
- let answer = await input.turn(reviewMessage(input.inputDir, run.finalOutput, round));
182
+ input.onRound?.(round);
183
+ let answer = await input.turn(reviewMessage(input.inputDir, run.finalOutput, round, cap));
166
184
  asked.push(answer);
167
185
  const first = stopped(answer);
168
186
  if (first)
@@ -205,12 +223,23 @@ export async function selfReviewPlan(input) {
205
223
  rounds.push({ round, findings, outcome: "revised" });
206
224
  if (findings.length === 0)
207
225
  return { run, asked, rounds, ended: null };
208
- if (round >= MAX_PLAN_REVIEW_ROUNDS)
209
- return end(REVIEW_CAP_ENDED);
226
+ // The cap of the plan as revised: a review that sized it up goes on.
227
+ const capNow = capFor(run.finalOutput);
228
+ if (round >= capNow)
229
+ return end(reviewCapEnded(Math.max(capNow, round)));
210
230
  }
211
231
  }
212
232
  /** The `## Self-review` section the host adds to the plan: how many rounds, and what each changed. */
213
- export function selfReviewSection(rounds, ended) {
233
+ export function selfReviewSection(rounds, ended,
234
+ /** The plan's own size, when the host sized the review to it and it ran no round. */
235
+ unreviewedSize) {
236
+ if (rounds.length === 0 && !ended && unreviewedSize) {
237
+ return [
238
+ "## Self-review",
239
+ "",
240
+ `None: the plan sizes this ticket ${unreviewedSize}, and a ${unreviewedSize} plan is not reviewed before its build. Its pull request is reviewed.`,
241
+ ].join("\n");
242
+ }
214
243
  const count = rounds.length === 1 ? "1 round" : `${rounds.length} rounds`;
215
244
  const lines = [
216
245
  "## Self-review",
@@ -50,6 +50,7 @@ import { type AttemptResult, type CloudIdentity, type CloudStage } from "./cloud
50
50
  import type { ContinuationInputs } from "./continuation.js";
51
51
  import { type PlanChange } from "./planChanges.js";
52
52
  import { type RunStageDeps } from "./runner.js";
53
+ import { type SessionTicketPath } from "./ticketPath.js";
53
54
  import type { JsonEvent, ModelTier, PipelineStage, StageId, StageResult, StopReason } from "./types.js";
54
55
  import { type VerifyCheckRun } from "./verify.js";
55
56
  import { snapshotWorkspace } from "./workspace.js";
@@ -154,6 +155,13 @@ export interface TurnFacts {
154
155
  * no person answers the plan's questions. Only ever on a plan turn.
155
156
  */
156
157
  ownPlans?: boolean;
158
+ /**
159
+ * `ticket-path.json`, as the host wrote it (`ticketPath.ts`): this ticket
160
+ * runs as one session (YAG-1306), so its plan is the short one, its review
161
+ * is sized to it, and a fix is about what is wrong. Absent on every other
162
+ * ticket, whose turns read exactly as they did.
163
+ */
164
+ ticketPath?: SessionTicketPath | null;
157
165
  }
158
166
  /** The file the host writes when a yak approves its own plans (`attempts/inputs.ts`, `yaks/ownPlans.ts`). */
159
167
  export declare const OWN_PLANS_FILE_NAME = "own-plans.md";
@@ -64,7 +64,8 @@ import { checkPlanPaths, selfReviewPlan, selfReviewSection } from "./planReview.
64
64
  import { PLAN_CHANGES_RULE, parsePlanChanges, planChangeNote, } from "./planChanges.js";
65
65
  import { runStage as defaultRunStage } from "./runner.js";
66
66
  import { scrubSecrets } from "./scrubSecrets.js";
67
- import { DECISIONS_READ_TOOL, PLAN_JSON_CONTRACT } from "./stages.js";
67
+ import { DECISIONS_READ_TOOL, PLAN_JSON_CONTRACT, YAK_PLAN_JSON_CONTRACT } from "./stages.js";
68
+ import { planReviewRoundsFor, planSizeOf, sessionTicketPathOf, TICKET_PATH_FILE_NAME, } from "./ticketPath.js";
68
69
  import { STAGE_WRAP_UP_GRACE_MS } from "./stageClock.js";
69
70
  import { editsMostlyFailed } from "./events.js";
70
71
  import { baselineDirs, parseChangedPaths, planPaths } from "./verify.js";
@@ -284,7 +285,22 @@ const PLAN_TOOLS = "read, grep, find, ls, bash, ask_yagni, team_read, prototype_
284
285
  * folder) the turn also draws the plan's UI preview: it gets write and edit
285
286
  * for the preview's files, and the rule that says when to draw one.
286
287
  */
287
- const planRules = (preview, ownPlans) => [
288
+ const planRules = (preview, ownPlans, path = null) => path
289
+ ? [
290
+ preview
291
+ ? `This turn you have ${PLAN_TOOLS}, and write and edit for the UI preview's files in ${preview.outDir} only: never for a file in the repository.`
292
+ : `This turn you have ${PLAN_TOOLS}, and no edit or write tool.`,
293
+ NARRATION_RULE,
294
+ ...PLAN_RULES_BEFORE_PREVIEW,
295
+ ...(preview ? [previewRule(preview.inputDir, preview.outDir)] : []),
296
+ `${SHORT_PLAN_FORMAT_RULE} ${ownPlans ? SHORT_DECIDE_RULE : SHORT_QUESTION_RULE}`,
297
+ SHORT_PLAN_CLOSE_RULE,
298
+ YAK_PLAN_JSON_CONTRACT,
299
+ shortPlanStop(path, ownPlans),
300
+ ].join("\n\n")
301
+ : planRulesBefore(preview, ownPlans);
302
+ /** The plan turn's rules on every ticket that is not a one-session yak's: as they always read. */
303
+ const planRulesBefore = (preview, ownPlans) => [
288
304
  preview
289
305
  ? `This turn you have ${PLAN_TOOLS}, and write and edit for the UI preview's files in ${preview.outDir} only: never for a file in the repository.`
290
306
  : `This turn you have ${PLAN_TOOLS}, and no edit or write tool.`,
@@ -322,6 +338,38 @@ const DECIDE_RULE = "This yak approves its own plans: no person answers this pla
322
338
  const PLAN_CLOSE_RULE = 'When the ticket check shows the problem is already gone, recommend closing the ticket instead of planning a change: ## Goal says so in one sentence, the ticket check holds the evidence, ## Plan says "Nothing to build." with no numbered steps, and the plan-json block carries "closeTicket" with the evidence and names no checks and no paths. A person then decides whether to close it.';
323
339
  const PLAN_STOP = "Then stop: next you review this plan yourself, in this session, for at most four rounds, fixing what you find. A person approves the plan before anything is built.";
324
340
  const OWN_PLANS_STOP = "Then stop: next you review this plan yourself, in this session, for at most four rounds, fixing what you find. Once the review ends, YAGNI approves the plan for this yak and the build starts.";
341
+ /**
342
+ * The short plan (YAG-1306, ADR-0060): what done means, the checks, the
343
+ * scope and what is left alone, and only the questions a person must
344
+ * answer. The host reads these headings (`readSessionPlan` in the backend's
345
+ * `attempts/plan.ts`): Done when becomes the plan's items and its
346
+ * acceptance criteria, Scope its files, Not doing what the review never
347
+ * calls missing.
348
+ */
349
+ const SHORT_PLAN_FORMAT_RULE = 'End the turn with the plan as your last message, and keep it short. ## Goal: one sentence. ## Done when: what is true when this is finished, one line each, from the ticket\'s acceptance criteria or yours; a reviewer holds the change to these lines. ## Checks: the commands you will run to prove it. ## Scope: the files or folders you will change, one per line in code spans (say "new" beside one the plan creates), then one line for each assumption you plan on. ## Not doing: what you leave alone on purpose, one line each, when there is anything. ## Questions: only when a person must answer something before you build. Then the plan-json block. Write no step list, no ticket-check table and no risks section: the premises you checked are yours to have checked, not to list.';
350
+ const SHORT_QUESTION_RULE = "Where a person must choose, ask it as a question in the plan-json block; where you would choose yourself, choose, and say it under ## Scope.";
351
+ /** {@link DECIDE_RULE} for the short plan, which has no Risks section to state an assumption in. */
352
+ const SHORT_DECIDE_RULE = "This yak approves its own plans: no person answers this plan's questions. So where there is a choice of approach, choose, and say it under ## Scope as the assumption you plan on, with what would change it. Put a question in the plan-json block only for a change of direction, with its evidence (file:line, command or query) in the question's text: the ticket's premise is false, or the right change is far larger than the ticket.";
353
+ const SHORT_PLAN_CLOSE_RULE = 'When checking the ticket shows the problem is already gone, recommend closing it instead of planning a change: ## Goal says so in one sentence, ## Done when holds the evidence (the command, file:line or query, and what it showed), and the plan-json block carries "closeTicket" with that evidence and names no checks and no paths. A person then decides whether to close it.';
354
+ const reviewWords = (rounds) => rounds === 0
355
+ ? "is not reviewed again"
356
+ : rounds === 1
357
+ ? "you review once"
358
+ : `you review for at most ${rounds} rounds`;
359
+ /** How a one-session plan turn ends: the review its size gets, and whether anyone is waited on. */
360
+ const shortPlanStop = (path, ownPlans) => {
361
+ const by = path.planReviewRounds;
362
+ const review = `Then stop. What comes next depends on the size you gave it: a small plan ${reviewWords(by.small)}, a standard plan ${reviewWords(by.standard)}, a complex plan ${reviewWords(by.complex)}, in this session.`;
363
+ return ownPlans
364
+ ? `${review} YAGNI then approves the plan for this yak and the build starts.`
365
+ : `${review} A small or standard plan with no question then starts its build at once, and a person reads it while you build; any other plan waits for a person.`;
366
+ };
367
+ /**
368
+ * A one-session ticket's fix (YAG-1306): about what is wrong, never every
369
+ * item a review lists. What is not fixed is answered in the outcomes file,
370
+ * so its thread is told why.
371
+ */
372
+ const CORRECTNESS_FIX_RULE = "Fix what is wrong, not everything that is asked. An item is yours to fix when it names a bug, a failing check, a conflict, a broken contract, a security or data problem, or something the plan's Done when requires, and whenever a person on the Team asked for it themselves. For any other item (style, naming, a refactor, a nice-to-have) change nothing, and dispute it in the outcomes file with one line on why it is not a correctness problem.";
325
373
  /**
326
374
  * How a turn treats a review's items. The host acknowledges each thread at
327
375
  * take and posts the outcomes after its push (`attempts/review.ts`), with the
@@ -362,7 +410,7 @@ export function turnMessage(facts) {
362
410
  parts.push(handOffAnswerLine(at("hand-off-answer.md"), "plan"));
363
411
  if (newSince)
364
412
  parts.push(newSince);
365
- parts.push(planRules(facts.preview ? { inputDir: facts.inputDir, outDir: facts.outDir } : undefined, facts.ownPlans === true));
413
+ parts.push(planRules(facts.preview ? { inputDir: facts.inputDir, outDir: facts.outDir } : undefined, facts.ownPlans === true, facts.ticketPath ?? null));
366
414
  return parts.join("\n\n");
367
415
  }
368
416
  if (facts.stage === "implement" && facts.resumed && !facts.continuation) {
@@ -371,7 +419,7 @@ export function turnMessage(facts) {
371
419
  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}`);
372
420
  }
373
421
  else if (facts.stage === "fix" && facts.review) {
374
- 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. Fix each item that asks for a change with the smallest change that does it and commit; answer each item that only asks a question in the outcomes file that section names, with no commit for it.`, FIX_RULE);
422
+ 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. ${facts.ticketPath ? `${CORRECTNESS_FIX_RULE} Answer each item that only asks a question in the outcomes file that section names, with no commit for it, and commit what you fix.` : "Fix each item that asks for a change with the smallest change that does it and commit; answer each item that only asks a question in the outcomes file that section names, with no commit for it."}`, FIX_RULE);
375
423
  }
376
424
  else {
377
425
  const why = facts.continuation?.priorStop
@@ -387,7 +435,7 @@ export function turnMessage(facts) {
387
435
  parts.push("Check the work on this branch against the plan: run the checks, fix only what this change broke, and commit any fix.");
388
436
  }
389
437
  if (facts.review) {
390
- 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". Address every item (answer an item that only asks a question, with no change for it) and write the outcomes file that section names.`, FIX_RULE);
438
+ 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". ${facts.ticketPath ? `${CORRECTNESS_FIX_RULE} Answer an item that only asks a question, with no change for it, and write` : "Address every item (answer an item that only asks a question, with no change for it) and write"} the outcomes file that section names.`, FIX_RULE);
391
439
  }
392
440
  }
393
441
  if (facts.handOffAnswer)
@@ -797,13 +845,31 @@ async function runTurn(input, deps, pulse) {
797
845
  },
798
846
  now,
799
847
  };
848
+ // What the host said about how this ticket runs (YAG-1306); null on every
849
+ // ticket that is not a one-session yak's.
850
+ const ticketPath = sessionTicketPathOf(readOrNull(join(input.inputDir, TICKET_PATH_FILE_NAME)));
851
+ // A stage's rows say when a turn takes the same stage up again (YAG-1306):
852
+ // the host resumed a stage an earlier turn stopped in, or this is one more
853
+ // message of this turn (a re-ask, a review round). A count of stages then
854
+ // counts one, and the time inside each row is still the time it took.
855
+ let stageOpened = Boolean(input.continuation?.priorStop);
856
+ /** The plan review round whose turn is running, for its stage rows; null outside one. */
857
+ let reviewRound = null;
800
858
  const turn = async (message) => {
801
- input.emit({ type: "pipeline_stage", stage: stageId, phase: "start", at: now() });
859
+ // Only on a one-session ticket: every other ticket's stream is as it was.
860
+ const marks = ticketPath
861
+ ? {
862
+ ...(stageOpened ? { resumed: true } : {}),
863
+ ...(reviewRound !== null ? { round: reviewRound } : {}),
864
+ }
865
+ : {};
866
+ stageOpened = true;
867
+ input.emit({ type: "pipeline_stage", stage: stageId, phase: "start", ...marks, at: now() });
802
868
  try {
803
869
  return await runStage(withClock(turnStage), { ticket: message }, runDeps);
804
870
  }
805
871
  finally {
806
- input.emit({ type: "pipeline_stage", stage: stageId, phase: "finish", at: now() });
872
+ input.emit({ type: "pipeline_stage", stage: stageId, phase: "finish", ...marks, at: now() });
807
873
  }
808
874
  };
809
875
  // On the CLI's own stderr, whose tail the host logs: a value that named
@@ -831,6 +897,7 @@ async function runTurn(input, deps, pulse) {
831
897
  // The env the turn's child runs on, so the message and the agents the
832
898
  // child is offered (`builtinAgents`) read one value.
833
899
  codeWriter: resolveCodeWriter(input.childEnv),
900
+ ...(ticketPath ? { ticketPath } : {}),
834
901
  });
835
902
  const notes = [];
836
903
  const stages = [];
@@ -874,11 +941,19 @@ async function runTurn(input, deps, pulse) {
874
941
  turn,
875
942
  withBlock,
876
943
  timeLeftMs,
944
+ // The host sizes a one-session ticket's review to its plan.
945
+ ...(ticketPath
946
+ ? { maxRounds: (text) => planReviewRoundsFor(ticketPath, text) }
947
+ : {}),
948
+ onRound: (round) => {
949
+ reviewRound = round;
950
+ },
877
951
  ...(input.signal ? { signal: input.signal } : {}),
878
952
  });
953
+ reviewRound = null;
879
954
  stages.push(...reviewed.asked);
880
955
  run = reviewed.run;
881
- sections.push(selfReviewSection(reviewed.rounds, reviewed.ended));
956
+ sections.push(selfReviewSection(reviewed.rounds, reviewed.ended, ticketPath ? planSizeOf(run.finalOutput) : null));
882
957
  if (reviewed.ended) {
883
958
  const note = `The plan's review ended before a clean round (${reviewed.rounds.length} round(s)): ${reviewed.ended}.`;
884
959
  notes.push(note);
@@ -95,6 +95,17 @@ export declare const FOLLOW_UPS_RULE: string;
95
95
  */
96
96
  export declare const CLOSE_TICKET_RULE: string;
97
97
  export declare const PLAN_JSON_CONTRACT: string;
98
+ /**
99
+ * The short plan's block (YAG-1306, ADR-0060): what a yak whose ticket runs
100
+ * as one session ends its plan on. The host reads it with the reader it
101
+ * reads {@link PLAN_JSON_CONTRACT}'s block with, which ignores what a short
102
+ * plan leaves out; every other Team's plan keeps the long contract. What
103
+ * done means, what is left alone and the scope are the plan's own sections
104
+ * (`sessionLane.ts`), never repeated here. A question in it is a person's:
105
+ * one that carries a recommendation is read as decided (`isStatedQuestion`
106
+ * in `@yagni/shared`), so the contract asks for none.
107
+ */
108
+ export declare const YAK_PLAN_JSON_CONTRACT: string;
98
109
  /**
99
110
  * The one-attempt lane's session (`yagni go --headless --cloud`): plan,
100
111
  * implement, review, fix, then verify and finish, which run no model. One
@@ -193,7 +193,7 @@ export const FOLLOW_UPS_RULE = '- "followUps" lists what you found that the tick
193
193
  * answers, Close the ticket or Plan it anyway, and nothing is built.
194
194
  */
195
195
  export const CLOSE_TICKET_RULE = '- "closeTicket" is only for a ticket whose problem the ticket check shows is already gone: ' +
196
- 'say why in one line and list the evidence, each the command, file:line or query and what it showed. ' +
196
+ "say why in one line and list the evidence, each the command, file:line or query and what it showed. " +
197
197
  'Then the plan has no steps, and "checks" and "paths" stay empty. A person decides whether to close ' +
198
198
  "the ticket. Leave it out whenever there is anything to build.";
199
199
  export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json block and nothing after it:\n" +
@@ -240,6 +240,47 @@ export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json bl
240
240
  FOLLOW_UPS_RULE +
241
241
  "\n" +
242
242
  CLOSE_TICKET_RULE;
243
+ /**
244
+ * The short plan's block (YAG-1306, ADR-0060): what a yak whose ticket runs
245
+ * as one session ends its plan on. The host reads it with the reader it
246
+ * reads {@link PLAN_JSON_CONTRACT}'s block with, which ignores what a short
247
+ * plan leaves out; every other Team's plan keeps the long contract. What
248
+ * done means, what is left alone and the scope are the plan's own sections
249
+ * (`sessionLane.ts`), never repeated here. A question in it is a person's:
250
+ * one that carries a recommendation is read as decided (`isStatedQuestion`
251
+ * in `@yagni/shared`), so the contract asks for none.
252
+ */
253
+ export const YAK_PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json block and nothing after it:\n" +
254
+ "```plan-json\n" +
255
+ "{\n" +
256
+ ' "checks": [{"name": "lint", "command": "pnpm lint", "cwd": "apps/web"}],\n' +
257
+ ' "paths": ["apps/web"],\n' +
258
+ ' "questions": [{"text": "...", "kind": "decision", "alternatives": [{"answer": "...", "why": "..."}]}],\n' +
259
+ ' "size": "small|standard|complex",\n' +
260
+ ' "sizeReason": "one line on why the size"\n' +
261
+ "}\n" +
262
+ "```\n" +
263
+ "Rules the host enforces:\n" +
264
+ '- "checks" are the commands that prove the change, each run from "cwd" (repo-relative, "." for the root). ' +
265
+ '"paths" are the package folders the change touches.\n' +
266
+ '- "questions" holds only what a person must answer before you can build, and is empty when there is nothing: ' +
267
+ "a question there makes the build wait for a person. Settle what you can read or run yourself, and make the " +
268
+ "choices you would make yourself, saying each as one line under ## Scope. Write no recommendation on a question " +
269
+ "you need answered; give at most two alternatives a person could pick.\n" +
270
+ '- "size" is your own judgment of the build (small: a one-file or config fix; standard: a change across one or ' +
271
+ 'two packages; complex: a cross-package, schema or contract change), with one line as "sizeReason". A small or ' +
272
+ "standard plan with no question starts its build without waiting for a person; a complex plan, one with a " +
273
+ "question, or one with no size waits for one. Size it honestly: a plan sized too small is built unseen.\n" +
274
+ "Add these only when they apply, and leave them out otherwise:\n" +
275
+ '- "repositoriesNeeded": [{"repository": "owner/name", "summary": "one line on what changes there"}] when the ' +
276
+ "change writes to more than one repository the ticket's Other repositories section lists, in the order they " +
277
+ "must be built and merged, this one included. Never a repository the change only reads.\n" +
278
+ '- "wrongRepository": {"repository": "owner/name", "why": "one line", "confidence": "high|low"} and ' +
279
+ '"dependsOn": [{"repository": "owner/name", "what": "one line"}]:\n' +
280
+ RIGHT_REPOSITORY_RULE +
281
+ "\n" +
282
+ '- "closeTicket": {"why": "one line", "evidence": ["the command, file:line or query, and what it showed"]}:\n' +
283
+ CLOSE_TICKET_RULE;
243
284
  /**
244
285
  * The cloud plan stage's task: the input folder the host wrote, read first,
245
286
  * then a plan grounded in the installed checkout, inside the stage's own
@@ -0,0 +1,20 @@
1
+ export declare const TICKET_PATH_FILE_NAME = "ticket-path.json";
2
+ declare const SIZES: readonly ["small", "standard", "complex"];
3
+ type PlanSize = (typeof SIZES)[number];
4
+ export interface SessionTicketPath {
5
+ /** The plan review's rounds by the plan's own size. */
6
+ planReviewRounds: Record<PlanSize, number>;
7
+ /** The fix rounds a review may start before a person is asked. */
8
+ fixRoundCap: number;
9
+ }
10
+ /** The host's file as the turn reads it, or null for none, or one that is not the one-session path. */
11
+ export declare function sessionTicketPathOf(text: string | null): SessionTicketPath | null;
12
+ /** The size a plan's text gives itself in its plan-json block, or null. */
13
+ export declare function planSizeOf(planText: string): PlanSize | null;
14
+ /**
15
+ * The rounds the plan as it stands is reviewed for: the host's number for
16
+ * its size, or every round when the turn has no path or the plan no size.
17
+ */
18
+ export declare function planReviewRoundsFor(path: SessionTicketPath | null, planText: string): number;
19
+ export {};
20
+ //# sourceMappingURL=ticketPath.d.ts.map
@@ -0,0 +1,59 @@
1
+ /**
2
+ * What the host told this turn about how its ticket runs (YAG-1306): the
3
+ * `ticket-path.json` the host writes beside `ticket.md` for a yak whose
4
+ * ticket runs as one session (`attempts/inputs.ts` in the backend, from
5
+ * `ticketPathFileOf` in `@yagni/shared`). The session holds no copy of the
6
+ * rule: it reads the numbers. Without the file, or with one that does not
7
+ * read, the turn works as it did before the path existed: the long plan,
8
+ * four review rounds, every review item addressed.
9
+ */
10
+ import { extractPlanJson } from "./planOutput.js";
11
+ import { MAX_PLAN_REVIEW_ROUNDS } from "./planReview.js";
12
+ export const TICKET_PATH_FILE_NAME = "ticket-path.json";
13
+ const SIZES = ["small", "standard", "complex"];
14
+ const rounds = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0
15
+ ? Math.min(value, MAX_PLAN_REVIEW_ROUNDS)
16
+ : null;
17
+ /** The host's file as the turn reads it, or null for none, or one that is not the one-session path. */
18
+ export function sessionTicketPathOf(text) {
19
+ if (!text)
20
+ return null;
21
+ let parsed;
22
+ try {
23
+ parsed = JSON.parse(text);
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
29
+ return null;
30
+ const file = parsed;
31
+ if (file.path !== "one_session")
32
+ return null;
33
+ const by = (file.planReviewRounds ?? {});
34
+ const small = rounds(by.small);
35
+ const standard = rounds(by.standard);
36
+ const complex = rounds(by.complex);
37
+ const cap = file.fixRoundCap;
38
+ if (small === null || standard === null || complex === null)
39
+ return null;
40
+ if (typeof cap !== "number" || !Number.isInteger(cap) || cap < 1)
41
+ return null;
42
+ return { planReviewRounds: { small, standard, complex }, fixRoundCap: cap };
43
+ }
44
+ /** The size a plan's text gives itself in its plan-json block, or null. */
45
+ export function planSizeOf(planText) {
46
+ const size = extractPlanJson(planText)?.size;
47
+ return SIZES.find((known) => known === size) ?? null;
48
+ }
49
+ /**
50
+ * The rounds the plan as it stands is reviewed for: the host's number for
51
+ * its size, or every round when the turn has no path or the plan no size.
52
+ */
53
+ export function planReviewRoundsFor(path, planText) {
54
+ if (!path)
55
+ return MAX_PLAN_REVIEW_ROUNDS;
56
+ const size = planSizeOf(planText);
57
+ return size ? path.planReviewRounds[size] : MAX_PLAN_REVIEW_ROUNDS;
58
+ }
59
+ //# sourceMappingURL=ticketPath.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2390.1",
3
+ "version": "1.2.14-staging.2406.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": "05b87e8cc5cd5acfb5b577b04a145c8c566a2708"
61
+ "yagniSourceSha": "028be749156c881690fc451262308059c79524ac"
62
62
  }