@turri-dev/cli 0.1.4-next.318a98a → 0.1.4-next.4342332
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/.pi/themes/turri-dark.json +67 -66
- package/.pi/themes/turri-light.json +71 -73
- package/README.md +39 -127
- package/assets/jellyfish/dark-00.png +0 -0
- package/assets/jellyfish/dark-01.png +0 -0
- package/assets/jellyfish/dark-02.png +0 -0
- package/assets/jellyfish/dark-03.png +0 -0
- package/assets/jellyfish/dark-04.png +0 -0
- package/assets/jellyfish/dark-05.png +0 -0
- package/assets/jellyfish/dark-06.png +0 -0
- package/assets/jellyfish/dark-07.png +0 -0
- package/assets/jellyfish/dark-08.png +0 -0
- package/assets/jellyfish/dark-09.png +0 -0
- package/assets/jellyfish/dark-10.png +0 -0
- package/assets/jellyfish/dark-11.png +0 -0
- package/assets/jellyfish/dark-12.png +0 -0
- package/assets/jellyfish/dark-13.png +0 -0
- package/assets/jellyfish/dark-14.png +0 -0
- package/assets/jellyfish/light-00.png +0 -0
- package/assets/jellyfish/light-01.png +0 -0
- package/assets/jellyfish/light-02.png +0 -0
- package/assets/jellyfish/light-03.png +0 -0
- package/assets/jellyfish/light-04.png +0 -0
- package/assets/jellyfish/light-05.png +0 -0
- package/assets/jellyfish/light-06.png +0 -0
- package/assets/jellyfish/light-07.png +0 -0
- package/assets/jellyfish/light-08.png +0 -0
- package/assets/jellyfish/light-09.png +0 -0
- package/assets/jellyfish/light-10.png +0 -0
- package/assets/jellyfish/light-11.png +0 -0
- package/assets/jellyfish/light-12.png +0 -0
- package/assets/jellyfish/light-13.png +0 -0
- package/assets/jellyfish/light-14.png +0 -0
- package/dist/ask.js +34 -15
- package/dist/brand.js +7 -7
- package/dist/cli-options.js +12 -6
- package/dist/config-edit.js +1 -0
- package/dist/config.js +5 -2
- package/dist/cultivate-cli.js +16 -23
- package/dist/extension.js +41 -29
- package/dist/init-config.js +5 -0
- package/dist/loop-cli.js +19 -7
- package/dist/loop-tools.js +11 -5
- package/dist/module-report.js +5 -4
- package/dist/pi.js +76 -19
- package/dist/question-dialog.js +1 -0
- package/dist/regenerate/activity.js +21 -0
- package/dist/regenerate/list-arguments.js +121 -0
- package/dist/regenerate/loop.js +21 -8
- package/dist/regenerate/plain-palette.js +51 -36
- package/dist/regenerate/regenerate.js +4 -2
- package/dist/regenerate/self-check.js +13 -6
- package/dist/regenerate/side-panel.js +1 -1
- package/dist/regenerate/spec-map-view.js +9 -5
- package/dist/regenerate/test-scripts.js +54 -10
- package/dist/regenerate/unit-review.js +1 -1
- package/dist/regenerate-cli.js +11 -5
- package/dist/release-cli.js +3 -8
- package/dist/review/live.js +2 -1
- package/dist/run-report.js +39 -1
- package/dist/validate-cli.js +3 -8
- package/docs/README.md +5 -12
- package/docs/authoring-plain.md +37 -119
- package/docs/config.md +53 -178
- package/docs/deploy.md +21 -80
- package/docs/development.md +13 -41
- package/docs/headless.md +45 -121
- package/docs/images/how-turri-works.svg +29 -31
- package/docs/installation.md +13 -40
- package/docs/parser.md +15 -43
- package/docs/regenerating.md +229 -938
- package/docs/sandbox.md +38 -152
- package/docs/skills-and-gates.md +50 -171
- package/docs/theming.md +45 -46
- package/docs/using.md +69 -345
- package/genome/rules/bullet-continuation.md +5 -13
- package/genome/rules/concise-specs-examples.md +2 -4
- package/genome/rules/concise-specs-integration-examples.md +2 -6
- package/genome/rules/concise-specs.md +1 -2
- package/genome/rules/func-specs.md +1 -0
- package/genome/rules/integration-embedded-testing.md +1 -4
- package/genome/rules/integrations.md +1 -2
- package/genome/rules/project-model.md +14 -35
- package/genome/rules/stdlib.md +14 -49
- package/genome/rules/turri-regeneration.md +48 -0
- package/genome/skills/add-implementation-requirement/SKILL.md +1 -2
- package/genome/skills/analyze-if-func-spec-too-complex/SKILL.md +3 -8
- package/genome/skills/brood/SKILL.md +37 -127
- package/genome/skills/brood/references/intent.md +4 -12
- package/genome/skills/brood/references/product.md +24 -76
- package/genome/skills/brood/references/stack.md +7 -29
- package/genome/skills/brood/references/testing.md +11 -42
- package/genome/skills/bud/SKILL.md +32 -109
- package/genome/skills/bud/references/intent.md +4 -11
- package/genome/skills/implement-conformance-testing-script/SKILL.md +3 -6
- package/genome/skills/implement-unit-testing-script/SKILL.md +1 -2
- package/genome/skills/mature/SKILL.md +21 -69
- package/genome/skills/refactor-module/SKILL.md +24 -2
- package/genome/skills/spawn/SKILL.md +28 -113
- package/package.json +1 -1
package/dist/loop-tools.js
CHANGED
|
@@ -110,6 +110,10 @@ function plainFileOf(cwd, given, what) {
|
|
|
110
110
|
export function asksFromScratch(words) {
|
|
111
111
|
return FROM_SCRATCH.test(words);
|
|
112
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
|
+
}
|
|
113
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;
|
|
114
118
|
/** regenerate: regenerate a module's code up to its spec as it is now. */
|
|
115
119
|
export function regenerateTool(options) {
|
|
@@ -131,6 +135,7 @@ export function regenerateTool(options) {
|
|
|
131
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.",
|
|
132
136
|
"Never stop pulses and start them again yourself to follow a spec change: regenerate does it.",
|
|
133
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.',
|
|
134
139
|
],
|
|
135
140
|
parameters: Type.Object({
|
|
136
141
|
plain_file: Type.Optional(Type.String({ description: "Path to the .plain file. Omitted: the module the project's config.turri.yaml names" })),
|
|
@@ -139,8 +144,9 @@ export function regenerateTool(options) {
|
|
|
139
144
|
functionalities: Type.Optional(Type.Array(Type.String(), {
|
|
140
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",
|
|
141
146
|
})),
|
|
142
|
-
from_scratch: Type.Optional(Type.
|
|
143
|
-
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',
|
|
144
150
|
})),
|
|
145
151
|
model: MODEL_PARAM,
|
|
146
152
|
wait: WAIT_PARAM,
|
|
@@ -151,15 +157,15 @@ export function regenerateTool(options) {
|
|
|
151
157
|
if (!check.ok)
|
|
152
158
|
throw new Error(`${relative(options.cwd, plainFile) || plainFile} does not parse, so nothing can be regenerated from it yet: ${check.error}`);
|
|
153
159
|
const again = given.functionalities ?? [];
|
|
154
|
-
if (again.length > 0 && given.from_scratch
|
|
160
|
+
if (again.length > 0 && given.from_scratch !== undefined)
|
|
155
161
|
throw new Error("Name functionalities or set from_scratch, not both: from scratch regenerates every one of them.");
|
|
156
162
|
// Named functionalities are work on functionalities, as engine chooses a model for it; the rest, spec changes.
|
|
157
163
|
const work = again.length > 0 ? "functionalities" : "spec_changes";
|
|
158
164
|
const model = options.model !== undefined ? options.model(ctx, plainFile, given.model, work) : given.model;
|
|
159
165
|
const loop = options.loop(ctx);
|
|
160
166
|
const request = { ...(model !== undefined ? { model } : {}), ...(given.guidance !== undefined ? { guidance: given.guidance } : {}) };
|
|
161
|
-
const statuses = given.from_scratch
|
|
162
|
-
? await loop.fromScratch(plainFile, request)
|
|
167
|
+
const statuses = given.from_scratch !== undefined
|
|
168
|
+
? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
|
|
163
169
|
: again.length > 0
|
|
164
170
|
? await loop.regenerateAgain(plainFile, again, request)
|
|
165
171
|
: await loop.bringUp(plainFile, request);
|
package/dist/module-report.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { brand } from "./brand.js";
|
|
1
2
|
/** Colours for what the command line prints. */
|
|
2
3
|
export const c = {
|
|
3
4
|
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
4
5
|
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
success: brand.success,
|
|
7
|
+
error: brand.error,
|
|
8
|
+
warning: brand.warning,
|
|
9
|
+
accent: brand.accent,
|
|
9
10
|
};
|
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,32 @@ 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
|
+
}
|
|
253
|
+
/** How long a request to the model may go without anything coming back before the provider is said to be stalling; 0 never. */
|
|
254
|
+
export const PROVIDER_STALL_MS = Number(process.env.TURRI_PROVIDER_STALL ?? 120) * 1000;
|
|
226
255
|
/** A provider error that passes: overloaded, rate limited, unreachable, timed out. */
|
|
227
256
|
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
257
|
/** Wait, unless the job is stopped first. */
|
|
@@ -251,7 +280,7 @@ async function askOnce(session, text, onDelta) {
|
|
|
251
280
|
// Calls to one tool failing one after another - arguments it refuses, or errors - with nothing going through.
|
|
252
281
|
let failing = 0;
|
|
253
282
|
let failingTool;
|
|
254
|
-
|
|
283
|
+
harnessStops.delete(session);
|
|
255
284
|
reportNow("waiting for the model");
|
|
256
285
|
// Every entry says which agent it is from, and what it runs on - for reading one agent at a time.
|
|
257
286
|
const agent = agentOf(session);
|
|
@@ -263,7 +292,30 @@ async function askOnce(session, text, onDelta) {
|
|
|
263
292
|
if (agent !== undefined)
|
|
264
293
|
reportAgent({ label: agent.label, ...(agent.model !== undefined ? { model: agent.model } : {}), turns: 1 });
|
|
265
294
|
reportModelEvent({ kind: "turn", ...modelEventOf(session) });
|
|
295
|
+
// The provider stalling: a request to the model that nothing has come back on - not a token, not an error - for
|
|
296
|
+
// long. Said once for each silence; the turn goes on waiting, its own time limit ending it if it must.
|
|
297
|
+
let toolsRunning = 0;
|
|
298
|
+
let stall;
|
|
299
|
+
const watchForStall = (afterMs = PROVIDER_STALL_MS) => {
|
|
300
|
+
if (stall !== undefined)
|
|
301
|
+
clearTimeout(stall);
|
|
302
|
+
stall = toolsRunning > 0 || PROVIDER_STALL_MS <= 0 ? undefined : setTimeout(() => {
|
|
303
|
+
reportModelEvent({ kind: "provider_stall", ...modelEventOf(session), waitMs: PROVIDER_STALL_MS });
|
|
304
|
+
debugLogOf(session)?.note(`the provider has sent nothing back for ${seconds(PROVIDER_STALL_MS)}`);
|
|
305
|
+
}, afterMs);
|
|
306
|
+
};
|
|
266
307
|
const unsubscribe = session.subscribe((event) => {
|
|
308
|
+
if (event.type === "tool_execution_start")
|
|
309
|
+
toolsRunning += 1;
|
|
310
|
+
if (event.type === "tool_execution_end")
|
|
311
|
+
toolsRunning = Math.max(0, toolsRunning - 1);
|
|
312
|
+
// pi tries a failed request again itself first: the provider failing is said then, not only once pi gives up.
|
|
313
|
+
if (event.type === "auto_retry_start") {
|
|
314
|
+
reportModelEvent({ kind: "provider_retry", ...modelEventOf(session), error: event.errorMessage, attempt: event.attempt, of: event.maxAttempts, waitMs: event.delayMs });
|
|
315
|
+
watchForStall(event.delayMs + PROVIDER_STALL_MS);
|
|
316
|
+
}
|
|
317
|
+
else
|
|
318
|
+
watchForStall();
|
|
267
319
|
if (event.type === "message_update") {
|
|
268
320
|
const update = event.assistantMessageEvent;
|
|
269
321
|
if (update.type === "text_delta") {
|
|
@@ -308,14 +360,13 @@ async function askOnce(session, text, onDelta) {
|
|
|
308
360
|
if (event.type === "tool_execution_end") {
|
|
309
361
|
failing = event.isError ? (event.toolName === failingTool ? failing + 1 : 1) : 0;
|
|
310
362
|
failingTool = event.isError ? event.toolName : undefined;
|
|
311
|
-
if (failing >= FAILURES_BEFORE_STOP && !
|
|
363
|
+
if (failing >= FAILURES_BEFORE_STOP && !harnessStops.has(session)) {
|
|
312
364
|
// A call its tool refuses never reaches the tool, so no guard on the tools sees it: an agent can
|
|
313
365
|
// make the same bad call, worded a little differently, thousands of times. Its turn ends here, and
|
|
314
366
|
// the harness goes on from there, as after any turn.
|
|
315
|
-
stoppedFailing = true;
|
|
316
367
|
reportActivity(` stopped the agent's turn: ${failing} ${shownName(event.toolName)} calls failed in a row`);
|
|
317
368
|
debugLogOf(session)?.note(`turn stopped: ${failing} ${event.toolName} calls failed in a row`);
|
|
318
|
-
|
|
369
|
+
stopTurn(session, `${failing} ${shownName(event.toolName)} calls failed in a row`);
|
|
319
370
|
}
|
|
320
371
|
const output = resultText(event.result);
|
|
321
372
|
transcript({ kind: "result", text: clipText(output, MAX_TOOL_RESULT), error: event.isError, full: output });
|
|
@@ -376,7 +427,7 @@ async function askOnce(session, text, onDelta) {
|
|
|
376
427
|
stopped = true;
|
|
377
428
|
reportActivity(` stopped the agent's turn: its ${formatLimit(limitMs)} are up`);
|
|
378
429
|
debug?.note(`turn stopped: its ${formatLimit(limitMs)} are up${how}`);
|
|
379
|
-
|
|
430
|
+
stopTurn(session, `its ${formatLimit(limitMs)} were up`);
|
|
380
431
|
};
|
|
381
432
|
const atNextRequest = timed
|
|
382
433
|
? session.subscribe((event) => {
|
|
@@ -392,6 +443,7 @@ async function askOnce(session, text, onDelta) {
|
|
|
392
443
|
}
|
|
393
444
|
// What the model is sent, and only that: its task is its system prompt, which the log already holds whole.
|
|
394
445
|
debug?.prompt(text);
|
|
446
|
+
watchForStall();
|
|
395
447
|
try {
|
|
396
448
|
// Its images, when its conversation does not hold them: the first turn, and the first after a compaction.
|
|
397
449
|
const images = sessionImages.get(session);
|
|
@@ -412,19 +464,24 @@ async function askOnce(session, text, onDelta) {
|
|
|
412
464
|
clearTimeout(timer);
|
|
413
465
|
if (backstop !== undefined)
|
|
414
466
|
clearTimeout(backstop);
|
|
467
|
+
if (stall !== undefined)
|
|
468
|
+
clearTimeout(stall);
|
|
415
469
|
atNextRequest?.();
|
|
416
470
|
unsubscribe();
|
|
417
471
|
stop?.removeEventListener("abort", onStop);
|
|
418
472
|
reportNow(undefined);
|
|
419
473
|
}
|
|
420
|
-
|
|
421
|
-
|
|
474
|
+
// turri ended the turn itself - its time was up, the agent went round in a circle: the abort that ended it is its own.
|
|
475
|
+
const stoppedFor = harnessStops.get(session);
|
|
476
|
+
harnessStops.delete(session);
|
|
477
|
+
if (stoppedFor !== undefined)
|
|
478
|
+
out = `${out.trim()}\n\n[the turn was stopped: ${stoppedFor}]`.trim();
|
|
422
479
|
if (stop?.aborted) {
|
|
423
480
|
debug?.note(`turn stopped on request after ${seconds(Date.now() - turnStarted)}`);
|
|
424
481
|
throw new JobStoppedError();
|
|
425
482
|
}
|
|
426
|
-
// A turn ended
|
|
427
|
-
if (providerError !== undefined &&
|
|
483
|
+
// A turn turri ended is ended, whatever the provider was doing then: what comes back of the abort is not the provider failing.
|
|
484
|
+
if (providerError !== undefined && stoppedFor === undefined) {
|
|
428
485
|
debug?.note(`turn ended with a provider error after ${seconds(Date.now() - turnStarted)}: ${providerError}`);
|
|
429
486
|
throw new ProviderError(`${session.model?.id ?? "model"}: ${providerError}`);
|
|
430
487
|
}
|
|
@@ -614,7 +671,7 @@ export function guardRepeats(tools, session, budget) {
|
|
|
614
671
|
refused += 1;
|
|
615
672
|
if (refused > REFUSED_BEFORE_STOP) {
|
|
616
673
|
reportActivity(` stopped the agent's turn: ${refused} calls to tools this turn does not have`);
|
|
617
|
-
|
|
674
|
+
stopTurn(current, `${refused} calls to tools this turn does not have`);
|
|
618
675
|
throw new Error(`Stopped: ${refused} calls to tools this turn does not have.`);
|
|
619
676
|
}
|
|
620
677
|
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 +681,7 @@ export function guardRepeats(tools, session, budget) {
|
|
|
624
681
|
if (budget !== undefined && !budget.finish.includes(tool.name) && calls > budget.calls) {
|
|
625
682
|
if (calls > budget.calls * 2) {
|
|
626
683
|
reportActivity(` stopped the agent's turn: ${calls} tool calls, past its budget of ${budget.calls}`);
|
|
627
|
-
|
|
684
|
+
stopTurn(session(), `${calls} tool calls, past its budget of ${budget.calls}`);
|
|
628
685
|
throw new Error(`Stopped: ${calls} tool calls, past the budget of ${budget.calls}.`);
|
|
629
686
|
}
|
|
630
687
|
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 +709,7 @@ export function guardRepeats(tools, session, budget) {
|
|
|
652
709
|
}
|
|
653
710
|
if (repeats > REPEATS_BEFORE_STOP) {
|
|
654
711
|
reportActivity(` stopped the agent's turn: it made the same ${tool.name} call ${repeats} times with nothing changed`);
|
|
655
|
-
|
|
712
|
+
stopTurn(session(), `the same ${tool.name} call ${repeats} times with nothing changed`);
|
|
656
713
|
throw new Error(`Stopped: the same ${tool.name} call ${repeats} times with nothing changed.`);
|
|
657
714
|
}
|
|
658
715
|
if (repeats > REPEATS_ALLOWED) {
|
|
@@ -695,7 +752,7 @@ export async function createExecutor(opts) {
|
|
|
695
752
|
modelRuntime: await subAgentModelRuntime(),
|
|
696
753
|
tools: hasShell ? [...opts.tools, ENVIRONMENT_ERROR_TOOL] : opts.tools,
|
|
697
754
|
// 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),
|
|
755
|
+
customTools: guardRepeats(maskToolResults(withListArguments(withEnvironmentErrors)), () => session, opts.budget),
|
|
699
756
|
sessionManager,
|
|
700
757
|
resourceLoader: await subAgentResources(opts.cwd, opts.rules === true, [opts.system, opts.task].filter((part) => part !== undefined && part !== "").join("\n\n") || undefined),
|
|
701
758
|
});
|
|
@@ -814,7 +871,7 @@ export async function createJudge(opts) {
|
|
|
814
871
|
model,
|
|
815
872
|
modelRuntime,
|
|
816
873
|
tools: [...(opts.extraTools ?? []), "submit_verdict"],
|
|
817
|
-
customTools: [opts.verdictTool],
|
|
874
|
+
customTools: withListArguments([opts.verdictTool]),
|
|
818
875
|
sessionManager: SessionManager.inMemory(opts.cwd),
|
|
819
876
|
// Judges assess specs against the rules, so they have them too.
|
|
820
877
|
resourceLoader: await subAgentResources(opts.cwd, true, opts.task),
|
package/dist/question-dialog.js
CHANGED
|
@@ -90,6 +90,27 @@ export function onModelEvent(listener) {
|
|
|
90
90
|
modelListeners.add(listener);
|
|
91
91
|
return () => modelListeners.delete(listener);
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* The model provider failing or stalling, in a line for the person: the chat's notification, a headless run's console.
|
|
95
|
+
* A turn turri stopped itself is the work going its normal course - kept in the activity, the pulse's log and the run
|
|
96
|
+
* report, not said.
|
|
97
|
+
*/
|
|
98
|
+
export function describeTurnIncident(event) {
|
|
99
|
+
const who = event.role ?? event.label ?? "an agent";
|
|
100
|
+
const model = event.model !== undefined ? ` (${event.model})` : "";
|
|
101
|
+
if (event.kind === "provider_retry") {
|
|
102
|
+
const wait = Math.round((event.waitMs ?? 0) / 1000);
|
|
103
|
+
return `The model provider failed${model}: ${(event.error ?? "").slice(0, 160)} - trying ${who}'s request again in ${wait}s (${event.attempt} of ${event.of}).`;
|
|
104
|
+
}
|
|
105
|
+
if (event.kind === "provider_stall") {
|
|
106
|
+
return `The model provider has sent nothing back to ${who}${model} for ${formatSilence(event.waitMs ?? 0)} - still waiting.`;
|
|
107
|
+
}
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
function formatSilence(ms) {
|
|
111
|
+
const seconds = Math.round(ms / 1000);
|
|
112
|
+
return seconds >= 60 && seconds % 60 === 0 ? `${seconds / 60}m` : seconds >= 60 ? `${Math.floor(seconds / 60)}m ${seconds % 60}s` : `${seconds}s`;
|
|
113
|
+
}
|
|
93
114
|
export function reportModelEvent(event) {
|
|
94
115
|
if (modelListeners.size === 0)
|
|
95
116
|
return;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2
|
+
/** The tool's arguments that take a list of objects. */
|
|
3
|
+
function listArguments(schema) {
|
|
4
|
+
const required = new Set(schema.required ?? []);
|
|
5
|
+
return Object.entries(schema.properties ?? {})
|
|
6
|
+
.filter(([, property]) => property.type === "array" && property.items?.type === "object")
|
|
7
|
+
.map(([name, property]) => ({ name, required: required.has(name), item: property.items }));
|
|
8
|
+
}
|
|
9
|
+
/** JSON text, fenced or not, as what it holds; anything else as it is. */
|
|
10
|
+
function parsed(value) {
|
|
11
|
+
if (typeof value !== "string")
|
|
12
|
+
return value;
|
|
13
|
+
const text = value
|
|
14
|
+
.trim()
|
|
15
|
+
.replace(/^```(?:json)?\s*/i, "")
|
|
16
|
+
.replace(/\s*```$/, "");
|
|
17
|
+
if (!/^[[{]/.test(text))
|
|
18
|
+
return value;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(text);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const escaped = (name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
27
|
+
/**
|
|
28
|
+
* Arguments the model wrote inside another argument's text - `answer</a>\n<b>[...]</b>\n<c>...` - taken out of it and
|
|
29
|
+
* given as their own, where they were not given already. Which argument each was found in, for the refusal.
|
|
30
|
+
*/
|
|
31
|
+
function untucked(args, names) {
|
|
32
|
+
const out = { ...args };
|
|
33
|
+
const foundIn = new Map();
|
|
34
|
+
const anyTag = names.map(escaped).join("|");
|
|
35
|
+
for (const [key, value] of Object.entries(args)) {
|
|
36
|
+
if (typeof value !== "string")
|
|
37
|
+
continue;
|
|
38
|
+
let cut = value.search(new RegExp(`</${escaped(key)}>`));
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
if (name === key || (out[name] !== undefined && out[name] !== ""))
|
|
41
|
+
continue;
|
|
42
|
+
const match = new RegExp(`<${escaped(name)}>([\\s\\S]*?)(?:</${escaped(name)}>|(?=<(?:${anyTag})>)|$)`).exec(value);
|
|
43
|
+
if (match === null)
|
|
44
|
+
continue;
|
|
45
|
+
out[name] = match[1].trim();
|
|
46
|
+
foundIn.set(name, key);
|
|
47
|
+
cut = cut === -1 ? match.index : Math.min(cut, match.index);
|
|
48
|
+
}
|
|
49
|
+
if (cut !== -1)
|
|
50
|
+
out[key] = value.slice(0, cut).trim();
|
|
51
|
+
}
|
|
52
|
+
return { args: out, foundIn };
|
|
53
|
+
}
|
|
54
|
+
/** What an entry of the list looks like, as JSON: its fields, the optional ones marked. */
|
|
55
|
+
function shapeOf(item) {
|
|
56
|
+
const required = new Set(item.required ?? []);
|
|
57
|
+
const entries = Object.entries(item.properties ?? {});
|
|
58
|
+
const fields = entries.map(([name, field]) => `"${name}"${required.has(name) ? "" : "?"}: ${field.type ?? "value"}`).join(", ");
|
|
59
|
+
const sample = (field) => (field.type === "number" || field.type === "integer" ? "1" : field.type === "boolean" ? "true" : field.type === "string" ? '"..."' : "...");
|
|
60
|
+
const example = entries
|
|
61
|
+
.filter(([name]) => required.has(name))
|
|
62
|
+
.map(([name, field]) => `"${name}": ${sample(field)}`)
|
|
63
|
+
.join(", ");
|
|
64
|
+
return { fields: `{${fields}}`, example: `{${example}}` };
|
|
65
|
+
}
|
|
66
|
+
/** Why a list argument is not one, said so a model can make the call right next time - or undefined when it is. */
|
|
67
|
+
function problemOf(list, value, foundIn) {
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
return list.required ? "you left it out" : undefined;
|
|
70
|
+
if (!Array.isArray(value)) {
|
|
71
|
+
if (foundIn !== undefined)
|
|
72
|
+
return `you wrote it inside \`${foundIn}\``;
|
|
73
|
+
return typeof value === "string" ? "you sent it as text, not a list" : `you sent ${isObject(value) ? "an object" : `a ${typeof value}`}, not a list`;
|
|
74
|
+
}
|
|
75
|
+
const bad = value.findIndex((entry) => !isObject(entry));
|
|
76
|
+
if (bad === -1)
|
|
77
|
+
return undefined;
|
|
78
|
+
return `entry ${bad + 1} is ${typeof value[bad] === "string" ? "text" : `a ${typeof value[bad]}`}, not an object`;
|
|
79
|
+
}
|
|
80
|
+
/** The arguments with their lists made lists where they plainly are; refused, saying what is wanted, where they are not. */
|
|
81
|
+
export function prepareListArguments(toolName, schema, raw) {
|
|
82
|
+
const lists = listArguments(schema);
|
|
83
|
+
if (lists.length === 0 || !isObject(raw))
|
|
84
|
+
return raw;
|
|
85
|
+
const { args, foundIn } = untucked(raw, Object.keys(schema.properties ?? {}));
|
|
86
|
+
const problems = [];
|
|
87
|
+
for (const list of lists) {
|
|
88
|
+
let value = parsed(args[list.name]);
|
|
89
|
+
if (isObject(value))
|
|
90
|
+
value = [value];
|
|
91
|
+
if (Array.isArray(value))
|
|
92
|
+
value = value.map(parsed);
|
|
93
|
+
if (value !== undefined)
|
|
94
|
+
args[list.name] = value;
|
|
95
|
+
const problem = problemOf(list, value, foundIn.get(list.name));
|
|
96
|
+
if (problem === undefined)
|
|
97
|
+
continue;
|
|
98
|
+
const { fields, example } = shapeOf(list.item);
|
|
99
|
+
problems.push(`- \`${list.name}\`: ${problem}. It is a list of objects, each ${fields} - e.g. "${list.name}": [${example}].`);
|
|
100
|
+
}
|
|
101
|
+
if (problems.length === 0)
|
|
102
|
+
return args;
|
|
103
|
+
throw new Error([
|
|
104
|
+
`${toolName} was not run - its arguments are not in the shape it takes:`,
|
|
105
|
+
...problems,
|
|
106
|
+
"Each argument is a field of its own in the call, at the top level: a list is a JSON array of objects, never text, and never written inside another argument's text.",
|
|
107
|
+
].join("\n"));
|
|
108
|
+
}
|
|
109
|
+
/** The tools, each that takes a list of objects preparing its arguments so before they are checked. */
|
|
110
|
+
export function withListArguments(tools) {
|
|
111
|
+
return tools.map((tool) => {
|
|
112
|
+
const schema = tool.parameters;
|
|
113
|
+
if (listArguments(schema).length === 0)
|
|
114
|
+
return tool;
|
|
115
|
+
const before = tool.prepareArguments;
|
|
116
|
+
return {
|
|
117
|
+
...tool,
|
|
118
|
+
prepareArguments: (args) => prepareListArguments(tool.name, schema, before !== undefined ? before(args) : args),
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
package/dist/regenerate/loop.js
CHANGED
|
@@ -597,7 +597,14 @@ export function createWorkLoop(options) {
|
|
|
597
597
|
}
|
|
598
598
|
return {
|
|
599
599
|
report: released !== undefined ? `${report}\n\n${released}` : report,
|
|
600
|
-
details: {
|
|
600
|
+
details: {
|
|
601
|
+
passed: result.landed,
|
|
602
|
+
landed: result.landed,
|
|
603
|
+
...(released !== undefined ? { released: true } : {}),
|
|
604
|
+
...(result.story !== undefined ? { story: result.story } : {}),
|
|
605
|
+
// The spec gaps its agents met, for a headless run to say - in the chat the report puts them to the person.
|
|
606
|
+
...(result.specGaps !== undefined && result.specGaps.length > 0 ? { specGaps: result.specGaps } : {}),
|
|
607
|
+
},
|
|
601
608
|
};
|
|
602
609
|
},
|
|
603
610
|
});
|
|
@@ -1240,17 +1247,21 @@ export function createWorkLoop(options) {
|
|
|
1240
1247
|
startAgain(entry, `it now requires ${requires.join(", ")}, which its code was not built on`);
|
|
1241
1248
|
return loop.bringUp(plainFile, request);
|
|
1242
1249
|
},
|
|
1243
|
-
async fromScratch(plainFile, request = {}) {
|
|
1250
|
+
async fromScratch(plainFile, { chain, ...request } = {}) {
|
|
1244
1251
|
const file = resolve(options.cwd, plainFile);
|
|
1245
|
-
// Where its code lives: the tips its module is built in, or - none built yet - its own codebase.
|
|
1246
|
-
|
|
1252
|
+
// Where its code lives: the tips its module is built in, or - none built yet - its own codebase. The whole chain:
|
|
1253
|
+
// every codebase in those chains, bottom first - a tip taken back to nothing is otherwise started from a copy of
|
|
1254
|
+
// the code below it.
|
|
1255
|
+
const chains = chainsFor(file);
|
|
1256
|
+
const codebases = [...new Map((chain === true ? chains.flat() : chains.map(tipOf)).map((entry) => [entry.buildDir, entry])).values()];
|
|
1247
1257
|
for (const entry of codebases) {
|
|
1248
1258
|
if (modules.get(entry.buildDir)?.running !== undefined)
|
|
1249
1259
|
throw new Error(`${entry.moduleName} has a pulse running: halt it, or ask again once it is done.`);
|
|
1250
1260
|
}
|
|
1261
|
+
const why = chain === true ? "asked to be regenerated from scratch, with its whole chain" : "asked to be regenerated from scratch";
|
|
1251
1262
|
for (const entry of codebases)
|
|
1252
1263
|
if (started(entry))
|
|
1253
|
-
startAgain(entry,
|
|
1264
|
+
startAgain(entry, why);
|
|
1254
1265
|
return loop.bringUp(plainFile, request);
|
|
1255
1266
|
},
|
|
1256
1267
|
halt(target, reason) {
|
|
@@ -1511,7 +1522,7 @@ export function describeModules(statuses, options = {}) {
|
|
|
1511
1522
|
` Ask the user whether to start ${codebases.join(", ")} over, and say why: ${codebases.join(", ")} was built without ` +
|
|
1512
1523
|
`${requires.join(", ")}, so no change to its code can bring ${requires.join(", ")} in - its code and conformance ` +
|
|
1513
1524
|
"tests are taken out, kept in its history, and built again from the bottom of the chain. Only if they agree, " +
|
|
1514
|
-
`call regenerate with ${basename(status.plainFile)} and from_scratch.`,
|
|
1525
|
+
`call regenerate with ${basename(status.plainFile)} and from_scratch: "module".`,
|
|
1515
1526
|
];
|
|
1516
1527
|
};
|
|
1517
1528
|
return statuses
|
|
@@ -1565,7 +1576,7 @@ const defaultConformanceRunner = async (job, onDelta) => {
|
|
|
1565
1576
|
writeTestsRecord(result.conformanceDir, job.planned.step.tree);
|
|
1566
1577
|
recordHistory(job.buildDir, `conformance tests: ${job.planned.title}`);
|
|
1567
1578
|
}
|
|
1568
|
-
return { landed: result.passed, report: describeSpecDiffConformance(result) };
|
|
1579
|
+
return { landed: result.passed, report: describeSpecDiffConformance(result), ...(result.specGaps !== undefined ? { specGaps: result.specGaps } : {}) };
|
|
1569
1580
|
};
|
|
1570
1581
|
/** A job as a spec diff render, landed on its unit tests: conformance is a track of its own. */
|
|
1571
1582
|
const defaultRunner = async (job, onDelta) => {
|
|
@@ -1581,7 +1592,9 @@ const defaultRunner = async (job, onDelta) => {
|
|
|
1581
1592
|
onDelta,
|
|
1582
1593
|
});
|
|
1583
1594
|
// Landed code can be tried.
|
|
1584
|
-
return { landed: result.passed, report: withTryItLine(describeSpecDiff(result), result.passed && result.restructured !== true), story: codeStory(result)
|
|
1595
|
+
return { landed: result.passed, report: withTryItLine(describeSpecDiff(result), result.passed && result.restructured !== true), story: codeStory(result),
|
|
1596
|
+
...(result.specGaps !== undefined ? { specGaps: result.specGaps } : {}),
|
|
1597
|
+
};
|
|
1585
1598
|
};
|
|
1586
1599
|
/** How a code pulse went, for its line in the notes: the rounds it took, its test runs, what the debugger found. */
|
|
1587
1600
|
export function codeStory(result) {
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* On a dark surface - turri-dark's abyss, #0a0f1a, pi's dark ones - in the design system's colours alone: a section's
|
|
3
|
+
* header in pink, a concept in neon, text in quotes or backticks in siesta tan. Every colour at least 7:1 on abyss and 4.8:1 on the blue whale fill
|
|
4
|
+
* of an added line; on the eggplant of a removed one, the design system's only fill of that warmth, its pinks and
|
|
5
|
+
* grauzone drop to 3.7:1.
|
|
6
|
+
*/
|
|
2
7
|
const DARK = {
|
|
3
8
|
roles: {
|
|
4
|
-
section: { colour: "#
|
|
5
|
-
concept: { colour: "#
|
|
6
|
-
link: { colour: "#
|
|
7
|
-
literal: { colour: "#
|
|
8
|
-
keyword: { colour: "#
|
|
9
|
-
module: { colour: "#
|
|
10
|
-
comment: { colour: "#
|
|
11
|
-
bullet: { colour: "#
|
|
9
|
+
section: { colour: "#ff7fa6", bold: true },
|
|
10
|
+
concept: { colour: "#5ce1e6" },
|
|
11
|
+
link: { colour: "#f4f7f9", underline: true },
|
|
12
|
+
literal: { colour: "#e9d8c8" },
|
|
13
|
+
keyword: { colour: "#f4f7f9", bold: true },
|
|
14
|
+
module: { colour: "#f4f7f9" },
|
|
15
|
+
comment: { colour: "#85a3b2", italic: true },
|
|
16
|
+
bullet: { colour: "#85a3b2" },
|
|
12
17
|
},
|
|
13
|
-
added: "#
|
|
14
|
-
removed: "#
|
|
15
|
-
addedFill: "#
|
|
16
|
-
removedFill: "#
|
|
17
|
-
muted: "#
|
|
18
|
+
added: "#5ce1e6",
|
|
19
|
+
removed: "#ff7fa6",
|
|
20
|
+
addedFill: "#1e3442",
|
|
21
|
+
removedFill: "#732553",
|
|
22
|
+
muted: "#85a3b2",
|
|
18
23
|
};
|
|
19
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* On a light surface - turri-light's white, pi's light ones - in the design system's deep colours, the only ones it has
|
|
26
|
+
* that read on white. Every colour at least 7:1 on white, and 5:1 on the neon hover and siesta tan fills.
|
|
27
|
+
*/
|
|
20
28
|
const LIGHT = {
|
|
21
29
|
roles: {
|
|
22
|
-
section: { colour: "#
|
|
23
|
-
concept: { colour: "#
|
|
24
|
-
link: { colour: "#
|
|
25
|
-
literal: { colour: "#
|
|
26
|
-
keyword: { colour: "#
|
|
27
|
-
module: { colour: "#
|
|
28
|
-
comment: { colour: "#
|
|
29
|
-
bullet: { colour: "#
|
|
30
|
+
section: { colour: "#3e5a6b", bold: true },
|
|
31
|
+
concept: { colour: "#732553" },
|
|
32
|
+
link: { colour: "#1e3442", underline: true },
|
|
33
|
+
literal: { colour: "#1e3442" },
|
|
34
|
+
keyword: { colour: "#0a0f1a", bold: true },
|
|
35
|
+
module: { colour: "#1e3442" },
|
|
36
|
+
comment: { colour: "#3e5a6b", italic: true },
|
|
37
|
+
bullet: { colour: "#3e5a6b" },
|
|
30
38
|
},
|
|
31
|
-
added: "#
|
|
32
|
-
removed: "#
|
|
33
|
-
addedFill: "#
|
|
34
|
-
removedFill: "#
|
|
35
|
-
muted: "#
|
|
39
|
+
added: "#1e3442",
|
|
40
|
+
removed: "#732553",
|
|
41
|
+
addedFill: "#8eebee",
|
|
42
|
+
removedFill: "#e9d8c8",
|
|
43
|
+
muted: "#3e5a6b",
|
|
36
44
|
};
|
|
37
45
|
const rgb = (hex) => {
|
|
38
46
|
const value = Number.parseInt(hex.slice(1), 16);
|
|
@@ -57,17 +65,24 @@ const fillWith = (hex, text, truecolor) => {
|
|
|
57
65
|
return `${on}${text.replace(/\x1b\[(?:0|49)?m/g, (reset) => `${reset}${on}`)}\x1b[49m`;
|
|
58
66
|
};
|
|
59
67
|
/**
|
|
60
|
-
*
|
|
61
|
-
* on
|
|
62
|
-
* to white, 7.34:1 on brand black.
|
|
68
|
+
* Neon, for what is shown to do what its spec says - regen's ◆: the design system's colour for what can be followed,
|
|
69
|
+
* 12.2:1 on abyss. On a light surface, where neon is illegible (1.6:1 on white), blue whale, 12.9:1 on white.
|
|
63
70
|
*/
|
|
64
|
-
export const
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
export const BRAND_NEON = { light: "#1e3442", dark: "#5ce1e6" };
|
|
72
|
+
/**
|
|
73
|
+
* Pink, the one pink thing in a view - the banner's wordmark: 6.54:1 on abyss. On a light surface, where pink is
|
|
74
|
+
* too pale (2.9:1 on white), eggplant, 9.9:1 on white.
|
|
75
|
+
*/
|
|
76
|
+
export const BRAND_PINK = { light: "#732553", dark: "#ff5c8d" };
|
|
77
|
+
const brandInk = (colours) => (theme) => {
|
|
78
|
+
const colour = theme.appearance === "light" ? colours.light : colours.dark;
|
|
68
79
|
const truecolor = (theme.getColorMode?.() ?? "truecolor") === "truecolor";
|
|
69
80
|
return (text) => paintWith({ colour, bold: true }, text, truecolor);
|
|
70
|
-
}
|
|
81
|
+
};
|
|
82
|
+
/** Text in neon on a theme - blue whale on a light one - in as many colours as the terminal has. */
|
|
83
|
+
export const brandNeon = brandInk(BRAND_NEON);
|
|
84
|
+
/** Text in pink on a theme - eggplant on a light one - in as many colours as the terminal has. */
|
|
85
|
+
export const brandPink = brandInk(BRAND_PINK);
|
|
71
86
|
/** How a spec diff is painted on a theme: its palette by whether the theme is dark or light, in as many colours as the terminal has. */
|
|
72
87
|
export function plainPaint(theme) {
|
|
73
88
|
const palette = theme.appearance === "light" ? LIGHT : DARK;
|
|
@@ -281,9 +281,11 @@ export async function renderSpecDiff(options) {
|
|
|
281
281
|
const work = createWorkLedger();
|
|
282
282
|
// What it checks its own work with: the diff its reviewer is shown, and whether a test catches a bug - neither decides anything.
|
|
283
283
|
const gate = createUnitGate(buildDir, scripts.unit);
|
|
284
|
+
// can_it_fail, for the coding agent and its reviewer: on unless mutation-testing says otherwise.
|
|
285
|
+
const mutationTesting = scripts.unit !== undefined && configForSpec(tip.plainFile).mutationTesting !== false;
|
|
284
286
|
const selfChecks = [
|
|
285
287
|
createMyDiffTool({ dir: buildDir, what: "code" }),
|
|
286
|
-
...(
|
|
288
|
+
...(mutationTesting ? [createCanItFailTool({ buildDir, script: scripts.unit })] : []),
|
|
287
289
|
];
|
|
288
290
|
// A server it built, it can start and try from outside - stopped when it is done.
|
|
289
291
|
const services = createServiceTools({ dir: buildDir });
|
|
@@ -499,7 +501,7 @@ export async function renderSpecDiff(options) {
|
|
|
499
501
|
forChange: true,
|
|
500
502
|
...(options.cases !== undefined ? { cases: options.cases } : {}),
|
|
501
503
|
label: `${moduleName} spec change`,
|
|
502
|
-
...(
|
|
504
|
+
...(mutationTesting ? { unitScript: scripts.unit } : {}),
|
|
503
505
|
testingScript: { path: relative(root, scripts.unit), content: readFileSync(scripts.unit, "utf8") },
|
|
504
506
|
model: options.judgeModel ?? modelSpec(inheritModel(configForSpec(tip.plainFile).judgeModel, modelOnly(options.model))),
|
|
505
507
|
send: async (next) => {
|