@yagni-app/code-staging 1.2.14-staging.2312.1 → 1.2.14-staging.2314.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/pipeline/personas.d.ts +1 -1
- package/dist/extension/pipeline/personas.js +14 -1
- package/dist/extension/pipeline/planReview.d.ts +125 -0
- package/dist/extension/pipeline/planReview.js +320 -0
- package/dist/extension/pipeline/sessionLane.d.ts +4 -1
- package/dist/extension/pipeline/sessionLane.js +86 -9
- package/package.json +2 -2
|
@@ -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\n## 2. Plan, then stop\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 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";
|
|
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
|
/**
|
|
@@ -93,9 +93,11 @@ You work one ticket for a Team, in its repository, checked out in your working d
|
|
|
93
93
|
|
|
94
94
|
Read 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.
|
|
95
95
|
|
|
96
|
+
Check 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.
|
|
97
|
+
|
|
96
98
|
## 2. Plan, then stop
|
|
97
99
|
|
|
98
|
-
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. You have no edit or write tool until the plan is approved, and anything you change in tracked files before then is put back.
|
|
100
|
+
Open 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.
|
|
99
101
|
|
|
100
102
|
## 3. Build
|
|
101
103
|
|
|
@@ -113,6 +115,15 @@ Commit on the branch you are on, with clear messages. Never push, never open or
|
|
|
113
115
|
|
|
114
116
|
Never 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.
|
|
115
117
|
`;
|
|
118
|
+
/**
|
|
119
|
+
* The plan reviewer (`planReview.ts`): a fresh child that reads a session
|
|
120
|
+
* lane's plan against the ticket and the code, with no part in writing it.
|
|
121
|
+
* Its questions and its output block ride its task.
|
|
122
|
+
*/
|
|
123
|
+
const PLAN_REVIEWER_ROLE = `You are a plan reviewer. You read a plan another session wrote for a ticket, before a person approves it, and you find what would make the build wrong, unsafe or incomplete. You did not write the plan, so take none of it on trust: verify its claims in the code yourself. You change nothing: you read, search and run read-only commands (git log, git show, a test, a type check).`;
|
|
124
|
+
const PLAN_REVIEWER_GROUNDING = `You are grounded. Call ask_yagni before you judge a convention or a company-specific call, and team_read with the Team's connected tools to check a fact outside this repository.`;
|
|
125
|
+
const PLAN_REVIEWER_FINISH = `Be strict about evidence and honest about verdicts. Every finding names its evidence; one you cannot back is dropped. A sound plan has nothing major, and saying so is a good review. Finish in ONE turn: your last message ends with the block the task gives.`;
|
|
126
|
+
const PLAN_REVIEWER_BODY = [PLAN_REVIEWER_ROLE, PLAN_REVIEWER_GROUNDING, PLAN_REVIEWER_FINISH].join("\n\n");
|
|
116
127
|
const CLOUD_PLANNER_BODY = [CLOUD_PLANNER_ROLE, CLOUD_PLANNER_GROUNDING, CLOUD_PLANNER_FINISH].join("\n\n");
|
|
117
128
|
const WORKER_BODY = `You are a worker with full capabilities, operating in an isolated context to implement a plan. Work autonomously and use the tools as needed.
|
|
118
129
|
|
|
@@ -288,6 +299,7 @@ export const PERSONA_BODIES = {
|
|
|
288
299
|
planner: PLANNER_BODY,
|
|
289
300
|
cloud_planner: CLOUD_PLANNER_BODY,
|
|
290
301
|
session: WORK_A_TICKET_SKILL,
|
|
302
|
+
plan_reviewer: PLAN_REVIEWER_BODY,
|
|
291
303
|
worker: WORKER_BODY,
|
|
292
304
|
reviewer: REVIEWER_BODY,
|
|
293
305
|
advisor: ADVISOR_BODY,
|
|
@@ -385,6 +397,7 @@ export const BLIND_PERSONA_BODIES = {
|
|
|
385
397
|
prefix: PREFIX_BODY, // grounding-free by construction (no grounding text at all)
|
|
386
398
|
planner: PLANNER_BLIND,
|
|
387
399
|
cloud_planner: [CLOUD_PLANNER_ROLE, CLOUD_PLANNER_FINISH].join("\n\n"),
|
|
400
|
+
plan_reviewer: [PLAN_REVIEWER_ROLE, PLAN_REVIEWER_FINISH].join("\n\n"),
|
|
388
401
|
worker: WORKER_BLIND,
|
|
389
402
|
reviewer: REVIEWER_BLIND,
|
|
390
403
|
advisor: ADVISOR_BLIND,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session-lane plan held to the bar a person expects before the gate: a
|
|
3
|
+
* fresh reviewer reads it, round after round, until a round finds nothing
|
|
4
|
+
* major, and the host checks that every path it cites is in the repository.
|
|
5
|
+
*
|
|
6
|
+
* The reviewer is its own child, with no session file: it shares nothing with
|
|
7
|
+
* the session that wrote the plan, so the plan is never graded by the context
|
|
8
|
+
* that wrote it. Its major findings go back to the session, which revises the
|
|
9
|
+
* plan in the same conversation. No round cap: what the run may spend and its
|
|
10
|
+
* clock are the only limits. The plan then carries a `## Self-review` section
|
|
11
|
+
* the host writes, and a `## Paths not found` section when it cites a path
|
|
12
|
+
* the host could not find, both of which the gate's page shows as the plan's
|
|
13
|
+
* own sections.
|
|
14
|
+
*/
|
|
15
|
+
import type { StageResult } from "./types.js";
|
|
16
|
+
import type { WorktreeExec } from "./worktree.js";
|
|
17
|
+
/** The agent the reviewer's child runs as (`personas.ts`). */
|
|
18
|
+
export declare const PLAN_REVIEWER_AGENT = "plan_reviewer";
|
|
19
|
+
/** The caller the model proxy attributes a review round to. */
|
|
20
|
+
export declare const PLAN_REVIEW_CALLER_LABEL = "go:plan-review";
|
|
21
|
+
/** What the reviewer may use: it reads and runs, and changes nothing. */
|
|
22
|
+
export declare const PLAN_REVIEWER_TOOLS: string[];
|
|
23
|
+
/** A round starts only with this much of the run's time left: a review and a revision both fit. */
|
|
24
|
+
export declare const MIN_REVIEW_ROUND_MS: number;
|
|
25
|
+
/** One major finding a reviewer backed with evidence. */
|
|
26
|
+
export interface PlanFinding {
|
|
27
|
+
dimension: string;
|
|
28
|
+
finding: string;
|
|
29
|
+
evidence: string;
|
|
30
|
+
fix: string;
|
|
31
|
+
}
|
|
32
|
+
/** One round of the review, as the plan's Self-review section says it. */
|
|
33
|
+
export interface ReviewRound {
|
|
34
|
+
round: number;
|
|
35
|
+
findings: PlanFinding[];
|
|
36
|
+
/** `clean`: nothing major. `revised`: the session revised the plan. `unrevised`: it could not. */
|
|
37
|
+
outcome: "clean" | "revised" | "unrevised";
|
|
38
|
+
}
|
|
39
|
+
/** The reviewer's message: the ticket's inputs, the plan as written, and the block it ends on. */
|
|
40
|
+
export declare function planReviewTask(inputDir: string, planText: string, round: number): string;
|
|
41
|
+
/** The reviewer's last ```plan-review block that reads, or null when it wrote none. */
|
|
42
|
+
export declare function parsePlanReview(text: string): {
|
|
43
|
+
findings: PlanFinding[];
|
|
44
|
+
} | null;
|
|
45
|
+
/** The message that brings a round's major findings back to the session that wrote the plan. */
|
|
46
|
+
export declare function revisionMessage(findings: readonly PlanFinding[]): string;
|
|
47
|
+
/**
|
|
48
|
+
* The plan's review, round after round, until one finds nothing major. Each
|
|
49
|
+
* round runs a fresh reviewer (`review`); an answer that does not read is
|
|
50
|
+
* asked for once more. Major findings go to the session (`turn`), whose answer
|
|
51
|
+
* stands only when it carries its plan-json block (`withBlock`, the lane's
|
|
52
|
+
* re-ask). It ends without a clean round when the attempt is stopped, the run
|
|
53
|
+
* has under {@link MIN_REVIEW_ROUND_MS} left, the proxy refuses a call for
|
|
54
|
+
* credits or the run's budget (the review's or the revision's, named), a
|
|
55
|
+
* child runs out of time, the reviewer twice
|
|
56
|
+
* writes no review that reads, or the session's revision carries no block; the
|
|
57
|
+
* last plan with its block stands, and `ended` says why.
|
|
58
|
+
*/
|
|
59
|
+
export declare function selfReviewPlan(input: {
|
|
60
|
+
run: StageResult;
|
|
61
|
+
inputDir: string;
|
|
62
|
+
turn: (message: string) => Promise<StageResult>;
|
|
63
|
+
review: (task: string) => Promise<StageResult>;
|
|
64
|
+
withBlock: (run: StageResult) => Promise<{
|
|
65
|
+
run: StageResult;
|
|
66
|
+
asked: StageResult[];
|
|
67
|
+
}>;
|
|
68
|
+
/** The run's time left before its turn's finish; undefined when it has no deadline. */
|
|
69
|
+
timeLeftMs: () => number | undefined;
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
run: StageResult;
|
|
73
|
+
asked: StageResult[];
|
|
74
|
+
rounds: ReviewRound[];
|
|
75
|
+
ended: string | null;
|
|
76
|
+
}>;
|
|
77
|
+
/** The `## Self-review` section the host adds to the plan: how many rounds, and what each changed. */
|
|
78
|
+
export declare function selfReviewSection(rounds: readonly ReviewRound[], ended: string | null): string;
|
|
79
|
+
/** A path a plan cites, and whether the line that cites it says the plan creates it. */
|
|
80
|
+
export interface CitedPath {
|
|
81
|
+
path: string;
|
|
82
|
+
markedNew: boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The paths a plan cites in inline code: path characters only, with a folder
|
|
86
|
+
* and a file name that has an extension (`src/pipeline/stages.ts`,
|
|
87
|
+
* `stages.ts:210-238`). A bare name, a package (`@yagni/shared`), a command, a
|
|
88
|
+
* glob or a URL is not one. Fenced blocks (the plan-json block, commands) are
|
|
89
|
+
* left out.
|
|
90
|
+
*/
|
|
91
|
+
export declare function citedPaths(planText: string): CitedPath[];
|
|
92
|
+
/**
|
|
93
|
+
* The cited paths the host could not find, a path the plan says it creates
|
|
94
|
+
* aside. A path is found when it is a tracked file, the end of one (a path
|
|
95
|
+
* from a package's own folder, `pipeline/stages.ts`), or on disk (`exists`
|
|
96
|
+
* reads an absolute path as it is and a relative one from the checkout).
|
|
97
|
+
*/
|
|
98
|
+
export declare function missingPaths(cited: readonly CitedPath[], tracked: readonly string[], exists: (path: string) => boolean): string[];
|
|
99
|
+
/** The re-ask that brings the paths the host could not find back to the session. */
|
|
100
|
+
export declare function pathsReask(missing: readonly string[]): string;
|
|
101
|
+
/** The `## Paths not found` section the host adds when the plan still cites paths it could not find. */
|
|
102
|
+
export declare function missingPathsSection(missing: readonly string[]): string;
|
|
103
|
+
/**
|
|
104
|
+
* The plan's cited paths checked against the checkout: those it could not
|
|
105
|
+
* find are asked of the session once (its answer stands only with its block),
|
|
106
|
+
* and what is still missing is the section the plan carries to the gate.
|
|
107
|
+
*/
|
|
108
|
+
export declare function checkPlanPaths(input: {
|
|
109
|
+
run: StageResult;
|
|
110
|
+
cwd: string;
|
|
111
|
+
exec: WorktreeExec;
|
|
112
|
+
exists: (path: string) => boolean;
|
|
113
|
+
turn: (message: string) => Promise<StageResult>;
|
|
114
|
+
withBlock: (run: StageResult) => Promise<{
|
|
115
|
+
run: StageResult;
|
|
116
|
+
asked: StageResult[];
|
|
117
|
+
}>;
|
|
118
|
+
signal?: AbortSignal;
|
|
119
|
+
}): Promise<{
|
|
120
|
+
run: StageResult;
|
|
121
|
+
asked: StageResult[];
|
|
122
|
+
section: string | null;
|
|
123
|
+
notes: string[];
|
|
124
|
+
}>;
|
|
125
|
+
//# sourceMappingURL=planReview.d.ts.map
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session-lane plan held to the bar a person expects before the gate: a
|
|
3
|
+
* fresh reviewer reads it, round after round, until a round finds nothing
|
|
4
|
+
* major, and the host checks that every path it cites is in the repository.
|
|
5
|
+
*
|
|
6
|
+
* The reviewer is its own child, with no session file: it shares nothing with
|
|
7
|
+
* the session that wrote the plan, so the plan is never graded by the context
|
|
8
|
+
* that wrote it. Its major findings go back to the session, which revises the
|
|
9
|
+
* plan in the same conversation. No round cap: what the run may spend and its
|
|
10
|
+
* clock are the only limits. The plan then carries a `## Self-review` section
|
|
11
|
+
* the host writes, and a `## Paths not found` section when it cites a path
|
|
12
|
+
* the host could not find, both of which the gate's page shows as the plan's
|
|
13
|
+
* own sections.
|
|
14
|
+
*/
|
|
15
|
+
import { creditExhaustionReason } from "./orchestrator.js";
|
|
16
|
+
import { extractPlanJson } from "./planOutput.js";
|
|
17
|
+
/** The agent the reviewer's child runs as (`personas.ts`). */
|
|
18
|
+
export const PLAN_REVIEWER_AGENT = "plan_reviewer";
|
|
19
|
+
/** The caller the model proxy attributes a review round to. */
|
|
20
|
+
export const PLAN_REVIEW_CALLER_LABEL = "go:plan-review";
|
|
21
|
+
/** What the reviewer may use: it reads and runs, and changes nothing. */
|
|
22
|
+
export const PLAN_REVIEWER_TOOLS = ["read", "grep", "find", "ls", "bash", "ask_yagni", "team_read"];
|
|
23
|
+
/** A round starts only with this much of the run's time left: a review and a revision both fit. */
|
|
24
|
+
export const MIN_REVIEW_ROUND_MS = 10 * 60_000;
|
|
25
|
+
const MAX_FINDINGS = 10;
|
|
26
|
+
const PLAN_REVIEW_BLOCK = /```plan-review[^\n]*\n([\s\S]*?)```/gi;
|
|
27
|
+
function clipped(value, max) {
|
|
28
|
+
if (typeof value !== "string")
|
|
29
|
+
return "";
|
|
30
|
+
const text = value.replace(/\s+/g, " ").trim();
|
|
31
|
+
return text.length > max ? `${text.slice(0, max - 3)}...` : text;
|
|
32
|
+
}
|
|
33
|
+
/** The reviewer's message: the ticket's inputs, the plan as written, and the block it ends on. */
|
|
34
|
+
export function planReviewTask(inputDir, planText, round) {
|
|
35
|
+
const at = (file) => `${inputDir.replace(/\/+$/, "")}/${file}`;
|
|
36
|
+
return [
|
|
37
|
+
`Review this plan, round ${round}. Another session wrote it for the ticket in ${at("ticket.md")}; a person approves it next, and a builder executes it.`,
|
|
38
|
+
`Read the ticket, every image it names, and ${at("checks.json")}, ${at("memo.md")} and ${at("playbook.md")} when they exist. Then read the code the plan touches. Change nothing in the repository and commit nothing.`,
|
|
39
|
+
[
|
|
40
|
+
"Judge the plan on these questions, and verify each against the code before you answer it:",
|
|
41
|
+
'1. Ticket check: does the plan open with a premises table, each premise checked with the command, file or query that shows it, or marked as not checkable, and with "Done when"? Is a premise it marks as checked really true? A missing ticket check, a missing "Done when", or a false premise is major.',
|
|
42
|
+
"2. Half-measures: is any step a shortcut where the right fix is known and cheap now?",
|
|
43
|
+
"3. Needless complexity: a new file, abstraction, option or flag the ticket does not need?",
|
|
44
|
+
"4. Unintended side effects: other callers of the code it changes, shared state, contracts, data. Search for the callers; do not guess.",
|
|
45
|
+
"5. Observability: when the change fails in production, will anyone see it?",
|
|
46
|
+
'6. Spec coverage: does it do everything the ticket and its "Done when" ask, and do its checks cover a real failure the change could have?',
|
|
47
|
+
].join("\n"),
|
|
48
|
+
"Every finding needs evidence: a file and line, a command and its output, or the ticket's own words. Drop a finding you cannot back. List only what is major: a flaw that would make the build wrong, unsafe or incomplete, or a premise that is false. Leave out style, wording and anything minor. Finding nothing major is a good answer for a sound plan.",
|
|
49
|
+
[
|
|
50
|
+
"End with a fenced ```plan-review block and nothing after it:",
|
|
51
|
+
"```plan-review",
|
|
52
|
+
'{"findings": [{"dimension": "ticket check | half-measure | complexity | side effects | observability | spec coverage", "finding": "one line", "evidence": "file:line, or the command and what it showed", "fix": "one line on what the plan should change"}]}',
|
|
53
|
+
"```",
|
|
54
|
+
'An empty "findings" list means the plan has nothing major.',
|
|
55
|
+
].join("\n"),
|
|
56
|
+
`The plan:\n\n${planText.trim()}`,
|
|
57
|
+
].join("\n\n");
|
|
58
|
+
}
|
|
59
|
+
/** The reviewer's last ```plan-review block that reads, or null when it wrote none. */
|
|
60
|
+
export function parsePlanReview(text) {
|
|
61
|
+
let found = null;
|
|
62
|
+
for (const match of text.matchAll(PLAN_REVIEW_BLOCK)) {
|
|
63
|
+
let parsed;
|
|
64
|
+
try {
|
|
65
|
+
parsed = JSON.parse(match[1] ?? "");
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
71
|
+
continue;
|
|
72
|
+
const list = parsed.findings;
|
|
73
|
+
if (!Array.isArray(list))
|
|
74
|
+
continue;
|
|
75
|
+
const findings = list.flatMap((entry) => {
|
|
76
|
+
if (!entry || typeof entry !== "object")
|
|
77
|
+
return [];
|
|
78
|
+
const row = entry;
|
|
79
|
+
const finding = clipped(row.finding, 500);
|
|
80
|
+
if (!finding)
|
|
81
|
+
return [];
|
|
82
|
+
return [
|
|
83
|
+
{
|
|
84
|
+
dimension: clipped(row.dimension, 60),
|
|
85
|
+
finding,
|
|
86
|
+
evidence: clipped(row.evidence, 500),
|
|
87
|
+
fix: clipped(row.fix, 500),
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
});
|
|
91
|
+
found = { findings: findings.slice(0, MAX_FINDINGS) };
|
|
92
|
+
}
|
|
93
|
+
return found;
|
|
94
|
+
}
|
|
95
|
+
/** The message that brings a round's major findings back to the session that wrote the plan. */
|
|
96
|
+
export function revisionMessage(findings) {
|
|
97
|
+
const items = findings.map((f, index) => [
|
|
98
|
+
`${index + 1}. ${f.dimension ? `(${f.dimension}) ` : ""}${f.finding}`,
|
|
99
|
+
f.evidence ? ` Evidence: ${f.evidence}` : null,
|
|
100
|
+
f.fix ? ` Suggested fix: ${f.fix}` : null,
|
|
101
|
+
]
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
.join("\n"));
|
|
104
|
+
return [
|
|
105
|
+
"A fresh reviewer read your plan against the ticket and the code, and found these major problems:",
|
|
106
|
+
items.join("\n"),
|
|
107
|
+
"Check each one against the code. Revise the plan for every one that is real; for one that is wrong, keep the plan as it is and say why in one line under ## Risks. Then send the whole revised plan again as your last message, in the same format, ending with the plan-json block. The reviewer reads it again.",
|
|
108
|
+
].join("\n\n");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The plan's review, round after round, until one finds nothing major. Each
|
|
112
|
+
* round runs a fresh reviewer (`review`); an answer that does not read is
|
|
113
|
+
* asked for once more. Major findings go to the session (`turn`), whose answer
|
|
114
|
+
* stands only when it carries its plan-json block (`withBlock`, the lane's
|
|
115
|
+
* re-ask). It ends without a clean round when the attempt is stopped, the run
|
|
116
|
+
* has under {@link MIN_REVIEW_ROUND_MS} left, the proxy refuses a call for
|
|
117
|
+
* credits or the run's budget (the review's or the revision's, named), a
|
|
118
|
+
* child runs out of time, the reviewer twice
|
|
119
|
+
* writes no review that reads, or the session's revision carries no block; the
|
|
120
|
+
* last plan with its block stands, and `ended` says why.
|
|
121
|
+
*/
|
|
122
|
+
export async function selfReviewPlan(input) {
|
|
123
|
+
let run = input.run;
|
|
124
|
+
const asked = [];
|
|
125
|
+
const rounds = [];
|
|
126
|
+
const end = (ended) => ({ run, asked, rounds, ended });
|
|
127
|
+
for (let round = 1;; round += 1) {
|
|
128
|
+
if (input.signal?.aborted)
|
|
129
|
+
return end("the attempt was stopped");
|
|
130
|
+
const left = input.timeLeftMs();
|
|
131
|
+
if (left !== undefined && left < MIN_REVIEW_ROUND_MS)
|
|
132
|
+
return end("the run's time ran low");
|
|
133
|
+
let review = null;
|
|
134
|
+
for (let tries = 0; tries < 2 && !review; tries += 1) {
|
|
135
|
+
const said = await input.review(planReviewTask(input.inputDir, run.finalOutput, round));
|
|
136
|
+
asked.push(said);
|
|
137
|
+
const spent = creditExhaustionReason(said);
|
|
138
|
+
if (spent)
|
|
139
|
+
return end(`the review was refused: ${spent}`);
|
|
140
|
+
if (said.timedOut)
|
|
141
|
+
return end("the review ran out of the run's time");
|
|
142
|
+
if (input.signal?.aborted)
|
|
143
|
+
return end("the attempt was stopped");
|
|
144
|
+
review = said.exitCode === 0 ? parsePlanReview(said.finalOutput) : null;
|
|
145
|
+
}
|
|
146
|
+
if (!review)
|
|
147
|
+
return end("the reviewer wrote no review that reads, twice");
|
|
148
|
+
if (review.findings.length === 0) {
|
|
149
|
+
rounds.push({ round, findings: [], outcome: "clean" });
|
|
150
|
+
return { run, asked, rounds, ended: null };
|
|
151
|
+
}
|
|
152
|
+
const revised = await input.turn(revisionMessage(review.findings));
|
|
153
|
+
asked.push(revised);
|
|
154
|
+
// A revision that never ran says why, never that it carried no plan.
|
|
155
|
+
const unrevised = (why) => {
|
|
156
|
+
rounds.push({ round, findings: review.findings, outcome: "unrevised" });
|
|
157
|
+
return end(why);
|
|
158
|
+
};
|
|
159
|
+
const refused = creditExhaustionReason(revised);
|
|
160
|
+
if (refused)
|
|
161
|
+
return unrevised(`the revision was refused: ${refused}`);
|
|
162
|
+
if (revised.timedOut)
|
|
163
|
+
return unrevised("the revision ran out of the run's time");
|
|
164
|
+
if (input.signal?.aborted)
|
|
165
|
+
return unrevised("the attempt was stopped");
|
|
166
|
+
const blocked = revised.exitCode === 0 ? await input.withBlock(revised) : { run: revised, asked: [] };
|
|
167
|
+
asked.push(...blocked.asked);
|
|
168
|
+
if (blocked.run.exitCode !== 0 || extractPlanJson(blocked.run.finalOutput) === null) {
|
|
169
|
+
return unrevised("the session's revision carried no plan, so the plan before it stands");
|
|
170
|
+
}
|
|
171
|
+
run = blocked.run;
|
|
172
|
+
rounds.push({ round, findings: review.findings, outcome: "revised" });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** The `## Self-review` section the host adds to the plan: how many rounds, and what each changed. */
|
|
176
|
+
export function selfReviewSection(rounds, ended) {
|
|
177
|
+
const count = rounds.length === 1 ? "1 round" : `${rounds.length} rounds`;
|
|
178
|
+
const lines = [
|
|
179
|
+
"## Self-review",
|
|
180
|
+
"",
|
|
181
|
+
rounds.length > 0
|
|
182
|
+
? `A fresh reviewer read this plan against the ticket and the code before it reached you: ${count}.`
|
|
183
|
+
: "A fresh reviewer was to read this plan against the ticket and the code before it reached you.",
|
|
184
|
+
"",
|
|
185
|
+
];
|
|
186
|
+
for (const round of rounds) {
|
|
187
|
+
if (round.outcome === "clean") {
|
|
188
|
+
lines.push(`- Round ${round.round}: nothing major.`);
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const named = round.findings.map((f) => clipped(f.finding, 200)).join("; ");
|
|
192
|
+
const n = round.findings.length;
|
|
193
|
+
const found = `${n} major finding${n === 1 ? "" : "s"}`;
|
|
194
|
+
lines.push(round.outcome === "revised"
|
|
195
|
+
? `- Round ${round.round}: ${found}, and the plan was revised for them: ${named}`
|
|
196
|
+
: `- Round ${round.round}: ${found}, and the plan could not be revised for them: ${named}`);
|
|
197
|
+
}
|
|
198
|
+
if (ended) {
|
|
199
|
+
lines.push(`- The review ended before a clean round: ${ended}. Read this plan with that in mind.`);
|
|
200
|
+
}
|
|
201
|
+
return lines.join("\n");
|
|
202
|
+
}
|
|
203
|
+
const NEW_MARK = /\b(?:new|creates?|created|creating|adds?|added|adding)\b/i;
|
|
204
|
+
const FILE_LAST_PART = /\.[A-Za-z0-9]{1,8}$/;
|
|
205
|
+
/**
|
|
206
|
+
* The paths a plan cites in inline code: path characters only, with a folder
|
|
207
|
+
* and a file name that has an extension (`src/pipeline/stages.ts`,
|
|
208
|
+
* `stages.ts:210-238`). A bare name, a package (`@yagni/shared`), a command, a
|
|
209
|
+
* glob or a URL is not one. Fenced blocks (the plan-json block, commands) are
|
|
210
|
+
* left out.
|
|
211
|
+
*/
|
|
212
|
+
export function citedPaths(planText) {
|
|
213
|
+
const byPath = new Map();
|
|
214
|
+
const prose = planText.replace(/```[\s\S]*?```/g, "");
|
|
215
|
+
for (const line of prose.split("\n")) {
|
|
216
|
+
const markedNew = NEW_MARK.test(line);
|
|
217
|
+
for (const match of line.matchAll(/`([^`\n]+)`/g)) {
|
|
218
|
+
const path = match[1]
|
|
219
|
+
.trim()
|
|
220
|
+
.replace(/^\.\//, "")
|
|
221
|
+
.replace(/#L\d.*$/, "")
|
|
222
|
+
.replace(/:\d+(?:[-:]\d+)*$/, "");
|
|
223
|
+
if (!/^[\w@./+-]+$/.test(path) || !path.includes("/") || path.endsWith("/"))
|
|
224
|
+
continue;
|
|
225
|
+
// An absolute path keeps its leading slash; no other part may be empty or climb.
|
|
226
|
+
const parts = path.split("/");
|
|
227
|
+
if (parts.includes("..") || parts.slice(1).includes(""))
|
|
228
|
+
continue;
|
|
229
|
+
if (!FILE_LAST_PART.test(path.split("/").at(-1) ?? ""))
|
|
230
|
+
continue;
|
|
231
|
+
byPath.set(path, (byPath.get(path) ?? false) || markedNew);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return [...byPath].map(([path, markedNew]) => ({ path, markedNew }));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The cited paths the host could not find, a path the plan says it creates
|
|
238
|
+
* aside. A path is found when it is a tracked file, the end of one (a path
|
|
239
|
+
* from a package's own folder, `pipeline/stages.ts`), or on disk (`exists`
|
|
240
|
+
* reads an absolute path as it is and a relative one from the checkout).
|
|
241
|
+
*/
|
|
242
|
+
export function missingPaths(cited, tracked, exists) {
|
|
243
|
+
const files = new Set(tracked);
|
|
244
|
+
return cited
|
|
245
|
+
.filter(({ path, markedNew }) => {
|
|
246
|
+
if (markedNew)
|
|
247
|
+
return false;
|
|
248
|
+
if (path.startsWith("/"))
|
|
249
|
+
return !exists(path);
|
|
250
|
+
if (files.has(path) || exists(path))
|
|
251
|
+
return false;
|
|
252
|
+
const tail = `/${path}`;
|
|
253
|
+
return !tracked.some((file) => file.endsWith(tail));
|
|
254
|
+
})
|
|
255
|
+
.map(({ path }) => path);
|
|
256
|
+
}
|
|
257
|
+
/** The re-ask that brings the paths the host could not find back to the session. */
|
|
258
|
+
export function pathsReask(missing) {
|
|
259
|
+
return [
|
|
260
|
+
"Your plan names these paths, and they are not in the repository:",
|
|
261
|
+
missing.map((path) => `- \`${path}\``).join("\n"),
|
|
262
|
+
'For each one, correct the path, or, when it is a file the plan creates, say "new" on the line that names it; a path in another repository is written in full from where that repository is checked out. Send the whole plan again as your last message, ending with the plan-json block.',
|
|
263
|
+
].join("\n\n");
|
|
264
|
+
}
|
|
265
|
+
/** The `## Paths not found` section the host adds when the plan still cites paths it could not find. */
|
|
266
|
+
export function missingPathsSection(missing) {
|
|
267
|
+
return [
|
|
268
|
+
"## Paths not found",
|
|
269
|
+
"",
|
|
270
|
+
"The plan names these paths, and they are not in the repository. Check them before you approve:",
|
|
271
|
+
"",
|
|
272
|
+
...missing.map((path) => `- \`${path}\``),
|
|
273
|
+
].join("\n");
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* The plan's cited paths checked against the checkout: those it could not
|
|
277
|
+
* find are asked of the session once (its answer stands only with its block),
|
|
278
|
+
* and what is still missing is the section the plan carries to the gate.
|
|
279
|
+
*/
|
|
280
|
+
export async function checkPlanPaths(input) {
|
|
281
|
+
const listed = await input
|
|
282
|
+
.exec(["git", "ls-files"], input.cwd, input.signal)
|
|
283
|
+
.catch(() => ({ code: -1, output: "" }));
|
|
284
|
+
if (listed.code !== 0) {
|
|
285
|
+
return {
|
|
286
|
+
run: input.run,
|
|
287
|
+
asked: [],
|
|
288
|
+
section: null,
|
|
289
|
+
notes: ["The plan's paths could not be checked: git could not list the repository's files."],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const tracked = listed.output.split("\n").filter(Boolean);
|
|
293
|
+
const missingIn = (text) => missingPaths(citedPaths(text), tracked, input.exists);
|
|
294
|
+
let run = input.run;
|
|
295
|
+
let missing = missingIn(run.finalOutput);
|
|
296
|
+
const asked = [];
|
|
297
|
+
if (missing.length > 0 && !input.signal?.aborted) {
|
|
298
|
+
const again = await input.turn(pathsReask(missing));
|
|
299
|
+
asked.push(again);
|
|
300
|
+
const blocked = again.exitCode === 0 && !again.timedOut
|
|
301
|
+
? await input.withBlock(again)
|
|
302
|
+
: { run: again, asked: [] };
|
|
303
|
+
asked.push(...blocked.asked);
|
|
304
|
+
if (blocked.run.exitCode === 0 && extractPlanJson(blocked.run.finalOutput) !== null) {
|
|
305
|
+
run = blocked.run;
|
|
306
|
+
missing = missingIn(run.finalOutput);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return {
|
|
310
|
+
run,
|
|
311
|
+
asked,
|
|
312
|
+
section: missing.length > 0 ? missingPathsSection(missing) : null,
|
|
313
|
+
notes: missing.length > 0
|
|
314
|
+
? [
|
|
315
|
+
`The plan names ${missing.length} path(s) the host could not find in the repository; the plan's page lists them.`,
|
|
316
|
+
]
|
|
317
|
+
: [],
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=planReview.js.map
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
*
|
|
18
18
|
* - Plan turn: read, search, run anything (tests, Docker, the app), no edit
|
|
19
19
|
* or write tool. Its last message is the plan with the plan-json block,
|
|
20
|
-
* asked for once more when the block is missing
|
|
20
|
+
* asked for once more when the block is missing. A fresh reviewer then
|
|
21
|
+
* reads the plan, round after round until one finds nothing major, each
|
|
22
|
+
* major finding revised in the same session, and the host checks the
|
|
23
|
+
* paths the plan cites (`planReview.ts`). This process writes
|
|
21
24
|
* `plan.md`, `plan.json` and `result.json` as the cloud lane's plan stage
|
|
22
25
|
* does (`completeCloudSession`). Anything the turn changed in tracked
|
|
23
26
|
* files, or committed, is put back before the plan's gate, so nothing is
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
*
|
|
18
18
|
* - Plan turn: read, search, run anything (tests, Docker, the app), no edit
|
|
19
19
|
* or write tool. Its last message is the plan with the plan-json block,
|
|
20
|
-
* asked for once more when the block is missing
|
|
20
|
+
* asked for once more when the block is missing. A fresh reviewer then
|
|
21
|
+
* reads the plan, round after round until one finds nothing major, each
|
|
22
|
+
* major finding revised in the same session, and the host checks the
|
|
23
|
+
* paths the plan cites (`planReview.ts`). This process writes
|
|
21
24
|
* `plan.md`, `plan.json` and `result.json` as the cloud lane's plan stage
|
|
22
25
|
* does (`completeCloudSession`). Anything the turn changed in tracked
|
|
23
26
|
* files, or committed, is put back before the plan's gate, so nothing is
|
|
@@ -51,6 +54,7 @@ import { creditExhaustionReason } from "./orchestrator.js";
|
|
|
51
54
|
import { WORK_A_TICKET_SKILL } from "./personas.js";
|
|
52
55
|
import { healPlacedSecrets, publicationBase } from "./placedValueHeal.js";
|
|
53
56
|
import { extractPlanJson } from "./planOutput.js";
|
|
57
|
+
import { checkPlanPaths, PLAN_REVIEW_CALLER_LABEL, PLAN_REVIEWER_AGENT, PLAN_REVIEWER_TOOLS, selfReviewPlan, selfReviewSection, } from "./planReview.js";
|
|
54
58
|
import { PLAN_CHANGES_RULE, parsePlanChanges, planChangeNote, } from "./planChanges.js";
|
|
55
59
|
import { runStage as defaultRunStage } from "./runner.js";
|
|
56
60
|
import { scrubSecrets } from "./scrubSecrets.js";
|
|
@@ -183,9 +187,11 @@ const PLAN_RULES = [
|
|
|
183
187
|
"This turn you have read, grep, find, ls, bash, ask_yagni, team_read, prototype_read and subagent, and no edit or write tool.",
|
|
184
188
|
"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.",
|
|
185
189
|
`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.`,
|
|
186
|
-
"
|
|
190
|
+
"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.",
|
|
191
|
+
"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.",
|
|
192
|
+
'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 has the one step "Close the ticket: nothing to build", and the plan-json block names no checks and no paths.',
|
|
187
193
|
PLAN_JSON_CONTRACT,
|
|
188
|
-
"Then stop: a person approves the plan before anything is built.",
|
|
194
|
+
"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.",
|
|
189
195
|
].join("\n\n");
|
|
190
196
|
/** The one message a turn sends the session. Pure. */
|
|
191
197
|
export function turnMessage(facts) {
|
|
@@ -538,16 +544,18 @@ async function runTurn(input, deps, pulse) {
|
|
|
538
544
|
}
|
|
539
545
|
}
|
|
540
546
|
const stageId = feedStage(input.stage);
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
547
|
+
/** The run's time left before the turn's finish, read again for every child. */
|
|
548
|
+
const timeLeftMs = () => input.deadlineMs === undefined ? undefined : input.deadlineMs - now() - TURN_FINISH_RESERVE_MS;
|
|
549
|
+
const withClock = (stage) => {
|
|
550
|
+
const left = timeLeftMs();
|
|
551
|
+
return left === undefined ? stage : { ...stage, timeBudgetMs: Math.max(60_000, left) };
|
|
552
|
+
};
|
|
544
553
|
const turnStage = {
|
|
545
554
|
id: stageId,
|
|
546
555
|
agent: "session",
|
|
547
556
|
model: SESSION_TIER,
|
|
548
557
|
tools: writes ? BUILD_TURN_TOOLS : PLAN_TURN_TOOLS,
|
|
549
558
|
taskTemplate: "{ticket}",
|
|
550
|
-
...(timeBudgetMs !== undefined ? { timeBudgetMs } : {}),
|
|
551
559
|
};
|
|
552
560
|
let decisionsRecorded = 0;
|
|
553
561
|
const inboxDir = sessionInboxDir(input.inputDir, input.identity.executionId);
|
|
@@ -584,12 +592,40 @@ async function runTurn(input, deps, pulse) {
|
|
|
584
592
|
const turn = async (message) => {
|
|
585
593
|
input.emit({ type: "pipeline_stage", stage: stageId, phase: "start", at: now() });
|
|
586
594
|
try {
|
|
587
|
-
return await runStage(turnStage, { ticket: message }, runDeps);
|
|
595
|
+
return await runStage(withClock(turnStage), { ticket: message }, runDeps);
|
|
588
596
|
}
|
|
589
597
|
finally {
|
|
590
598
|
input.emit({ type: "pipeline_stage", stage: stageId, phase: "finish", at: now() });
|
|
591
599
|
}
|
|
592
600
|
};
|
|
601
|
+
// The plan's reviewer: a fresh child with no session file, so it shares
|
|
602
|
+
// nothing with the session that wrote the plan; its tool calls ride the
|
|
603
|
+
// plan's stream and its spend is the run's.
|
|
604
|
+
const reviewStage = {
|
|
605
|
+
id: "plan",
|
|
606
|
+
agent: PLAN_REVIEWER_AGENT,
|
|
607
|
+
model: SESSION_TIER,
|
|
608
|
+
tools: PLAN_REVIEWER_TOOLS,
|
|
609
|
+
taskTemplate: "{ticket}",
|
|
610
|
+
};
|
|
611
|
+
const review = (task) => runStage(withClock(reviewStage), { ticket: task }, {
|
|
612
|
+
cwd: input.cwd,
|
|
613
|
+
env: input.childEnv,
|
|
614
|
+
callerLabel: PLAN_REVIEW_CALLER_LABEL,
|
|
615
|
+
...(input.runId ? { attribution: { runId: input.runId } } : {}),
|
|
616
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
617
|
+
stageWriteCapable: false,
|
|
618
|
+
onEvent: (event) => {
|
|
619
|
+
notePulse(pulse, event, now());
|
|
620
|
+
// Only its tool calls: the host narrates a message on the stream as
|
|
621
|
+
// the session's own words (`harnessActivity.ts`), and the review is
|
|
622
|
+
// not the yak speaking. Its findings reach the session as a turn.
|
|
623
|
+
if (event.type === "tool_execution_start" || event.type === "tool_execution_end") {
|
|
624
|
+
input.emit({ ...event, yagni: { stage: stageId } });
|
|
625
|
+
}
|
|
626
|
+
},
|
|
627
|
+
now,
|
|
628
|
+
});
|
|
593
629
|
const message = turnMessage({
|
|
594
630
|
stage: input.stage,
|
|
595
631
|
resumed,
|
|
@@ -630,7 +666,48 @@ async function runTurn(input, deps, pulse) {
|
|
|
630
666
|
const planned = await planWithBlock(run, turn, input.signal);
|
|
631
667
|
stages.push(...planned.asked);
|
|
632
668
|
run = planned.run;
|
|
633
|
-
|
|
669
|
+
const sections = [];
|
|
670
|
+
// A plan with its block is reviewed until a round finds nothing major,
|
|
671
|
+
// then its cited paths are checked; one without has nothing to review.
|
|
672
|
+
if (extractPlanJson(run.finalOutput) !== null &&
|
|
673
|
+
turnStop(run, false, input.signal?.aborted === true).stop === "clean") {
|
|
674
|
+
const withBlock = (answer) => planWithBlock(answer, turn, input.signal);
|
|
675
|
+
const reviewed = await selfReviewPlan({
|
|
676
|
+
run,
|
|
677
|
+
inputDir: input.inputDir,
|
|
678
|
+
turn,
|
|
679
|
+
review,
|
|
680
|
+
withBlock,
|
|
681
|
+
timeLeftMs,
|
|
682
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
683
|
+
});
|
|
684
|
+
stages.push(...reviewed.asked);
|
|
685
|
+
run = reviewed.run;
|
|
686
|
+
sections.push(selfReviewSection(reviewed.rounds, reviewed.ended));
|
|
687
|
+
if (reviewed.ended) {
|
|
688
|
+
const note = `The plan's review ended before a clean round (${reviewed.rounds.length} round(s)): ${reviewed.ended}.`;
|
|
689
|
+
notes.push(note);
|
|
690
|
+
input.writeErr(note);
|
|
691
|
+
}
|
|
692
|
+
const checked = await checkPlanPaths({
|
|
693
|
+
run,
|
|
694
|
+
cwd: input.cwd,
|
|
695
|
+
exec,
|
|
696
|
+
exists: (path) => exists(isAbsolute(path) ? path : join(input.cwd, path)),
|
|
697
|
+
turn,
|
|
698
|
+
withBlock,
|
|
699
|
+
...(input.signal ? { signal: input.signal } : {}),
|
|
700
|
+
});
|
|
701
|
+
stages.push(...checked.asked);
|
|
702
|
+
run = checked.run;
|
|
703
|
+
if (checked.section)
|
|
704
|
+
sections.push(checked.section);
|
|
705
|
+
notes.push(...checked.notes);
|
|
706
|
+
}
|
|
707
|
+
planText =
|
|
708
|
+
sections.length > 0
|
|
709
|
+
? [run.finalOutput.trimEnd(), ...sections].join("\n\n")
|
|
710
|
+
: run.finalOutput;
|
|
634
711
|
notes.push(...(await putBackPlanTurn(input.cwd, start, exec, snapshot, input.signal)));
|
|
635
712
|
}
|
|
636
713
|
const stop = turnStop(run, writes, input.signal?.aborted === true);
|
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.2314.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": "c2e377750b3dd156d520b92af3d0ab8bfcd72e6d"
|
|
62
62
|
}
|