@yagni-app/code-staging 1.2.14-staging.2357.1 → 1.2.14-staging.2370.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.
- package/dist/extension/index.d.ts +8 -0
- package/dist/extension/index.js +12 -1
- package/dist/extension/permission/gate.d.ts +2 -0
- package/dist/extension/permission/gate.js +2 -0
- package/dist/extension/permission/guardian.d.ts +8 -2
- package/dist/extension/permission/guardian.js +1 -0
- package/dist/extension/pipeline/helperSessions.d.ts +12 -0
- package/dist/extension/pipeline/helperSessions.js +33 -0
- package/dist/extension/pipeline/resilience.js +1 -1
- package/dist/extension/pipeline/runner.d.ts +8 -0
- package/dist/extension/pipeline/runner.js +2 -1
- package/dist/extension/pipeline/sessionLane.js +72 -22
- package/dist/extension/subagentRender.d.ts +6 -0
- package/dist/extension/subagents.js +32 -0
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { type GuardianDiagnosticEvent } from "./permission/guardian.js";
|
|
2
3
|
import { type SpendResponse } from "./costHud.js";
|
|
3
4
|
import { runInitPass as defaultRunInitPass } from "./initPass.js";
|
|
4
5
|
import { startMcp as defaultStartMcp } from "./mcp/startup.js";
|
|
@@ -150,6 +151,13 @@ export declare function parseSpendResponse(data: unknown): SpendResponse | null;
|
|
|
150
151
|
* justification are command/model content and ride the debug tier (never
|
|
151
152
|
* uploaded by /feedback) plus the opt-in storage stream.
|
|
152
153
|
*/
|
|
154
|
+
/**
|
|
155
|
+
* A Guardian review as the always-on log line holds it: the verdict, the
|
|
156
|
+
* tool and the timing. The model's raw output (a repaired or malformed
|
|
157
|
+
* verdict, rationale and all) stays at `debug`; the malformed-verdict
|
|
158
|
+
* telemetry still posts it.
|
|
159
|
+
*/
|
|
160
|
+
export declare function guardianReviewLogLine(ev: GuardianDiagnosticEvent, env: NodeJS.ProcessEnv): Record<string, unknown>;
|
|
153
161
|
export declare function logGateOutcomeTrail(ev: GuardianGateEvent, env: NodeJS.ProcessEnv): void;
|
|
154
162
|
export declare function registerYagni(pi: ExtensionAPI, deps?: RegisterYagniDeps): Promise<void>;
|
|
155
163
|
export default function (pi: ExtensionAPI): Promise<void>;
|
package/dist/extension/index.js
CHANGED
|
@@ -134,6 +134,16 @@ export function parseSpendResponse(data) {
|
|
|
134
134
|
* justification are command/model content and ride the debug tier (never
|
|
135
135
|
* uploaded by /feedback) plus the opt-in storage stream.
|
|
136
136
|
*/
|
|
137
|
+
/**
|
|
138
|
+
* A Guardian review as the always-on log line holds it: the verdict, the
|
|
139
|
+
* tool and the timing. The model's raw output (a repaired or malformed
|
|
140
|
+
* verdict, rationale and all) stays at `debug`; the malformed-verdict
|
|
141
|
+
* telemetry still posts it.
|
|
142
|
+
*/
|
|
143
|
+
export function guardianReviewLogLine(ev, env) {
|
|
144
|
+
const { rawOutput: _raw, ...line } = ev;
|
|
145
|
+
return isDebug(env) ? { ...ev } : { ...line };
|
|
146
|
+
}
|
|
137
147
|
export function logGateOutcomeTrail(ev, env) {
|
|
138
148
|
logEvent({
|
|
139
149
|
source: "guardian",
|
|
@@ -142,6 +152,7 @@ export function logGateOutcomeTrail(ev, env) {
|
|
|
142
152
|
sessionId: env.YAGNI_SESSION_ID ?? undefined,
|
|
143
153
|
fields: {
|
|
144
154
|
outcome: ev.outcome,
|
|
155
|
+
...(ev.tool ? { tool: ev.tool } : {}),
|
|
145
156
|
mode: ev.mode,
|
|
146
157
|
consulted: ev.consulted,
|
|
147
158
|
},
|
|
@@ -1154,7 +1165,7 @@ export async function registerYagni(pi, deps = {}) {
|
|
|
1154
1165
|
}),
|
|
1155
1166
|
}),
|
|
1156
1167
|
onGuardianReview: (ev) => {
|
|
1157
|
-
guardianLogSink(ev);
|
|
1168
|
+
guardianLogSink(guardianReviewLogLine(ev, env));
|
|
1158
1169
|
// A malformed verdict (repair FAILED — still really failing) is a real
|
|
1159
1170
|
// failure on our side that must reach Sentry for EVERY workspace
|
|
1160
1171
|
// (independent of the opt-in storage tier). A REPAIRED verdict (repair
|
|
@@ -155,6 +155,8 @@ export interface GuardianGateEvent {
|
|
|
155
155
|
mode: PermissionMode;
|
|
156
156
|
tier?: string;
|
|
157
157
|
durationMs?: number;
|
|
158
|
+
/** The tool the decision was about (`bash`, for every Guardian path today). */
|
|
159
|
+
tool?: string;
|
|
158
160
|
/** Whether a Guardian LLM consult actually ran for this decision. */
|
|
159
161
|
consulted: boolean;
|
|
160
162
|
/** Escape ask dialogs only: the L2 prefix fold's summary at dialog-build
|
|
@@ -1217,6 +1217,7 @@ export function registerPermissionGate(pi, deps = {}) {
|
|
|
1217
1217
|
const execJustification = decision.classifyJustification;
|
|
1218
1218
|
const eventBase = {
|
|
1219
1219
|
command,
|
|
1220
|
+
tool: event.toolName,
|
|
1220
1221
|
...(execJustification ? { execJustification } : {}),
|
|
1221
1222
|
mode: modeAtEntry,
|
|
1222
1223
|
...(guardianTier ? { tier: guardianTier } : {}),
|
|
@@ -1327,6 +1328,7 @@ export function registerPermissionGate(pi, deps = {}) {
|
|
|
1327
1328
|
if (!deps.onGuardianReview)
|
|
1328
1329
|
return;
|
|
1329
1330
|
void Promise.resolve(deps.onGuardianReview(buildDiagnosticEvent(outcome, {
|
|
1331
|
+
tool: event.toolName,
|
|
1330
1332
|
durationMs,
|
|
1331
1333
|
tier: guardianTier,
|
|
1332
1334
|
...(reviewResult.repaired ? { repaired: true } : {}),
|
|
@@ -200,6 +200,8 @@ export declare function reviewCommand(command: string, deps: ReviewCommandDeps):
|
|
|
200
200
|
export interface GuardianDiagnosticEvent {
|
|
201
201
|
event: "guardian_review";
|
|
202
202
|
outcome: GuardianOutcome | GuardianError;
|
|
203
|
+
/** The tool the verdict was about. */
|
|
204
|
+
tool?: string;
|
|
203
205
|
durationMs?: number;
|
|
204
206
|
tier?: string;
|
|
205
207
|
/** True when the lenient repair ladder salvaged a broken verdict — the
|
|
@@ -212,8 +214,11 @@ export interface GuardianDiagnosticEvent {
|
|
|
212
214
|
rationale?: string;
|
|
213
215
|
/**
|
|
214
216
|
* Scrubbed + capped copy of the unparseable model output, present only for
|
|
215
|
-
* `outcome: "malformed"` or `repaired: true`. Always
|
|
216
|
-
* it is already `scrubSecrets`-redacted and size-capped at the
|
|
217
|
+
* `outcome: "malformed"` or `repaired: true`. Always on the event (NOT
|
|
218
|
+
* debug-gated): it is already `scrubSecrets`-redacted and size-capped at the
|
|
219
|
+
* source, and the malformed-verdict telemetry posts it. The machine's log
|
|
220
|
+
* line holds it only at `debug` (`guardianReviewLogLine` in `index.ts`): it
|
|
221
|
+
* can carry the model's rationale, which stays off the always-on log.
|
|
217
222
|
*/
|
|
218
223
|
rawOutput?: string;
|
|
219
224
|
}
|
|
@@ -222,6 +227,7 @@ export interface GuardianDiagnosticEvent {
|
|
|
222
227
|
* (could contain secrets). YAGNI_DEBUG=1 adds rationale and a command hash.
|
|
223
228
|
*/
|
|
224
229
|
export declare function buildDiagnosticEvent(outcome: GuardianOutcome | GuardianError, opts: {
|
|
230
|
+
tool?: string;
|
|
225
231
|
durationMs?: number;
|
|
226
232
|
tier?: string;
|
|
227
233
|
repaired?: boolean;
|
|
@@ -590,6 +590,7 @@ export function buildDiagnosticEvent(outcome, opts) {
|
|
|
590
590
|
const ev = {
|
|
591
591
|
event: "guardian_review",
|
|
592
592
|
outcome,
|
|
593
|
+
...(opts.tool ? { tool: opts.tool } : {}),
|
|
593
594
|
...(opts.durationMs !== undefined ? { durationMs: opts.durationMs } : {}),
|
|
594
595
|
...(opts.tier !== undefined ? { tier: opts.tier } : {}),
|
|
595
596
|
...(opts.repaired ? { repaired: true } : {}),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** The child's env: the folder a session-lane turn's helpers keep their conversations in. */
|
|
2
|
+
export declare const HELPER_SESSIONS_DIR_ENV = "YAGNI_HELPER_SESSIONS_DIR";
|
|
3
|
+
/** The helpers folder the env names, or null when it names none (or a relative path). */
|
|
4
|
+
export declare function helperSessionsDirOf(env: NodeJS.ProcessEnv): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* The session file of one helper's try: `<dir>/<call>-try<n>.jsonl`, the call
|
|
7
|
+
* reduced to letters, digits, `_` and `-` (the host stores no other name).
|
|
8
|
+
*/
|
|
9
|
+
export declare function helperSessionFile(dir: string, call: string, tryNo: number): string;
|
|
10
|
+
/** The file's name as the parent's tool result records it. */
|
|
11
|
+
export declare function helperSessionName(file: string): string;
|
|
12
|
+
//# sourceMappingURL=helperSessions.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a helper keeps its own conversation.
|
|
3
|
+
*
|
|
4
|
+
* A session-lane turn names a folder in its child's env
|
|
5
|
+
* ({@link HELPER_SESSIONS_DIR_ENV}); each helper it starts (a subagent's
|
|
6
|
+
* try, a plan review round) then runs on its own pi session file there instead
|
|
7
|
+
* of `--no-session`, and the host stores the folder with the session's parts
|
|
8
|
+
* (the backend's `attempts/liveTranscript.ts`). The file is named by the call
|
|
9
|
+
* that started the helper and its try, so a retry never resumes the failed
|
|
10
|
+
* try's file. Without the folder (every developer's own CLI) a helper keeps
|
|
11
|
+
* no file, as before.
|
|
12
|
+
*/
|
|
13
|
+
import { basename, isAbsolute, join } from "node:path";
|
|
14
|
+
/** The child's env: the folder a session-lane turn's helpers keep their conversations in. */
|
|
15
|
+
export const HELPER_SESSIONS_DIR_ENV = "YAGNI_HELPER_SESSIONS_DIR";
|
|
16
|
+
/** The helpers folder the env names, or null when it names none (or a relative path). */
|
|
17
|
+
export function helperSessionsDirOf(env) {
|
|
18
|
+
const dir = env[HELPER_SESSIONS_DIR_ENV]?.trim();
|
|
19
|
+
return dir && isAbsolute(dir) ? dir : null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The session file of one helper's try: `<dir>/<call>-try<n>.jsonl`, the call
|
|
23
|
+
* reduced to letters, digits, `_` and `-` (the host stores no other name).
|
|
24
|
+
*/
|
|
25
|
+
export function helperSessionFile(dir, call, tryNo) {
|
|
26
|
+
const safe = call.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 120) || "helper";
|
|
27
|
+
return join(dir, `${safe}-try${Math.max(1, Math.trunc(tryNo))}.jsonl`);
|
|
28
|
+
}
|
|
29
|
+
/** The file's name as the parent's tool result records it. */
|
|
30
|
+
export function helperSessionName(file) {
|
|
31
|
+
return basename(file);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=helperSessions.js.map
|
|
@@ -188,7 +188,7 @@ export function withResilience(base, policy, opts = {}) {
|
|
|
188
188
|
};
|
|
189
189
|
const startedAt = now();
|
|
190
190
|
try {
|
|
191
|
-
last = await base(stage, ctx, { ...deps, signal: composed, onEvent });
|
|
191
|
+
last = await base(stage, ctx, { ...deps, signal: composed, onEvent, tryNo: attempt });
|
|
192
192
|
}
|
|
193
193
|
finally {
|
|
194
194
|
clearTimeout(wallTimer);
|
|
@@ -105,6 +105,14 @@ export interface RunStageDeps {
|
|
|
105
105
|
* Absent on every /go stage and subagent child.
|
|
106
106
|
*/
|
|
107
107
|
sessionFile?: string;
|
|
108
|
+
/**
|
|
109
|
+
* A helper's own session file for one try (`helperSessions.ts`): the child
|
|
110
|
+
* runs on `sessionFileFor(tryNo)` when no `sessionFile` is set. Each try
|
|
111
|
+
* gets a new file, so a retry never resumes the failed try's conversation.
|
|
112
|
+
*/
|
|
113
|
+
sessionFileFor?: (tryNo: number) => string;
|
|
114
|
+
/** This try's number, from 1: set by the resilience wrapper. */
|
|
115
|
+
tryNo?: number;
|
|
108
116
|
}
|
|
109
117
|
/**
|
|
110
118
|
* Default per-line stdout ceiling (16 MiB). A legitimate NDJSON event — even one
|
|
@@ -133,7 +133,8 @@ export async function runStage(stage, ctx, deps) {
|
|
|
133
133
|
lens: ctx.lens,
|
|
134
134
|
...(tierCap ? { tierCap } : {}),
|
|
135
135
|
});
|
|
136
|
-
const
|
|
136
|
+
const sessionFile = deps.sessionFile ?? deps.sessionFileFor?.(deps.tryNo ?? 1);
|
|
137
|
+
const passthrough = sessionFile ? onSessionFile(invocation, sessionFile) : invocation;
|
|
137
138
|
const { piCli, extensionPath } = resolveChild();
|
|
138
139
|
const argv = groundedChildArgv(passthrough, {
|
|
139
140
|
piCli,
|
|
@@ -51,6 +51,7 @@ import { scanChange } from "./changeScan.js";
|
|
|
51
51
|
import { CODE_WRITER_ENV, ignoredCodeWriter, resolveCodeWriter, } from "./codeWriter.js";
|
|
52
52
|
import { completeCloudSession, RESULT_FILE_NAME, } from "./cloud.js";
|
|
53
53
|
import { finishExec } from "./finish.js";
|
|
54
|
+
import { HELPER_SESSIONS_DIR_ENV, helperSessionFile } from "./helperSessions.js";
|
|
54
55
|
import { MISSION_CHECKS_FILE_NAME, readMissionChecksFile } from "./missionChecks.js";
|
|
55
56
|
import { creditExhaustionReason } from "./orchestrator.js";
|
|
56
57
|
import { WORK_A_TICKET_SKILL } from "./personas.js";
|
|
@@ -243,8 +244,16 @@ const PULL_REQUEST_CONTRACT = (outDir) => `Before the report, write ${join(outDi
|
|
|
243
244
|
"give a **Before:** and **After:** pair as the user meets it. Then what you verified and how, and what you did not " +
|
|
244
245
|
"verify and why. Short sentences, no file-by-file list. Never quote command output, a log, or a value from the " +
|
|
245
246
|
"environment: everyone on the repository reads it. Write no title, checks table or plan version: YAGNI adds those.";
|
|
247
|
+
/**
|
|
248
|
+
* The yak's own words on each step, kept in its stored conversation: a build
|
|
249
|
+
* turn's also show on the live feed, a plan turn's do not
|
|
250
|
+
* (`harnessActivity.ts`'s narrating stages). One per step, never one per
|
|
251
|
+
* tool call, so a turn stays well under the feed's event cap.
|
|
252
|
+
*/
|
|
253
|
+
const NARRATION_RULE = "Narrate as you go, in one short line each: when you start a step of your work (reading the ticket, checking a premise, writing the plan, building one part, running the checks), say what you are doing and why; when a step settles something, say what it settled. One line per step, not one per tool call.";
|
|
246
254
|
const BUILD_RULES = (outDir, who) => [
|
|
247
255
|
"Write tools are on now. Work as your playbook says:",
|
|
256
|
+
`- ${NARRATION_RULE}`,
|
|
248
257
|
"- Prefer the smallest change that meets the ticket, and keep the diff to what the ticket needs.",
|
|
249
258
|
WRITER_RULE(who),
|
|
250
259
|
"- 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.",
|
|
@@ -276,6 +285,7 @@ const planRules = (preview, ownPlans) => [
|
|
|
276
285
|
preview
|
|
277
286
|
? `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.`
|
|
278
287
|
: `This turn you have ${PLAN_TOOLS}, and no edit or write tool.`,
|
|
288
|
+
NARRATION_RULE,
|
|
279
289
|
...PLAN_RULES_BEFORE_PREVIEW,
|
|
280
290
|
...(preview ? [previewRule(preview.inputDir, preview.outDir)] : []),
|
|
281
291
|
`${PLAN_FORMAT_RULE} ${ownPlans ? DECIDE_RULE : QUESTION_RULE}`,
|
|
@@ -645,7 +655,34 @@ async function runTurn(input, deps, pulse) {
|
|
|
645
655
|
};
|
|
646
656
|
const paths = sessionPaths(deps.home ?? homedir(), input.identity.attemptId);
|
|
647
657
|
const resumed = exists(paths.sessionFile);
|
|
648
|
-
|
|
658
|
+
const laneDir = join(paths.sessionFile, "..");
|
|
659
|
+
mkdir(laneDir);
|
|
660
|
+
// Each helper's own conversation, beside the session's, for the host to
|
|
661
|
+
// store with it (`helperSessions.ts`); without the folder they keep none.
|
|
662
|
+
const helpersDir = ((dir) => {
|
|
663
|
+
try {
|
|
664
|
+
mkdir(dir);
|
|
665
|
+
return dir;
|
|
666
|
+
}
|
|
667
|
+
catch {
|
|
668
|
+
input.writeErr("The helpers' conversations are not kept this turn: their folder could not be made.");
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
})(join(laneDir, "helpers"));
|
|
672
|
+
// The turn's log id, for the host to keep this session's extension log
|
|
673
|
+
// lines and no one else's: one line per turn's id, each once.
|
|
674
|
+
const logId = input.childEnv.YAGNI_SESSION_ID?.trim();
|
|
675
|
+
if (logId) {
|
|
676
|
+
const idsFile = join(laneDir, "session-ids");
|
|
677
|
+
try {
|
|
678
|
+
const known = readOrNull(idsFile) ?? "";
|
|
679
|
+
if (!known.split("\n").includes(logId))
|
|
680
|
+
writeFile(idsFile, `${known}${logId}\n`);
|
|
681
|
+
}
|
|
682
|
+
catch {
|
|
683
|
+
input.writeErr("This turn's extension log lines are not kept: its session id could not be written.");
|
|
684
|
+
}
|
|
685
|
+
}
|
|
649
686
|
mkdir(join(paths.skillFile, ".."));
|
|
650
687
|
// The playbook, installed where the session (and anything it runs) can
|
|
651
688
|
// read it again, and handed to every turn as its system prompt.
|
|
@@ -716,6 +753,7 @@ async function runTurn(input, deps, pulse) {
|
|
|
716
753
|
...input.childEnv,
|
|
717
754
|
[SESSION_INPUT_DIR_ENV]: input.inputDir,
|
|
718
755
|
...(inboxDir ? { [SESSION_INBOX_DIR_ENV]: inboxDir } : {}),
|
|
756
|
+
...(helpersDir ? { [HELPER_SESSIONS_DIR_ENV]: helpersDir } : {}),
|
|
719
757
|
},
|
|
720
758
|
sessionFile: paths.sessionFile,
|
|
721
759
|
callerLabel: SESSION_CALLER_LABEL,
|
|
@@ -746,9 +784,11 @@ async function runTurn(input, deps, pulse) {
|
|
|
746
784
|
input.emit({ type: "pipeline_stage", stage: stageId, phase: "finish", at: now() });
|
|
747
785
|
}
|
|
748
786
|
};
|
|
749
|
-
// The plan's reviewer: a fresh child
|
|
750
|
-
//
|
|
751
|
-
//
|
|
787
|
+
// The plan's reviewer: a fresh child that shares nothing with the session
|
|
788
|
+
// that wrote the plan, each round on its own session file in the helpers
|
|
789
|
+
// folder (named by the execution and the round), so the host keeps why it
|
|
790
|
+
// asked for a revision; its tool calls ride the plan's stream and its spend
|
|
791
|
+
// is the run's.
|
|
752
792
|
const reviewStage = {
|
|
753
793
|
id: "plan",
|
|
754
794
|
agent: PLAN_REVIEWER_AGENT,
|
|
@@ -756,24 +796,34 @@ async function runTurn(input, deps, pulse) {
|
|
|
756
796
|
tools: PLAN_REVIEWER_TOOLS,
|
|
757
797
|
taskTemplate: "{ticket}",
|
|
758
798
|
};
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
799
|
+
let reviewRounds = 0;
|
|
800
|
+
const review = (task) => {
|
|
801
|
+
reviewRounds += 1;
|
|
802
|
+
const round = reviewRounds;
|
|
803
|
+
return runStage(withClock(reviewStage), { ticket: task }, {
|
|
804
|
+
cwd: input.cwd,
|
|
805
|
+
env: input.childEnv,
|
|
806
|
+
...(helpersDir
|
|
807
|
+
? {
|
|
808
|
+
sessionFileFor: (tryNo) => helperSessionFile(helpersDir, `plan-review-${input.identity.executionId}-r${round}`, tryNo),
|
|
809
|
+
}
|
|
810
|
+
: {}),
|
|
811
|
+
callerLabel: PLAN_REVIEW_CALLER_LABEL,
|
|
812
|
+
...(input.runId ? { attribution: { runId: input.runId } } : {}),
|
|
813
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
814
|
+
stageWriteCapable: false,
|
|
815
|
+
onEvent: (event) => {
|
|
816
|
+
notePulse(pulse, event, now());
|
|
817
|
+
// Only its tool calls: the host narrates a message on the stream as
|
|
818
|
+
// the session's own words (`harnessActivity.ts`), and the review is
|
|
819
|
+
// not the yak speaking. Its findings reach the session as a turn.
|
|
820
|
+
if (event.type === "tool_execution_start" || event.type === "tool_execution_end") {
|
|
821
|
+
input.emit({ ...event, yagni: { stage: stageId } });
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
now,
|
|
825
|
+
});
|
|
826
|
+
};
|
|
777
827
|
// On the CLI's own stderr, whose tail the host logs: a value that named
|
|
778
828
|
// nobody is the session writing, said once per turn.
|
|
779
829
|
const ignoredWriter = ignoredCodeWriter(input.childEnv[CODE_WRITER_ENV]);
|
|
@@ -68,6 +68,12 @@ export interface SubagentTaskProgress {
|
|
|
68
68
|
droppedActions: number;
|
|
69
69
|
/** The child's final report, present once the task resolved. */
|
|
70
70
|
report?: string;
|
|
71
|
+
/**
|
|
72
|
+
* The file each try kept the child's whole conversation in, in the
|
|
73
|
+
* session-lane turn's helpers folder (`helperSessions.ts`); absent where
|
|
74
|
+
* helpers keep none.
|
|
75
|
+
*/
|
|
76
|
+
sessionFiles?: string[];
|
|
71
77
|
stopReason?: string;
|
|
72
78
|
errorMessage?: string;
|
|
73
79
|
}
|
|
@@ -26,6 +26,7 @@ import { Type } from "typebox";
|
|
|
26
26
|
import { sanitizeCallerSegment } from "./config.js";
|
|
27
27
|
import { logEvent } from "./errorSink.js";
|
|
28
28
|
import { resolveCodeWriter } from "./pipeline/codeWriter.js";
|
|
29
|
+
import { helperSessionFile, helperSessionName, helperSessionsDirOf, } from "./pipeline/helperSessions.js";
|
|
29
30
|
import { withResilience } from "./pipeline/resilience.js";
|
|
30
31
|
import { runStage } from "./pipeline/runner.js";
|
|
31
32
|
import { isSessionLaneTurn } from "./pipeline/sessionLane.js";
|
|
@@ -563,6 +564,20 @@ export function subagentTelemetry(env) {
|
|
|
563
564
|
},
|
|
564
565
|
});
|
|
565
566
|
}
|
|
567
|
+
/** The helpers folder the env names, made if missing; null when it names none or cannot be made. */
|
|
568
|
+
function usableHelpersDir(env) {
|
|
569
|
+
const dir = helperSessionsDirOf(env);
|
|
570
|
+
if (!dir)
|
|
571
|
+
return null;
|
|
572
|
+
try {
|
|
573
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
574
|
+
return dir;
|
|
575
|
+
}
|
|
576
|
+
catch {
|
|
577
|
+
logEvent({ source: "subagent", level: "warn", event: "helper_sessions_dir_unwritable" });
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
566
581
|
export function makeSubagentTool(deps = {}) {
|
|
567
582
|
// The default runner rides the /go pipeline's resilience wrapper, so a chat
|
|
568
583
|
// subagent gets the same idle ceiling and transient-only retry as a /go
|
|
@@ -666,6 +681,9 @@ export function makeSubagentTool(deps = {}) {
|
|
|
666
681
|
}
|
|
667
682
|
const cwd = ctx?.cwd ?? process.cwd();
|
|
668
683
|
const agents = discover({ cwd, homeDir: deps.homeDir, env: deps.env });
|
|
684
|
+
// A session-lane turn's helpers each keep their own conversation there
|
|
685
|
+
// (`helperSessions.ts`); a folder that cannot be made keeps none, as before.
|
|
686
|
+
const helpersDir = usableHelpersDir(deps.env ?? process.env);
|
|
669
687
|
const resolved = [];
|
|
670
688
|
for (const req of requested) {
|
|
671
689
|
// A tasks[] entry names its own agent first; absent that, it inherits
|
|
@@ -743,6 +761,20 @@ export function makeSubagentTool(deps = {}) {
|
|
|
743
761
|
if (applyChildEvent(progress, ev))
|
|
744
762
|
emit();
|
|
745
763
|
},
|
|
764
|
+
// Each try its own file, named by this call, this task and the
|
|
765
|
+
// try; the tool result records every file the task used.
|
|
766
|
+
...(helpersDir
|
|
767
|
+
? {
|
|
768
|
+
sessionFileFor: (tryNo) => {
|
|
769
|
+
const file = helperSessionFile(helpersDir, `subagent-${toolCallId}-${index}`, tryNo);
|
|
770
|
+
progress.sessionFiles = [
|
|
771
|
+
...(progress.sessionFiles ?? []),
|
|
772
|
+
helperSessionName(file),
|
|
773
|
+
];
|
|
774
|
+
return file;
|
|
775
|
+
},
|
|
776
|
+
}
|
|
777
|
+
: {}),
|
|
746
778
|
});
|
|
747
779
|
finalizeTask(progress, result, Date.now());
|
|
748
780
|
// Record the child's spend into the session accumulator so the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yagni-app/code-staging",
|
|
3
|
-
"version": "1.2.14-staging.
|
|
3
|
+
"version": "1.2.14-staging.2370.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": "
|
|
61
|
+
"yagniSourceSha": "ec09dfa1062eed059f4d9d8591c480e21d7636c2"
|
|
62
62
|
}
|