@turri-dev/cli 0.1.3-next.f74e98a → 0.1.4-next.318a98a
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/extension.js +61 -18
- package/dist/genome.js +1 -1
- package/dist/loop-tools.js +20 -7
- package/dist/pi-launch.js +5 -0
- package/dist/question-dialog.js +8 -3
- package/dist/questioning.js +1 -1
- package/dist/regenerate/activity.js +2 -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/loop.js +116 -10
- package/dist/regenerate/notes.js +66 -17
- package/dist/regenerate/prompt.js +3 -1
- package/dist/regenerate/regenerate.js +12 -8
- package/dist/regenerate/regression.js +2 -1
- package/dist/regenerate/requires.js +55 -2
- package/dist/regenerate/unit-review.js +11 -0
- package/dist/release-tools.js +1 -1
- package/dist/resume-line.js +4 -0
- package/dist/spec-tools.js +10 -45
- package/docs/authoring-plain.md +9 -6
- package/docs/installation.md +3 -0
- package/docs/regenerating.md +39 -13
- package/docs/skills-and-gates.md +2 -2
- package/docs/using.md +4 -3
- package/genome/skills/bud/SKILL.md +67 -36
- package/genome/skills/bud/references/intent.md +4 -0
- package/package.json +3 -3
- package/genome/skills/bud/references/checklist.md +0 -44
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ npm install -g @turri-dev/cli # puts `turri` on your PATH
|
|
|
27
27
|
turri doctor # checks the machine
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
To work on turri itself, run it from a clone
|
|
30
|
+
To follow `main` as it moves, or work on turri itself, run it [from a clone](#from-a-clone) instead.
|
|
31
31
|
|
|
32
32
|
`doctor` checks for Node 22.19+, bash, the OS sandbox and a model provider for pi; in a project, the toolchains its
|
|
33
33
|
modules need, what its testing scripts run against this machine, and that each model `config.turri.yaml` names
|
|
@@ -73,6 +73,27 @@ Rather not install Node and the rest? **turri** also runs in Docker, from one im
|
|
|
73
73
|
|
|
74
74
|
Choosing models: [models](#models); what to do next: [use](#use).
|
|
75
75
|
|
|
76
|
+
### From a clone
|
|
77
|
+
|
|
78
|
+
In place of the npm package - for the latest of `main`, or to change turri itself:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
git clone git@github.com:turri-oss/turri.git && cd turri
|
|
82
|
+
npm install
|
|
83
|
+
npm link # puts `turri` on your PATH, pointing at this clone
|
|
84
|
+
turri doctor
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The clone runs its TypeScript sources directly, so there is nothing to build. When new commits land:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git pull
|
|
91
|
+
npm install # picks up any dependency that changed
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
A **turri** already running keeps the code it started with - start it again to run what you pulled. More in
|
|
95
|
+
[installation](docs/installation.md#from-a-clone).
|
|
96
|
+
|
|
76
97
|
## Why
|
|
77
98
|
|
|
78
99
|
In the age of coding agents, writing code is getting easy. The hard and important part is
|
package/dist/extension.js
CHANGED
|
@@ -90,15 +90,23 @@ aside) {
|
|
|
90
90
|
// The question, with what the asker gives to read for it - a brief to confirm - above it; what it said of its work
|
|
91
91
|
// before asking is kept in its record, never put in the dialog.
|
|
92
92
|
// A dialog of turri's own: a long brief scrolls above the question, and the options always show (question-dialog.ts).
|
|
93
|
-
const dialog = (question, context, options) => ctx.ui.custom((tui, theme, _keybindings, done) =>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
const dialog = (question, context, options) => ctx.ui.custom((tui, theme, _keybindings, done) => {
|
|
94
|
+
const shown = new QuestionDialog({
|
|
95
|
+
question,
|
|
96
|
+
...(context !== undefined ? { context } : {}),
|
|
97
|
+
...(options !== undefined ? { options } : {}),
|
|
98
|
+
rows: () => tui.terminal.rows,
|
|
99
|
+
style: { accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text) },
|
|
100
|
+
done: (answer) => {
|
|
101
|
+
if (questionShown === shown)
|
|
102
|
+
questionShown = undefined;
|
|
103
|
+
done(answer);
|
|
104
|
+
},
|
|
105
|
+
requestRender: () => tui.requestRender(),
|
|
106
|
+
});
|
|
107
|
+
questionShown = shown;
|
|
108
|
+
return shown;
|
|
109
|
+
});
|
|
102
110
|
const asking = (asked) => runAsk(asked, {
|
|
103
111
|
select: (title, options, context) => dialog(title, context, options),
|
|
104
112
|
input: (title, context) => dialog(title, context),
|
|
@@ -117,6 +125,12 @@ aside) {
|
|
|
117
125
|
}
|
|
118
126
|
/** The side panel, as a question open in the chat reaches it: set once the extension has its panel. */
|
|
119
127
|
let questionPeek;
|
|
128
|
+
/**
|
|
129
|
+
* The question open in the chat now, if any. The side panel gives the keys back to it: pi would give them to what had the
|
|
130
|
+
* focus when the panel first opened, and a panel kept beside the chat outlives that question - the keys would go to a
|
|
131
|
+
* dialog already answered, and nothing would take them.
|
|
132
|
+
*/
|
|
133
|
+
let questionShown;
|
|
120
134
|
/** A widget with nothing to draw: below the editor, it takes no line. */
|
|
121
135
|
const PEEK_KEY_WIDGET = "turri-peek-key";
|
|
122
136
|
/**
|
|
@@ -534,7 +548,7 @@ export default function (pi) {
|
|
|
534
548
|
loopTools: [
|
|
535
549
|
regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named, work) => jobModel(ctx, work ?? "spec_changes", named, plainFile), wait: () => false }),
|
|
536
550
|
driftTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx) }),
|
|
537
|
-
haltTool({ jobs }),
|
|
551
|
+
haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop }),
|
|
538
552
|
conformTool({ cwd, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, "spec_changes", named, plainFile), wait: () => false }),
|
|
539
553
|
],
|
|
540
554
|
// The escalation becomes a real dialog in the TUI. Without dialog-capable
|
|
@@ -1405,25 +1419,37 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1405
1419
|
// The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
|
|
1406
1420
|
// list, finished jobs included, put in the transcript where it stays.
|
|
1407
1421
|
pi.registerCommand("halt", {
|
|
1408
|
-
description: "Halt a queued or running pulse, or what activate started: /halt [pulse id | activated <name>]",
|
|
1422
|
+
description: "Halt a queued or running pulse, a module's planned pulses, or what activate started: /halt [pulse id | module | activated <name>]",
|
|
1409
1423
|
handler: async (args, ctx) => {
|
|
1410
1424
|
if (!ctx.hasUI)
|
|
1411
1425
|
return;
|
|
1412
1426
|
const live = jobs.list().filter((job) => job.status === "running" || job.status === "queued");
|
|
1413
1427
|
const deployed = runningDeployed();
|
|
1428
|
+
const loop = workLoops.get(jobs)?.loop;
|
|
1429
|
+
// A module's planned pulses, one line a module: halting one halts the module.
|
|
1430
|
+
const plannedRows = loop?.planned() ?? [];
|
|
1431
|
+
const planned = [...new Set(plannedRows.map((row) => row.module ?? ""))].filter((module) => module !== "");
|
|
1414
1432
|
let id = args.trim();
|
|
1415
1433
|
if (id === "") {
|
|
1416
|
-
if (live.length === 0 && deployed.length === 0)
|
|
1417
|
-
return ctx.ui.notify("Nothing is regenerating or
|
|
1434
|
+
if (live.length === 0 && deployed.length === 0 && planned.length === 0)
|
|
1435
|
+
return ctx.ui.notify("Nothing is regenerating, queued or planned.", "info");
|
|
1418
1436
|
const label = (job) => `${job.id} ${job.status.padEnd(8)} ${pulseName(job)}`;
|
|
1419
|
-
const
|
|
1437
|
+
const plannedLabel = (module) => {
|
|
1438
|
+
const rows = plannedRows.filter((row) => row.module === module);
|
|
1439
|
+
const waiting = rows.find((row) => row.id.endsWith("-waiting"));
|
|
1440
|
+
return `${module} ${waiting !== undefined ? waiting.summary : `${rows.length} planned`} - halts the module`;
|
|
1441
|
+
};
|
|
1442
|
+
const labels = [...live.map(label), ...planned.map(plannedLabel), ...deployed.map((item) => deployedLabel(item.name, item.url ?? item.command))];
|
|
1420
1443
|
const picked = await ctx.ui.select("Halt which?", labels);
|
|
1421
1444
|
const job = live.find((candidate) => picked !== undefined && label(candidate) === picked);
|
|
1445
|
+
const module = planned.find((name) => picked !== undefined && plannedLabel(name) === picked);
|
|
1422
1446
|
const server = deployed.find((item) => picked !== undefined && deployedLabel(item.name, item.url ?? item.command) === picked);
|
|
1423
1447
|
if (server !== undefined)
|
|
1424
1448
|
id = `activated ${server.name}`;
|
|
1425
1449
|
else if (job !== undefined)
|
|
1426
1450
|
id = job.id;
|
|
1451
|
+
else if (module !== undefined)
|
|
1452
|
+
id = module;
|
|
1427
1453
|
else
|
|
1428
1454
|
return;
|
|
1429
1455
|
}
|
|
@@ -1432,7 +1458,7 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1432
1458
|
const stopped = await stopDeployed({ name });
|
|
1433
1459
|
return shownAfterCommand(pi, ctx, `/halt ${id}`, stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running as ${name}.`, "info");
|
|
1434
1460
|
}
|
|
1435
|
-
ctx.ui.notify(stopJob(jobs, id), "info");
|
|
1461
|
+
ctx.ui.notify(stopJob(jobs, id, undefined, loop), "info");
|
|
1436
1462
|
},
|
|
1437
1463
|
});
|
|
1438
1464
|
// Debug mode, for the render agents started from now on - see debug-log.ts.
|
|
@@ -1508,6 +1534,7 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1508
1534
|
}
|
|
1509
1535
|
needsLooking.delete(jobs);
|
|
1510
1536
|
if (panel !== undefined) {
|
|
1537
|
+
panel.keepChatFocus();
|
|
1511
1538
|
panel.handle?.setHidden(false);
|
|
1512
1539
|
panel.keys = true;
|
|
1513
1540
|
panel.handle?.focus();
|
|
@@ -1515,7 +1542,21 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1515
1542
|
}
|
|
1516
1543
|
// Not awaited: the panel lives on while the jobs it shows run.
|
|
1517
1544
|
void ctx.ui.custom((tui, theme, _keybindings, done) => {
|
|
1518
|
-
|
|
1545
|
+
// What the chat shows when the panel takes the keys - its editor, or a pi dialog - for when it gives them back.
|
|
1546
|
+
const focusedNow = () => tui.getFocusedComponent?.() ?? null;
|
|
1547
|
+
let chatFocus = focusedNow();
|
|
1548
|
+
const keepChatFocus = () => {
|
|
1549
|
+
const focused = focusedNow();
|
|
1550
|
+
if (focused !== null && focused !== component && !(focused instanceof QuestionDialog))
|
|
1551
|
+
chatFocus = focused;
|
|
1552
|
+
};
|
|
1553
|
+
// The keys back to the chat: to the question open there now, else to what it showed - never to a question answered
|
|
1554
|
+
// while the panel was open.
|
|
1555
|
+
const giveBack = () => entry.handle?.unfocus({ target: questionShown ?? chatFocus });
|
|
1556
|
+
const close = () => {
|
|
1557
|
+
giveBack();
|
|
1558
|
+
done(undefined);
|
|
1559
|
+
};
|
|
1519
1560
|
panelTerminal = tui.terminal;
|
|
1520
1561
|
let component;
|
|
1521
1562
|
// Beside the chat: the chat drawn narrower, on the left, and a click on either side giving it the keys - undone
|
|
@@ -1548,10 +1589,11 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1548
1589
|
// Beside the chat, back to it: the chat has the keys, the panel stays.
|
|
1549
1590
|
const toChat = () => {
|
|
1550
1591
|
entry.keys = false;
|
|
1551
|
-
|
|
1592
|
+
giveBack();
|
|
1552
1593
|
tui.requestRender();
|
|
1553
1594
|
};
|
|
1554
1595
|
const toPanel = () => {
|
|
1596
|
+
keepChatFocus();
|
|
1555
1597
|
entry.keys = true;
|
|
1556
1598
|
entry.handle?.focus();
|
|
1557
1599
|
tui.requestRender();
|
|
@@ -1604,7 +1646,7 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1604
1646
|
return focused !== null && focused !== component;
|
|
1605
1647
|
},
|
|
1606
1648
|
});
|
|
1607
|
-
const entry = { view, close, keys: true };
|
|
1649
|
+
const entry = { view, close, keepChatFocus, keys: true };
|
|
1608
1650
|
panel = entry;
|
|
1609
1651
|
layOut();
|
|
1610
1652
|
// Every key goes to the panel while it shows, whatever has the focus: a question the chat model asks in the
|
|
@@ -2007,6 +2049,7 @@ function registerDeploy(pi, cwd, jobs, state) {
|
|
|
2007
2049
|
cwd,
|
|
2008
2050
|
state,
|
|
2009
2051
|
jobs,
|
|
2052
|
+
workLoop: () => workLoops.get(jobs)?.loop,
|
|
2010
2053
|
defaultPlainFile: () => readProjectConfig(cwd).module,
|
|
2011
2054
|
});
|
|
2012
2055
|
for (const tool of tools)
|
package/dist/genome.js
CHANGED
|
@@ -185,7 +185,7 @@ export async function runSkill(opts) {
|
|
|
185
185
|
// Built renders were lost with the process; queue what the specs hold that is not built.
|
|
186
186
|
if (resumed !== undefined && opts.renderQueue !== undefined) {
|
|
187
187
|
for (const file of plainFilesIn(opts.cwd))
|
|
188
|
-
void opts.renderQueue.bringUp(file).catch(() => undefined);
|
|
188
|
+
void opts.renderQueue.bringUp(file, { specChange: true }).catch(() => undefined);
|
|
189
189
|
}
|
|
190
190
|
if (liveStep !== undefined && liveProxy !== undefined) {
|
|
191
191
|
const continuous = liveStep.gate.continuous;
|
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.`;
|
|
@@ -188,7 +192,7 @@ export function driftTool(options) {
|
|
|
188
192
|
}
|
|
189
193
|
const ACTIVATED_PARAM = Type.Optional(Type.String({ description: 'What activate started, by name - or "all" for every one' }));
|
|
190
194
|
const HALT_PULSE_PARAMS = Type.Object({
|
|
191
|
-
job_id: Type.Optional(Type.String({ description: "The pulse's id, or the start of it" })),
|
|
195
|
+
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
196
|
reason: Type.Optional(Type.String({ description: "Why it is halted, kept with it - what the spec now says that it did not, say" })),
|
|
193
197
|
activated: ACTIVATED_PARAM,
|
|
194
198
|
});
|
|
@@ -201,12 +205,21 @@ export function haltTool(options) {
|
|
|
201
205
|
name: "halt",
|
|
202
206
|
label: "Halt",
|
|
203
207
|
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.
|
|
208
|
+
? "Halt a pulse, a module's planned pulses, or what activate started. A pulse: a queued one never starts, a running one has its " +
|
|
209
|
+
"agent stopped at once, and the pulses queued behind it move up - what a running pulse already changed is rolled back, and what " +
|
|
210
|
+
"it was regenerating counts as not regenerated. A planned row (planned-<module>-...) or a module's name halts the module: its " +
|
|
211
|
+
"running pulse stopped, none of its planned pulses started, and the modules built on it waiting - until it is asked for again " +
|
|
212
|
+
"with regenerate; a spec change does not start it. A module whose .plain file is gone is dropped. What activate started: the " +
|
|
213
|
+
"one named, or every one."
|
|
207
214
|
: "Stop what activate started: the one named, or every one.",
|
|
208
215
|
promptSnippet: jobs !== undefined ? "halt a pulse, or what activate started" : "stop a deployed server, or all of them",
|
|
209
|
-
promptGuidelines: jobs !== undefined
|
|
216
|
+
promptGuidelines: jobs !== undefined
|
|
217
|
+
? [
|
|
218
|
+
"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.",
|
|
219
|
+
"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.",
|
|
220
|
+
"A planned row for a module that is no longer in the project is halted the same way, and dropped.",
|
|
221
|
+
]
|
|
222
|
+
: [],
|
|
210
223
|
parameters: (jobs !== undefined ? HALT_PULSE_PARAMS : HALT_ACTIVATED_PARAMS),
|
|
211
224
|
async execute(_id, params) {
|
|
212
225
|
if (params.job_id === undefined && params.activated === undefined) {
|
|
@@ -214,7 +227,7 @@ export function haltTool(options) {
|
|
|
214
227
|
}
|
|
215
228
|
const lines = [];
|
|
216
229
|
if (params.job_id !== undefined && jobs !== undefined)
|
|
217
|
-
lines.push(stopJob(jobs, params.job_id, params.reason));
|
|
230
|
+
lines.push(stopJob(jobs, params.job_id, params.reason, options.workLoop?.()));
|
|
218
231
|
if (params.activated !== undefined) {
|
|
219
232
|
const stopped = await stopDeployed(params.activated === "all" ? {} : { name: params.activated });
|
|
220
233
|
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/question-dialog.js
CHANGED
|
@@ -58,18 +58,23 @@ export class QuestionDialog {
|
|
|
58
58
|
const choices = this.options.options ?? [];
|
|
59
59
|
const body = this.input !== undefined
|
|
60
60
|
? this.input.render(inner)
|
|
61
|
-
:
|
|
61
|
+
: // A long option wraps, its lines under its first, rather than cut off where the person cannot read it.
|
|
62
|
+
choices.flatMap((choice, index) => wrapTextWithAnsi(choice, Math.max(1, inner - 2)).map((line, at) => {
|
|
63
|
+
const shown = `${at === 0 && index === this.selected ? "›" : " "} ${line}`;
|
|
64
|
+
return index === this.selected ? style.accent(shown) : shown;
|
|
65
|
+
}));
|
|
62
66
|
const hint = this.input !== undefined
|
|
63
67
|
? "enter answers · esc dismisses"
|
|
64
68
|
: "↑↓ choose · enter picks · esc dismisses";
|
|
65
69
|
// The brief gets what the question, the options and the hints leave of the screen.
|
|
66
|
-
const fixed = question.length + body.length +
|
|
70
|
+
const fixed = question.length + body.length + 5;
|
|
67
71
|
const room = Math.max(3, this.options.rows() - KEPT_ABOVE - fixed);
|
|
68
72
|
const scrolls = brief.length > room;
|
|
69
73
|
this.window = scrolls ? room - 1 : brief.length;
|
|
70
74
|
this.maxScroll = scrolls ? brief.length - this.window : 0;
|
|
71
75
|
this.scroll = Math.min(this.scroll, this.maxScroll);
|
|
72
|
-
|
|
76
|
+
// Set apart from what is drawn above it - the job panel's hints.
|
|
77
|
+
const lines = [""];
|
|
73
78
|
if (brief.length > 0) {
|
|
74
79
|
lines.push(...brief.slice(this.scroll, this.scroll + this.window).map(pad));
|
|
75
80
|
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.",
|
|
@@ -183,6 +183,8 @@ export function describeToolCall(name, args) {
|
|
|
183
183
|
return `± my_diff`;
|
|
184
184
|
case "update_notes":
|
|
185
185
|
return `✐ update_notes`;
|
|
186
|
+
case "report_spec_gap":
|
|
187
|
+
return `? spec gap: ${text("question") ?? ""}`.trimEnd();
|
|
186
188
|
case "copy_resource":
|
|
187
189
|
return `⎘ copy_resource ${path ?? text("to") ?? ""}`.trimEnd();
|
|
188
190
|
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");
|