@yagni-app/code-staging 1.2.14-staging.2374.1 → 1.2.14-staging.2376.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.
@@ -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 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. Then you review your own plan in this session, round by round, at most four: check it against the ticket and the code, fix what you find in place, and send the whole plan again with the round's verdict. 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";
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, run its checks, 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. Then you review your own plan in this session, round by round, at most four: check it against the ticket and the code, fix what you find in place, and send the whole plan again with the round's verdict. 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. Check your own work\n\nBefore you commit, run every check in the repository's CI that your diff can trip, and see each new test fail without your change before it passes with it. Fix what your change breaks. No helper reviews or judges your change: once YAGNI opens the pull request, its review reads the diff.\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 yourself, verify with a fresh subagent, 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, run its checks, commit and report.
86
86
  ---
87
87
 
88
88
  # How YAGNI works a ticket
@@ -103,9 +103,9 @@ Open the plan with the ticket check and "Done when". Name the files and the step
103
103
 
104
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
- ## 4. Verify
106
+ ## 4. Check your own work
107
107
 
108
- 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. 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.
108
+ Before you commit, run every check in the repository's CI that your diff can trip, and see each new test fail without your change before it passes with it. Fix what your change breaks. No helper reviews or judges your change: once YAGNI opens the pull request, its review reads the diff.
109
109
 
110
110
  ## 5. Commit and report
111
111
 
