@yagni-app/code-staging 1.2.14-staging.2338.1 → 1.2.14-staging.2347.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.
@@ -122,6 +122,12 @@ export interface AttemptResult extends CloudIdentity {
122
122
  * host writes each into the plan as Wright's decision.
123
123
  */
124
124
  planChanges?: PlanChange[];
125
+ /**
126
+ * The pull request's description the session wrote (`pull-request.md`,
127
+ * `sessionLane.ts`); absent when it wrote none. The host scrubs it and
128
+ * adds its own parts.
129
+ */
130
+ pullRequestText?: string;
125
131
  }
126
132
  /** The findings the result reports, blocking first. */
127
133
  export declare function openFindings(findings: readonly Finding[]): OpenFinding[];
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Who writes a session-lane build's code: the session itself, or the
3
+ * `implementer` subagent on a tier the host names. The host says which with
4
+ * each turn in {@link CODE_WRITER_ENV} (the backend's `attempts/codeWriter.ts`);
5
+ * the agents a session-lane turn is offered (`subagents.ts`) and its build
6
+ * message (`sessionLane.ts`) both read it here, so they never disagree.
7
+ *
8
+ * The session writes unless the value names a helper it can be served: unset
9
+ * and anything unreadable mean the session, so a typo never brings a helper
10
+ * back.
11
+ */
12
+ import type { ModelTier } from "./types.js";
13
+ /** `session`, or `helper:<tier>` with tier `efficient`, `standard` or `advanced`. */
14
+ export declare const CODE_WRITER_ENV = "YAGNI_GO_CODE_WRITER";
15
+ export type CodeWriter = {
16
+ writer: "session";
17
+ } | {
18
+ writer: "helper";
19
+ tier: ModelTier;
20
+ };
21
+ /**
22
+ * The value as the session reads it. A helper on `peak` is not one: the model
23
+ * proxy serves a subagent only up to `advanced`, so it would ask for a tier it
24
+ * is not served.
25
+ */
26
+ export declare function parseCodeWriter(raw: string | undefined): CodeWriter;
27
+ /**
28
+ * A value the host sent that names nobody this reads: neither `session` nor
29
+ * a helper on a tier it is served. The session writes then, and the turn says
30
+ * so (`sessionLane.ts`), so a setting that did not take never looks like one
31
+ * that is off. Null for unset, `session` and a helper that was read.
32
+ */
33
+ export declare function ignoredCodeWriter(raw: string | undefined): string | null;
34
+ /** Who writes, from an environment (the turn's child env, or `process.env`). */
35
+ export declare function resolveCodeWriter(env: NodeJS.ProcessEnv): CodeWriter;
36
+ //# sourceMappingURL=codeWriter.d.ts.map
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Who writes a session-lane build's code: the session itself, or the
3
+ * `implementer` subagent on a tier the host names. The host says which with
4
+ * each turn in {@link CODE_WRITER_ENV} (the backend's `attempts/codeWriter.ts`);
5
+ * the agents a session-lane turn is offered (`subagents.ts`) and its build
6
+ * message (`sessionLane.ts`) both read it here, so they never disagree.
7
+ *
8
+ * The session writes unless the value names a helper it can be served: unset
9
+ * and anything unreadable mean the session, so a typo never brings a helper
10
+ * back.
11
+ */
12
+ import { parseTierCap } from "./tierCap.js";
13
+ /** `session`, or `helper:<tier>` with tier `efficient`, `standard` or `advanced`. */
14
+ export const CODE_WRITER_ENV = "YAGNI_GO_CODE_WRITER";
15
+ const SESSION_WRITES = { writer: "session" };
16
+ const HELPER_PREFIX = "helper:";
17
+ /**
18
+ * The value as the session reads it. A helper on `peak` is not one: the model
19
+ * proxy serves a subagent only up to `advanced`, so it would ask for a tier it
20
+ * is not served.
21
+ */
22
+ export function parseCodeWriter(raw) {
23
+ const value = raw?.trim().toLowerCase() ?? "";
24
+ if (!value.startsWith(HELPER_PREFIX))
25
+ return SESSION_WRITES;
26
+ const tier = parseTierCap(value.slice(HELPER_PREFIX.length));
27
+ return tier && tier !== "peak" ? { writer: "helper", tier } : SESSION_WRITES;
28
+ }
29
+ /**
30
+ * A value the host sent that names nobody this reads: neither `session` nor
31
+ * a helper on a tier it is served. The session writes then, and the turn says
32
+ * so (`sessionLane.ts`), so a setting that did not take never looks like one
33
+ * that is off. Null for unset, `session` and a helper that was read.
34
+ */
35
+ export function ignoredCodeWriter(raw) {
36
+ const value = raw?.trim() ?? "";
37
+ if (!value || value.toLowerCase() === "session")
38
+ return null;
39
+ return parseCodeWriter(value).writer === "helper" ? null : value.slice(0, 60);
40
+ }
41
+ /** Who writes, from an environment (the turn's child env, or `process.env`). */
42
+ export function resolveCodeWriter(env) {
43
+ return parseCodeWriter(env[CODE_WRITER_ENV]);
44
+ }
45
+ //# sourceMappingURL=codeWriter.js.map
@@ -36,7 +36,7 @@ import type { PipelineStage } from "./types.js";
36
36
  * each fix. Its words never name the harness (the branding scrub rewrites
37
37
  * that word) and open with no bullet.
38
38
  */
39
- export declare const WORK_A_TICKET_SKILL = "---\nname: work-a-ticket\ndescription: How YAGNI works a ticket in one session, from reading it to a committed, honestly reported change. Read, run and plan with options and a recommendation, stop for approval, build the smallest change with subagents, verify with a fresh one, commit and report.\n---\n\n# How YAGNI works a ticket\n\nYou work one ticket for a Team, in its repository, checked out in your working directory on a machine that is yours for the whole run. A person approves your plan before anything is built. YAGNI pushes your commits, opens the pull request, waits for CI and the review, and brings you back with what they asked. Each time YAGNI resumes you, its message says which turn this is and what it needs back. This is a playbook, not a contract: use your judgement, and say what you did.\n\n## 1. Understand the ticket\n\nRead the ticket, its evidence and every image it names, the design, the memo, the checks, the Team's playbook and the Plan line's instructions. Read the code the ticket touches, and send searcher subagents for wide reads, in parallel. Settle facts by running things rather than guessing: the tests, a type check, the app, Docker, a query. Installing what a check needs is fine. Read the decision ledger (team_read with yagni_decisions_read_for_repository) and ask_yagni before you ask a person anything.\n\nCheck the ticket before you build on it. Each thing it states and your plan relies on (a bug, a file, a behaviour, a number) is a premise: check it against the code, the git history or the data, and keep the command, file or query that shows it. A premise you cannot check is marked so, never assumed. Take \"Done when\" from the ticket's acceptance criteria, or write it when the ticket has none. When the check shows the problem is already gone, your plan recommends closing the ticket, with the evidence, instead of a change.\n\n## 2. Plan, then stop\n\nOpen the plan with the ticket check and \"Done when\". Name the files and the steps. Where there is a real choice of approach, give the options, each with what it changes and what it costs, and recommend one. End the turn with the plan in the format the message gives, and stop. A fresh reviewer then reads your plan against the ticket and the code; when it finds something major, its findings come back to you in this session: check each one, revise the plan for the real ones, and send the whole plan again. You have no edit or write tool until the plan is approved, and anything you change in tracked files before then is put back.\n\n## 3. Build\n\nThe option the person approved is binding. The plan's steps are guidance: when the code shows a better step, take it, and record the departure and why. Prefer the smallest change that meets the ticket: no drive-by refactors and no files the ticket does not need. Hand fully specified chunks of work (the files, the change, the check that proves it) to the implementer subagent, and keep the judgement calls yourself. Run the checks that prove the change. A check that already failed on the unchanged code is not yours to fix; say so.\n\n## 4. Verify\n\nBefore you finish, dispatch a fresh verification subagent on your diff, with the ticket and the plan, and fix what it finds that is real. Send one. Only for a risky change (a migration, auth, money, data that cannot be restored) send two or three with different lenses and treat their agreement as confirmation.\n\n## 5. Commit and report\n\nCommit on the branch you are on, with clear messages. Never push, never open or edit a pull request, and never change the git identity or config. Write the report the message asks for last, and honestly: each check you ran with its real exit code, what you could not verify and why, and every departure from the plan and why. A check you did not run is not a pass.\n\n## Rules that always hold\n\nNever fabricate a path, a result or a check: \"not found\" and \"not verified\" are answers. Never print, commit or send a token or a variable's value. If the disk fills (\"no space left on device\"), stop and say so; do not delete or prune to go on. Call record_decision only for a consequential product or architecture call the plan did not settle.\n";
39
+ export declare const WORK_A_TICKET_SKILL = "---\nname: work-a-ticket\ndescription: How YAGNI works a ticket in one session, from reading it to a committed, honestly reported change. Read, run and plan with options and a recommendation, stop for approval, build the smallest change yourself, verify with a fresh subagent, commit and report.\n---\n\n# How YAGNI works a ticket\n\nYou work one ticket for a Team, in its repository, checked out in your working directory on a machine that is yours for the whole run. A person approves your plan before anything is built. YAGNI pushes your commits, opens the pull request, waits for CI and the review, and brings you back with what they asked. Each time YAGNI resumes you, its message says which turn this is and what it needs back. This is a playbook, not a contract: use your judgement, and say what you did.\n\n## 1. Understand the ticket\n\nRead the ticket, its evidence and every image it names, the design, the memo, the checks, the Team's playbook and the Plan line's instructions. Read the code the ticket touches, and send searcher subagents for wide reads, in parallel. Settle facts by running things rather than guessing: the tests, a type check, the app, Docker, a query. Installing what a check needs is fine. Read the decision ledger (team_read with yagni_decisions_read_for_repository) and ask_yagni before you ask a person anything.\n\nCheck the ticket before you build on it. Each thing it states and your plan relies on (a bug, a file, a behaviour, a number) is a premise: check it against the code, the git history or the data, and keep the command, file or query that shows it. A premise you cannot check is marked so, never assumed. Take \"Done when\" from the ticket's acceptance criteria, or write it when the ticket has none. When the check shows the problem is already gone, your plan recommends closing the ticket, with the evidence, instead of a change.\n\n## 2. Plan, then stop\n\nOpen the plan with the ticket check and \"Done when\". Name the files and the steps. Where there is a real choice of approach, give the options, each with what it changes and what it costs, and recommend one. End the turn with the plan in the format the message gives, and stop. A fresh reviewer then reads your plan against the ticket and the code; when it finds something major, its findings come back to you in this session: check each one, revise the plan for the real ones, and send the whole plan again. You have no edit or write tool until the plan is approved, and anything you change in tracked files before then is put back.\n\n## 3. Build\n\nThe option the person approved is binding. The plan's steps are guidance: when the code shows a better step, take it, and record the departure and why. Prefer the smallest change that meets the ticket: no drive-by refactors and no files the ticket does not need. Write the change yourself, in this session, with the ticket, the plan and the code you read in mind. Only when this turn's message names a helper, hand it fully specified chunks of work (the files, the change, the check that proves it) and keep the judgement calls yourself. Run the checks that prove the change. A check that already failed on the unchanged code is not yours to fix; say so.\n\n## 4. Verify\n\nBefore you finish, dispatch a fresh verification subagent on your diff, with the ticket and the plan, and fix what it finds that is real. Send one. Only for a risky change (a migration, auth, money, data that cannot be restored) send two or three with different lenses and treat their agreement as confirmation.\n\n## 5. Commit and report\n\nCommit on the branch you are on, with clear messages. Never push, never open or edit a pull request, and never change the git identity or config. Write the report the message asks for last, and honestly: each check you ran with its real exit code, what you could not verify and why, and every departure from the plan and why. A check you did not run is not a pass.\n\n## Rules that always hold\n\nNever fabricate a path, a result or a check: \"not found\" and \"not verified\" are answers. Never print, commit or send a token or a variable's value. If the disk fills (\"no space left on device\"), stop and say so; do not delete or prune to go on. Call record_decision only for a consequential product or architecture call the plan did not settle.\n";
40
40
  /** Persona body keyed by the agent name referenced in `stages.ts`. */
41
41
  export declare const PERSONA_BODIES: Record<string, string>;
42
42
  /**
@@ -82,7 +82,7 @@ const CLOUD_PLANNER_FINISH = `Complete the task fully: do not gold-plate, but do
82
82
  */
83
83
  export const WORK_A_TICKET_SKILL = `---
84
84
  name: work-a-ticket
85
- description: How YAGNI works a ticket in one session, from reading it to a committed, honestly reported change. Read, run and plan with options and a recommendation, stop for approval, build the smallest change with subagents, verify with a fresh one, commit and report.
85
+ description: How YAGNI works a ticket in one session, from reading it to a committed, honestly reported change. Read, run and plan with options and a recommendation, stop for approval, build the smallest change yourself, verify with a fresh subagent, commit and report.
86
86
  ---
87
87
 
88
88
  # How YAGNI works a ticket
@@ -101,7 +101,7 @@ Open the plan with the ticket check and "Done when". Name the files and the step
101
101
 
102
102
  ## 3. Build
103
103
 
104
- The option the person approved is binding. The plan's steps are guidance: when the code shows a better step, take it, and record the departure and why. Prefer the smallest change that meets the ticket: no drive-by refactors and no files the ticket does not need. Hand fully specified chunks of work (the files, the change, the check that proves it) to the implementer subagent, and keep the judgement calls yourself. Run the checks that prove the change. A check that already failed on the unchanged code is not yours to fix; say so.
104
+ The option the person approved is binding. The plan's steps are guidance: when the code shows a better step, take it, and record the departure and why. Prefer the smallest change that meets the ticket: no drive-by refactors and no files the ticket does not need. Write the change yourself, in this session, with the ticket, the plan and the code you read in mind. Only when this turn's message names a helper, hand it fully specified chunks of work (the files, the change, the check that proves it) and keep the judgement calls yourself. Run the checks that prove the change. A check that already failed on the unchanged code is not yours to fix; say so.
105
105
 
106
106
  ## 4. Verify
107
107
 
@@ -2,9 +2,10 @@
2
2
  * The session lane (`yagni go --headless --cloud --session`, 2026-10-28): a
3
3
  * ticket runs as ONE pi session, on the strongest tier, in one Machine the
4
4
  * host keeps for the whole run, in place of the cloud lane's stage graph.
5
- * The model works the ticket itself, with the `subagent` tool for what it
6
- * hands off, and the host meets it at the same checkpoints the cloud lane
7
- * has, by the same files.
5
+ * The model works the ticket itself and writes its change itself, with the
6
+ * `subagent` tool for wide reads and a fresh verifier (a helper that writes
7
+ * for it only when the host names one, `codeWriter.ts`), and the host meets
8
+ * it at the same checkpoints the cloud lane has, by the same files.
8
9
  *
9
10
  * Each host execution is one TURN of that session: this process runs one pi
10
11
  * child on the session file the run keeps under the run user's home
@@ -43,6 +44,7 @@
43
44
  * own clock.
44
45
  */
45
46
  import { type PlacedValues } from "../placedValues.js";
47
+ import { type CodeWriter } from "./codeWriter.js";
46
48
  import { type AttemptResult, type CloudIdentity, type CloudStage } from "./cloud.js";
47
49
  import type { ContinuationInputs } from "./continuation.js";
48
50
  import { type PlanChange } from "./planChanges.js";
@@ -63,6 +65,17 @@ export declare const SESSION_CALLER_LABEL = "go:session";
63
65
  export declare function isSessionLaneTurn(env?: NodeJS.ProcessEnv): boolean;
64
66
  /** The model's own account of a turn that builds, beside `result.json` in the output folder. */
65
67
  export declare const SESSION_REPORT_FILE_NAME = "session-report.json";
68
+ /**
69
+ * The pull request's description as the session writes it, beside its
70
+ * report. A file of its own, never a field of the report: Markdown of many
71
+ * lines inside JSON is easy to break, and a report that does not read loses
72
+ * the checks. The host scrubs it and adds its own parts.
73
+ */
74
+ export declare const PULL_REQUEST_FILE_NAME = "pull-request.md";
75
+ /** The most of the description a result carries (the host's bound, `MAX_PULL_REQUEST_TEXT_CHARS`). */
76
+ export declare const MAX_PULL_REQUEST_TEXT_CHARS = 20000;
77
+ /** The description as the result carries it: trimmed and bounded, or null when the file is missing or empty. */
78
+ export declare function pullRequestTextOf(text: string | null): string | null;
66
79
  /** What a plan turn may use: everything that reads or runs, nothing that edits. */
67
80
  export declare const PLAN_TURN_TOOLS: string[];
68
81
  /** What a turn that builds may use: the plan turn's tools and the writes. */
@@ -97,6 +110,8 @@ export interface TurnFacts {
97
110
  * (YAG-1162). Any stage, the plan's included.
98
111
  */
99
112
  newSinceLastTurn?: string | null;
113
+ /** Who writes the change, as the host said (`codeWriter.ts`); absent, the session. */
114
+ codeWriter?: CodeWriter;
100
115
  }
101
116
  /** The file the host writes a person's note for the next step to (`attempts/inputs.ts`). */
102
117
  export declare const NEXT_STEP_NOTE_FILE_NAME = "next-step-note.md";
@@ -2,9 +2,10 @@
2
2
  * The session lane (`yagni go --headless --cloud --session`, 2026-10-28): a
3
3
  * ticket runs as ONE pi session, on the strongest tier, in one Machine the
4
4
  * host keeps for the whole run, in place of the cloud lane's stage graph.
5
- * The model works the ticket itself, with the `subagent` tool for what it
6
- * hands off, and the host meets it at the same checkpoints the cloud lane
7
- * has, by the same files.
5
+ * The model works the ticket itself and writes its change itself, with the
6
+ * `subagent` tool for wide reads and a fresh verifier (a helper that writes
7
+ * for it only when the host names one, `codeWriter.ts`), and the host meets
8
+ * it at the same checkpoints the cloud lane has, by the same files.
8
9
  *
9
10
  * Each host execution is one TURN of that session: this process runs one pi
10
11
  * child on the session file the run keeps under the run user's home
@@ -47,6 +48,7 @@ import { homedir } from "node:os";
47
48
  import { isAbsolute, join, relative } from "node:path";
48
49
  import { openPlacedValues } from "../placedValues.js";
49
50
  import { scanChange } from "./changeScan.js";
51
+ import { CODE_WRITER_ENV, ignoredCodeWriter, resolveCodeWriter, } from "./codeWriter.js";
50
52
  import { completeCloudSession, RESULT_FILE_NAME, } from "./cloud.js";
51
53
  import { finishExec } from "./finish.js";
52
54
  import { MISSION_CHECKS_FILE_NAME, readMissionChecksFile } from "./missionChecks.js";
@@ -77,6 +79,20 @@ export function isSessionLaneTurn(env = process.env) {
77
79
  }
78
80
  /** The model's own account of a turn that builds, beside `result.json` in the output folder. */
79
81
  export const SESSION_REPORT_FILE_NAME = "session-report.json";
82
+ /**
83
+ * The pull request's description as the session writes it, beside its
84
+ * report. A file of its own, never a field of the report: Markdown of many
85
+ * lines inside JSON is easy to break, and a report that does not read loses
86
+ * the checks. The host scrubs it and adds its own parts.
87
+ */
88
+ export const PULL_REQUEST_FILE_NAME = "pull-request.md";
89
+ /** The most of the description a result carries (the host's bound, `MAX_PULL_REQUEST_TEXT_CHARS`). */
90
+ export const MAX_PULL_REQUEST_TEXT_CHARS = 20_000;
91
+ /** The description as the result carries it: trimmed and bounded, or null when the file is missing or empty. */
92
+ export function pullRequestTextOf(text) {
93
+ const words = text?.trim() ?? "";
94
+ return words ? words.slice(0, MAX_PULL_REQUEST_TEXT_CHARS) : null;
95
+ }
80
96
  /** What a plan turn may use: everything that reads or runs, nothing that edits. */
81
97
  export const PLAN_TURN_TOOLS = [
82
98
  "read",
@@ -165,13 +181,24 @@ const REPORT_CONTRACT = (outDir) => `Last, write ${join(outDir, SESSION_REPORT_F
165
181
  'not a pass, and goes in "notVerified". "baseline" is "fails_on_base" only when the check already ' +
166
182
  'failed on the unchanged code. "planChanges" lists only a step you did differently than plan.md ' +
167
183
  "says, or left out, never a choice the plan left to you. Then end your turn.";
168
- const BUILD_RULES = (outDir) => [
184
+ /** The build rule that says who writes the change: the host's value, in words. */
185
+ const WRITER_RULE = (who) => who.writer === "helper"
186
+ ? `- Hand fully specified chunks to the implementer subagent (it runs on the ${who.tier} tier and shares none of your context) and wide reads to searcher subagents, in parallel where they touch different files; keep the judgement calls yourself.`
187
+ : "- Write the change yourself, in this session: you hold the ticket, the plan and the code you read, and no subagent writes it for you. Send wide reads to searcher subagents, in parallel.";
188
+ const PULL_REQUEST_CONTRACT = (outDir) => `Before the report, write ${join(outDir, PULL_REQUEST_FILE_NAME)}: the description of this attempt's pull request ` +
189
+ "as it stands after this turn, whole, in Markdown, for a reviewer who has not read the ticket. Lead with the product, " +
190
+ 'never the files: what changes for the user, or one line "No product change: <what this is>". For a product change ' +
191
+ "give a **Before:** and **After:** pair as the user meets it. Then what you verified and how, and what you did not " +
192
+ "verify and why. Short sentences, no file-by-file list. Never quote command output, a log, or a value from the " +
193
+ "environment: everyone on the repository reads it. Write no title, checks table or plan version: YAGNI adds those.";
194
+ const BUILD_RULES = (outDir, who) => [
169
195
  "Write tools are on now. Work as your playbook says:",
170
196
  "- Prefer the smallest change that meets the ticket.",
171
- "- Hand fully specified chunks to the implementer subagent and wide reads to searcher subagents, in parallel where they touch different files; keep the judgement calls yourself.",
197
+ WRITER_RULE(who),
172
198
  "- Run the checks that prove the change (checks.json, the plan's checks) and fix what your change breaks.",
173
199
  "- 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.",
174
200
  "- Commit on the branch you are on. Never push and never open or edit a pull request: YAGNI pushes your commits and opens it.",
201
+ `- ${PULL_REQUEST_CONTRACT(outDir)}`,
175
202
  `- ${REPORT_CONTRACT(outDir)}`,
176
203
  ].join("\n");
177
204
  const INPUTS = (inputDir) => [
@@ -257,7 +284,7 @@ export function turnMessage(facts) {
257
284
  parts.push(note);
258
285
  if (newSince)
259
286
  parts.push(newSince);
260
- parts.push(BUILD_RULES(facts.outDir));
287
+ parts.push(BUILD_RULES(facts.outDir, facts.codeWriter ?? { writer: "session" }));
261
288
  return parts.join("\n\n");
262
289
  }
263
290
  const MAX_REPORTED_CHECKS = 40;
@@ -628,6 +655,12 @@ async function runTurn(input, deps, pulse) {
628
655
  },
629
656
  now,
630
657
  });
658
+ // On the CLI's own stderr, whose tail the host logs: a value that named
659
+ // nobody is the session writing, said once per turn.
660
+ const ignoredWriter = ignoredCodeWriter(input.childEnv[CODE_WRITER_ENV]);
661
+ if (ignoredWriter) {
662
+ input.writeErr(`Ignoring ${CODE_WRITER_ENV}=${JSON.stringify(ignoredWriter)}: it names neither the session nor a helper on a tier a subagent is served, so the session writes its change itself.`);
663
+ }
631
664
  const message = turnMessage({
632
665
  stage: input.stage,
633
666
  resumed,
@@ -639,6 +672,9 @@ async function runTurn(input, deps, pulse) {
639
672
  sentBack: exists(join(input.inputDir, "sent-back-plan.md")),
640
673
  nextStepNote: input.stage === "plan" ? null : readOrNull(join(input.inputDir, NEXT_STEP_NOTE_FILE_NAME)),
641
674
  newSinceLastTurn: readOrNull(join(input.inputDir, NEW_SINCE_LAST_TURN_FILE_NAME)),
675
+ // The env the turn's child runs on, so the message and the agents the
676
+ // child is offered (`builtinAgents`) read one value.
677
+ codeWriter: resolveCodeWriter(input.childEnv),
642
678
  });
643
679
  const notes = [];
644
680
  const stages = [];
@@ -769,7 +805,7 @@ async function runTurn(input, deps, pulse) {
769
805
  }, ran);
770
806
  const noted = { ...done.attempt, notes: [...notes, ...done.attempt.notes] };
771
807
  const attempt = writes
772
- ? withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)))
808
+ ? withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)), pullRequestTextOf(readOrNull(join(input.outDir, PULL_REQUEST_FILE_NAME))))
773
809
  : noted;
