@yagni-app/code-staging 1.2.14-staging.2349.1 → 1.2.14-staging.2351.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.
@@ -143,7 +143,14 @@ export interface TurnFacts {
143
143
  preview?: boolean;
144
144
  /** Who writes the change, as the host said (`codeWriter.ts`); absent, the session. */
145
145
  codeWriter?: CodeWriter;
146
+ /**
147
+ * The input folder has `own-plans.md`: this yak approves its own plans, so
148
+ * no person answers the plan's questions. Only ever on a plan turn.
149
+ */
150
+ ownPlans?: boolean;
146
151
  }
152
+ /** The file the host writes when a yak approves its own plans (`attempts/inputs.ts`, `yaks/ownPlans.ts`). */
153
+ export declare const OWN_PLANS_FILE_NAME = "own-plans.md";
147
154
  /** The file the host writes a person's note for the next step to (`attempts/inputs.ts`). */
148
155
  export declare const NEXT_STEP_NOTE_FILE_NAME = "next-step-note.md";
149
156
  /** The file the host writes a yak's new messages to (`attempts/inputs.ts`, `yaks/turns.ts`). */
@@ -177,6 +177,8 @@ function feedStage(stage) {
177
177
  return "fix";
178
178
  return "implement";
179
179
  }
180
+ /** The file the host writes when a yak approves its own plans (`attempts/inputs.ts`, `yaks/ownPlans.ts`). */
181
+ export const OWN_PLANS_FILE_NAME = "own-plans.md";
180
182
  /** The file the host writes a person's note for the next step to (`attempts/inputs.ts`). */
181
183
  export const NEXT_STEP_NOTE_FILE_NAME = "next-step-note.md";
182
184
  /** The file the host writes a yak's new messages to (`attempts/inputs.ts`, `yaks/turns.ts`). */
