@yagni-app/code-staging 1.2.14-staging.2389.1 → 1.2.14-staging.2394.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/cloud.d.ts +6 -1
- package/dist/extension/pipeline/needsPerson.d.ts +45 -0
- package/dist/extension/pipeline/needsPerson.js +97 -0
- package/dist/extension/pipeline/planReview.d.ts +14 -2
- package/dist/extension/pipeline/planReview.js +35 -6
- package/dist/extension/pipeline/sessionLane.d.ts +8 -0
- package/dist/extension/pipeline/sessionLane.js +103 -13
- package/dist/extension/pipeline/stages.d.ts +11 -0
- package/dist/extension/pipeline/stages.js +42 -1
- package/dist/extension/pipeline/ticketPath.d.ts +20 -0
- package/dist/extension/pipeline/ticketPath.js +59 -0
- package/package.json +2 -2
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* lives (`packages/shared/src/attempts.ts`): the two meet only at this JSON.
|
|
17
17
|
*/
|
|
18
18
|
import type { ContinuationStage } from "./continuation.js";
|
|
19
|
+
import type { AttemptAsk } from "./needsPerson.js";
|
|
19
20
|
import { type RunFinishOpts } from "./finish.js";
|
|
20
21
|
import { type PlanChange } from "./planChanges.js";
|
|
21
22
|
import { type VerifyCheckRun, type VerifyOutcome } from "./verify.js";
|
|
@@ -78,7 +79,9 @@ export declare function prepareCloudLane(input: {
|
|
|
78
79
|
problem: string;
|
|
79
80
|
};
|
|
80
81
|
/** The stop reasons `result.json` carries. */
|
|
81
|
-
export type ResultStopReason = "clean" | "round_cap" | "no_changes" | "budget_exceeded" | "failed" | "aborted"
|
|
82
|
+
export type ResultStopReason = "clean" | "round_cap" | "no_changes" | "budget_exceeded" | "failed" | "aborted"
|
|
83
|
+
/** The session lane's turn stopped to ask a person, with its ask (`needsPerson.ts`). */
|
|
84
|
+
| "needs_person";
|
|
82
85
|
/**
|
|
83
86
|
* The pipeline's stop as the result names it. `partial` (a write stage cut off
|
|
84
87
|
* after it began editing) is `failed` here; its change is still committed, and
|
|
@@ -140,6 +143,8 @@ export interface AttemptResult extends CloudIdentity {
|
|
|
140
143
|
* Absent on every other turn: the host then drafts the preview itself.
|
|
141
144
|
*/
|
|
142
145
|
uiPreview?: "drawn" | "none" | "not_drawn";
|
|
146
|
+
/** The session lane's ask on a `needs_person` stop (`needsPerson.ts`). */
|
|
147
|
+
ask?: AttemptAsk;
|
|
143
148
|
}
|
|
144
149
|
/** The findings the result reports, blocking first. */
|
|
145
150
|
export declare function openFindings(findings: readonly Finding[]): OpenFinding[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session that stops for a person writes its own ask: the question, what it
|
|
3
|
+
* found and the options it sees, in `needs-person.json` beside its report. The
|
|
4
|
+
* turn then ends `needs_person`, with the ask on `result.json`, and the host
|
|
5
|
+
* hands the ticket to a person with those words (cleaned of secrets and
|
|
6
|
+
* markup there). Only for a change of direction: the plan or the ticket is
|
|
7
|
+
* wrong about the code, or the right change is far larger than the ticket.
|
|
8
|
+
*
|
|
9
|
+
* This package does not depend on `@yagni/shared`, so the region between the
|
|
10
|
+
* markers below is a byte-for-byte copy of the same region of
|
|
11
|
+
* `packages/shared/src/attempts.ts`; `test/pipeline/needsPerson.test.ts` fails
|
|
12
|
+
* when the two differ. Change the shared file and copy the region here.
|
|
13
|
+
*/
|
|
14
|
+
import type { AttemptResult } from "./cloud.js";
|
|
15
|
+
/** The session's ask, beside its report in the output folder. */
|
|
16
|
+
export declare const NEEDS_PERSON_FILE_NAME = "needs-person.json";
|
|
17
|
+
/** What a session asks a person when it stops for one. */
|
|
18
|
+
export interface AttemptAsk {
|
|
19
|
+
question: string;
|
|
20
|
+
/** What it found, each the file:line, command or query and what it showed. */
|
|
21
|
+
evidence: string[];
|
|
22
|
+
/** The ways on it sees, its own first when it has one. */
|
|
23
|
+
options: string[];
|
|
24
|
+
}
|
|
25
|
+
/** The longest question, the longest evidence or option line, and how many of each. */
|
|
26
|
+
export declare const MAX_ASK_QUESTION_CHARS = 600;
|
|
27
|
+
export declare const MAX_ASK_LINE_CHARS = 400;
|
|
28
|
+
export declare const MAX_ASK_LINES = 8;
|
|
29
|
+
/** The ask as written, each part on one line and bounded; null without a question. */
|
|
30
|
+
export declare function parseAttemptAsk(value: unknown): AttemptAsk | null;
|
|
31
|
+
/** The ask as the file holds it, or null when the file is missing, does not read or asks nothing. */
|
|
32
|
+
export declare function readNeedsPerson(text: string | null): AttemptAsk | null;
|
|
33
|
+
/**
|
|
34
|
+
* The build rule that says when the session stops for a person, and how. A
|
|
35
|
+
* person answers it and the session resumes with their answer.
|
|
36
|
+
*/
|
|
37
|
+
export declare const NEEDS_PERSON_RULE: (outDir: string) => string;
|
|
38
|
+
/**
|
|
39
|
+
* A writing turn's result with the session's ask folded in: a turn that
|
|
40
|
+
* ended on its own (`clean`, or `no_changes`) with an ask stops
|
|
41
|
+
* `needs_person`, carrying the ask. A turn the host stopped (failed, aborted,
|
|
42
|
+
* out of time) keeps its own stop: that is what a person reads.
|
|
43
|
+
*/
|
|
44
|
+
export declare function withNeedsPerson(attempt: AttemptResult, ask: AttemptAsk | null): AttemptResult;
|
|
45
|
+
//# sourceMappingURL=needsPerson.d.ts.map
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A session that stops for a person writes its own ask: the question, what it
|
|
3
|
+
* found and the options it sees, in `needs-person.json` beside its report. The
|
|
4
|
+
* turn then ends `needs_person`, with the ask on `result.json`, and the host
|
|
5
|
+
* hands the ticket to a person with those words (cleaned of secrets and
|
|
6
|
+
* markup there). Only for a change of direction: the plan or the ticket is
|
|
7
|
+
* wrong about the code, or the right change is far larger than the ticket.
|
|
8
|
+
*
|
|
9
|
+
* This package does not depend on `@yagni/shared`, so the region between the
|
|
10
|
+
* markers below is a byte-for-byte copy of the same region of
|
|
11
|
+
* `packages/shared/src/attempts.ts`; `test/pipeline/needsPerson.test.ts` fails
|
|
12
|
+
* when the two differ. Change the shared file and copy the region here.
|
|
13
|
+
*/
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
/** The session's ask, beside its report in the output folder. */
|
|
16
|
+
export const NEEDS_PERSON_FILE_NAME = "needs-person.json";
|
|
17
|
+
/** The longest question, the longest evidence or option line, and how many of each. */
|
|
18
|
+
export const MAX_ASK_QUESTION_CHARS = 600;
|
|
19
|
+
export const MAX_ASK_LINE_CHARS = 400;
|
|
20
|
+
export const MAX_ASK_LINES = 8;
|
|
21
|
+
/** Words on one line, clipped; null for none. */
|
|
22
|
+
function askLine(value, max) {
|
|
23
|
+
if (typeof value !== "string")
|
|
24
|
+
return null;
|
|
25
|
+
const words = value.replace(/\s+/g, " ").trim();
|
|
26
|
+
return words ? words.slice(0, max) : null;
|
|
27
|
+
}
|
|
28
|
+
function askLines(value) {
|
|
29
|
+
if (!Array.isArray(value))
|
|
30
|
+
return [];
|
|
31
|
+
const lines = [];
|
|
32
|
+
for (const entry of value) {
|
|
33
|
+
if (lines.length >= MAX_ASK_LINES)
|
|
34
|
+
break;
|
|
35
|
+
const line = askLine(entry, MAX_ASK_LINE_CHARS);
|
|
36
|
+
if (line)
|
|
37
|
+
lines.push(line);
|
|
38
|
+
}
|
|
39
|
+
return lines;
|
|
40
|
+
}
|
|
41
|
+
/** The ask as written, each part on one line and bounded; null without a question. */
|
|
42
|
+
export function parseAttemptAsk(value) {
|
|
43
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
44
|
+
return null;
|
|
45
|
+
const raw = value;
|
|
46
|
+
const question = askLine(raw.question, MAX_ASK_QUESTION_CHARS);
|
|
47
|
+
if (!question)
|
|
48
|
+
return null;
|
|
49
|
+
return { question, evidence: askLines(raw.evidence), options: askLines(raw.options) };
|
|
50
|
+
}
|
|
51
|
+
// --- mirrored ask region: end
|
|
52
|
+
/** The ask as the file holds it, or null when the file is missing, does not read or asks nothing. */
|
|
53
|
+
export function readNeedsPerson(text) {
|
|
54
|
+
if (!text)
|
|
55
|
+
return null;
|
|
56
|
+
try {
|
|
57
|
+
return parseAttemptAsk(JSON.parse(text));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The build rule that says when the session stops for a person, and how. A
|
|
65
|
+
* person answers it and the session resumes with their answer.
|
|
66
|
+
*/
|
|
67
|
+
export const NEEDS_PERSON_RULE = (outDir) => `Stop and ask a person only for a change of direction: the plan or the ticket is wrong about the code, or the right change is far larger than the ticket, or a choice that cannot be undone that neither settles. Never for what a check, a read or a decision record answers. Then write ${join(outDir, NEEDS_PERSON_FILE_NAME)} as JSON: ` +
|
|
68
|
+
'{"question": "<one question a person can answer>", "evidence": ["<file:line, command or query, and what it showed>"], "options": ["<your recommendation first>", "<each other way on>"]}, ' +
|
|
69
|
+
"commit what is done so far, write the report, and end your turn: YAGNI hands the ticket to a person with your ask, and you resume with their answer.";
|
|
70
|
+
/**
|
|
71
|
+
* A writing turn's result with the session's ask folded in: a turn that
|
|
72
|
+
* ended on its own (`clean`, or `no_changes`) with an ask stops
|
|
73
|
+
* `needs_person`, carrying the ask. A turn the host stopped (failed, aborted,
|
|
74
|
+
* out of time) keeps its own stop: that is what a person reads.
|
|
75
|
+
*/
|
|
76
|
+
export function withNeedsPerson(attempt, ask) {
|
|
77
|
+
if (!ask)
|
|
78
|
+
return attempt;
|
|
79
|
+
if (attempt.stopReason !== "clean" && attempt.stopReason !== "no_changes") {
|
|
80
|
+
return {
|
|
81
|
+
...attempt,
|
|
82
|
+
notes: [
|
|
83
|
+
...attempt.notes,
|
|
84
|
+
`The session also wrote an ask for a person, but the turn stopped (${attempt.stopReason}) first.`,
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
...attempt,
|
|
90
|
+
stopReason: "needs_person",
|
|
91
|
+
ask,
|
|
92
|
+
// The ask's words ride on `ask` alone, where the host cleans them; a note
|
|
93
|
+
// is stored and read as it is.
|
|
94
|
+
notes: [...attempt.notes, "The session stopped to ask a person; its ask is on this result."],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=needsPerson.js.map
|
|
@@ -24,6 +24,8 @@ export declare const MIN_REVIEW_ROUND_MS: number;
|
|
|
24
24
|
export declare const MAX_PLAN_REVIEW_ROUNDS = 4;
|
|
25
25
|
/** How the review ends when its last round still lists a major (its wording names the cap above). */
|
|
26
26
|
export declare const REVIEW_CAP_ENDED = "the review reached its cap of four rounds; round 4's majors were revised but not checked again";
|
|
27
|
+
/** How the review ends at a cap of `cap` rounds with a major still listed; at four, {@link REVIEW_CAP_ENDED}. */
|
|
28
|
+
export declare function reviewCapEnded(cap: number): string;
|
|
27
29
|
/** One major finding the session backed with evidence. */
|
|
28
30
|
export interface PlanFinding {
|
|
29
31
|
dimension: string;
|
|
@@ -46,7 +48,7 @@ export declare const REVIEW_MESSAGE_OPENING = "Review the plan you just wrote";
|
|
|
46
48
|
* whole (its plan-json block included) so a compaction during the plan turn
|
|
47
49
|
* never leaves the session reviewing a summary of its own plan.
|
|
48
50
|
*/
|
|
49
|
-
export declare function reviewMessage(inputDir: string, planText: string, round: number): string;
|
|
51
|
+
export declare function reviewMessage(inputDir: string, planText: string, round: number, cap?: number): string;
|
|
50
52
|
/** The re-ask when a review round's answer carried no verdict that reads. */
|
|
51
53
|
export declare const VERDICT_REASK = "Your last message did not end with a plan-review block that reads. Send the whole plan again as your last message: the plan, then its plan-json block, then the plan-review block listing the majors you found this round (an empty list when there were none).";
|
|
52
54
|
/** The text without its plan-review blocks: the verdict never reaches the gate's plan. */
|
|
@@ -86,6 +88,14 @@ export declare function selfReviewPlan(input: {
|
|
|
86
88
|
}>;
|
|
87
89
|
/** The run's time left before its turn's finish; undefined when it has no deadline. */
|
|
88
90
|
timeLeftMs: () => number | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* The most rounds for the plan as it stands (YAG-1306: the host sizes the
|
|
93
|
+
* review to the plan), read again after every round, so a review that
|
|
94
|
+
* changes the plan's size takes the new size's rounds. Absent, four.
|
|
95
|
+
*/
|
|
96
|
+
maxRounds?: (planText: string) => number;
|
|
97
|
+
/** Told as each round's turn starts, with its number: the stream marks its stage rows with it. */
|
|
98
|
+
onRound?: (round: number) => void;
|
|
89
99
|
signal?: AbortSignal;
|
|
90
100
|
}): Promise<{
|
|
91
101
|
run: StageResult;
|
|
@@ -94,7 +104,9 @@ export declare function selfReviewPlan(input: {
|
|
|
94
104
|
ended: string | null;
|
|
95
105
|
}>;
|
|
96
106
|
/** The `## Self-review` section the host adds to the plan: how many rounds, and what each changed. */
|
|
97
|
-
export declare function selfReviewSection(rounds: readonly ReviewRound[], ended: string | null
|
|
107
|
+
export declare function selfReviewSection(rounds: readonly ReviewRound[], ended: string | null,
|
|
108
|
+
/** The plan's own size, when the host sized the review to it and it ran no round. */
|
|
109
|
+
unreviewedSize?: string | null): string;
|
|
98
110
|
/** A path a plan cites, and whether the line that cites it says the plan creates it. */
|
|
99
111
|
export interface CitedPath {
|
|
100
112
|
path: string;
|
|
@@ -24,6 +24,13 @@ export const MIN_REVIEW_ROUND_MS = 10 * 60_000;
|
|
|
24
24
|
export const MAX_PLAN_REVIEW_ROUNDS = 4;
|
|
25
25
|
/** How the review ends when its last round still lists a major (its wording names the cap above). */
|
|
26
26
|
export const REVIEW_CAP_ENDED = "the review reached its cap of four rounds; round 4's majors were revised but not checked again";
|
|
27
|
+
const ROUND_WORDS = ["no rounds", "one round", "two rounds", "three rounds", "four rounds"];
|
|
28
|
+
/** How the review ends at a cap of `cap` rounds with a major still listed; at four, {@link REVIEW_CAP_ENDED}. */
|
|
29
|
+
export function reviewCapEnded(cap) {
|
|
30
|
+
if (cap >= MAX_PLAN_REVIEW_ROUNDS)
|
|
31
|
+
return REVIEW_CAP_ENDED;
|
|
32
|
+
return `the review reached its cap of ${ROUND_WORDS[cap] ?? `${cap} rounds`}; round ${cap}'s majors were revised but not checked again`;
|
|
33
|
+
}
|
|
27
34
|
const MAX_FINDINGS = 10;
|
|
28
35
|
const PLAN_REVIEW_BLOCK = /```plan-review[^\n]*\n([\s\S]*?)```/gi;
|
|
29
36
|
function clipped(value, max) {
|
|
@@ -40,10 +47,15 @@ export const REVIEW_MESSAGE_OPENING = "Review the plan you just wrote";
|
|
|
40
47
|
* whole (its plan-json block included) so a compaction during the plan turn
|
|
41
48
|
* never leaves the session reviewing a summary of its own plan.
|
|
42
49
|
*/
|
|
43
|
-
export function reviewMessage(inputDir, planText, round) {
|
|
50
|
+
export function reviewMessage(inputDir, planText, round, cap = MAX_PLAN_REVIEW_ROUNDS) {
|
|
44
51
|
const at = (file) => `${inputDir.replace(/\/+$/, "")}/${file}`;
|
|
52
|
+
// On a sized review (YAG-1306) the plan may start its build with nobody
|
|
53
|
+
// approving it first, so the message does not promise that a person does.
|
|
54
|
+
const next = cap === MAX_PLAN_REVIEW_ROUNDS
|
|
55
|
+
? "A person approves it next, and the build follows it."
|
|
56
|
+
: "The build follows it.";
|
|
45
57
|
return [
|
|
46
|
-
`${REVIEW_MESSAGE_OPENING}, round ${round} of at most ${
|
|
58
|
+
`${REVIEW_MESSAGE_OPENING}, round ${round} of at most ${cap}, against the ticket in ${at("ticket.md")} and the code. ${next} Read again what you need and run what settles a fact; change no tracked file and commit nothing.`,
|
|
47
59
|
[
|
|
48
60
|
"Answer each of these questions against the code, not from memory:",
|
|
49
61
|
'1. Ticket check: is each premise the plan relies on checked, with the command, file:line or query that shows it, or marked as not checkable? Is a premise marked checked really true? Is "Done when" written? When the plan recommends closing the ticket, check that evidence again yourself.',
|
|
@@ -156,13 +168,19 @@ export async function selfReviewPlan(input) {
|
|
|
156
168
|
return "the attempt was stopped";
|
|
157
169
|
return null;
|
|
158
170
|
};
|
|
171
|
+
const capFor = (planText) => Math.max(0, Math.min(MAX_PLAN_REVIEW_ROUNDS, input.maxRounds?.(planText) ?? MAX_PLAN_REVIEW_ROUNDS));
|
|
159
172
|
for (let round = 1;; round += 1) {
|
|
160
173
|
if (input.signal?.aborted)
|
|
161
174
|
return end("the attempt was stopped");
|
|
175
|
+
// A plan sized for no review runs none, and ends as a clean one does.
|
|
176
|
+
const cap = capFor(run.finalOutput);
|
|
177
|
+
if (round > cap)
|
|
178
|
+
return { run, asked, rounds, ended: null };
|
|
162
179
|
const left = input.timeLeftMs();
|
|
163
180
|
if (left !== undefined && left < MIN_REVIEW_ROUND_MS)
|
|
164
181
|
return end("the run's time ran low");
|
|
165
|
-
|
|
182
|
+
input.onRound?.(round);
|
|
183
|
+
let answer = await input.turn(reviewMessage(input.inputDir, run.finalOutput, round, cap));
|
|
166
184
|
asked.push(answer);
|
|
167
185
|
const first = stopped(answer);
|
|
168
186
|
if (first)
|
|
@@ -205,12 +223,23 @@ export async function selfReviewPlan(input) {
|
|
|
205
223
|
rounds.push({ round, findings, outcome: "revised" });
|
|
206
224
|
if (findings.length === 0)
|
|
207
225
|
return { run, asked, rounds, ended: null };
|
|
208
|
-
|
|
209
|
-
|
|
226
|
+
// The cap of the plan as revised: a review that sized it up goes on.
|
|
227
|
+
const capNow = capFor(run.finalOutput);
|
|
228
|
+
if (round >= capNow)
|
|
229
|
+
return end(reviewCapEnded(Math.max(capNow, round)));
|
|
210
230
|
}
|
|
211
231
|
}
|
|
212
232
|
/** The `## Self-review` section the host adds to the plan: how many rounds, and what each changed. */
|
|
213
|
-
export function selfReviewSection(rounds, ended
|
|
233
|
+
export function selfReviewSection(rounds, ended,
|
|
234
|
+
/** The plan's own size, when the host sized the review to it and it ran no round. */
|
|
235
|
+
unreviewedSize) {
|
|
236
|
+
if (rounds.length === 0 && !ended && unreviewedSize) {
|
|
237
|
+
return [
|
|
238
|
+
"## Self-review",
|
|
239
|
+
"",
|
|
240
|
+
`None: the plan sizes this ticket ${unreviewedSize}, and a ${unreviewedSize} plan is not reviewed before its build. Its pull request is reviewed.`,
|
|
241
|
+
].join("\n");
|
|
242
|
+
}
|
|
214
243
|
const count = rounds.length === 1 ? "1 round" : `${rounds.length} rounds`;
|
|
215
244
|
const lines = [
|
|
216
245
|
"## Self-review",
|
|
@@ -50,6 +50,7 @@ import { type AttemptResult, type CloudIdentity, type CloudStage } from "./cloud
|
|
|
50
50
|
import type { ContinuationInputs } from "./continuation.js";
|
|
51
51
|
import { type PlanChange } from "./planChanges.js";
|
|
52
52
|
import { type RunStageDeps } from "./runner.js";
|
|
53
|
+
import { type SessionTicketPath } from "./ticketPath.js";
|
|
53
54
|
import type { JsonEvent, ModelTier, PipelineStage, StageId, StageResult, StopReason } from "./types.js";
|
|
54
55
|
import { type VerifyCheckRun } from "./verify.js";
|
|
55
56
|
import { snapshotWorkspace } from "./workspace.js";
|
|
@@ -154,6 +155,13 @@ export interface TurnFacts {
|
|
|
154
155
|
* no person answers the plan's questions. Only ever on a plan turn.
|
|
155
156
|
*/
|
|
156
157
|
ownPlans?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* `ticket-path.json`, as the host wrote it (`ticketPath.ts`): this ticket
|
|
160
|
+
* runs as one session (YAG-1306), so its plan is the short one, its review
|
|
161
|
+
* is sized to it, and a fix is about what is wrong. Absent on every other
|
|
162
|
+
* ticket, whose turns read exactly as they did.
|
|
163
|
+
*/
|
|
164
|
+
ticketPath?: SessionTicketPath | null;
|
|
157
165
|
}
|
|
158
166
|
/** The file the host writes when a yak approves its own plans (`attempts/inputs.ts`, `yaks/ownPlans.ts`). */
|
|
159
167
|
export declare const OWN_PLANS_FILE_NAME = "own-plans.md";
|
|
@@ -55,6 +55,7 @@ import { completeCloudSession, RESULT_FILE_NAME, } from "./cloud.js";
|
|
|
55
55
|
import { finishExec } from "./finish.js";
|
|
56
56
|
import { HELPER_SESSIONS_DIR_ENV } from "./helperSessions.js";
|
|
57
57
|
import { MISSION_CHECKS_FILE_NAME, readMissionChecksFile } from "./missionChecks.js";
|
|
58
|
+
import { NEEDS_PERSON_FILE_NAME, NEEDS_PERSON_RULE, readNeedsPerson, withNeedsPerson, } from "./needsPerson.js";
|
|
58
59
|
import { creditExhaustionReason } from "./orchestrator.js";
|
|
59
60
|
import { WORK_A_TICKET_SKILL } from "./personas.js";
|
|
60
61
|
import { healPlacedSecrets, publicationBase } from "./placedValueHeal.js";
|
|
@@ -63,7 +64,8 @@ import { checkPlanPaths, selfReviewPlan, selfReviewSection } from "./planReview.
|
|
|
63
64
|
import { PLAN_CHANGES_RULE, parsePlanChanges, planChangeNote, } from "./planChanges.js";
|
|
64
65
|
import { runStage as defaultRunStage } from "./runner.js";
|
|
65
66
|
import { scrubSecrets } from "./scrubSecrets.js";
|
|
66
|
-
import { DECISIONS_READ_TOOL, PLAN_JSON_CONTRACT } from "./stages.js";
|
|
67
|
+
import { DECISIONS_READ_TOOL, PLAN_JSON_CONTRACT, YAK_PLAN_JSON_CONTRACT } from "./stages.js";
|
|
68
|
+
import { planReviewRoundsFor, planSizeOf, sessionTicketPathOf, TICKET_PATH_FILE_NAME, } from "./ticketPath.js";
|
|
67
69
|
import { STAGE_WRAP_UP_GRACE_MS } from "./stageClock.js";
|
|
68
70
|
import { editsMostlyFailed } from "./events.js";
|
|
69
71
|
import { baselineDirs, parseChangedPaths, planPaths } from "./verify.js";
|
|
@@ -262,6 +264,7 @@ const BUILD_RULES = (outDir, who) => [
|
|
|
262
264
|
"- 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.",
|
|
263
265
|
"- 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.",
|
|
264
266
|
"- Commit on the branch you are on. Never push and never open or edit a pull request: YAGNI pushes your commits and opens it.",
|
|
267
|
+
`- ${NEEDS_PERSON_RULE(outDir)}`,
|
|
265
268
|
`- ${PULL_REQUEST_CONTRACT(outDir)}`,
|
|
266
269
|
`- ${REPORT_CONTRACT(outDir)}`,
|
|
267
270
|
].join("\n");
|
|
@@ -282,7 +285,22 @@ const PLAN_TOOLS = "read, grep, find, ls, bash, ask_yagni, team_read, prototype_
|
|
|
282
285
|
* folder) the turn also draws the plan's UI preview: it gets write and edit
|
|
283
286
|
* for the preview's files, and the rule that says when to draw one.
|
|
284
287
|
*/
|
|
285
|
-
const planRules = (preview, ownPlans) =>
|
|
288
|
+
const planRules = (preview, ownPlans, path = null) => path
|
|
289
|
+
? [
|
|
290
|
+
preview
|
|
291
|
+
? `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.`
|
|
292
|
+
: `This turn you have ${PLAN_TOOLS}, and no edit or write tool.`,
|
|
293
|
+
NARRATION_RULE,
|
|
294
|
+
...PLAN_RULES_BEFORE_PREVIEW,
|
|
295
|
+
...(preview ? [previewRule(preview.inputDir, preview.outDir)] : []),
|
|
296
|
+
`${SHORT_PLAN_FORMAT_RULE} ${ownPlans ? SHORT_DECIDE_RULE : SHORT_QUESTION_RULE}`,
|
|
297
|
+
SHORT_PLAN_CLOSE_RULE,
|
|
298
|
+
YAK_PLAN_JSON_CONTRACT,
|
|
299
|
+
shortPlanStop(path, ownPlans),
|
|
300
|
+
].join("\n\n")
|
|
301
|
+
: planRulesBefore(preview, ownPlans);
|
|
302
|
+
/** The plan turn's rules on every ticket that is not a one-session yak's: as they always read. */
|
|
303
|
+
const planRulesBefore = (preview, ownPlans) => [
|
|
286
304
|
preview
|
|
287
305
|
? `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.`
|
|
288
306
|
: `This turn you have ${PLAN_TOOLS}, and no edit or write tool.`,
|
|
@@ -316,10 +334,42 @@ const QUESTION_RULE = "Where there is a real choice of approach, ask it as a dec
|
|
|
316
334
|
* Where the yak approves its own plans (`own-plans.md`): YAGNI takes every
|
|
317
335
|
* recommendation, so a question only records a change of direction.
|
|
318
336
|
*/
|
|
319
|
-
const DECIDE_RULE = "This yak approves its own plans: no person answers this plan's questions, and YAGNI takes your recommendation on each one. So where there is a real choice of approach, decide on your recommendation: the plan's steps follow it, and ## Risks states it as the assumption you plan on, with what would change it. Put a question in the plan-json block only for a change of direction, with the evidence (file:line, command or query) in its checked lines: the ticket's premise is false, or the right change is far larger than the ticket.";
|
|
337
|
+
const DECIDE_RULE = "This yak approves its own plans: no person answers this plan's questions, and YAGNI takes your recommendation on each one. So where there is a real choice of approach, decide on your recommendation: the plan's steps follow it, and ## Risks states it as the assumption you plan on, with what would change it. Put a question in the plan-json block only for a change of direction, with the evidence (file:line, command or query) in its checked lines: the ticket's premise is false, or the right change is far larger than the ticket. Such a question hands the ticket to a person with your question, its evidence and its options: YAGNI does not answer it, and nothing is built until they do.";
|
|
320
338
|
const PLAN_CLOSE_RULE = 'When the ticket check shows the problem is already gone, recommend closing the ticket instead of planning a change: ## Goal says so in one sentence, the ticket check holds the evidence, ## Plan says "Nothing to build." with no numbered steps, and the plan-json block carries "closeTicket" with the evidence and names no checks and no paths. A person then decides whether to close it.';
|
|
321
339
|
const PLAN_STOP = "Then stop: next you review this plan yourself, in this session, for at most four rounds, fixing what you find. A person approves the plan before anything is built.";
|
|
322
340
|
const OWN_PLANS_STOP = "Then stop: next you review this plan yourself, in this session, for at most four rounds, fixing what you find. Once the review ends, YAGNI approves the plan for this yak and the build starts.";
|
|
341
|
+
/**
|
|
342
|
+
* The short plan (YAG-1306, ADR-0060): what done means, the checks, the
|
|
343
|
+
* scope and what is left alone, and only the questions a person must
|
|
344
|
+
* answer. The host reads these headings (`readSessionPlan` in the backend's
|
|
345
|
+
* `attempts/plan.ts`): Done when becomes the plan's items and its
|
|
346
|
+
* acceptance criteria, Scope its files, Not doing what the review never
|
|
347
|
+
* calls missing.
|
|
348
|
+
*/
|
|
349
|
+
const SHORT_PLAN_FORMAT_RULE = 'End the turn with the plan as your last message, and keep it short. ## Goal: one sentence. ## Done when: what is true when this is finished, one line each, from the ticket\'s acceptance criteria or yours; a reviewer holds the change to these lines. ## Checks: the commands you will run to prove it. ## Scope: the files or folders you will change, one per line in code spans (say "new" beside one the plan creates), then one line for each assumption you plan on. ## Not doing: what you leave alone on purpose, one line each, when there is anything. ## Questions: only when a person must answer something before you build. Then the plan-json block. Write no step list, no ticket-check table and no risks section: the premises you checked are yours to have checked, not to list.';
|
|
350
|
+
const SHORT_QUESTION_RULE = "Where a person must choose, ask it as a question in the plan-json block; where you would choose yourself, choose, and say it under ## Scope.";
|
|
351
|
+
/** {@link DECIDE_RULE} for the short plan, which has no Risks section to state an assumption in. */
|
|
352
|
+
const SHORT_DECIDE_RULE = "This yak approves its own plans: no person answers this plan's questions. So where there is a choice of approach, choose, and say it under ## Scope as the assumption you plan on, with what would change it. Put a question in the plan-json block only for a change of direction, with its evidence (file:line, command or query) in the question's text: the ticket's premise is false, or the right change is far larger than the ticket.";
|
|
353
|
+
const SHORT_PLAN_CLOSE_RULE = 'When checking the ticket shows the problem is already gone, recommend closing it instead of planning a change: ## Goal says so in one sentence, ## Done when holds the evidence (the command, file:line or query, and what it showed), and the plan-json block carries "closeTicket" with that evidence and names no checks and no paths. A person then decides whether to close it.';
|
|
354
|
+
const reviewWords = (rounds) => rounds === 0
|
|
355
|
+
? "is not reviewed again"
|
|
356
|
+
: rounds === 1
|
|
357
|
+
? "you review once"
|
|
358
|
+
: `you review for at most ${rounds} rounds`;
|
|
359
|
+
/** How a one-session plan turn ends: the review its size gets, and whether anyone is waited on. */
|
|
360
|
+
const shortPlanStop = (path, ownPlans) => {
|
|
361
|
+
const by = path.planReviewRounds;
|
|
362
|
+
const review = `Then stop. What comes next depends on the size you gave it: a small plan ${reviewWords(by.small)}, a standard plan ${reviewWords(by.standard)}, a complex plan ${reviewWords(by.complex)}, in this session.`;
|
|
363
|
+
return ownPlans
|
|
364
|
+
? `${review} YAGNI then approves the plan for this yak and the build starts.`
|
|
365
|
+
: `${review} A small or standard plan with no question then starts its build at once, and a person reads it while you build; any other plan waits for a person.`;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* A one-session ticket's fix (YAG-1306): about what is wrong, never every
|
|
369
|
+
* item a review lists. What is not fixed is answered in the outcomes file,
|
|
370
|
+
* so its thread is told why.
|
|
371
|
+
*/
|
|
372
|
+
const CORRECTNESS_FIX_RULE = "Fix what is wrong, not everything that is asked. An item is yours to fix when it names a bug, a failing check, a conflict, a broken contract, a security or data problem, or something the plan's Done when requires, and whenever a person on the Team asked for it themselves. For any other item (style, naming, a refactor, a nice-to-have) change nothing, and dispute it in the outcomes file with one line on why it is not a correctness problem.";
|
|
323
373
|
/**
|
|
324
374
|
* How a turn treats a review's items. The host acknowledges each thread at
|
|
325
375
|
* take and posts the outcomes after its push (`attempts/review.ts`), with the
|
|
@@ -328,6 +378,8 @@ const OWN_PLANS_STOP = "Then stop: next you review this plan yourself, in this s
|
|
|
328
378
|
* host posts the answer where it was asked.
|
|
329
379
|
*/
|
|
330
380
|
const FIX_RULE = "For each item: check it against the pull request on GitHub as it is now (read it with gh, and only read), then fix it, with a test that fails without the fix where it changes behavior, or dispute it with evidence a reviewer can check, or, when it only asks a question, answer it from the code as it is and change nothing for it. Never reply, comment, react or resolve on GitHub: YAGNI posts your outcomes where each item was asked once your turn ends.";
|
|
381
|
+
/** Where a person's answer to the attempt's stop is, and when to read it. */
|
|
382
|
+
const handOffAnswerLine = (file, before) => `Read ${file} before you ${before}: why the attempt stopped, and what a person answered.`;
|
|
331
383
|
/** The one message a turn sends the session. Pure. */
|
|
332
384
|
export function turnMessage(facts) {
|
|
333
385
|
const at = (file) => join(facts.inputDir, file);
|
|
@@ -354,9 +406,11 @@ export function turnMessage(facts) {
|
|
|
354
406
|
parts.push(`A person sent an earlier plan back: what they asked is in ${at("ticket.md")}, and that plan is ${at("sent-back-plan.md")}. ${PLANNED_ANYWAY}`);
|
|
355
407
|
}
|
|
356
408
|
}
|
|
409
|
+
if (facts.handOffAnswer)
|
|
410
|
+
parts.push(handOffAnswerLine(at("hand-off-answer.md"), "plan"));
|
|
357
411
|
if (newSince)
|
|
358
412
|
parts.push(newSince);
|
|
359
|
-
parts.push(planRules(facts.preview ? { inputDir: facts.inputDir, outDir: facts.outDir } : undefined, facts.ownPlans === true));
|
|
413
|
+
parts.push(planRules(facts.preview ? { inputDir: facts.inputDir, outDir: facts.outDir } : undefined, facts.ownPlans === true, facts.ticketPath ?? null));
|
|
360
414
|
return parts.join("\n\n");
|
|
361
415
|
}
|
|
362
416
|
if (facts.stage === "implement" && facts.resumed && !facts.continuation) {
|
|
@@ -365,7 +419,7 @@ export function turnMessage(facts) {
|
|
|
365
419
|
parts.push(`The person approved the plan. The plan as approved is ${at("plan.md")}: their answers are already in it, under Decisions and Not doing, and it supersedes the draft you wrote earlier in this session. Build that plan. Leave out everything under Not doing. ${PLAN_CHANGES_RULE}`);
|
|
366
420
|
}
|
|
367
421
|
else if (facts.stage === "fix" && facts.review) {
|
|
368
|
-
parts.push(`A review or the CI on this attempt's pull request asks for changes. They are in ${at("ticket.md")}, under "Review on this attempt's pull request", each with its id; the branch may hold a person's commits since your last turn, so read the code as it is now. Fix each item that asks for a change with the smallest change that does it and commit; answer each item that only asks a question in the outcomes file that section names, with no commit for it
|
|
422
|
+
parts.push(`A review or the CI on this attempt's pull request asks for changes. They are in ${at("ticket.md")}, under "Review on this attempt's pull request", each with its id; the branch may hold a person's commits since your last turn, so read the code as it is now. ${facts.ticketPath ? `${CORRECTNESS_FIX_RULE} Answer each item that only asks a question in the outcomes file that section names, with no commit for it, and commit what you fix.` : "Fix each item that asks for a change with the smallest change that does it and commit; answer each item that only asks a question in the outcomes file that section names, with no commit for it."}`, FIX_RULE);
|
|
369
423
|
}
|
|
370
424
|
else {
|
|
371
425
|
const why = facts.continuation?.priorStop
|
|
@@ -381,12 +435,11 @@ export function turnMessage(facts) {
|
|
|
381
435
|
parts.push("Check the work on this branch against the plan: run the checks, fix only what this change broke, and commit any fix.");
|
|
382
436
|
}
|
|
383
437
|
if (facts.review) {
|
|
384
|
-
parts.push(`A review or the CI on this attempt's pull request asks for changes: they are in ${at("ticket.md")}, under "Review on this attempt's pull request". Address every item (answer an item that only asks a question, with no change for it) and write the outcomes file that section names.`, FIX_RULE);
|
|
438
|
+
parts.push(`A review or the CI on this attempt's pull request asks for changes: they are in ${at("ticket.md")}, under "Review on this attempt's pull request". ${facts.ticketPath ? `${CORRECTNESS_FIX_RULE} Answer an item that only asks a question, with no change for it, and write` : "Address every item (answer an item that only asks a question, with no change for it) and write"} the outcomes file that section names.`, FIX_RULE);
|
|
385
439
|
}
|
|
386
440
|
}
|
|
387
|
-
if (facts.handOffAnswer)
|
|
388
|
-
parts.push(
|
|
389
|
-
}
|
|
441
|
+
if (facts.handOffAnswer)
|
|
442
|
+
parts.push(handOffAnswerLine(at("hand-off-answer.md"), "go on"));
|
|
390
443
|
// The host's file opens with "# A person added this while you worked" and
|
|
391
444
|
// carries the note fenced, so the session hears it in this turn's message,
|
|
392
445
|
// a resumed session included, whose ticket.md it read turns ago.
|
|
@@ -709,6 +762,16 @@ async function runTurn(input, deps, pulse) {
|
|
|
709
762
|
}
|
|
710
763
|
}
|
|
711
764
|
}
|
|
765
|
+
// An ask an earlier turn left is never this turn's.
|
|
766
|
+
const needsPersonFile = join(input.outDir, NEEDS_PERSON_FILE_NAME);
|
|
767
|
+
if (writes) {
|
|
768
|
+
try {
|
|
769
|
+
remove(needsPersonFile);
|
|
770
|
+
}
|
|
771
|
+
catch {
|
|
772
|
+
// One that cannot be removed is read as this turn's ask: a person is asked, never skipped.
|
|
773
|
+
}
|
|
774
|
+
}
|
|
712
775
|
// A yak's System's other repositories, each as the turn found it, for the
|
|
713
776
|
// read of a writing turn's change for a placed secret (YAG-1211).
|
|
714
777
|
const others = [];
|
|
@@ -782,13 +845,31 @@ async function runTurn(input, deps, pulse) {
|
|
|
782
845
|
},
|
|
783
846
|
now,
|
|
784
847
|
};
|
|
848
|
+
// What the host said about how this ticket runs (YAG-1306); null on every
|
|
849
|
+
// ticket that is not a one-session yak's.
|
|
850
|
+
const ticketPath = sessionTicketPathOf(readOrNull(join(input.inputDir, TICKET_PATH_FILE_NAME)));
|
|
851
|
+
// A stage's rows say when a turn takes the same stage up again (YAG-1306):
|
|
852
|
+
// the host resumed a stage an earlier turn stopped in, or this is one more
|
|
853
|
+
// message of this turn (a re-ask, a review round). A count of stages then
|
|
854
|
+
// counts one, and the time inside each row is still the time it took.
|
|
855
|
+
let stageOpened = Boolean(input.continuation?.priorStop);
|
|
856
|
+
/** The plan review round whose turn is running, for its stage rows; null outside one. */
|
|
857
|
+
let reviewRound = null;
|
|
785
858
|
const turn = async (message) => {
|
|
786
|
-
|
|
859
|
+
// Only on a one-session ticket: every other ticket's stream is as it was.
|
|
860
|
+
const marks = ticketPath
|
|
861
|
+
? {
|
|
862
|
+
...(stageOpened ? { resumed: true } : {}),
|
|
863
|
+
...(reviewRound !== null ? { round: reviewRound } : {}),
|
|
864
|
+
}
|
|
865
|
+
: {};
|
|
866
|
+
stageOpened = true;
|
|
867
|
+
input.emit({ type: "pipeline_stage", stage: stageId, phase: "start", ...marks, at: now() });
|
|
787
868
|
try {
|
|
788
869
|
return await runStage(withClock(turnStage), { ticket: message }, runDeps);
|
|
789
870
|
}
|
|
790
871
|
finally {
|
|
791
|
-
input.emit({ type: "pipeline_stage", stage: stageId, phase: "finish", at: now() });
|
|
872
|
+
input.emit({ type: "pipeline_stage", stage: stageId, phase: "finish", ...marks, at: now() });
|
|
792
873
|
}
|
|
793
874
|
};
|
|
794
875
|
// On the CLI's own stderr, whose tail the host logs: a value that named
|
|
@@ -816,6 +897,7 @@ async function runTurn(input, deps, pulse) {
|
|
|
816
897
|
// The env the turn's child runs on, so the message and the agents the
|
|
817
898
|
// child is offered (`builtinAgents`) read one value.
|
|
818
899
|
codeWriter: resolveCodeWriter(input.childEnv),
|
|
900
|
+
...(ticketPath ? { ticketPath } : {}),
|
|
819
901
|
});
|
|
820
902
|
const notes = [];
|
|
821
903
|
const stages = [];
|
|
@@ -859,11 +941,19 @@ async function runTurn(input, deps, pulse) {
|
|
|
859
941
|
turn,
|
|
860
942
|
withBlock,
|
|
861
943
|
timeLeftMs,
|
|
944
|
+
// The host sizes a one-session ticket's review to its plan.
|
|
945
|
+
...(ticketPath
|
|
946
|
+
? { maxRounds: (text) => planReviewRoundsFor(ticketPath, text) }
|
|
947
|
+
: {}),
|
|
948
|
+
onRound: (round) => {
|
|
949
|
+
reviewRound = round;
|
|
950
|
+
},
|
|
862
951
|
...(input.signal ? { signal: input.signal } : {}),
|
|
863
952
|
});
|
|
953
|
+
reviewRound = null;
|
|
864
954
|
stages.push(...reviewed.asked);
|
|
865
955
|
run = reviewed.run;
|
|
866
|
-
sections.push(selfReviewSection(reviewed.rounds, reviewed.ended));
|
|
956
|
+
sections.push(selfReviewSection(reviewed.rounds, reviewed.ended, ticketPath ? planSizeOf(run.finalOutput) : null));
|
|
867
957
|
if (reviewed.ended) {
|
|
868
958
|
const note = `The plan's review ended before a clean round (${reviewed.rounds.length} round(s)): ${reviewed.ended}.`;
|
|
869
959
|
notes.push(note);
|
|
@@ -973,7 +1063,7 @@ async function runTurn(input, deps, pulse) {
|
|
|
973
1063
|
...turnPromptFacts(input.childEnv),
|
|
974
1064
|
};
|
|
975
1065
|
const attempt = writes
|
|
976
|
-
? withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)), pullRequestTextOf(readOrNull(join(input.outDir, PULL_REQUEST_FILE_NAME))))
|
|
1066
|
+
? withNeedsPerson(withSessionAccount(noted, parseSessionReport(readOrNull(join(input.outDir, SESSION_REPORT_FILE_NAME)), knownBaselines(input.inputDir, readFile)), pullRequestTextOf(readOrNull(join(input.outDir, PULL_REQUEST_FILE_NAME)))), readNeedsPerson(readOrNull(needsPersonFile)))
|
|
977
1067
|
: uiPreview
|
|
978
1068
|
? { ...noted, uiPreview }
|
|
979
1069
|
: noted;
|
|
@@ -95,6 +95,17 @@ export declare const FOLLOW_UPS_RULE: string;
|
|
|
95
95
|
*/
|
|
96
96
|
export declare const CLOSE_TICKET_RULE: string;
|
|
97
97
|
export declare const PLAN_JSON_CONTRACT: string;
|
|
98
|
+
/**
|
|
99
|
+
* The short plan's block (YAG-1306, ADR-0060): what a yak whose ticket runs
|
|
100
|
+
* as one session ends its plan on. The host reads it with the reader it
|
|
101
|
+
* reads {@link PLAN_JSON_CONTRACT}'s block with, which ignores what a short
|
|
102
|
+
* plan leaves out; every other Team's plan keeps the long contract. What
|
|
103
|
+
* done means, what is left alone and the scope are the plan's own sections
|
|
104
|
+
* (`sessionLane.ts`), never repeated here. A question in it is a person's:
|
|
105
|
+
* one that carries a recommendation is read as decided (`isStatedQuestion`
|
|
106
|
+
* in `@yagni/shared`), so the contract asks for none.
|
|
107
|
+
*/
|
|
108
|
+
export declare const YAK_PLAN_JSON_CONTRACT: string;
|
|
98
109
|
/**
|
|
99
110
|
* The one-attempt lane's session (`yagni go --headless --cloud`): plan,
|
|
100
111
|
* implement, review, fix, then verify and finish, which run no model. One
|
|
@@ -193,7 +193,7 @@ export const FOLLOW_UPS_RULE = '- "followUps" lists what you found that the tick
|
|
|
193
193
|
* answers, Close the ticket or Plan it anyway, and nothing is built.
|
|
194
194
|
*/
|
|
195
195
|
export const CLOSE_TICKET_RULE = '- "closeTicket" is only for a ticket whose problem the ticket check shows is already gone: ' +
|
|
196
|
-
|
|
196
|
+
"say why in one line and list the evidence, each the command, file:line or query and what it showed. " +
|
|
197
197
|
'Then the plan has no steps, and "checks" and "paths" stay empty. A person decides whether to close ' +
|
|
198
198
|
"the ticket. Leave it out whenever there is anything to build.";
|
|
199
199
|
export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json block and nothing after it:\n" +
|
|
@@ -240,6 +240,47 @@ export const PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json bl
|
|
|
240
240
|
FOLLOW_UPS_RULE +
|
|
241
241
|
"\n" +
|
|
242
242
|
CLOSE_TICKET_RULE;
|
|
243
|
+
/**
|
|
244
|
+
* The short plan's block (YAG-1306, ADR-0060): what a yak whose ticket runs
|
|
245
|
+
* as one session ends its plan on. The host reads it with the reader it
|
|
246
|
+
* reads {@link PLAN_JSON_CONTRACT}'s block with, which ignores what a short
|
|
247
|
+
* plan leaves out; every other Team's plan keeps the long contract. What
|
|
248
|
+
* done means, what is left alone and the scope are the plan's own sections
|
|
249
|
+
* (`sessionLane.ts`), never repeated here. A question in it is a person's:
|
|
250
|
+
* one that carries a recommendation is read as decided (`isStatedQuestion`
|
|
251
|
+
* in `@yagni/shared`), so the contract asks for none.
|
|
252
|
+
*/
|
|
253
|
+
export const YAK_PLAN_JSON_CONTRACT = "End your answer with a fenced ```plan-json block and nothing after it:\n" +
|
|
254
|
+
"```plan-json\n" +
|
|
255
|
+
"{\n" +
|
|
256
|
+
' "checks": [{"name": "lint", "command": "pnpm lint", "cwd": "apps/web"}],\n' +
|
|
257
|
+
' "paths": ["apps/web"],\n' +
|
|
258
|
+
' "questions": [{"text": "...", "kind": "decision", "alternatives": [{"answer": "...", "why": "..."}]}],\n' +
|
|
259
|
+
' "size": "small|standard|complex",\n' +
|
|
260
|
+
' "sizeReason": "one line on why the size"\n' +
|
|
261
|
+
"}\n" +
|
|
262
|
+
"```\n" +
|
|
263
|
+
"Rules the host enforces:\n" +
|
|
264
|
+
'- "checks" are the commands that prove the change, each run from "cwd" (repo-relative, "." for the root). ' +
|
|
265
|
+
'"paths" are the package folders the change touches.\n' +
|
|
266
|
+
'- "questions" holds only what a person must answer before you can build, and is empty when there is nothing: ' +
|
|
267
|
+
"a question there makes the build wait for a person. Settle what you can read or run yourself, and make the " +
|
|
268
|
+
"choices you would make yourself, saying each as one line under ## Scope. Write no recommendation on a question " +
|
|
269
|
+
"you need answered; give at most two alternatives a person could pick.\n" +
|
|
270
|
+
'- "size" is your own judgment of the build (small: a one-file or config fix; standard: a change across one or ' +
|
|
271
|
+
'two packages; complex: a cross-package, schema or contract change), with one line as "sizeReason". A small or ' +
|
|
272
|
+
"standard plan with no question starts its build without waiting for a person; a complex plan, one with a " +
|
|
273
|
+
"question, or one with no size waits for one. Size it honestly: a plan sized too small is built unseen.\n" +
|
|
274
|
+
"Add these only when they apply, and leave them out otherwise:\n" +
|
|
275
|
+
'- "repositoriesNeeded": [{"repository": "owner/name", "summary": "one line on what changes there"}] when the ' +
|
|
276
|
+
"change writes to more than one repository the ticket's Other repositories section lists, in the order they " +
|
|
277
|
+
"must be built and merged, this one included. Never a repository the change only reads.\n" +
|
|
278
|
+
'- "wrongRepository": {"repository": "owner/name", "why": "one line", "confidence": "high|low"} and ' +
|
|
279
|
+
'"dependsOn": [{"repository": "owner/name", "what": "one line"}]:\n' +
|
|
280
|
+
RIGHT_REPOSITORY_RULE +
|
|
281
|
+
"\n" +
|
|
282
|
+
'- "closeTicket": {"why": "one line", "evidence": ["the command, file:line or query, and what it showed"]}:\n' +
|
|
283
|
+
CLOSE_TICKET_RULE;
|
|
243
284
|
/**
|
|
244
285
|
* The cloud plan stage's task: the input folder the host wrote, read first,
|
|
245
286
|
* then a plan grounded in the installed checkout, inside the stage's own
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const TICKET_PATH_FILE_NAME = "ticket-path.json";
|
|
2
|
+
declare const SIZES: readonly ["small", "standard", "complex"];
|
|
3
|
+
type PlanSize = (typeof SIZES)[number];
|
|
4
|
+
export interface SessionTicketPath {
|
|
5
|
+
/** The plan review's rounds by the plan's own size. */
|
|
6
|
+
planReviewRounds: Record<PlanSize, number>;
|
|
7
|
+
/** The fix rounds a review may start before a person is asked. */
|
|
8
|
+
fixRoundCap: number;
|
|
9
|
+
}
|
|
10
|
+
/** The host's file as the turn reads it, or null for none, or one that is not the one-session path. */
|
|
11
|
+
export declare function sessionTicketPathOf(text: string | null): SessionTicketPath | null;
|
|
12
|
+
/** The size a plan's text gives itself in its plan-json block, or null. */
|
|
13
|
+
export declare function planSizeOf(planText: string): PlanSize | null;
|
|
14
|
+
/**
|
|
15
|
+
* The rounds the plan as it stands is reviewed for: the host's number for
|
|
16
|
+
* its size, or every round when the turn has no path or the plan no size.
|
|
17
|
+
*/
|
|
18
|
+
export declare function planReviewRoundsFor(path: SessionTicketPath | null, planText: string): number;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=ticketPath.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the host told this turn about how its ticket runs (YAG-1306): the
|
|
3
|
+
* `ticket-path.json` the host writes beside `ticket.md` for a yak whose
|
|
4
|
+
* ticket runs as one session (`attempts/inputs.ts` in the backend, from
|
|
5
|
+
* `ticketPathFileOf` in `@yagni/shared`). The session holds no copy of the
|
|
6
|
+
* rule: it reads the numbers. Without the file, or with one that does not
|
|
7
|
+
* read, the turn works as it did before the path existed: the long plan,
|
|
8
|
+
* four review rounds, every review item addressed.
|
|
9
|
+
*/
|
|
10
|
+
import { extractPlanJson } from "./planOutput.js";
|
|
11
|
+
import { MAX_PLAN_REVIEW_ROUNDS } from "./planReview.js";
|
|
12
|
+
export const TICKET_PATH_FILE_NAME = "ticket-path.json";
|
|
13
|
+
const SIZES = ["small", "standard", "complex"];
|
|
14
|
+
const rounds = (value) => typeof value === "number" && Number.isInteger(value) && value >= 0
|
|
15
|
+
? Math.min(value, MAX_PLAN_REVIEW_ROUNDS)
|
|
16
|
+
: null;
|
|
17
|
+
/** The host's file as the turn reads it, or null for none, or one that is not the one-session path. */
|
|
18
|
+
export function sessionTicketPathOf(text) {
|
|
19
|
+
if (!text)
|
|
20
|
+
return null;
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(text);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
29
|
+
return null;
|
|
30
|
+
const file = parsed;
|
|
31
|
+
if (file.path !== "one_session")
|
|
32
|
+
return null;
|
|
33
|
+
const by = (file.planReviewRounds ?? {});
|
|
34
|
+
const small = rounds(by.small);
|
|
35
|
+
const standard = rounds(by.standard);
|
|
36
|
+
const complex = rounds(by.complex);
|
|
37
|
+
const cap = file.fixRoundCap;
|
|
38
|
+
if (small === null || standard === null || complex === null)
|
|
39
|
+
return null;
|
|
40
|
+
if (typeof cap !== "number" || !Number.isInteger(cap) || cap < 1)
|
|
41
|
+
return null;
|
|
42
|
+
return { planReviewRounds: { small, standard, complex }, fixRoundCap: cap };
|
|
43
|
+
}
|
|
44
|
+
/** The size a plan's text gives itself in its plan-json block, or null. */
|
|
45
|
+
export function planSizeOf(planText) {
|
|
46
|
+
const size = extractPlanJson(planText)?.size;
|
|
47
|
+
return SIZES.find((known) => known === size) ?? null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The rounds the plan as it stands is reviewed for: the host's number for
|
|
51
|
+
* its size, or every round when the turn has no path or the plan no size.
|
|
52
|
+
*/
|
|
53
|
+
export function planReviewRoundsFor(path, planText) {
|
|
54
|
+
if (!path)
|
|
55
|
+
return MAX_PLAN_REVIEW_ROUNDS;
|
|
56
|
+
const size = planSizeOf(planText);
|
|
57
|
+
return size ? path.planReviewRounds[size] : MAX_PLAN_REVIEW_ROUNDS;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ticketPath.js.map
|
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.2394.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": "e29ca9753a1280f9199a792f5a2288d1288129fe"
|
|
62
62
|
}
|