774
810
  // The cloud lane's finish wrote `result.json`; it is written again when
775
811
  // this turn adds to it (the model's account, the plan turn's put-back).
@@ -798,13 +834,23 @@ async function planWithBlock(run, turn, signal) {
798
834
  return { run: took ? again : run, asked: [again] };
799
835
  }
800
836
  /**
801
- * A writing turn's result with the model's own account folded in, and a
837
+ * A writing turn's result with the model's own account and its pull
838
+ * request's description folded in (one that wrote none says so), and a
802
839
  * clean turn that committed nothing read as having found nothing to change:
803
840
  * the host's `no_changes`, which it finishes as a clean one when the turn
804
841
  * verified work an earlier turn pushed.
805
842
  */
806
- function withSessionAccount(attempt, report) {
807
- const folded = withReport(attempt, report);
843
+ function withSessionAccount(attempt, report, pullRequestText) {
844
+ const reported = withReport(attempt, report);
845
+ const folded = pullRequestText
846
+ ? { ...reported, pullRequestText }
847
+ : {
848
+ ...reported,
849
+ notes: [
850
+ ...reported.notes,
851
+ `The session wrote no ${PULL_REQUEST_FILE_NAME}, so its pull request's description is YAGNI's own.`,
852
+ ],
853
+ };
808
854
  return folded.stopReason === "clean" && folded.commits.length === 0
809
855
  ? { ...folded, stopReason: "no_changes" }
810
856
  : folded;
@@ -13,7 +13,8 @@
13
13
  * any Claude Code plugin `agents/` dirs the launcher passed via
14
14
  * `YAGNI_CLAUDE_AGENT_DIRS` (project beats user beats plugin on a name
15
15
  * collision). A built-in `general` agent is always available, so the tool
16
- * works in a repo with no definitions at all.
16
+ * works in a repo with no definitions at all; a session-lane turn is the one
17
+ * exception (see {@link builtinAgents}).
17
18
  * Claude model names map onto YAGNI tiers (opus→advanced, sonnet→standard,
18
19
  * haiku→efficient); unknown models run on standard.
19
20
  */
@@ -72,6 +73,16 @@ export interface SubagentDef {
72
73
  * it declares.
73
74
  */
74
75
  export declare function verificationTier(env?: NodeJS.ProcessEnv): ModelTier;
76
+ /**
77
+ * The built-in agents a process is offered. Everywhere but a session-lane
78
+ * turn: all four. A session-lane turn (`pipeline/sessionLane.ts`) writes its
79
+ * change itself, so it is offered no built-in that writes for it: no
80
+ * `general`, and no `implementer` unless the host names a helper and its tier
81
+ * (`pipeline/codeWriter.ts`). Taken out of what is offered, never only asked
82
+ * in the turn's message, so it does not rest on the model obeying. A
83
+ * repository's own agents load over these as everywhere.
84
+ */
85
+ export declare function builtinAgents(env: NodeJS.ProcessEnv): SubagentDef[];
75
86
  /** Claude Code model names → YAGNI tiers; YAGNI tiers pass through. */
76
87
  export declare function mapModelTier(model: string | undefined): ModelTier;
77
88
  /**
@@ -13,7 +13,8 @@
13
13
  * any Claude Code plugin `agents/` dirs the launcher passed via
14
14
  * `YAGNI_CLAUDE_AGENT_DIRS` (project beats user beats plugin on a name
15
15
  * collision). A built-in `general` agent is always available, so the tool
16
- * works in a repo with no definitions at all.
16
+ * works in a repo with no definitions at all; a session-lane turn is the one
17
+ * exception (see {@link builtinAgents}).
17
18
  * Claude model names map onto YAGNI tiers (opus→advanced, sonnet→standard,
18
19
  * haiku→efficient); unknown models run on standard.
19
20
  */
@@ -24,6 +25,7 @@ import { parseFrontmatter, } from "@earendil-works/pi-coding-agent";
24
25
  import { Type } from "typebox";
25
26
  import { sanitizeCallerSegment } from "./config.js";
26
27
  import { logEvent } from "./errorSink.js";
28
+ import { resolveCodeWriter } from "./pipeline/codeWriter.js";
27
29
  import { withResilience } from "./pipeline/resilience.js";
28
30
  import { runStage } from "./pipeline/runner.js";
29
31
  import { isSessionLaneTurn } from "./pipeline/sessionLane.js";
@@ -245,6 +247,26 @@ function verificationAgent(env) {
245
247
  source: "builtin",
246
248
  };
247
249
  }
250
+ /**
251
+ * The built-in agents a process is offered. Everywhere but a session-lane
252
+ * turn: all four. A session-lane turn (`pipeline/sessionLane.ts`) writes its
253
+ * change itself, so it is offered no built-in that writes for it: no
254
+ * `general`, and no `implementer` unless the host names a helper and its tier
255
+ * (`pipeline/codeWriter.ts`). Taken out of what is offered, never only asked
256
+ * in the turn's message, so it does not rest on the model obeying. A
257
+ * repository's own agents load over these as everywhere.
258
+ */
259
+ export function builtinAgents(env) {
260
+ if (!isSessionLaneTurn(env)) {
261
+ return [GENERAL_AGENT, SEARCHER_AGENT, IMPLEMENTER_AGENT, verificationAgent(env)];
262
+ }
263
+ const who = resolveCodeWriter(env);
264
+ return [
265
+ SEARCHER_AGENT,
266
+ ...(who.writer === "helper" ? [{ ...IMPLEMENTER_AGENT, model: who.tier }] : []),
267
+ verificationAgent(env),
268
+ ];
269
+ }
248
270
  // Concrete tiers a subagent can actually run on. `balanced` is deliberately NOT
249
271
  // a member here even though it is a member of `ModelTier`: a subagent needs
250
272
  // ONE model for its whole run, and balanced is a session-level routing policy,
@@ -342,7 +364,7 @@ export function discoverSubagents(deps) {
342
364
  const home = deps.homeDir ?? homedir();
343
365
  const env = deps.env ?? process.env;
344
366
  const layers = [
345
- [GENERAL_AGENT, SEARCHER_AGENT, IMPLEMENTER_AGENT, verificationAgent(env)],
367
+ builtinAgents(env),
346
368
  ...pluginAgentDirs(env).map((dir) => loadAgentsFromDir(dir, "plugin")),
347
369
  loadAgentsFromDir(join(home, ".claude", "agents"), "user-claude"),
348
370
  loadAgentsFromDir(join(deps.cwd, ".pi", "agents"), "project-pi"),
@@ -470,7 +492,9 @@ const parameters = Type.Object({
470
492
  task: Type.Optional(Type.String({
471
493
  description: "The self-contained task. Include everything needed: the subagent shares none of your context.",
472
494
  })),
473
- agent: Type.Optional(Type.String({ description: "Agent name (see /agents). Defaults to general." })),
495
+ agent: Type.Optional(Type.String({
496
+ description: "Agent name (see /agents). Defaults to general where it is offered.",
497
+ })),
474
498
  tasks: Type.Optional(Type.Array(Type.Object({
475
499
  task: Type.String(),
476
500
  agent: Type.Optional(Type.String({
@@ -577,8 +601,12 @@ export function makeSubagentTool(deps = {}) {
577
601
  // the list is current as of session launch; /agents shows the live set.
578
602
  // Fails soft: discovery problems never block the tool.
579
603
  let agentListBlock = "";
604
+ // Whether a call that names no agent has one to run as: not in a
605
+ // session-lane turn, which is offered no `general`.
606
+ let hasGeneral = true;
580
607
  try {
581
608
  const discovered = discover({ cwd: process.cwd(), homeDir: deps.homeDir, env: deps.env });
609
+ hasGeneral = discovered.some((a) => a.name === GENERAL_AGENT_NAME);
582
610
  if (discovered.length > 0) {
583
611
  agentListBlock =
584
612
  " Available agents (first sentence only; /agents lists them in full):\n" +
@@ -602,7 +630,9 @@ export function makeSubagentTool(deps = {}) {
602
630
  "a compressed report. Use it for context-heavy exploration you don't need blow-by-blow, or to " +
603
631
  "run independent tasks in parallel via `tasks`. The subagent shares NONE of your conversation: " +
604
632
  "spell out the task completely. Agents come from this repo's .claude/agents and .pi/agents " +
605
- "(list them with /agents); omit `agent` for the general-purpose one. The list below was " +
633
+ `(list them with /agents); ${hasGeneral
634
+ ? "omit `agent` for the general-purpose one"
635
+ : "name the agent on every task, since no general-purpose one was offered at session launch"}. The list below was ` +
606
636
  "captured at session launch — if the session's cwd differs from the launch cwd it may be " +
607
637
  "stale; an unknown name is a hard error, so trust /agents over this list when they differ." +
608
638
  agentListBlock,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2338.1",
3
+ "version": "1.2.14-staging.2347.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": "b21f46be1a45b4fc1810754e49f64635b25f748e"
61
+ "yagniSourceSha": "a7e15e2da4a2f5b019b2b21df9208e4768fe5fb5"
62
62
  }