@@ -220,8 +222,10 @@ const REPORT_CONTRACT = (outDir) => `Last, write ${join(outDir, SESSION_REPORT_F
220
222
  '"planChanges": [{"step": <the step\'s number in plan.md, or null for the plan as a whole>, ' +
221
223
  '"instead": "<what you did instead>", "why": "<why>"}]}. ' +
222
224
  "List every check you ran on the final tree with its real exit code; a check you did not run is " +
223
- 'not a pass, and goes in "notVerified". "baseline" is "fails_on_base" only when the check already ' +
224
- 'failed on the unchanged code. "planChanges" lists only a step you did differently than plan.md ' +
225
+ 'not a pass, and goes in "notVerified". "baseline" is "fails_on_base" only when the check failed on ' +
226
+ "the unchanged code in a run this attempt made, yours or one checks.json's baseMeasured names; a " +
227
+ 'record alone never makes it so. A check may carry "note": the new test that proves a behavior ' +
228
+ 'change says there what it showed failing without the change. "planChanges" lists only a step you did differently than plan.md ' +
225
229
  "says, or left out, never a choice the plan left to you. Then end your turn.";
226
230
  /** The build rule that says who writes the change: the host's value, in words. */
227
231
  const WRITER_RULE = (who) => who.writer === "helper"
@@ -235,9 +239,11 @@ const PULL_REQUEST_CONTRACT = (outDir) => `Before the report, write ${join(outDi
235
239
  "environment: everyone on the repository reads it. Write no title, checks table or plan version: YAGNI adds those.";
236
240
  const BUILD_RULES = (outDir, who) => [
237
241
  "Write tools are on now. Work as your playbook says:",
238
- "- Prefer the smallest change that meets the ticket.",
242
+ "- Prefer the smallest change that meets the ticket, and keep the diff to what the ticket needs.",
239
243
  WRITER_RULE(who),
240
- "- Run the checks that prove the change (checks.json, the plan's checks) and fix what your change breaks.",
244
+ "- Read the repository's CI workflows (.github/workflows, or the CI it uses) and run every check there your diff can trip, beside checks.json and the plan's checks; fix what your change breaks.",
245
+ "- Each behavior change gets a test. Run it once without the change and see it fail, then with it; in the report, that test's check says in its note what failed without the change.",
246
+ "- A check checks.json marks measureOnBase, or one you would call fails_on_base, is measured on the unchanged code during this attempt: before your first edit, or in a git worktree at the commit this branch started from. A red in the repository's record is not a measurement, however recent; a baseMeasured entry in checks.json is.",
241
247
  "- Before you finish, dispatch a fresh verification subagent on your diff with the ticket and the plan, and fix what it finds that is real.",
242
248
  "- Commit on the branch you are on. Never push and never open or edit a pull request: YAGNI pushes your commits and opens it.",
243
249
  `- ${PULL_REQUEST_CONTRACT(outDir)}`,
@@ -260,13 +266,16 @@ const PLAN_TOOLS = "read, grep, find, ls, bash, ask_yagni, team_read, prototype_
260
266
  * folder) the turn also draws the plan's UI preview: it gets write and edit
261
267
  * for the preview's files, and the rule that says when to draw one.
262
268
  */
263
- const planRules = (preview) => [
269
+ const planRules = (preview, ownPlans) => [
264
270
  preview
265
271
  ? `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.`
266
272
  : `This turn you have ${PLAN_TOOLS}, and no edit or write tool.`,
267
273
  ...PLAN_RULES_BEFORE_PREVIEW,
268
274
  ...(preview ? [previewRule(preview.inputDir, preview.outDir)] : []),
269
- ...PLAN_RULES_AFTER_PREVIEW,
275
+ `${PLAN_FORMAT_RULE} ${ownPlans ? DECIDE_RULE : QUESTION_RULE}`,
276
+ PLAN_CLOSE_RULE,
277
+ PLAN_JSON_CONTRACT,
278
+ ownPlans ? OWN_PLANS_STOP : PLAN_STOP,
270
279
  ].join("\n\n");
271
280
  /** When a plan turn draws the plan's UI preview, and what it writes when the plan has nothing to show. */
272
281
  const previewRule = (inputDir, outDir) => `A person reads this plan beside its UI preview, and you draw it: read ${join(inputDir, UI_PREVIEW_BRIEF_FILE_NAME)} before you plan. ` +
@@ -281,14 +290,25 @@ const previewReask = (inputDir, outDir, problems) => `The plan has no UI preview
281
290
  const PLAN_RULES_BEFORE_PREVIEW = [
282
291
  "Run whatever settles a fact: the tests, a type check, the app, Docker, a query. Change no tracked file and commit nothing: anything this turn changes in the repository is put back before the plan's gate.",
283
292
  `Call team_read with tool "${DECISIONS_READ_TOOL}" before you ask a person anything: a question an earlier decision on this repository already answers is not a question.`,
284
- "Check the ticket before you plan on it: each premise it states that the plan relies on, against the code, the git history or the data.",
285
- ];
286
- const PLAN_RULES_AFTER_PREVIEW = [
287
- "End the turn with the plan as your last message. Open it with ## Ticket check: a table of premise | checked, or not checkable | the command, file:line or query that shows it, one row per premise. Then ## Done when: the ticket's acceptance criteria, or yours when it has none, one line each. Then ## Goal (one sentence), ## Plan (numbered steps, each naming the file or function), ## Files to modify / create (say \"new\" beside a file the plan creates), ## Checks and ## Risks, then the plan-json block. Where there is a real choice of approach, ask it as a decision question with your recommendation and its alternatives; the plan's steps follow your recommendation.",
288
- '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.',
289
- PLAN_JSON_CONTRACT,
290
- "Then stop: a fresh reviewer reads the plan next, and its major findings come back to you in this session to revise. A person approves the plan before anything is built.",
293
+ "Check the ticket before you plan on it: each premise it states that the plan relies on, against the code, the git history or the data. Read each one yourself, in this session: a searcher subagent's summary only says where to look.",
291
294
  ];
295
+ const PLAN_FORMAT_RULE = 'End the turn with the plan as your last message. Open it with ## Ticket check: a table of premise | checked, or not checkable | the command, file:line or query that shows it, one row per premise. Then ## Done when: the ticket\'s acceptance criteria, or yours when it has none, one line each. Then ## Goal (one sentence), ## Plan (numbered steps, each naming the file or function), ## Files to modify / create (say "new" beside a file the plan creates), ## Checks and ## Risks, then the plan-json block.';
296
+ /** Where a person answers the plan: a real choice is theirs to make. */
297
+ const QUESTION_RULE = "Where there is a real choice of approach, ask it as a decision question with your recommendation and its alternatives; the plan's steps follow your recommendation.";
298
+ /**
299
+ * Where the yak approves its own plans (`own-plans.md`): YAGNI takes every
300
+ * recommendation, so a question only records a change of direction.
301
+ */
302
+ const DECIDE_RULE = "This yak approves its own plans: no person answers this plan's questions, and YAGNI takes your recommendation on each one. So where there is a real choice of approach, decide on your recommendation: the plan's steps follow it, and ## Risks states it 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 the evidence (file:line, command or query) in its checked lines: the ticket's premise is false, or the right change is far larger than the ticket.";
303
+ 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.';
304
+ const PLAN_STOP = "Then stop: a fresh reviewer reads the plan next, and its major findings come back to you in this session to revise. A person approves the plan before anything is built.";
305
+ const OWN_PLANS_STOP = "Then stop: a fresh reviewer reads the plan next, and its major findings come back to you in this session to revise. Once it finds nothing major, YAGNI approves the plan for this yak and the build starts.";
306
+ /**
307
+ * How a turn treats a review's items. The host acknowledges each thread at
308
+ * take and posts the outcomes after its push (`attempts/review.ts`), with the
309
+ * marker Proctor reads, so a reply of the session's own is noise or worse.
310
+ */
311
+ const FIX_RULE = "For each item: check it against the pull request on GitHub as it is now (read it with gh, and only read), then fix it, with a test that fails without the fix where it changes behavior, or dispute it with evidence a reviewer can check. Never reply, comment, react or resolve on GitHub: YAGNI posts your outcomes on each thread after it pushes your commit.";
292
312
  /** The one message a turn sends the session. Pure. */
293
313
  export function turnMessage(facts) {
294
314
  const at = (file) => join(facts.inputDir, file);
@@ -305,14 +325,14 @@ export function turnMessage(facts) {
305
325
  parts.push(`Plan this ticket again from ${at("ticket.md")}.`);
306
326
  }
307
327
  else {
308
- parts.push("This is the plan turn of a YAGNI attempt. Work the ticket as your playbook says, up to the plan: nothing is built until a person approves it.", INPUTS(facts.inputDir));
328
+ parts.push("This is the plan turn of a YAGNI attempt. Work the ticket as your playbook says, up to the plan: nothing is built until the plan is approved.", INPUTS(facts.inputDir));
309
329
  if (facts.sentBack) {
310
330
  parts.push(`A person sent an earlier plan back: what they asked is in ${at("ticket.md")}, and that plan is ${at("sent-back-plan.md")}. ${PLANNED_ANYWAY}`);
311
331
  }
312
332
  }
313
333
  if (newSince)
314
334
  parts.push(newSince);
315
- parts.push(planRules(facts.preview ? { inputDir: facts.inputDir, outDir: facts.outDir } : undefined));
335
+ parts.push(planRules(facts.preview ? { inputDir: facts.inputDir, outDir: facts.outDir } : undefined, facts.ownPlans === true));
316
336
  return parts.join("\n\n");
317
337
  }
318
338
  if (facts.stage === "implement" && facts.resumed && !facts.continuation) {
@@ -321,7 +341,7 @@ export function turnMessage(facts) {
321
341
  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}`);
322
342
  }
323
343
  else if (facts.stage === "fix" && facts.review) {
324
- 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.`);
344
+ 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.`, FIX_RULE);
325
345
  }