@@ -2,10 +2,11 @@
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 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.
5
+ * The model works the ticket itself, writes its change itself and runs its
6
+ * own checks, with the `subagent` tool for wide reads (a helper that writes
7
+ * for it only when the host names one, `codeWriter.ts`; no helper that judges
8
+ * it: the pull request's review does), and the host meets it at the same
9
+ * checkpoints the cloud lane has, by the same files.
9
10
  *
10
11
  * Each host execution is one TURN of that session: this process runs one pi
11
12
  * child on the session file the run keeps under the run user's home
@@ -28,7 +29,7 @@
28
29
  * written before a person approves (the host also checks the checkout out
29
30
  * again before the build, `checkOutTurnStart`).
30
31
  * - Build, fix and verify turns: the write tools come on. The model builds,
31
- * verifies with a fresh `verification` subagent, commits and never
32
+ * runs the checks its diff can trip, commits and never
32
33
  * pushes, and writes its own account to `session-report.json`. This
33
34
  * process then runs what the cloud lane's finish runs (the secret and
34
35
  * binary scan, a commit of anything left, in the ticket's repository
@@ -2,10 +2,11 @@
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 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.
5
+ * The model works the ticket itself, writes its change itself and runs its
6
+ * own checks, with the `subagent` tool for wide reads (a helper that writes
7
+ * for it only when the host names one, `codeWriter.ts`; no helper that judges
8
+ * it: the pull request's review does), and the host meets it at the same
9
+ * checkpoints the cloud lane has, by the same files.
9
10
  *
10
11
  * Each host execution is one TURN of that session: this process runs one pi
11
12
  * child on the session file the run keeps under the run user's home
@@ -28,7 +29,7 @@
28
29
  * written before a person approves (the host also checks the checkout out
29
30
  * again before the build, `checkOutTurnStart`).
30
31
  * - Build, fix and verify turns: the write tools come on. The model builds,
31
- * verifies with a fresh `verification` subagent, commits and never
32
+ * runs the checks its diff can trip, commits and never
32
33
  * pushes, and writes its own account to `session-report.json`. This
33
34
  * process then runs what the cloud lane's finish runs (the secret and
34
35
  * binary scan, a commit of anything left, in the ticket's repository
@@ -260,7 +261,6 @@ const BUILD_RULES = (outDir, who) => [
260
261
  "- 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.",
261
262
  "- 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.",
262
263
  "- 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.",
263
- "- 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.",
264
264
  "- Commit on the branch you are on. Never push and never open or edit a pull request: YAGNI pushes your commits and opens it.",
265
265
  `- ${PULL_REQUEST_CONTRACT(outDir)}`,
266
266
  `- ${REPORT_CONTRACT(outDir)}`,
@@ -49,6 +49,12 @@ export declare const MAX_PARALLEL_SUBAGENTS_ULTRA = 8;
49
49
  * subagent would inherit.
50
50
  */
51
51
  export declare const DEFAULT_SUBAGENT_TOOLS: string[];
52
+ /**
53
+ * The read-only surface: the searcher's, and every non-built-in agent's in a
54
+ * session-lane turn, whatever its file declares. No bash: a shell writes as
55
+ * surely as edit does.
56
+ */
57
+ export declare const READ_ONLY_SUBAGENT_TOOLS: string[];
52
58
  export type SubagentSource = "project-claude" | "project-pi" | "user-claude" | "plugin" | "builtin";
53
59
  /**
54
60
  * Claude Code plugin `agents/` dirs, delimiter-joined by the yagni launcher
@@ -64,23 +70,16 @@ export interface SubagentDef {
64
70
  body: string;
65
71
  source: SubagentSource;
66
72
  }
67
- /**
68
- * The tier the built-in verification agent asks for: `peak` in a session-lane
69
- * turn (`pipeline/sessionLane.ts`), the one place the proxy serves a verifier
70
- * above its advanced ceiling for subagents, and `advanced` everywhere else (the
71
- * CLI, desktop, the attempt lane's stage graph), so a request never asks for a
72
- * tier it would not be served. A repo's own `verification` agent keeps the tier
73
- * it declares.
74
- */
75
- export declare function verificationTier(env?: NodeJS.ProcessEnv): ModelTier;
76
73
  /**
77
74
  * The built-in agents a process is offered. Everywhere but a session-lane
78
75
  * 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.
76
+ * change itself and runs its own checks, and the pull request's review is the
77
+ * independent one, so it is offered no built-in that writes or judges for it:
78
+ * no `general`, no `verification`, and no `implementer` unless the host names
79
+ * a helper and its tier (`pipeline/codeWriter.ts`). Taken out of what is
80
+ * offered, never only asked in the turn's message, so it does not rest on the
81
+ * model obeying. On that lane a repository's own agents load read-only and
82
+ * never replace one of these ({@link discoverSubagents}, {@link buildSubagentStage}).
84
83
  */
85
84
  export declare function builtinAgents(env: NodeJS.ProcessEnv): SubagentDef[];
86
85
  /** Claude Code model names → YAGNI tiers; YAGNI tiers pass through. */
@@ -94,7 +93,7 @@ export declare function parseAgentMarkdown(content: string, fallbackName: string
94
93
  export interface DiscoverDeps {
95
94
  cwd: string;
96
95
  homeDir?: string;
97
- /** Env seam for the plugin agent dirs and the verification agent's tier (defaults to process.env). */
96
+ /** Env seam for the plugin agent dirs and whether this is a session-lane turn (defaults to process.env). */
98
97
  env?: NodeJS.ProcessEnv;
99
98
  }
100
99
  /**
@@ -102,11 +101,21 @@ export interface DiscoverDeps {
102
101
  * dirs (launcher-provided), then user `~/.claude/agents`, then the repo's
103
102
  * `.pi/agents` and `.claude/agents` — later wins on a name collision, so a
104
103
  * project definition beats a user one beats a plugin one beats the built-in.
104
+ * In a session-lane turn a built-in the turn is offered keeps its name: an
105
+ * agent file named like it does not replace it.
105
106
  */
106
107
  export declare function discoverSubagents(deps: DiscoverDeps): SubagentDef[];
107
108
  export declare function formatAgentList(agents: SubagentDef[]): string;
109
+ /**
110
+ * `sessionLane`: the process is a session-lane turn, where an agent that is
111
+ * not built in (a repository's, the user's, a plugin's) runs with
112
+ * {@link READ_ONLY_SUBAGENT_TOOLS} whatever its file declares, a file with no
113
+ * tools list included: nothing but the session writes a yak's code. Built-ins
114
+ * keep their own tools (the helper implementer, when the host names one).
115
+ */
108
116
  export declare function buildSubagentStage(def: SubagentDef, task: string, opts?: {
109
117
  grounded?: boolean;
118
+ sessionLane?: boolean;
110
119
  }): {
111
120
  stage: PipelineStage;
112
121
  ctx: {
@@ -97,6 +97,12 @@ export const DEFAULT_SUBAGENT_TOOLS = [
97
97
  "write",
98
98
  "ask_yagni",
99
99
  ];
100
+ /**
101
+ * The read-only surface: the searcher's, and every non-built-in agent's in a
102
+ * session-lane turn, whatever its file declares. No bash: a shell writes as
103
+ * surely as edit does.
104
+ */
105
+ export const READ_ONLY_SUBAGENT_TOOLS = ["read", "grep", "find", "ls", "ask_yagni"];
100
106
  /**
101
107
  * Claude Code plugin `agents/` dirs, delimiter-joined by the yagni launcher
102
108
  * (see yagni-code-cli claudeCompat.ts — trust gating happens there).
@@ -152,7 +158,7 @@ const SEARCHER_AGENT = {
152
158
  "summarizing files. Read-only. Use for any broad look-around you would " +
153
159
  "otherwise do with a chain of grep/read calls.",
154
160
  model: "efficient",
155
- tools: ["read", "grep", "find", "ls", "ask_yagni"],
161
+ tools: READ_ONLY_SUBAGENT_TOOLS,
156
162
  body: SEARCHER_BODY,
157
163
  source: "builtin",
158
164
  };
@@ -216,56 +222,44 @@ What you could not check, and why.
216
222
 
217
223
  A HOLDS after real digging is valuable; a rubber stamp is not. If you found
218
224
  nothing, say exactly what you tried to break and how.`;
219
- /**
220
- * The tier the built-in verification agent asks for: `peak` in a session-lane
221
- * turn (`pipeline/sessionLane.ts`), the one place the proxy serves a verifier
222
- * above its advanced ceiling for subagents, and `advanced` everywhere else (the
223
- * CLI, desktop, the attempt lane's stage graph), so a request never asks for a
224
- * tier it would not be served. A repo's own `verification` agent keeps the tier
225
- * it declares.
226
- */
227
- export function verificationTier(env = process.env) {
228
- return isSessionLaneTurn(env) ? "peak" : "advanced";
229
- }
230
225
  /** The diamond's reduce layer: refute-first review of completed work, on
231
- * {@link verificationTier} (judgment is the whole job, so the premium is worth
232
- * paying where the lane serves it). One by default, on the subagent lane's
233
- * clock ({@link SUBAGENT_WALL_TIMEOUT_MS}), like every other subagent.
234
- * It has no edit/write tools; bash is included for `git diff`-style inspection
235
- * and is restricted to read-only USE by the persona, the same prompt-level
236
- * stance as /go's reviewer, not a technical guarantee. */
237
- function verificationAgent(env) {
238
- return {
239
- name: "verification",
240
- description: "Adversarial verification of completed work: tries to refute a change, " +
241
- "plan, or claim and reports concrete failure scenarios. Does not edit " +
242
- "files. Send one; send two or three with different lenses (correctness, " +
243
- "edge cases, codebase fit) only for a risky change such as a migration, " +
244
- "auth or money, and treat agreement as confirmation.",
245
- model: verificationTier(env),
246
- tools: ["read", "grep", "find", "ls", "bash", "ask_yagni"],
247
- body: VERIFICATION_BODY,
248
- source: "builtin",
249
- };
250
- }
226
+ * `advanced`, the strongest tier the proxy serves a subagent. One by default,
227
+ * on the subagent lane's clock ({@link SUBAGENT_WALL_TIMEOUT_MS}), like every
228
+ * other subagent. It has no edit/write tools; bash is included for
229
+ * `git diff`-style inspection and is restricted to read-only USE by the
230
+ * persona, the same prompt-level stance as /go's reviewer, not a technical
231
+ * guarantee. Not offered in a session-lane turn (see {@link builtinAgents}). */
232
+ const VERIFICATION_AGENT = {
233
+ name: "verification",
234
+ description: "Adversarial verification of completed work: tries to refute a change, " +
235
+ "plan, or claim and reports concrete failure scenarios. Does not edit " +
236
+ "files. Send one; send two or three with different lenses (correctness, " +
237
+ "edge cases, codebase fit) only for a risky change such as a migration, " +
238
+ "auth or money, and treat agreement as confirmation.",
239
+ model: "advanced",
240
+ tools: ["read", "grep", "find", "ls", "bash", "ask_yagni"],
241
+ body: VERIFICATION_BODY,
242
+ source: "builtin",
243
+ };
251
244
  /**
252
245
  * The built-in agents a process is offered. Everywhere but a session-lane
253
246
  * turn: all four. A session-lane turn (`pipeline/sessionLane.ts`) writes its
254
- * change itself, so it is offered no built-in that writes for it: no
255
- * `general`, and no `implementer` unless the host names a helper and its tier
256
- * (`pipeline/codeWriter.ts`). Taken out of what is offered, never only asked
257
- * in the turn's message, so it does not rest on the model obeying. A
258
- * repository's own agents load over these as everywhere.
247
+ * change itself and runs its own checks, and the pull request's review is the
248
+ * independent one, so it is offered no built-in that writes or judges for it:
249
+ * no `general`, no `verification`, and no `implementer` unless the host names
250
+ * a helper and its tier (`pipeline/codeWriter.ts`). Taken out of what is
251
+ * offered, never only asked in the turn's message, so it does not rest on the
252
+ * model obeying. On that lane a repository's own agents load read-only and
253
+ * never replace one of these ({@link discoverSubagents}, {@link buildSubagentStage}).
259
254
  */
260
255
  export function builtinAgents(env) {
261
256
  if (!isSessionLaneTurn(env)) {
262
- return [GENERAL_AGENT, SEARCHER_AGENT, IMPLEMENTER_AGENT, verificationAgent(env)];
257
+ return [GENERAL_AGENT, SEARCHER_AGENT, IMPLEMENTER_AGENT, VERIFICATION_AGENT];
263
258
  }
264
259
  const who = resolveCodeWriter(env);
265
260
  return [
266
261
  SEARCHER_AGENT,
267
262
  ...(who.writer === "helper" ? [{ ...IMPLEMENTER_AGENT, model: who.tier }] : []),
268
- verificationAgent(env),
269
263
  ];
270
264
  }
271
265
  // Concrete tiers a subagent can actually run on. `balanced` is deliberately NOT
@@ -360,21 +354,28 @@ function loadAgentsFromDir(dir, source) {
360
354
  * dirs (launcher-provided), then user `~/.claude/agents`, then the repo's
361
355
  * `.pi/agents` and `.claude/agents` — later wins on a name collision, so a
362
356
  * project definition beats a user one beats a plugin one beats the built-in.
357
+ * In a session-lane turn a built-in the turn is offered keeps its name: an
358
+ * agent file named like it does not replace it.
363
359
  */
364
360
  export function discoverSubagents(deps) {
365
361
  const home = deps.homeDir ?? homedir();
366
362
  const env = deps.env ?? process.env;
363
+ const builtins = builtinAgents(env);
367
364
  const layers = [
368
- builtinAgents(env),
365
+ builtins,
369
366
  ...pluginAgentDirs(env).map((dir) => loadAgentsFromDir(dir, "plugin")),
370
367
  loadAgentsFromDir(join(home, ".claude", "agents"), "user-claude"),
371
368
  loadAgentsFromDir(join(deps.cwd, ".pi", "agents"), "project-pi"),
372
369
  loadAgentsFromDir(join(deps.cwd, ".claude", "agents"), "project-claude"),
373
370
  ];
371
+ const kept = isSessionLaneTurn(env) ? new Set(builtins.map((a) => a.name)) : new Set();
374
372
  const byName = new Map();
375
373
  for (const layer of layers) {
376
- for (const agent of layer)
374
+ for (const agent of layer) {
375
+ if (agent.source !== "builtin" && kept.has(agent.name))
376
+ continue;
377
377
  byName.set(agent.name, agent);
378
+ }
378
379
  }
379
380
  return [...byName.values()];
380
381
  }
@@ -474,16 +475,24 @@ const BUILTIN_BLIND_BODIES = {
474
475
  /** The canonical grounding-strip filter lives in grounding.ts; one home,
475
476
  * shared with the advisor consults. */
476
477
  import { stripGroundingTool } from "./grounding.js";
478
+ /**
479
+ * `sessionLane`: the process is a session-lane turn, where an agent that is
480
+ * not built in (a repository's, the user's, a plugin's) runs with
481
+ * {@link READ_ONLY_SUBAGENT_TOOLS} whatever its file declares, a file with no
482
+ * tools list included: nothing but the session writes a yak's code. Built-ins
483
+ * keep their own tools (the helper implementer, when the host names one).
484
+ */
477
485
  export function buildSubagentStage(def, task, opts = {}) {
478
486
  const grounded = opts.grounded !== false;
487
+ const tools = opts.sessionLane === true && def.source !== "builtin"
488
+ ? READ_ONLY_SUBAGENT_TOOLS
489
+ : (def.tools ?? DEFAULT_SUBAGENT_TOOLS);
479
490
  return {
480
491
  stage: {
481
492
  id: "implement",
482
493
  agent: def.name,
483
494
  model: def.model,
484
- tools: grounded
485
- ? (def.tools ?? DEFAULT_SUBAGENT_TOOLS)
486
- : stripGroundingTool(def.tools ?? DEFAULT_SUBAGENT_TOOLS),
495
+ tools: grounded ? [...tools] : stripGroundingTool(tools),
487
496
  taskTemplate: "{ticket}",
488
497
  },
489
498
  ctx: { ticket: task, grounded },
@@ -603,6 +612,7 @@ export function makeSubagentTool(deps = {}) {
603
612
  };
604
613
  const discover = deps.discover ?? discoverSubagents;
605
614
  const grounded = deps.grounded !== false;
615
+ const sessionLane = isSessionLaneTurn(deps.env ?? process.env);
606
616
  // Resolve the effective body for a spawned subagent: the grounding-free
607
617
  // twin for builtins under `grounding: false`; the definition's own body
608
618
  // everywhere else (user/project content rides verbatim).
@@ -732,7 +742,10 @@ export function makeSubagentTool(deps = {}) {
732
742
  try {
733
743
  outcomes = await Promise.all(resolved.map(async ({ def, task }, index) => {
734
744
  const progress = progresses[index];
735
- const { stage, ctx: stageCtx } = buildSubagentStage(def, task, { grounded });
745
+ const { stage, ctx: stageCtx } = buildSubagentStage(def, task, {
746
+ grounded,
747
+ sessionLane,
748
+ });
736
749
  const result = await run()(stage, stageCtx, {
737
750
  cwd,
738
751
  signal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "1.2.14-staging.2374.1",
3
+ "version": "1.2.14-staging.2376.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": "be8cac14c8f7c30cf826d20c7b17535dd3b61298"
61
+ "yagniSourceSha": "e3853de07ba33a6c7cdd6308eff6f15a31cf8d27"
62
62
  }