@turri-dev/cli 0.1.3-next.f74e98a → 0.1.4-next.172be6f
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/README.md +22 -1
- package/dist/ask.js +34 -15
- package/dist/cli-options.js +12 -6
- package/dist/config-edit.js +1 -0
- package/dist/config.js +5 -2
- package/dist/extension.js +86 -25
- package/dist/genome.js +1 -1
- package/dist/init-config.js +5 -0
- package/dist/loop-cli.js +13 -1
- package/dist/loop-tools.js +31 -12
- package/dist/pi-launch.js +5 -0
- package/dist/pi.js +48 -19
- package/dist/question-dialog.js +9 -3
- package/dist/questioning.js +1 -1
- package/dist/regenerate/activity.js +14 -0
- package/dist/regenerate/conform.js +5 -5
- package/dist/regenerate/conformance-agents.js +28 -8
- package/dist/regenerate/conformance.js +24 -10
- package/dist/regenerate/list-arguments.js +121 -0
- package/dist/regenerate/loop.js +137 -18
- package/dist/regenerate/notes.js +66 -17
- package/dist/regenerate/prompt.js +3 -1
- package/dist/regenerate/regenerate.js +16 -10
- package/dist/regenerate/regression.js +2 -1
- package/dist/regenerate/requires.js +55 -2
- package/dist/regenerate/self-check.js +13 -6
- package/dist/regenerate/test-scripts.js +54 -10
- package/dist/regenerate/unit-review.js +12 -1
- package/dist/regenerate-cli.js +11 -5
- package/dist/release-tools.js +1 -1
- package/dist/resume-line.js +4 -0
- package/dist/review/live.js +2 -1
- package/dist/run-report.js +34 -1
- package/dist/spec-tools.js +10 -45
- package/docs/authoring-plain.md +9 -6
- package/docs/config.md +3 -2
- package/docs/headless.md +30 -3
- package/docs/installation.md +3 -0
- package/docs/regenerating.md +69 -20
- package/docs/skills-and-gates.md +5 -3
- package/docs/using.md +20 -9
- package/genome/skills/bud/SKILL.md +67 -36
- package/genome/skills/bud/references/intent.md +4 -0
- package/genome/skills/refactor-module/SKILL.md +24 -2
- package/package.json +3 -3
- package/genome/skills/bud/references/checklist.md +0 -44
package/dist/loop-tools.js
CHANGED
|
@@ -70,7 +70,11 @@ export async function loopReply(loop, statuses, wait) {
|
|
|
70
70
|
return { content: [{ type: "text", text }], details: { jobIds } };
|
|
71
71
|
}
|
|
72
72
|
/** Halt a pulse by its id, or the start of it: what it was, and what moves up behind it. `reason`: why, kept with it. */
|
|
73
|
-
export function stopJob(jobs, named, reason) {
|
|
73
|
+
export function stopJob(jobs, named, reason, loop) {
|
|
74
|
+
// A planned row, or a module by its name: the module is halted - its rows are planned again from the spec each look.
|
|
75
|
+
const module = /^planned-/.test(named.trim()) || !jobs.list().some((job) => job.id.startsWith(named.trim())) ? loop?.halt(named, reason) : undefined;
|
|
76
|
+
if (module !== undefined)
|
|
77
|
+
return module;
|
|
74
78
|
const matches = jobs.list().filter((job) => job.id.startsWith(named.trim()));
|
|
75
79
|
if (matches.length === 0)
|
|
76
80
|
return `No pulse ${named}. /pulses shows them.`;
|
|
@@ -106,6 +110,10 @@ function plainFileOf(cwd, given, what) {
|
|
|
106
110
|
export function asksFromScratch(words) {
|
|
107
111
|
return FROM_SCRATCH.test(words);
|
|
108
112
|
}
|
|
113
|
+
/** Whether a /regenerate asking for its module from scratch asks for its whole requires chain with it. */
|
|
114
|
+
export function asksWholeChain(words) {
|
|
115
|
+
return /\bchain\b|\bevery module\b|\ball (the )?modules\b/i.test(words);
|
|
116
|
+
}
|
|
109
117
|
const FROM_SCRATCH = /\b(from (scratch|nothing|zero|the (start|beginning|ground up))|start(ing)? (it )?(over|afresh)|afresh|anew|clean slate|(delete|wipe|remove|drop|throw away)\b.{0,30}\b(module|code|codebase|everything|all of it))/i;
|
|
110
118
|
/** regenerate: regenerate a module's code up to its spec as it is now. */
|
|
111
119
|
export function regenerateTool(options) {
|
|
@@ -127,6 +135,7 @@ export function regenerateTool(options) {
|
|
|
127
135
|
"A change to a file the spec links - an API surface, a mapping document - is a change to the spec: regenerate sees it by itself, and regenerates every functional spec that uses what links it.",
|
|
128
136
|
"Never stop pulses and start them again yourself to follow a spec change: regenerate does it.",
|
|
129
137
|
"Set from_scratch only when the user asks for the module to be regenerated from scratch - started over, its code deleted - in this conversation, or agrees to it when a module's status says it has to start over: never to fix a pulse that did not land.",
|
|
138
|
+
'from_scratch "module" takes out the code where the module is built; the modules below keep theirs, and the module starts from a copy of the code below it. "chain" takes out every codebase of its requires chain, the base\'s too, and builds all of it again from the bottom: use it after modules were split, merged or moved (refactor-module), or when the user asks for the whole chain.',
|
|
130
139
|
],
|
|
131
140
|
parameters: Type.Object({
|
|
132
141
|
plain_file: Type.Optional(Type.String({ description: "Path to the .plain file. Omitted: the module the project's config.turri.yaml names" })),
|
|
@@ -135,8 +144,9 @@ export function regenerateTool(options) {
|
|
|
135
144
|
functionalities: Type.Optional(Type.Array(Type.String(), {
|
|
136
145
|
description: "Functional specs already built, by id, to regenerate though their spec did not change. Omitted: what the spec now differs from the code in",
|
|
137
146
|
})),
|
|
138
|
-
from_scratch: Type.Optional(Type.
|
|
139
|
-
description: "Only when the user asks for it: the module's code and conformance tests deleted - committed first, so its lineage keeps them - and the whole module regenerated from its spec"
|
|
147
|
+
from_scratch: Type.Optional(Type.Union([Type.Literal("module"), Type.Literal("chain")], {
|
|
148
|
+
description: "Only when the user asks for it: the module's code and conformance tests deleted - committed first, so its lineage keeps them - and the whole module regenerated from its spec. " +
|
|
149
|
+
'"chain": every module of its requires chain too, built again from the bottom',
|
|
140
150
|
})),
|
|
141
151
|
model: MODEL_PARAM,
|
|
142
152
|
wait: WAIT_PARAM,
|
|
@@ -147,15 +157,15 @@ export function regenerateTool(options) {
|
|
|
147
157
|
if (!check.ok)
|
|
148
158
|
throw new Error(`${relative(options.cwd, plainFile) || plainFile} does not parse, so nothing can be regenerated from it yet: ${check.error}`);
|
|
149
159
|
const again = given.functionalities ?? [];
|
|
150
|
-
if (again.length > 0 && given.from_scratch
|
|
160
|
+
if (again.length > 0 && given.from_scratch !== undefined)
|
|
151
161
|
throw new Error("Name functionalities or set from_scratch, not both: from scratch regenerates every one of them.");
|
|
152
162
|
// Named functionalities are work on functionalities, as engine chooses a model for it; the rest, spec changes.
|
|
153
163
|
const work = again.length > 0 ? "functionalities" : "spec_changes";
|
|
154
164
|
const model = options.model !== undefined ? options.model(ctx, plainFile, given.model, work) : given.model;
|
|
155
165
|
const loop = options.loop(ctx);
|
|
156
166
|
const request = { ...(model !== undefined ? { model } : {}), ...(given.guidance !== undefined ? { guidance: given.guidance } : {}) };
|
|
157
|
-
const statuses = given.from_scratch
|
|
158
|
-
? await loop.fromScratch(plainFile, request)
|
|
167
|
+
const statuses = given.from_scratch !== undefined
|
|
168
|
+
? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
|
|
159
169
|
: again.length > 0
|
|
160
170
|
? await loop.regenerateAgain(plainFile, again, request)
|
|
161
171
|
: await loop.bringUp(plainFile, request);
|
|
@@ -188,7 +198,7 @@ export function driftTool(options) {
|
|
|
188
198
|
}
|
|
189
199
|
const ACTIVATED_PARAM = Type.Optional(Type.String({ description: 'What activate started, by name - or "all" for every one' }));
|
|
190
200
|
const HALT_PULSE_PARAMS = Type.Object({
|
|
191
|
-
job_id: Type.Optional(Type.String({ description: "The pulse's id, or the start of it" })),
|
|
201
|
+
job_id: Type.Optional(Type.String({ description: "The pulse's id, or the start of it; a planned row's id (planned-<module>-...), or a module's name, halts the module" })),
|
|
192
202
|
reason: Type.Optional(Type.String({ description: "Why it is halted, kept with it - what the spec now says that it did not, say" })),
|
|
193
203
|
activated: ACTIVATED_PARAM,
|
|
194
204
|
});
|
|
@@ -201,12 +211,21 @@ export function haltTool(options) {
|
|
|
201
211
|
name: "halt",
|
|
202
212
|
label: "Halt",
|
|
203
213
|
description: jobs !== undefined
|
|
204
|
-
? "Halt a pulse, or what activate started. A pulse: a queued one never starts, a running one has its
|
|
205
|
-
"and the pulses queued behind it move up - what a running pulse already changed is rolled back, and what
|
|
206
|
-
"counts as not regenerated.
|
|
214
|
+
? "Halt a pulse, a module's planned pulses, or what activate started. A pulse: a queued one never starts, a running one has its " +
|
|
215
|
+
"agent stopped at once, and the pulses queued behind it move up - what a running pulse already changed is rolled back, and what " +
|
|
216
|
+
"it was regenerating counts as not regenerated. A planned row (planned-<module>-...) or a module's name halts the module: its " +
|
|
217
|
+
"running pulse stopped, none of its planned pulses started, and the modules built on it waiting - until it is asked for again " +
|
|
218
|
+
"with regenerate; a spec change does not start it. A module whose .plain file is gone is dropped. What activate started: the " +
|
|
219
|
+
"one named, or every one."
|
|
207
220
|
: "Stop what activate started: the one named, or every one.",
|
|
208
221
|
promptSnippet: jobs !== undefined ? "halt a pulse, or what activate started" : "stop a deployed server, or all of them",
|
|
209
|
-
promptGuidelines: jobs !== undefined
|
|
222
|
+
promptGuidelines: jobs !== undefined
|
|
223
|
+
? [
|
|
224
|
+
"Halt a pulse only when the user asks, or your instructions say to. Name which one, and say which pulses were queued behind it - they will now run.",
|
|
225
|
+
"Halting a planned row halts its whole module - one planned pulse cannot be taken out alone, as the plan is made again from the spec. To build some of it later, or cut it differently, use steer; to drop work, change the spec.",
|
|
226
|
+
"A planned row for a module that is no longer in the project is halted the same way, and dropped.",
|
|
227
|
+
]
|
|
228
|
+
: [],
|
|
210
229
|
parameters: (jobs !== undefined ? HALT_PULSE_PARAMS : HALT_ACTIVATED_PARAMS),
|
|
211
230
|
async execute(_id, params) {
|
|
212
231
|
if (params.job_id === undefined && params.activated === undefined) {
|
|
@@ -214,7 +233,7 @@ export function haltTool(options) {
|
|
|
214
233
|
}
|
|
215
234
|
const lines = [];
|
|
216
235
|
if (params.job_id !== undefined && jobs !== undefined)
|
|
217
|
-
lines.push(stopJob(jobs, params.job_id, params.reason));
|
|
236
|
+
lines.push(stopJob(jobs, params.job_id, params.reason, options.workLoop?.()));
|
|
218
237
|
if (params.activated !== undefined) {
|
|
219
238
|
const stopped = await stopDeployed(params.activated === "all" ? {} : { name: params.activated });
|
|
220
239
|
lines.push(stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running${params.activated === "all" ? "" : ` as ${params.activated}`}.`);
|
package/dist/pi-launch.js
CHANGED
|
@@ -11,6 +11,7 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
11
11
|
import { main, SettingsManager } from "@earendil-works/pi-coding-agent";
|
|
12
12
|
import { ProcessTerminal } from "@earendil-works/pi-tui";
|
|
13
13
|
import "./terminal-images.js";
|
|
14
|
+
import { resumeLine } from "./resume-line.js";
|
|
14
15
|
/**
|
|
15
16
|
* pi, started the way its own CLI starts it, for `turri`.
|
|
16
17
|
*
|
|
@@ -31,6 +32,10 @@ const setTitle = ProcessTerminal.prototype.setTitle;
|
|
|
31
32
|
ProcessTerminal.prototype.setTitle = function (title) {
|
|
32
33
|
setTitle.call(this, title.replace(/^π(?= |$)/, "🪼 turri"));
|
|
33
34
|
};
|
|
35
|
+
// What pi prints on the way out to resume the session names pi - its APP_NAME, a constant - which may not be on the
|
|
36
|
+
// PATH at all: turri takes the same flags, so it is turri the line names.
|
|
37
|
+
const write = process.stdout.write.bind(process.stdout);
|
|
38
|
+
process.stdout.write = ((chunk, ...rest) => write(typeof chunk === "string" ? resumeLine(chunk) : chunk, ...rest));
|
|
34
39
|
// pi's own keys stand: a new line is shift+enter or ctrl+j. turri's side panel is on ctrl+h (job-panel.ts PANEL_KEY).
|
|
35
40
|
// What pi's CLI does before main: the process title, pi's environment markers, the HTTP
|
|
36
41
|
// dispatcher. Not exported, so loaded from the file - beside pi's entry point, wherever npm put it.
|
package/dist/pi.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createAgentSession, DefaultResourceLoader, getAgentDir, ModelRegistry,
|
|
|
4
4
|
import { loadRules, renderRulesBlock } from "./rules.js";
|
|
5
5
|
import { inheritModel, stackOf, readProjectConfig, ROLE_THINKING, roleModel, roleTurnLimitMs, splitModelSpec } from "./config.js";
|
|
6
6
|
import { maskToolResults } from "./regenerate/masking.js";
|
|
7
|
+
import { withListArguments } from "./regenerate/list-arguments.js";
|
|
7
8
|
import { checkAgainstScript, ENVIRONMENT_ERROR_TOOL, EnvironmentError, environmentErrorTool, sandboxGapOf } from "./regenerate/environment-error.js";
|
|
8
9
|
import { MODULES_DIR, projectRootOf, sessionsDir } from "./regenerate/paths.js";
|
|
9
10
|
import { currentStopSignal, describeToolCall, describeToolResult, JobStoppedError, shownName, reportActivity, reportNow, reportAgent, reportTranscript, reportModelEvent, reportUsage, } from "./regenerate/activity.js";
|
|
@@ -146,6 +147,19 @@ export class ProviderError extends Error {
|
|
|
146
147
|
this.name = "ProviderError";
|
|
147
148
|
}
|
|
148
149
|
}
|
|
150
|
+
/** Why turri itself ended a session's turn under way: the abort that comes back is its own, not the provider failing. */
|
|
151
|
+
const harnessStops = new WeakMap();
|
|
152
|
+
/**
|
|
153
|
+
* End the agent's turn, turri's own doing - it is going round in a circle, its time is up. The turn ends as any turn
|
|
154
|
+
* does: what the agent said stands, and the harness goes on from there. Never a provider error.
|
|
155
|
+
*/
|
|
156
|
+
export function stopTurn(session, reason) {
|
|
157
|
+
if (session === undefined || harnessStops.has(session))
|
|
158
|
+
return;
|
|
159
|
+
harnessStops.set(session, reason);
|
|
160
|
+
reportModelEvent({ kind: "stopped", ...modelEventOf(session), reason });
|
|
161
|
+
void session.abort();
|
|
162
|
+
}
|
|
149
163
|
/**
|
|
150
164
|
* Run one turn and return the assistant's text, streaming deltas to `onDelta`.
|
|
151
165
|
*
|
|
@@ -212,17 +226,30 @@ async function askUnrestricted(session, text, onDelta) {
|
|
|
212
226
|
catch (error) {
|
|
213
227
|
if (!(error instanceof ProviderError) || !TRANSIENT_PROVIDER_ERROR.test(error.message) || attempt >= PROVIDER_RETRIES)
|
|
214
228
|
throw error;
|
|
215
|
-
const wait =
|
|
216
|
-
|
|
217
|
-
|
|
229
|
+
const wait = providerRetryDelay(attempt);
|
|
230
|
+
const shown = `${Math.round(wait / 1000)}s (${attempt + 1} of ${PROVIDER_RETRIES})`;
|
|
231
|
+
reportActivity(` the model provider is failing for now - trying again in ${shown}`);
|
|
232
|
+
reportNow(`the model provider is failing - trying again in ${shown}`);
|
|
233
|
+
reportModelEvent({ kind: "provider_retry", ...modelEventOf(session), error: error.message, attempt: attempt + 1, of: PROVIDER_RETRIES, waitMs: wait });
|
|
234
|
+
debugLogOf(session)?.note(`provider failing - trying again in ${shown}: ${error.message.slice(0, 200)}`);
|
|
218
235
|
await waitOrStop(wait);
|
|
236
|
+
reportNow(undefined);
|
|
219
237
|
prompt = "Carry on where you were: the model provider failed part-way through your last turn.";
|
|
220
238
|
}
|
|
221
239
|
}
|
|
222
240
|
}
|
|
223
|
-
/**
|
|
224
|
-
|
|
241
|
+
/**
|
|
242
|
+
* How many times, after pi's own retries, a turn whose provider failed for a moment is tried again; the first wait,
|
|
243
|
+
* doubled each time up to the longest - 15s, 30s, 1m, 2m, 4m, 5m: an outage of about 13 minutes is waited out.
|
|
244
|
+
*/
|
|
245
|
+
export const PROVIDER_RETRIES = 6;
|
|
225
246
|
export const PROVIDER_RETRY_DELAY_MS = Number(process.env.TURRI_PROVIDER_RETRY_DELAY ?? 15) * 1000;
|
|
247
|
+
export const PROVIDER_RETRY_MAX_DELAY_MS = 20 * PROVIDER_RETRY_DELAY_MS;
|
|
248
|
+
/** The wait before try `attempt + 1`: doubled each time, up to the longest, with a tenth either way so parallel jobs do not all come back at once. */
|
|
249
|
+
export function providerRetryDelay(attempt, random = Math.random) {
|
|
250
|
+
const base = Math.min(PROVIDER_RETRY_DELAY_MS * 2 ** attempt, PROVIDER_RETRY_MAX_DELAY_MS);
|
|
251
|
+
return Math.round(base * (0.9 + 0.2 * random()));
|
|
252
|
+
}
|
|
226
253
|
/** A provider error that passes: overloaded, rate limited, unreachable, timed out. */
|
|
227
254
|
const TRANSIENT_PROVIDER_ERROR = /\b(429|500|502|503|504|529)\b|overloaded|high demand|rate.?limit|too many requests|unavailable|fetch failed|network|connection|timed? ?out|ECONNRESET|socket|terminated/i;
|
|
228
255
|
/** Wait, unless the job is stopped first. */
|
|
@@ -251,7 +278,7 @@ async function askOnce(session, text, onDelta) {
|
|
|
251
278
|
// Calls to one tool failing one after another - arguments it refuses, or errors - with nothing going through.
|
|
252
279
|
let failing = 0;
|
|
253
280
|
let failingTool;
|
|
254
|
-
|
|
281
|
+
harnessStops.delete(session);
|
|
255
282
|
reportNow("waiting for the model");
|
|
256
283
|
// Every entry says which agent it is from, and what it runs on - for reading one agent at a time.
|
|
257
284
|
const agent = agentOf(session);
|
|
@@ -308,14 +335,13 @@ async function askOnce(session, text, onDelta) {
|
|
|
308
335
|
if (event.type === "tool_execution_end") {
|
|
309
336
|
failing = event.isError ? (event.toolName === failingTool ? failing + 1 : 1) : 0;
|
|
310
337
|
failingTool = event.isError ? event.toolName : undefined;
|
|
311
|
-
if (failing >= FAILURES_BEFORE_STOP && !
|
|
338
|
+
if (failing >= FAILURES_BEFORE_STOP && !harnessStops.has(session)) {
|
|
312
339
|
// A call its tool refuses never reaches the tool, so no guard on the tools sees it: an agent can
|
|
313
340
|
// make the same bad call, worded a little differently, thousands of times. Its turn ends here, and
|
|
314
341
|
// the harness goes on from there, as after any turn.
|
|
315
|
-
stoppedFailing = true;
|
|
316
342
|
reportActivity(` stopped the agent's turn: ${failing} ${shownName(event.toolName)} calls failed in a row`);
|
|
317
343
|
debugLogOf(session)?.note(`turn stopped: ${failing} ${event.toolName} calls failed in a row`);
|
|
318
|
-
|
|
344
|
+
stopTurn(session, `${failing} ${shownName(event.toolName)} calls failed in a row`);
|
|
319
345
|
}
|
|
320
346
|
const output = resultText(event.result);
|
|
321
347
|
transcript({ kind: "result", text: clipText(output, MAX_TOOL_RESULT), error: event.isError, full: output });
|
|
@@ -376,7 +402,7 @@ async function askOnce(session, text, onDelta) {
|
|
|
376
402
|
stopped = true;
|
|
377
403
|
reportActivity(` stopped the agent's turn: its ${formatLimit(limitMs)} are up`);
|
|
378
404
|
debug?.note(`turn stopped: its ${formatLimit(limitMs)} are up${how}`);
|
|
379
|
-
|
|
405
|
+
stopTurn(session, `its ${formatLimit(limitMs)} were up`);
|
|
380
406
|
};
|
|
381
407
|
const atNextRequest = timed
|
|
382
408
|
? session.subscribe((event) => {
|
|
@@ -417,14 +443,17 @@ async function askOnce(session, text, onDelta) {
|
|
|
417
443
|
stop?.removeEventListener("abort", onStop);
|
|
418
444
|
reportNow(undefined);
|
|
419
445
|
}
|
|
420
|
-
|
|
421
|
-
|
|
446
|
+
// turri ended the turn itself - its time was up, the agent went round in a circle: the abort that ended it is its own.
|
|
447
|
+
const stoppedFor = harnessStops.get(session);
|
|
448
|
+
harnessStops.delete(session);
|
|
449
|
+
if (stoppedFor !== undefined)
|
|
450
|
+
out = `${out.trim()}\n\n[the turn was stopped: ${stoppedFor}]`.trim();
|
|
422
451
|
if (stop?.aborted) {
|
|
423
452
|
debug?.note(`turn stopped on request after ${seconds(Date.now() - turnStarted)}`);
|
|
424
453
|
throw new JobStoppedError();
|
|
425
454
|
}
|
|
426
|
-
// A turn ended
|
|
427
|
-
if (providerError !== undefined &&
|
|
455
|
+
// A turn turri ended is ended, whatever the provider was doing then: what comes back of the abort is not the provider failing.
|
|
456
|
+
if (providerError !== undefined && stoppedFor === undefined) {
|
|
428
457
|
debug?.note(`turn ended with a provider error after ${seconds(Date.now() - turnStarted)}: ${providerError}`);
|
|
429
458
|
throw new ProviderError(`${session.model?.id ?? "model"}: ${providerError}`);
|
|
430
459
|
}
|
|
@@ -614,7 +643,7 @@ export function guardRepeats(tools, session, budget) {
|
|
|
614
643
|
refused += 1;
|
|
615
644
|
if (refused > REFUSED_BEFORE_STOP) {
|
|
616
645
|
reportActivity(` stopped the agent's turn: ${refused} calls to tools this turn does not have`);
|
|
617
|
-
|
|
646
|
+
stopTurn(current, `${refused} calls to tools this turn does not have`);
|
|
618
647
|
throw new Error(`Stopped: ${refused} calls to tools this turn does not have.`);
|
|
619
648
|
}
|
|
620
649
|
throw new Error(`Not run: your work is done and checked - this turn is for ${[...only].join(" and ")} alone, and nothing else is ` +
|
|
@@ -624,7 +653,7 @@ export function guardRepeats(tools, session, budget) {
|
|
|
624
653
|
if (budget !== undefined && !budget.finish.includes(tool.name) && calls > budget.calls) {
|
|
625
654
|
if (calls > budget.calls * 2) {
|
|
626
655
|
reportActivity(` stopped the agent's turn: ${calls} tool calls, past its budget of ${budget.calls}`);
|
|
627
|
-
|
|
656
|
+
stopTurn(session(), `${calls} tool calls, past its budget of ${budget.calls}`);
|
|
628
657
|
throw new Error(`Stopped: ${calls} tool calls, past the budget of ${budget.calls}.`);
|
|
629
658
|
}
|
|
630
659
|
throw new Error(`Not run: you have made ${budget.calls} tool calls, which is all you have. Decide now with what you know: call ` +
|
|
@@ -652,7 +681,7 @@ export function guardRepeats(tools, session, budget) {
|
|
|
652
681
|
}
|
|
653
682
|
if (repeats > REPEATS_BEFORE_STOP) {
|
|
654
683
|
reportActivity(` stopped the agent's turn: it made the same ${tool.name} call ${repeats} times with nothing changed`);
|
|
655
|
-
|
|
684
|
+
stopTurn(session(), `the same ${tool.name} call ${repeats} times with nothing changed`);
|
|
656
685
|
throw new Error(`Stopped: the same ${tool.name} call ${repeats} times with nothing changed.`);
|
|
657
686
|
}
|
|
658
687
|
if (repeats > REPEATS_ALLOWED) {
|
|
@@ -695,7 +724,7 @@ export async function createExecutor(opts) {
|
|
|
695
724
|
modelRuntime: await subAgentModelRuntime(),
|
|
696
725
|
tools: hasShell ? [...opts.tools, ENVIRONMENT_ERROR_TOOL] : opts.tools,
|
|
697
726
|
// What an agent is shown never holds a credential the project passed: each value is its name (masking.ts).
|
|
698
|
-
customTools: guardRepeats(maskToolResults(withEnvironmentErrors), () => session, opts.budget),
|
|
727
|
+
customTools: guardRepeats(maskToolResults(withListArguments(withEnvironmentErrors)), () => session, opts.budget),
|
|
699
728
|
sessionManager,
|
|
700
729
|
resourceLoader: await subAgentResources(opts.cwd, opts.rules === true, [opts.system, opts.task].filter((part) => part !== undefined && part !== "").join("\n\n") || undefined),
|
|
701
730
|
});
|
|
@@ -814,7 +843,7 @@ export async function createJudge(opts) {
|
|
|
814
843
|
model,
|
|
815
844
|
modelRuntime,
|
|
816
845
|
tools: [...(opts.extraTools ?? []), "submit_verdict"],
|
|
817
|
-
customTools: [opts.verdictTool],
|
|
846
|
+
customTools: withListArguments([opts.verdictTool]),
|
|
818
847
|
sessionManager: SessionManager.inMemory(opts.cwd),
|
|
819
848
|
// Judges assess specs against the rules, so they have them too.
|
|
820
849
|
resourceLoader: await subAgentResources(opts.cwd, true, opts.task),
|
package/dist/question-dialog.js
CHANGED
|
@@ -25,6 +25,7 @@ export class QuestionDialog {
|
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
this.input = undefined;
|
|
28
|
+
this.selected = Math.min(Math.max(0, options.selected ?? 0), options.options.length - 1);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
get focused() {
|
|
@@ -58,18 +59,23 @@ export class QuestionDialog {
|
|
|
58
59
|
const choices = this.options.options ?? [];
|
|
59
60
|
const body = this.input !== undefined
|
|
60
61
|
? this.input.render(inner)
|
|
61
|
-
:
|
|
62
|
+
: // A long option wraps, its lines under its first, rather than cut off where the person cannot read it.
|
|
63
|
+
choices.flatMap((choice, index) => wrapTextWithAnsi(choice, Math.max(1, inner - 2)).map((line, at) => {
|
|
64
|
+
const shown = `${at === 0 && index === this.selected ? "›" : " "} ${line}`;
|
|
65
|
+
return index === this.selected ? style.accent(shown) : shown;
|
|
66
|
+
}));
|
|
62
67
|
const hint = this.input !== undefined
|
|
63
68
|
? "enter answers · esc dismisses"
|
|
64
69
|
: "↑↓ choose · enter picks · esc dismisses";
|
|
65
70
|
// The brief gets what the question, the options and the hints leave of the screen.
|
|
66
|
-
const fixed = question.length + body.length +
|
|
71
|
+
const fixed = question.length + body.length + 5;
|
|
67
72
|
const room = Math.max(3, this.options.rows() - KEPT_ABOVE - fixed);
|
|
68
73
|
const scrolls = brief.length > room;
|
|
69
74
|
this.window = scrolls ? room - 1 : brief.length;
|
|
70
75
|
this.maxScroll = scrolls ? brief.length - this.window : 0;
|
|
71
76
|
this.scroll = Math.min(this.scroll, this.maxScroll);
|
|
72
|
-
|
|
77
|
+
// Set apart from what is drawn above it - the job panel's hints.
|
|
78
|
+
const lines = [""];
|
|
73
79
|
if (brief.length > 0) {
|
|
74
80
|
lines.push(...brief.slice(this.scroll, this.scroll + this.window).map(pad));
|
|
75
81
|
if (scrolls) {
|
package/dist/questioning.js
CHANGED
|
@@ -43,7 +43,7 @@ export function questioningQuestion(phases) {
|
|
|
43
43
|
return {
|
|
44
44
|
question: `How many questions should I ask you in ${named}?`,
|
|
45
45
|
options: QUESTIONING_LEVELS.map((level) => level.option),
|
|
46
|
-
context: `Light, medium and thorough cap each of ${named} at 3, 5 and 10 questions - broader with fewer, so every level ` +
|
|
46
|
+
context: `Light, medium and thorough cap ${phases.length === 1 ? named : `each of ${named}`} at 3, 5 and 10 questions - broader with fewer, so every level ` +
|
|
47
47
|
"covers the same ground, only in less or more depth. What the questions leave open, turri decides itself and " +
|
|
48
48
|
"says what it chose. With best judgement, turri asks as much as it judges each phase needs. Each phase still " +
|
|
49
49
|
"ends with your confirmation of its summary.",
|
|
@@ -90,6 +90,18 @@ export function onModelEvent(listener) {
|
|
|
90
90
|
modelListeners.add(listener);
|
|
91
91
|
return () => modelListeners.delete(listener);
|
|
92
92
|
}
|
|
93
|
+
/** A provider retry or a stop, in a line for the person: the chat's notification, a headless run's console. */
|
|
94
|
+
export function describeTurnIncident(event) {
|
|
95
|
+
const who = event.role ?? event.label ?? "an agent";
|
|
96
|
+
const model = event.model !== undefined ? ` (${event.model})` : "";
|
|
97
|
+
if (event.kind === "provider_retry") {
|
|
98
|
+
const wait = Math.round((event.waitMs ?? 0) / 1000);
|
|
99
|
+
return `The model provider failed${model}: ${(event.error ?? "").slice(0, 160)} - trying ${who}'s turn again in ${wait}s (${event.attempt} of ${event.of}).`;
|
|
100
|
+
}
|
|
101
|
+
if (event.kind === "stopped")
|
|
102
|
+
return `turri stopped ${who}'s turn${model}: ${event.reason ?? "it was stopped"} - carrying on from there.`;
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
93
105
|
export function reportModelEvent(event) {
|
|
94
106
|
if (modelListeners.size === 0)
|
|
95
107
|
return;
|
|
@@ -183,6 +195,8 @@ export function describeToolCall(name, args) {
|
|
|
183
195
|
return `± my_diff`;
|
|
184
196
|
case "update_notes":
|
|
185
197
|
return `✐ update_notes`;
|
|
198
|
+
case "report_spec_gap":
|
|
199
|
+
return `? spec gap: ${text("question") ?? ""}`.trimEnd();
|
|
186
200
|
case "copy_resource":
|
|
187
201
|
return `⎘ copy_resource ${path ?? text("to") ?? ""}`.trimEnd();
|
|
188
202
|
case "can_it_fail":
|
|
@@ -7,7 +7,7 @@ import { abandonWork, startWork } from "./lineage.js";
|
|
|
7
7
|
import { ensureRegressionPasses } from "./regression.js";
|
|
8
8
|
import { modulesRoot, projectDirOf } from "./paths.js";
|
|
9
9
|
import { applySpecDiff, snapshotSpec, specGapsText } from "./regenerate.js";
|
|
10
|
-
import {
|
|
10
|
+
import { gapMark, gapsSince } from "./notes.js";
|
|
11
11
|
import { sectionsOf } from "./state.js";
|
|
12
12
|
import { describeStop } from "./stop-report.js";
|
|
13
13
|
import { missingTestLabels } from "./test-kinds.js";
|
|
@@ -41,8 +41,8 @@ export async function renderSpecDiffConformance(options) {
|
|
|
41
41
|
// state, not to what an interrupted run left half-written. The tests and the whole suite are
|
|
42
42
|
// one unit, landed whole or undone whole.
|
|
43
43
|
const unit = startWork([buildDir, conformanceDir], moduleName);
|
|
44
|
-
// The
|
|
45
|
-
const
|
|
44
|
+
// The spec gaps its agents report from here on are told with the result.
|
|
45
|
+
const gapsFrom = gapMark();
|
|
46
46
|
const conformance = await renderConformanceTests({
|
|
47
47
|
plainFile: tip.plainFile,
|
|
48
48
|
frid: lastFrid,
|
|
@@ -58,8 +58,8 @@ export async function renderSpecDiffConformance(options) {
|
|
|
58
58
|
});
|
|
59
59
|
// What the codebase now has conformance tests for, as their labels say.
|
|
60
60
|
const tested = () => frids.filter((frid) => missingTestLabels(conformanceDir, frid, []).length === 0);
|
|
61
|
-
//
|
|
62
|
-
const base = { moduleName, buildDir, conformanceDir, diff: applied, conformance, specGaps:
|
|
61
|
+
// A gap is the person's to decide, whether the tests passed or not.
|
|
62
|
+
const base = { moduleName, buildDir, conformanceDir, diff: applied, conformance, specGaps: gapsSince(gapsFrom, [buildDir, conformanceDir]) };
|
|
63
63
|
if (!conformance.passed) {
|
|
64
64
|
abandonWork(unit, moduleName, notLandedWhy("for the spec change", conformance.unlabelled));
|
|
65
65
|
return { ...base, tested: tested(), passed: false, stoppedAt: "conformance" };
|
|
@@ -7,7 +7,7 @@ import { confinedTools } from "./confine.js";
|
|
|
7
7
|
import { ensureInModulesScratch, modulesScratchDir } from "./paths.js";
|
|
8
8
|
import { workspaceBlock } from "./workspace.js";
|
|
9
9
|
import { reportActivity } from "./activity.js";
|
|
10
|
-
import { runTiming } from "./test-scripts.js";
|
|
10
|
+
import { runTiming, withTestingScripts } from "./test-scripts.js";
|
|
11
11
|
import { createWebTools, WEB_TOOLS } from "./web.js";
|
|
12
12
|
import { diffFiles, digestFiles } from "./codebase.js";
|
|
13
13
|
import { ERROR_CAUSE_RULES, fixMethod, INTEGRITY_RULES, specPrimer } from "./prompt.js";
|
|
@@ -378,9 +378,17 @@ export function explorePrompt(buildDir, spec, scope, testingScripts, question, p
|
|
|
378
378
|
...(testingScripts !== undefined && testingScripts.length > 0
|
|
379
379
|
? [
|
|
380
380
|
"",
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
...(testingScripts.some((script) => script.prepare === true)
|
|
382
|
+
? [
|
|
383
|
+
"These are the project's prepare script, which the harness runs on the build first, and its conformance testing",
|
|
384
|
+
"script, which runs only once the prepare script passes and decides whether the tests pass - read both for what",
|
|
385
|
+
"they build or install before the tests run, and so what the tests can depend on:",
|
|
386
|
+
]
|
|
387
|
+
: [
|
|
388
|
+
"This is the project's conformance testing script, which the harness runs to decide whether the",
|
|
389
|
+
"tests pass - read it for what it builds or installs before the tests run, and so what the tests can depend on:",
|
|
390
|
+
]),
|
|
391
|
+
...testingScripts.flatMap((script) => ["", `<script${script.prepare === true ? ' kind="prepare environment"' : ""} path="${script.path}" run-as="${script.runs}">`, script.content.trimEnd(), "</script>"]),
|
|
384
392
|
]
|
|
385
393
|
: []),
|
|
386
394
|
...(previous !== undefined && question === undefined
|
|
@@ -704,7 +712,7 @@ export function unfoundedEvidence(evidence, opened) {
|
|
|
704
712
|
"opened, the testing script, or the failing run - each with where. What <how to invoke it> says is not evidence: it " +
|
|
705
713
|
"may be wrong, so check it against the testing script and the files.");
|
|
706
714
|
}
|
|
707
|
-
const inPrompt = (source) => /^(the )?(conformance )?testing script$|^(the )?failing run$/i.test(source.trim());
|
|
715
|
+
const inPrompt = (source) => /^(the )?(conformance )?testing script$|^(the )?prepare script$|^(the )?failing run$/i.test(source.trim());
|
|
708
716
|
const unread = given.filter((item) => !inPrompt(item.source) && !opened(item.source.trim()));
|
|
709
717
|
if (unread.length > 0) {
|
|
710
718
|
return (`Your evidence cites ${unread.map((item) => item.source.trim()).join(", ")}, which you did not open. Open each file you cite ` +
|
|
@@ -735,7 +743,7 @@ export async function judgeFailure(options) {
|
|
|
735
743
|
description: "For code: the conformance testing script's own words for what it needs the build to have - the file, entry point or module the run failed on - copied exactly from the script",
|
|
736
744
|
})),
|
|
737
745
|
evidence: Type.Optional(Type.Array(Type.Object({
|
|
738
|
-
source: Type.String({ description: "Where: the path of a file you opened, `testing script`, or `failing run`" }),
|
|
746
|
+
source: Type.String({ description: "Where: the path of a file you opened, `testing script`, `prepare script` where there is one, or `failing run`" }),
|
|
739
747
|
shows: Type.String({ description: "What it shows, e.g. `the script runs node dist/cli.js` or `tsconfig.json emits src/cli.ts as dist/src/cli.js`" }),
|
|
740
748
|
}), { description: "What you found yourself, each with where - never what <how to invoke it> claims unchecked" })),
|
|
741
749
|
functionalities: Type.Optional(Type.Array(Type.Object({
|
|
@@ -900,6 +908,12 @@ export function judgePrompt(options) {
|
|
|
900
908
|
"what is wrong. What it does with the tests, the tests have to fit; what it needs of the code - a file it runs or",
|
|
901
909
|
"checks for, a command it builds with - the code has to provide. A verdict that the script is wrong is neither",
|
|
902
910
|
"code nor tests: say which of the two has to change to get past it.",
|
|
911
|
+
...(scripts.some((script) => script.prepare === true)
|
|
912
|
+
? [
|
|
913
|
+
"The prepare script below it runs on the build before every run, and the conformance testing script only once it",
|
|
914
|
+
"passes: it binds the same way - neither agent can change it, and what it needs of the code the code provides.",
|
|
915
|
+
]
|
|
916
|
+
: []),
|
|
903
917
|
"",
|
|
904
918
|
]
|
|
905
919
|
: []),
|
|
@@ -929,7 +943,10 @@ export function judgePrompt(options) {
|
|
|
929
943
|
"",
|
|
930
944
|
`<how to invoke it>\n${options.invocation.trim()}\n</how to invoke it>`,
|
|
931
945
|
"",
|
|
932
|
-
...scripts.flatMap((script) =>
|
|
946
|
+
...scripts.flatMap((script) => {
|
|
947
|
+
const tag = script.prepare === true ? "prepare script" : "conformance testing script";
|
|
948
|
+
return [`<${tag} path="${script.path}" run-as="${script.runs}">`, script.content.trimEnd(), `</${tag}>`, ""];
|
|
949
|
+
}),
|
|
933
950
|
...(options.run.timedOut === true ? [...timedOutBlock(options.run), ""] : []),
|
|
934
951
|
`<failing run exit="${options.run.exitCode}" command="${options.run.command}">`,
|
|
935
952
|
runTiming(options.run),
|
|
@@ -1004,7 +1021,10 @@ export async function createCodeFixer(options) {
|
|
|
1004
1021
|
model: options.model,
|
|
1005
1022
|
label: `${options.label} coding agent`, role: "coding",
|
|
1006
1023
|
system: `${fence.note}\n\n${workspaceBlock({ dir: options.buildDir, hasMyDiff: options.toolNames.includes("my_diff") })}`,
|
|
1007
|
-
|
|
1024
|
+
// What the conformance testing script needs of the build, the code provides: the fixer reads it, not only a judge's quote of it.
|
|
1025
|
+
task: options.testingScripts !== undefined
|
|
1026
|
+
? withTestingScripts(codeFixerTask(options), options.testingScripts.scripts, ["conformance", "unit"], options.testingScripts.root)
|
|
1027
|
+
: codeFixerTask(options),
|
|
1008
1028
|
compaction: { instructions: CODER_COMPACTION },
|
|
1009
1029
|
...(options.checkEnvironment !== undefined ? { checkEnvironment: options.checkEnvironment } : {}),
|
|
1010
1030
|
});
|
|
@@ -9,7 +9,7 @@ import { abandonWork, diffSinceSnapshot, moduleDirOf, recordHistory, startWork,
|
|
|
9
9
|
import { createWorkLedger, describeAccounts, SUBMIT_WORK_NOTE, unanswered, unansweredPrompt } from "./submit-work.js";
|
|
10
10
|
import { CONFORMANCE_COMPACTION } from "./compaction.js";
|
|
11
11
|
import { NOTES_TURN, notesForSession, passedOutcome, readNotes, reflectOnReview, withNotes } from "./notes.js";
|
|
12
|
-
import { labelsPrompt, labelsPromptFor, misplacedConformanceTests, misplacedTestsPrompt, missingTestLabels } from "./test-kinds.js";
|
|
12
|
+
import { acceptanceLabel, acceptanceText, labelsPrompt, labelsPromptFor, misplacedConformanceTests, misplacedTestsPrompt, missingTestLabels } from "./test-kinds.js";
|
|
13
13
|
import { createScriptTool, findTestScripts, projectRootFor, requireTestScripts, runConformanceScript, runUnitScript, failureSignature, STUCK_ROUNDS, scriptFailure, staticChecksOnly, withTestingScripts, } from "./test-scripts.js";
|
|
14
14
|
import { createWebTools, WEB_TOOLS } from "./web.js";
|
|
15
15
|
import { createMyDiffTool } from "./self-check.js";
|
|
@@ -157,9 +157,11 @@ export async function renderConformanceTests(options) {
|
|
|
157
157
|
// may read the code but writes only tests. An explorer reads the code first and writes down how the
|
|
158
158
|
// software is invoked, which is what the tests are written against.
|
|
159
159
|
const label = `${moduleName} ${options.diff !== undefined ? "spec change" : frid}`;
|
|
160
|
-
const specContext = { moduleName, text: specText(specifications, moduleName, frids, required, options.change ?? options.diff, sectionModules(tree, moduleName)) };
|
|
161
160
|
// For a spec change: the functionalities it touches, whose acceptance tests are labelled, checked and reviewed.
|
|
162
161
|
const touched = forChange ? touchedFunctionalities(tree, frids, options.diff) : [];
|
|
162
|
+
// The acceptance tests the run's tests carry out: every functionality the change touches, or the one under test.
|
|
163
|
+
const carriedOut = forChange ? touched : [{ frid: frid, acceptanceTests: specifications[ACCEPTANCE_TESTS] ?? [] }];
|
|
164
|
+
const specContext = { moduleName, text: specText(specifications, moduleName, frids, required, carriedOut, options.change ?? options.diff, sectionModules(tree, moduleName)) };
|
|
163
165
|
// Any functionality of the codebase - this module's, and those of the modules it requires. A
|
|
164
166
|
// functionality's run may raise a spec conflict only with that functionality; a spec diff's, between any two.
|
|
165
167
|
const own = (forChange ? frids : frids.slice(0, frids.indexOf(frid) + 1)).map((id) => ({ module: moduleName, frid: id }));
|
|
@@ -223,11 +225,15 @@ export async function renderConformanceTests(options) {
|
|
|
223
225
|
};
|
|
224
226
|
stage(`exploring the code for how it is invoked${options.model ? ` (${options.model})` : ""}`);
|
|
225
227
|
// The explorer reads the conformance testing script too: it is how the tests are built and run, and so how they reach the software.
|
|
228
|
+
// The prepare script, where there is one, runs on the build before it - and only once it passes does the suite run.
|
|
226
229
|
const testingScripts = [
|
|
230
|
+
...(scripts.prepare !== undefined
|
|
231
|
+
? [{ path: relative(root, scripts.prepare), runs: "<script> <copy of the build>, before every run of the conformance testing script", content: readFileSync(scripts.prepare, "utf8"), prepare: true }]
|
|
232
|
+
: []),
|
|
227
233
|
{ path: relative(root, scripts.conformance), runs: "<script> <copy of the build> <copy of the whole conformance suite>", content: readFileSync(scripts.conformance, "utf8") },
|
|
228
234
|
];
|
|
229
235
|
// The acceptance tests the explorer's plan has to carry out, step by step.
|
|
230
|
-
const toCarryOut =
|
|
236
|
+
const toCarryOut = carriedOut
|
|
231
237
|
.map((item) => ({ module: moduleName, frid: item.frid, count: item.acceptanceTests.length }))
|
|
232
238
|
.filter((item) => item.count > 0);
|
|
233
239
|
let invocation = await exploreInvocation({ buildDir, spec: specContext, scope, testingScripts, acceptance: toCarryOut, label, model: options.model, onDelta: options.onDelta });
|
|
@@ -272,6 +278,7 @@ export async function renderConformanceTests(options) {
|
|
|
272
278
|
cwd: conformanceDir,
|
|
273
279
|
customTools: [
|
|
274
280
|
notes.tool,
|
|
281
|
+
notes.gapTool,
|
|
275
282
|
work.tool,
|
|
276
283
|
...createWebTools(),
|
|
277
284
|
...fence.tools,
|
|
@@ -285,7 +292,7 @@ export async function renderConformanceTests(options) {
|
|
|
285
292
|
}),
|
|
286
293
|
createCopyResourceTool({ resources: linkedResources, dir: conformanceDir }),
|
|
287
294
|
],
|
|
288
|
-
tools: [...fence.names, "run_conformance_tests", "my_diff", "ask_explorer", "update_notes", "submit_work", "copy_resource", ...WEB_TOOLS],
|
|
295
|
+
tools: [...fence.names, "run_conformance_tests", "my_diff", "ask_explorer", "update_notes", "report_spec_gap", "submit_work", "copy_resource", ...WEB_TOOLS],
|
|
289
296
|
model: options.model,
|
|
290
297
|
label: `${label} conformance agent`,
|
|
291
298
|
role: "conformance",
|
|
@@ -313,12 +320,14 @@ export async function renderConformanceTests(options) {
|
|
|
313
320
|
// The unit tests, and the conformance suite - to reproduce the failure and check the fix, seeing only its output.
|
|
314
321
|
tools: [
|
|
315
322
|
fixerNotes.tool,
|
|
323
|
+
fixerNotes.gapTool,
|
|
316
324
|
createScriptTool({ kind: "unit", script: scripts.unit, run: () => runUnitScript(buildDir, scripts.unit), runs: unitRuns }),
|
|
317
325
|
fixerConformanceRuns.tool,
|
|
318
326
|
...fixerServices.tools,
|
|
319
327
|
],
|
|
320
|
-
toolNames: ["run_unit_tests", "run_conformance_tests", ...fixerServices.names, "update_notes"],
|
|
328
|
+
toolNames: ["run_unit_tests", "run_conformance_tests", ...fixerServices.names, "update_notes", "report_spec_gap"],
|
|
321
329
|
checkEnvironment: { run: () => runUnitScript(buildDir, scripts.unit), script: scripts.unit },
|
|
330
|
+
testingScripts: { scripts, root },
|
|
322
331
|
});
|
|
323
332
|
fixerConformanceRuns.newTurn();
|
|
324
333
|
return ask(fixer, withNotes(text, buildDir), options.onDelta);
|
|
@@ -687,7 +696,7 @@ export async function renderConformanceTests(options) {
|
|
|
687
696
|
buildDir,
|
|
688
697
|
conformanceDir,
|
|
689
698
|
spec: specContext,
|
|
690
|
-
functionalities:
|
|
699
|
+
functionalities: carriedOut,
|
|
691
700
|
forChange,
|
|
692
701
|
invocation,
|
|
693
702
|
label,
|
|
@@ -947,9 +956,10 @@ export function failureLine(run) {
|
|
|
947
956
|
}
|
|
948
957
|
/**
|
|
949
958
|
* The spec as the explorer, the judge and the coding agent are shown it - its functional specs
|
|
950
|
-
* numbered with their ids, so a spec conflict can name them
|
|
959
|
+
* numbered with their ids, so a spec conflict can name them, and the acceptance tests the run carries
|
|
960
|
+
* out labelled as their tests are, so a verdict can quote them.
|
|
951
961
|
*/
|
|
952
|
-
function specText(specifications, moduleName, frids, required, diff, modules) {
|
|
962
|
+
function specText(specifications, moduleName, frids, required, acceptance, diff, modules) {
|
|
953
963
|
// Every functionality in the codebase, each with its module: the required modules' first, then this one's.
|
|
954
964
|
const numbered = (key, items) => key === FUNCTIONAL_REQUIREMENTS
|
|
955
965
|
? [
|
|
@@ -957,10 +967,14 @@ function specText(specifications, moduleName, frids, required, diff, modules) {
|
|
|
957
967
|
]
|
|
958
968
|
: items;
|
|
959
969
|
// Each section in its tag, as every agent is shown it (see specPrimer).
|
|
960
|
-
const sections = [DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS, FUNCTIONAL_REQUIREMENTS
|
|
970
|
+
const sections = [DEFINITIONS, NON_FUNCTIONAL_REQUIREMENTS, TEST_REQUIREMENTS, FUNCTIONAL_REQUIREMENTS]
|
|
961
971
|
.map((key) => [key, specifications[key] ?? []])
|
|
962
972
|
.filter(([, items]) => items.length > 0)
|
|
963
|
-
.map(([key, items]) => (key === FUNCTIONAL_REQUIREMENTS
|
|
973
|
+
.map(([key, items]) => (key === FUNCTIONAL_REQUIREMENTS ? section(key, numbered(key, items)) : moduleSection(key, items, moduleName, modules)));
|
|
974
|
+
// Not only the last functionality's: a spec change's run carries out the acceptance tests of every one it touches.
|
|
975
|
+
const tests = acceptance.flatMap((item) => item.acceptanceTests.map((test, index) => `${acceptanceLabel(item.frid, index + 1)}: ${acceptanceText(test)}`));
|
|
976
|
+
if (tests.length > 0)
|
|
977
|
+
sections.push(section(ACCEPTANCE_TESTS, tests));
|
|
964
978
|
if (diff !== undefined)
|
|
965
979
|
sections.push(specChangeBlock(diff));
|
|
966
980
|
return sections.join("\n\n");
|