326
346
  else {
327
347
  const why = facts.continuation?.priorStop
@@ -337,7 +357,7 @@ export function turnMessage(facts) {
337
357
  parts.push("Check the work on this branch against the plan: run the checks, fix only what this change broke, and commit any fix.");
338
358
  }
339
359
  if (facts.review) {
340
- 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 and write the outcomes file that section names.`);
360
+ 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 and write the outcomes file that section names.`, FIX_RULE);
341
361
  }
342
362
  }
343
363
  if (facts.handOffAnswer) {
@@ -420,7 +440,12 @@ export function parseSessionReport(text, known = new Map()) {
420
440
  /** The checks the host named in `checks.json`, by their command, with how each stands on the base. */
421
441
  function knownBaselines(inputDir, readFile) {
422
442
  const read = readMissionChecksFile(join(inputDir, MISSION_CHECKS_FILE_NAME), readFile);
423
- return new Map((read.file?.checks ?? []).map((check) => [check.command.replace(/\s+/g, " "), check.status]));
443
+ // A check the session was told to measure on the base takes no baseline
444
+ // from the record: only the session's own measurement may excuse it.
445
+ return new Map((read.file?.checks ?? []).map((check) => [
446
+ check.command.replace(/\s+/g, " "),
447
+ check.measureOnBase ? "runnable" : check.status,
448
+ ]));
424
449
  }
425
450
  /** The report's checks and its words on `result.json`: the model's own account, never the host's proof. */
426
451
  export function withReport(attempt, report) {
@@ -756,6 +781,9 @@ async function runTurn(input, deps, pulse) {
756
781
  nextStepNote: input.stage === "plan" ? null : readOrNull(join(input.inputDir, NEXT_STEP_NOTE_FILE_NAME)),
757
782
  newSinceLastTurn: readOrNull(join(input.inputDir, NEW_SINCE_LAST_TURN_FILE_NAME)),
758
783
  ...(drawsPreview ? { preview: true } : {}),
784
+ ...(input.stage === "plan" && exists(join(input.inputDir, OWN_PLANS_FILE_NAME))
785
+ ? { ownPlans: true }
786
+ : {}),
759
787
  // The env the turn's child runs on, so the message and the agents the
760
788
  // child is offered (`builtinAgents`) read one value.
761
789
  codeWriter: resolveCodeWriter(input.childEnv),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2349.1",
3
+ "version": "1.2.14-staging.2351.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": "5dde9f4b58a461d01339e98d569f6f8739f0b0e8"
61
+ "yagniSourceSha": "59922a7f75610bfa512989a2a60beb9921f016a8"
62
62
  }