@turri-dev/cli 0.4.3-next.620bae9 → 0.4.3-next.7ada234
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 +1 -0
- package/dist/background-skills.d.ts +4 -1
- package/dist/background-skills.js +9 -1
- package/dist/capture/agents.d.ts +406 -0
- package/dist/capture/agents.js +379 -0
- package/dist/capture/area.d.ts +58 -0
- package/dist/capture/area.js +197 -0
- package/dist/capture/assemble.d.ts +112 -0
- package/dist/capture/assemble.js +453 -0
- package/dist/capture/capture.d.ts +116 -0
- package/dist/capture/capture.js +1315 -0
- package/dist/capture/chat.d.ts +29 -0
- package/dist/capture/chat.js +94 -0
- package/dist/capture/checks.d.ts +142 -0
- package/dist/capture/checks.js +649 -0
- package/dist/capture/config.d.ts +13 -0
- package/dist/capture/config.js +66 -0
- package/dist/capture/interface.d.ts +71 -0
- package/dist/capture/interface.js +199 -0
- package/dist/capture/map.d.ts +56 -0
- package/dist/capture/map.js +530 -0
- package/dist/capture/models.d.ts +4 -0
- package/dist/capture/models.js +16 -0
- package/dist/capture/plan.d.ts +7 -0
- package/dist/capture/plan.js +13 -0
- package/dist/capture/progress.d.ts +111 -0
- package/dist/capture/progress.js +266 -0
- package/dist/capture/python-interface.d.ts +3 -0
- package/dist/capture/python-interface.js +17 -0
- package/dist/capture/report.d.ts +75 -0
- package/dist/capture/report.js +268 -0
- package/dist/capture/runners.d.ts +6 -0
- package/dist/capture/runners.js +59 -0
- package/dist/capture/scripts.d.ts +26 -0
- package/dist/capture/scripts.js +38 -0
- package/dist/capture/state.d.ts +310 -0
- package/dist/capture/state.js +43 -0
- package/dist/capture/trial.d.ts +34 -0
- package/dist/capture/trial.js +89 -0
- package/dist/capture-cli.d.ts +1 -0
- package/dist/capture-cli.js +77 -0
- package/dist/chat-tab-header.d.ts +3 -2
- package/dist/chat-tab-header.js +22 -9
- package/dist/chat-tabs.d.ts +7 -1
- package/dist/chat-tabs.js +10 -6
- package/dist/chat-terminal.js +27 -6
- package/dist/chats.d.ts +14 -8
- package/dist/chats.js +46 -20
- package/dist/cli.js +32 -14
- package/dist/config-edit.js +5 -2
- package/dist/config.d.ts +15 -2
- package/dist/config.js +62 -3
- package/dist/extension.d.ts +2 -1
- package/dist/extension.js +225 -68
- package/dist/identity.js +2 -1
- package/dist/init-config.d.ts +4 -1
- package/dist/init-config.js +31 -4
- package/dist/loop-cli.js +5 -1
- package/dist/loop-tools.js +5 -1
- package/dist/new-project.d.ts +5 -0
- package/dist/new-project.js +11 -0
- package/dist/pi-launch.js +2 -0
- package/dist/pi-themes.d.ts +3 -0
- package/dist/pi-themes.js +21 -0
- package/dist/pi.d.ts +2 -2
- package/dist/pi.js +4 -4
- package/dist/plain-code-blocks.d.ts +14 -0
- package/dist/plain-code-blocks.js +56 -0
- package/dist/pointer-hover.d.ts +1 -1
- package/dist/pointer-hover.js +4 -0
- package/dist/question-dialog.d.ts +5 -0
- package/dist/question-dialog.js +26 -3
- package/dist/regenerate/agent-env.js +5 -1
- package/dist/regenerate/command-check.js +80 -11
- package/dist/regenerate/job-panel.d.ts +5 -107
- package/dist/regenerate/job-panel.js +4 -289
- package/dist/regenerate/loop.js +9 -1
- package/dist/regenerate/side-panel.d.ts +2 -0
- package/dist/regenerate/side-panel.js +32 -5
- package/dist/regenerate/spec-map-view.d.ts +2 -2
- package/dist/regenerate/test-scripts.d.ts +5 -0
- package/dist/regenerate/test-scripts.js +4 -0
- package/dist/reopen.d.ts +29 -0
- package/dist/reopen.js +47 -0
- package/dist/sentinel-chat.js +7 -2
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +3 -1
- package/dist/setup.js +9 -1
- package/dist/terminal-notifications.d.ts +37 -0
- package/dist/terminal-notifications.js +164 -0
- package/docs/README.md +2 -0
- package/docs/capture.md +227 -0
- package/docs/chats.md +6 -3
- package/docs/config.md +18 -4
- package/docs/development.md +4 -1
- package/docs/hosting.md +2 -2
- package/docs/launch.md +2 -2
- package/docs/regenerating.md +1 -1
- package/docs/sandbox.md +4 -2
- package/docs/sentinel.md +11 -11
- package/docs/theming.md +3 -3
- package/docs/using.md +7 -3
- package/genome/capture/capture.md +26 -0
- package/genome/capture/check-conventions.md +5 -0
- package/genome/capture/check-reference.md +12 -0
- package/genome/capture/compact.md +7 -0
- package/genome/capture/concepts.md +3 -0
- package/genome/capture/divide.md +9 -0
- package/genome/capture/feature.md +45 -0
- package/genome/capture/interface.md +9 -0
- package/genome/capture/modules.md +25 -0
- package/genome/capture/outline.md +11 -0
- package/genome/capture/python-interface.py +111 -0
- package/genome/capture/readability.md +12 -0
- package/genome/capture/reference.md +10 -0
- package/genome/capture/runners/python-requirements.sh +67 -0
- package/genome/capture/split.md +9 -0
- package/genome/capture/survey.md +39 -0
- package/genome/capture/trial.md +18 -0
- package/genome/capture/verify.md +7 -0
- package/genome/rules/turri-regeneration.md +1 -1
- package/package.json +1 -1
package/dist/reopen.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
/**
|
|
3
|
+
* turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
|
|
4
|
+
* the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
|
|
5
|
+
* (cli.ts) starts the chat as a process of its own, with turri's theme, its screen and the folder's models, and names
|
|
6
|
+
* it a file to write in: a chat that is to open again elsewhere writes where, with what, and quits; `turri` reads it and
|
|
7
|
+
* starts the chat there as it started the first - the theme, the screen and that folder's models worked out the same.
|
|
8
|
+
* A chat `turri` did not start - a host's, a desktop app's - has no file, and is never offered it.
|
|
9
|
+
*/
|
|
10
|
+
/** The file the chat `turri` started writes where it is to open again. */
|
|
11
|
+
export const REOPEN_FILE_ENV = "TURRI_REOPEN_FILE";
|
|
12
|
+
/** Said to the chat opened again, at its start: the capture whose report it tells - what the capture said of itself. */
|
|
13
|
+
export const REOPENED_AFTER_CAPTURE = "TURRI_REOPENED_AFTER_CAPTURE";
|
|
14
|
+
/** Whether this chat can open again in another folder: `turri` started it. */
|
|
15
|
+
export function canReopen() {
|
|
16
|
+
return (process.env[REOPEN_FILE_ENV] ?? "") !== "";
|
|
17
|
+
}
|
|
18
|
+
/** Ask `turri` to open the chat again in `dir` once it has quit - the caller quits it. False when it cannot (`canReopen`). */
|
|
19
|
+
export function reopenIn(dir, options = {}) {
|
|
20
|
+
const file = process.env[REOPEN_FILE_ENV];
|
|
21
|
+
if (file === undefined || file === "")
|
|
22
|
+
return false;
|
|
23
|
+
const reopening = { dir, args: options.args ?? [], env: options.env ?? {} };
|
|
24
|
+
writeFileSync(file, JSON.stringify(reopening));
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/** What the chat that quit asked for, taken - its file removed - or undefined when it asked for nothing. */
|
|
28
|
+
export function takeReopening(file) {
|
|
29
|
+
let text;
|
|
30
|
+
try {
|
|
31
|
+
text = readFileSync(file, "utf8");
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
rmSync(file, { force: true });
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(text);
|
|
39
|
+
if (typeof parsed.dir !== "string" || !Array.isArray(parsed.args) || parsed.args.some((arg) => typeof arg !== "string"))
|
|
40
|
+
return undefined;
|
|
41
|
+
const env = Object.fromEntries(Object.entries(parsed.env ?? {}).filter((entry) => typeof entry[1] === "string"));
|
|
42
|
+
return { dir: parsed.dir, args: parsed.args, env };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/sentinel-chat.js
CHANGED
|
@@ -177,6 +177,8 @@ export function noticeDialogs(pi, session, link, context) {
|
|
|
177
177
|
pi.on("agent_settled", () => void ask());
|
|
178
178
|
return {
|
|
179
179
|
put(notice) {
|
|
180
|
+
if (session.terminal)
|
|
181
|
+
return; // The terminal centre received it, including the question whether to start.
|
|
180
182
|
try {
|
|
181
183
|
pi.appendEntry(NOTICE_ENTRY, notice);
|
|
182
184
|
}
|
|
@@ -191,13 +193,14 @@ export function noticeDialogs(pi, session, link, context) {
|
|
|
191
193
|
},
|
|
192
194
|
concluded(conclusion) {
|
|
193
195
|
try {
|
|
194
|
-
|
|
196
|
+
if (!session.terminal)
|
|
197
|
+
pi.appendEntry(CONCLUDED_ENTRY, conclusion);
|
|
195
198
|
}
|
|
196
199
|
catch {
|
|
197
200
|
/* the agent is still told */
|
|
198
201
|
}
|
|
199
202
|
// A host that shows the person the conclusion itself: the chat knows of it - in order, with no turn of its own.
|
|
200
|
-
const shown = session.host.pulseEndsShown === true;
|
|
203
|
+
const shown = session.terminal || session.host.pulseEndsShown === true;
|
|
201
204
|
void pi.sendMessage({
|
|
202
205
|
customType: "turri_sentinel_concluded",
|
|
203
206
|
content: concludedNote(conclusion, { shown }),
|
|
@@ -206,6 +209,8 @@ export function noticeDialogs(pi, session, link, context) {
|
|
|
206
209
|
}, shown ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
|
|
207
210
|
},
|
|
208
211
|
over(notice) {
|
|
212
|
+
if (session.terminal)
|
|
213
|
+
return;
|
|
209
214
|
asking.get(notice.id)?.abort();
|
|
210
215
|
const at = waiting.indexOf(notice);
|
|
211
216
|
if (at !== -1)
|
package/dist/sentinel.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare function keepGuidance(cwd: string, text: string): void;
|
|
|
30
30
|
* What a chat of the person's is told of the pulses that end: told itself, of those asked for in it - or, with the
|
|
31
31
|
* sentinel on, nothing, the sentinel telling the person what needs them.
|
|
32
32
|
*/
|
|
33
|
-
export declare function pulseEndsBlock(sentinel: boolean): string;
|
|
33
|
+
export declare function pulseEndsBlock(sentinel: boolean, terminal?: boolean): string;
|
|
34
34
|
/**
|
|
35
35
|
* What the chat the person is in is told of a pulse that landed, with the sentinel on: that it landed, what the sentinel
|
|
36
36
|
* does with it - and to tell the person so, and do nothing else about it. `launching`: launch-after-pulse is on - it is
|
package/dist/sentinel.js
CHANGED
|
@@ -119,7 +119,9 @@ export function keepGuidance(cwd, text) {
|
|
|
119
119
|
* What a chat of the person's is told of the pulses that end: told itself, of those asked for in it - or, with the
|
|
120
120
|
* sentinel on, nothing, the sentinel telling the person what needs them.
|
|
121
121
|
*/
|
|
122
|
-
export function pulseEndsBlock(sentinel) {
|
|
122
|
+
export function pulseEndsBlock(sentinel, terminal = false) {
|
|
123
|
+
if (sentinel && terminal)
|
|
124
|
+
return "<pulse-ends>\nThe sentinel checks finished pulses. Their results, its conclusions and its notices go to the notification centre (/notifications). Do not announce them here. Answer if the person asks; when they accept a notice's action, do the task you are given.\n</pulse-ends>";
|
|
123
125
|
return sentinel
|
|
124
126
|
? [
|
|
125
127
|
"<pulse-ends>",
|
package/dist/setup.js
CHANGED
|
@@ -10,7 +10,7 @@ import { fetchLatest, newerThan, turrisOnPath, versionFindings } from "./turri-v
|
|
|
10
10
|
import { sandboxAvailable, sandboxWithAsync } from "./regenerate/os-sandbox.js";
|
|
11
11
|
import { findTestScripts, onThisMachine } from "./regenerate/test-scripts.js";
|
|
12
12
|
import { configKeyOptions, parseArgs } from "./cli-options.js";
|
|
13
|
-
import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf } from "./config.js";
|
|
13
|
+
import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf, configProblems } from "./config.js";
|
|
14
14
|
import { checkModels, modelsInUse, piModelAccess } from "./model-check.js";
|
|
15
15
|
import { bedrockRegionFor, describeBedrockRegion, regionInGeography } from "./bedrock-region.js";
|
|
16
16
|
import { baseFilesAsync } from "./regenerate/base-folder.js";
|
|
@@ -230,6 +230,14 @@ async function allChecks(options) {
|
|
|
230
230
|
const project = options.dir;
|
|
231
231
|
if (project === undefined)
|
|
232
232
|
return checks;
|
|
233
|
+
// A config that does not parse is read as empty - every setting at its default, the models pi's own: said first.
|
|
234
|
+
checks.push(...configProblems(project).map((problem) => ({
|
|
235
|
+
level: "missing",
|
|
236
|
+
name: "Config",
|
|
237
|
+
detail: problem.text,
|
|
238
|
+
more: [`turri reads a config that does not parse as empty: none of ${problem.file} applies - not its models, not conformance tests, no other setting.`],
|
|
239
|
+
fix: `Set each key once in ${problem.file}, then run turri doctor again`,
|
|
240
|
+
})));
|
|
233
241
|
if (hasProjectConfig(project) || existsSync(join(project, "plain_modules")))
|
|
234
242
|
checks.push(...(await checkProject(project, { has: (command) => onThisMachine(command, env) !== undefined })));
|
|
235
243
|
if (hasProjectConfig(project))
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { TurriCore } from "./chats.ts";
|
|
3
|
+
import type { Conclusion, Notice } from "./notice.ts";
|
|
4
|
+
import { type DialogStyle } from "./question-dialog.ts";
|
|
5
|
+
/** The terminal session's inbox. A notice keeps its identity and live state from the session that answers it. */
|
|
6
|
+
export interface TerminalNotification {
|
|
7
|
+
title: string;
|
|
8
|
+
detail: string;
|
|
9
|
+
conclusion?: string;
|
|
10
|
+
warning?: boolean;
|
|
11
|
+
notice?: Notice;
|
|
12
|
+
seen: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class TerminalNotifications {
|
|
15
|
+
readonly items: TerminalNotification[];
|
|
16
|
+
private readonly reviews;
|
|
17
|
+
get count(): number;
|
|
18
|
+
needsAnswer(item: TerminalNotification): boolean;
|
|
19
|
+
add(title: string, detail: string, options?: Pick<TerminalNotification, "notice" | "warning">): void;
|
|
20
|
+
/** Only the sentinel's review shares a row. The pulse result and the question whether to start it are independent. */
|
|
21
|
+
private review;
|
|
22
|
+
put(notice: Notice, work?: Pick<Conclusion, "job" | "check">): void;
|
|
23
|
+
concluded(result: Conclusion): void;
|
|
24
|
+
}
|
|
25
|
+
/** The notifications tab. Opening or leaving a detail never answers its notice. Only an explicit choice does. */
|
|
26
|
+
interface NotificationStyle extends DialogStyle {
|
|
27
|
+
warning(text: string): string;
|
|
28
|
+
button(text: string, selected: boolean): string;
|
|
29
|
+
}
|
|
30
|
+
export declare function notificationView(session: TurriCore, style: NotificationStyle, leave: () => void): {
|
|
31
|
+
count: () => number;
|
|
32
|
+
inDetail: () => boolean;
|
|
33
|
+
render(width: number, available: number): readonly string[];
|
|
34
|
+
handleInput(data: string): void;
|
|
35
|
+
handleMouse: (event: TuiMouseEvent) => import("@earendil-works/pi-tui").TuiMouseEventResult | undefined;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Container, SelectList, Text, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { QuestionDialog } from "./question-dialog.js";
|
|
3
|
+
export class TerminalNotifications {
|
|
4
|
+
items = [];
|
|
5
|
+
reviews = new Map();
|
|
6
|
+
get count() {
|
|
7
|
+
return this.items.filter((item) => !item.seen || this.needsAnswer(item)).length;
|
|
8
|
+
}
|
|
9
|
+
needsAnswer(item) {
|
|
10
|
+
return item.notice?.state === "open" && item.notice.kind !== "fixed";
|
|
11
|
+
}
|
|
12
|
+
add(title, detail, options = {}) {
|
|
13
|
+
this.items.unshift({ title, detail, seen: false, ...options });
|
|
14
|
+
}
|
|
15
|
+
/** Only the sentinel's review shares a row. The pulse result and the question whether to start it are independent. */
|
|
16
|
+
review(about, title) {
|
|
17
|
+
const key = about.check ? `check:${about.check}` : about.job ? `pulse:${about.job}` : undefined;
|
|
18
|
+
const known = key && this.reviews.get(key);
|
|
19
|
+
if (known)
|
|
20
|
+
return known;
|
|
21
|
+
const item = { title, detail: "", seen: false };
|
|
22
|
+
this.items.unshift(item);
|
|
23
|
+
if (key)
|
|
24
|
+
this.reviews.set(key, item);
|
|
25
|
+
return item;
|
|
26
|
+
}
|
|
27
|
+
put(notice, work) {
|
|
28
|
+
const about = [notice.module, notice.pulse !== undefined ? `pulse ${notice.pulse}` : undefined].filter(Boolean).join(" · ");
|
|
29
|
+
const heading = notice.kind === "fixed" ? "Fixed" : "Sentinel";
|
|
30
|
+
const title = [heading, about, notice.summary].filter(Boolean).join(" · ");
|
|
31
|
+
const detail = notice.evidence.join("\n\n");
|
|
32
|
+
if (notice.kind === "sentinel-start")
|
|
33
|
+
return this.add(title, detail, { notice });
|
|
34
|
+
const item = this.review(work ?? notice, title);
|
|
35
|
+
if (!item.conclusion)
|
|
36
|
+
item.warning = notice.severity !== "info";
|
|
37
|
+
Object.assign(item, { title, detail, notice, seen: false });
|
|
38
|
+
}
|
|
39
|
+
concluded(result) {
|
|
40
|
+
const what = result.pulse !== undefined ? `pulse ${result.pulse}` : result.job ?? result.check;
|
|
41
|
+
const verdict = result.verdict === "holds" ? "it holds" : result.verdict === "wrong" ? "found something wrong" : "not checked";
|
|
42
|
+
const item = this.review(result, ["Sentinel", result.module, what, verdict].filter(Boolean).join(" · "));
|
|
43
|
+
item.conclusion = `${verdict}: ${result.summary}`;
|
|
44
|
+
item.warning = result.verdict !== "holds";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function notificationView(session, style, leave) {
|
|
48
|
+
const inbox = session.notifications;
|
|
49
|
+
const { accent, muted } = style;
|
|
50
|
+
const listBox = new Container();
|
|
51
|
+
const markRead = () => {
|
|
52
|
+
for (const item of inbox.items)
|
|
53
|
+
item.seen = true;
|
|
54
|
+
session.changed();
|
|
55
|
+
};
|
|
56
|
+
const readLabel = " mark all as read ";
|
|
57
|
+
let pressedRead = false;
|
|
58
|
+
const listHeader = {
|
|
59
|
+
render(width) {
|
|
60
|
+
const button = truncateToWidth(readLabel, width);
|
|
61
|
+
const room = width - visibleWidth(button);
|
|
62
|
+
const title = truncateToWidth("notifications", Math.max(0, room - 1), "");
|
|
63
|
+
return [style.bold(accent(title)) + " ".repeat(room - visibleWidth(title)) + style.button(button, false)];
|
|
64
|
+
},
|
|
65
|
+
handleMouse(event) {
|
|
66
|
+
if (event.button !== "left" || (event.type !== "press" && event.type !== "click"))
|
|
67
|
+
return;
|
|
68
|
+
const inside = event.x >= Math.max(0, event.width - visibleWidth(readLabel)) && event.x < event.width && event.y === 0;
|
|
69
|
+
const down = pressedRead;
|
|
70
|
+
pressedRead = event.type === "press" && inside;
|
|
71
|
+
if (!inside)
|
|
72
|
+
return;
|
|
73
|
+
if (event.type === "click" && down)
|
|
74
|
+
markRead();
|
|
75
|
+
return { handled: true };
|
|
76
|
+
},
|
|
77
|
+
invalidate() { },
|
|
78
|
+
};
|
|
79
|
+
let list;
|
|
80
|
+
let rows = [];
|
|
81
|
+
let labels = [];
|
|
82
|
+
let visible = 0;
|
|
83
|
+
let detail;
|
|
84
|
+
let selectedNotice;
|
|
85
|
+
let detailState;
|
|
86
|
+
let height = 20;
|
|
87
|
+
const back = () => { detail = undefined; selectedNotice = undefined; };
|
|
88
|
+
const show = (item, steering = false) => {
|
|
89
|
+
item.seen = true;
|
|
90
|
+
const notice = item.notice;
|
|
91
|
+
selectedNotice = notice;
|
|
92
|
+
detailState = notice?.state;
|
|
93
|
+
const open = notice?.state === "open";
|
|
94
|
+
const actions = open && notice.kind !== "fixed" ? notice.actions.map((action, index) => `${index + 1}. ${action.label}`) : [];
|
|
95
|
+
const steer = "Say what to do instead…";
|
|
96
|
+
const ignore = "Ignore - leave it as the build has it";
|
|
97
|
+
const options = [...actions, ...(open && notice.ignorable ? [ignore] : []), ...(open && notice.kind === undefined ? [steer] : []), ...(open ? ["Dismiss"] : []), "Back"];
|
|
98
|
+
const target = notice && session.chats().find((chat) => chat.id === notice.chat);
|
|
99
|
+
detail = new QuestionDialog({
|
|
100
|
+
question: steering ? "What should be done about it?" : "notifications",
|
|
101
|
+
context: [item.warning ? style.warning(item.title) : item.title, item.detail, item.conclusion, ...(open && notice.kind === undefined && target ? [`Accepted work goes to ${target.title}.`] : [])].filter(Boolean).join("\n\n"),
|
|
102
|
+
...(steering ? {} : { options, choiceButton: style.button }), rows: () => height,
|
|
103
|
+
style, requestRender: () => { },
|
|
104
|
+
done(answer) {
|
|
105
|
+
if (!answer || !notice || notice.state !== "open" || (!steering && answer === "Back"))
|
|
106
|
+
return back();
|
|
107
|
+
if (!steering && answer === steer)
|
|
108
|
+
return show(item, true);
|
|
109
|
+
if (steering)
|
|
110
|
+
session.answer(notice.id, { steer: answer });
|
|
111
|
+
else if (answer === "Dismiss")
|
|
112
|
+
session.answer(notice.id, { dismiss: true });
|
|
113
|
+
else if (answer === ignore)
|
|
114
|
+
session.answer(notice.id, { ignore: true });
|
|
115
|
+
else
|
|
116
|
+
session.answer(notice.id, { action: actions.indexOf(answer) });
|
|
117
|
+
back();
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
session.changed();
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
count: () => inbox.count,
|
|
124
|
+
inDetail: () => detail !== undefined,
|
|
125
|
+
render(width, available) {
|
|
126
|
+
height = available;
|
|
127
|
+
if (selectedNotice && selectedNotice.state !== detailState)
|
|
128
|
+
back();
|
|
129
|
+
if (detail)
|
|
130
|
+
return detail.render(width);
|
|
131
|
+
const next = inbox.items;
|
|
132
|
+
const lines = next.map((item) => {
|
|
133
|
+
const label = `${inbox.needsAnswer(item) ? "? " : item.seen ? " " : "• "}${item.notice && item.notice.state !== "open" ? `[${item.notice.state}] ` : ""}${item.title.replace(/\s+/g, " ")}`;
|
|
134
|
+
return item.warning ? style.warning(label) : label;
|
|
135
|
+
});
|
|
136
|
+
const room = Math.max(1, available - 4);
|
|
137
|
+
if (!list || room !== visible || next.length !== rows.length || next.some((item, i) => item !== rows[i] || lines[i] !== labels[i])) {
|
|
138
|
+
// Keep the same item selected when a pulse finishes while the person is reading the list.
|
|
139
|
+
const selected = rows[Number(list?.getSelectedItem()?.value)];
|
|
140
|
+
rows = next.slice();
|
|
141
|
+
labels = lines;
|
|
142
|
+
visible = room;
|
|
143
|
+
list = new SelectList(rows.map((_item, i) => ({ value: String(i), label: labels[i] })), room, { selectedPrefix: accent, selectedText: accent, description: muted, scrollInfo: muted, noMatch: muted });
|
|
144
|
+
list.setSelectedIndex(selected ? rows.indexOf(selected) : 0);
|
|
145
|
+
list.onSelect = ({ value }) => show(rows[Number(value)]);
|
|
146
|
+
list.onCancel = leave;
|
|
147
|
+
listBox.clear();
|
|
148
|
+
listBox.addChild(listHeader);
|
|
149
|
+
listBox.addChild(rows.length ? list : new Text("No notifications this session.", 0, 0));
|
|
150
|
+
listBox.addChild(new Text(muted(rows.length ? "↑↓ select · enter open · r mark all read · esc back" : "esc back"), 0, 0));
|
|
151
|
+
}
|
|
152
|
+
return listBox.render(width);
|
|
153
|
+
},
|
|
154
|
+
handleInput(data) {
|
|
155
|
+
if (detail)
|
|
156
|
+
detail.handleInput(data);
|
|
157
|
+
else if (data === "r")
|
|
158
|
+
markRead();
|
|
159
|
+
else
|
|
160
|
+
list?.handleInput(data);
|
|
161
|
+
},
|
|
162
|
+
handleMouse: (event) => detail ? detail.handleMouse(event) : listBox.handleMouse(event),
|
|
163
|
+
};
|
|
164
|
+
}
|
package/docs/README.md
CHANGED
|
@@ -16,6 +16,7 @@ turri is the first coding agent with the power of regenerative software: [\*\*\*
|
|
|
16
16
|
| what my machine needs, and why a check failed | [installation](installation.md) |
|
|
17
17
|
| what turri needs of this machine, and what `turri doctor` checks | [installation](installation.md#what-turri-doctor-checks) |
|
|
18
18
|
| how to start a project, or add a feature, in a conversation | [using](using.md#in-a-conversation) |
|
|
19
|
+
| how to bring an existing codebase under \*\*\*plain | [capture](capture.md) |
|
|
19
20
|
| how to have several chats open at once, and reopen them | [chats](chats.md) |
|
|
20
21
|
| what checks each pulse as it finishes, and tells me what needs me | [the sentinel](sentinel.md) |
|
|
21
22
|
| which model codes, and how to change it | [using](using.md#choosing-a-model), [the project config](config.md#models) |
|
|
@@ -48,6 +49,7 @@ turri is the first coding agent with the power of regenerative software: [\*\*\*
|
|
|
48
49
|
| [A Claude subscription](claude-subscription.md) | running every agent on a Claude Pro, Max or Team subscription through Claude Code: setting it up, its models, checking it yourself, in turri-desktop, its limits, when it does not work |
|
|
49
50
|
| [The project config](config.md) | `config.turri.yaml` and a module's own `config.turri.<module>.yaml`: where they are read from, every key, models and their inheritance, conformance, the testing scripts, which file builds a module, the old `config.yaml` |
|
|
50
51
|
| [Launch](launch.md) | trying what is built: the launch track, a commit in dist/<module>, starting it on your machine, after every pulse, `turri launch` |
|
|
52
|
+
| [Capture](capture.md) | an existing codebase captured into \*\*\*plain, offline: what it aims for, how it scales, what it writes, the report, resuming |
|
|
51
53
|
| [Running unattended](headless.md) | regenerating overnight or in CI: before you leave it, the command, the results, resuming, rebuilding one functionality |
|
|
52
54
|
| [Authoring \*\*\*plain](authoring-plain.md) | a \*\*\*plain project, what \*\*\*plain is made of, the rules, writing \*\*\*plain with the agent, the skills, checking \*\*\*plain |
|
|
53
55
|
| [Regenerating](regenerating.md) | where things go, one job, a whole module and how its work is cut into jobs, each job's cases, \*\*\*plain changes, conformance tests, the two records of what is built |
|
package/docs/capture.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Capture
|
|
2
|
+
|
|
3
|
+
Capture takes an existing codebase and captures what it does into \*\*\*plain. From then on you work on the \*\*\*plain: the code is regenerated from it, and the original codebase is abandoned.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
cd ~/my-app
|
|
7
|
+
turri capture # this folder, into ./plain
|
|
8
|
+
turri capture ../other-app --harness-model anthropic/claude-opus-4-5 --coding-model anthropic/claude-sonnet-4-5
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
In the chat, `/capture [path]` does the same in the background. Only you start it: the chat can tell you about it, but cannot run it, since a capture turns conformance tests on in the project it writes (`src/capture/`).
|
|
12
|
+
|
|
13
|
+
The chat that started `/capture` keeps a trace you can scroll back through. Each milestone shows elapsed time and, once reported, the model cost so far. For example:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
capture · 0s · compact capture: 10/64 source, test and contract files, 305/4000 lines, 0/24 mapped interface entries - within all three limits
|
|
17
|
+
capture · 1s · survey · plan: I’ll trace the calculator’s commands and check how its tests exercise them.
|
|
18
|
+
capture · 14s · $0.08 · survey: Both arithmetic commands reject invalid arguments before computing a result.
|
|
19
|
+
capture · 14s · $0.08 · surveyed: calc-cli
|
|
20
|
+
capture · 1m 12s · $0.42 · captured calc-cli in one pass: 3 functional specs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Each agent, including a testing-script writer, opens with a **plan**: one sentence about what it will inspect, write or test. If it goes straight to a tool, the trace shows its assigned task instead. Each capture agent reports a concrete finding in its existing submission: what it discovered, corrected or could not verify. Once the harness accepts that submission, the finding appears by the agent's name alongside the progress lines. Testing-script writers describe what their scripts check. Neither the plan nor the finding needs a separate model call. These transcript entries do not start a chat turn or enter the chat model's context. While capture runs, the widget above the input shows finer detail, including what each agent is doing right now (`src/capture/progress.ts`):
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
capture shorty ✓ survey ━ ✓ outline ━ ⠋ features ─ ○ concepts ─ ○ readability ─ ○ interface ─ ○ trial ─ ○ scripts phase 3 of 8
|
|
27
|
+
██████████▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 1 of 3 features captured, 2 at work · 2m 10s · $0.84
|
|
28
|
+
feature shorty#shorten-link 40s ○ read app/api/links.py · thinking
|
|
29
|
+
feature shorty#follow-link 15s ○ read app/repositories/sqlite.py · waiting for the model
|
|
30
|
+
captured shorty#service-info: 1 functional spec
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- **The phases** of the selected pipeline: those done ticked, the current one spinning and those to come. Compact captures have five; staged captures have eight.
|
|
34
|
+
- **Under them, the phase's own work,** where it is counted, as the regen panel draws functional specs: done in green, at work in the accent colour, waiting `▓`. Then that work in words - while outlining, the features outlined so far and the areas still to outline; then the features captured of those to capture - how long the capture has taken, and what its models have cost.
|
|
35
|
+
- **A line for each agent at work:** what it captures, for how long, the last file it read or searched, and what it is doing now.
|
|
36
|
+
- **The last line:** what the capture said last.
|
|
37
|
+
|
|
38
|
+
`turri capture` prints a line as each step ends.
|
|
39
|
+
|
|
40
|
+
When it ends, turri asks whether to open the captured project. A chat works on the project of the folder it was opened in, and `plain/` is a project of its own. So on yes, the chat closes and `turri` starts it again in `plain/`, as it started the first - turri's theme, its screen, that folder's config - on the chat's model and thinking (`src/reopen.ts`). There, `ctrl+h` shows its \*\*\*plain, `/regenerate` builds it, and the chat tells you its report. On no, the chat tells you the report where you are, and `cd plain && turri` opens it later. A host - a desktop app - opens projects itself, so it is not asked.
|
|
41
|
+
|
|
42
|
+
## What it aims for
|
|
43
|
+
|
|
44
|
+
**The interface, whole and exact.** What a user, a client or a script calls is the contract the regenerated software must keep, call for call: every command and subcommand; every option with each name it has, its value, choices and default; every route with its method, path, parameters, fields and status codes; every environment variable and configuration key; every message, output format and exit code a script sees. It is never guessed, never left out as obvious or as the stack's - a stack says how errors are shaped, never which options exist - and never cut for readability. So it is not left to prose at all. It is taken from the code as data - each entry checked against the code it cites - into each part's **interface reference**, a linked resource beside the \*\*\*plain (`resources/interface/<part>.md`) that every functional spec about it carries, through the part's interface concept (`:HttpieInterface:`), to every agent that regenerates or tests the code: the details exact there, the prose free to name them and say what each does. Then capture holds the \*\*\*plain to it: the conventions every feature follows are checked against the code before any feature is written; each writer works from the reference's entries in its feature's files; what no functional spec names goes to a writer of its own; and each module's \*\*\*plain is checked against the reference and the code at the end (steps 3, 4, 8, 9 and 13 below).
|
|
45
|
+
|
|
46
|
+
**Scenarios that hold on the original.** The scenarios are what the regenerated code's conformance tests check, so one the original itself fails is wrong twice: a coding agent builds to it, or its module's tests fail for good. They are written by agents that read the original and never run it, so before the \*\*\*plain is written each is run against a copy of the original, as its conformance test will run it, and corrected to what the original does (step 14). And each module is a concern of its own, never one that holds everything, put in the order its behaviour is built in, so its scenarios need only the modules before it (step 10).
|
|
47
|
+
|
|
48
|
+
**Readable \*\*\*plain, not a transcript of the code** - about everything else. An agent that reads code tends to write every detail down, and \*\*\*plain nobody can read is \*\*\*plain nobody reviews. Every capture agent is told (`genome/capture/capture.md`):
|
|
49
|
+
|
|
50
|
+
- **What someone sees, not what the code does.** A line stays when a user or client would notice the difference and care. Function names, file layout, helpers and internal data shapes are left out.
|
|
51
|
+
- **Only where the code departs from the default.** The default is the stack's conventions, the domain's conventions, and the functional specs before this one. An odd rule is written exactly; cookie-cutter behaviour takes a line or none.
|
|
52
|
+
- **Exact where exactness is the contract.** Endpoints, fields, status codes, flags and formats are captured exactly.
|
|
53
|
+
- **Edge cases go in scenarios.** A functional spec states the rule - `the url is an absolute http or https URL` - and its scenarios pin the edges with concrete values. An example, or what one wrong input answers (`nope` answers 422 `validation_error`), is a scenario's, never said again in the functional spec. How a wrong input is answered is the stack's, unless the original answers otherwise.
|
|
54
|
+
|
|
55
|
+
**About 80% right.** Capture tries its scenarios on the original, but does not regenerate and compare. You close the gap afterwards: regenerate, run the original's tests (or the conformance tests written from the scenarios) against the result, and capture what is missing as ordinary \*\*\*plain changes.
|
|
56
|
+
|
|
57
|
+
**Offline.** No capture agent can ask anything. Whatever the code leaves open, each agent decides itself, and says so. The [report](#the-report) collects every such decision.
|
|
58
|
+
|
|
59
|
+
## How capture scales
|
|
60
|
+
|
|
61
|
+
For Python libraries the interface reference also records statically declared package exports, import paths used in the original tests, callable signatures and fields of their result types. When Python 3 is available, a helper reads syntax trees without importing the project. Dynamic exports still need the agents' source check. These literal details belong in the linked reference, leaving the functional specs to describe behaviour. A survey that already found distinct concerns too large for a single module can hand that decision directly to the staged writers.
|
|
62
|
+
|
|
63
|
+
Capture chooses a pipeline automatically, before the first model call. The CLI says which it chose and why; the report records the choice. It uses the map rather than asking an agent to estimate the work.
|
|
64
|
+
|
|
65
|
+
Size selects **staged** if **any one** of three counts exceeds its limit: **more than 64** source, test and contract files, **more than 4,000** lines across those files, or **more than 24** interface entries outside tests. Otherwise capture starts **compact**. A count exactly at its limit does not exceed it. Bytes, assets, docs and dependency lock files do not enter the decision.
|
|
66
|
+
|
|
67
|
+
- **Compact:** after the survey and interface reference, **one writer** reads the program and its tests and writes one module directly. There is no separate feature outline, writer per feature, module planner, concept reconciliation or readability pass. The conventions and reference still get checked, a fresh agent verifies the module against the code, and the scenarios are still tried on the original. Testing scripts and the parser check are the same on both paths.
|
|
68
|
+
- **Staged:** the code is outlined by area, written by feature and checked by module. `TURRI_CAPTURE_LEAF_LINES` controls splitting within this pipeline. Division runs only across multiple leaves, reconciliation only for conflicting definitions. Reference and trial work is batched and independent writers run up to `--parallel` at a time.
|
|
69
|
+
|
|
70
|
+
A short program need not be simple. A compact capture checks the same three limits again using the discovered interface. Independently of size, it switches to staged if the survey finds multiple parts, or the writer cannot fit the behaviour and scenarios into one module of up to eight functional specs. A writer can ask to expand rather than omit behaviour; an invalid draft that still fails the normal checks after retries also expands. Capture reuses the survey, conventions and reference. The choice is saved with its checkpoints; captures started before compact mode resume on the staged path.
|
|
71
|
+
|
|
72
|
+
## How it works
|
|
73
|
+
|
|
74
|
+
Both pipelines share the map, survey, interface reference and final checks. The numbered steps below describe the staged pipeline in full.
|
|
75
|
+
|
|
76
|
+
1. **The map** (`src/capture/map.ts`), with no model. Every file the codebase holds, read through git when it is a repo, so what git ignores is left out. Also left out: dependencies, caches, capture's own output folder, and any turri project inside the codebase (a folder with a `config.turri.yaml`, an earlier capture's among them), since its \*\*\*plain is not the code. Each file gets:
|
|
77
|
+
- its kind: source, test, doc, asset, contract, manifest
|
|
78
|
+
- its lines
|
|
79
|
+
- the surfaces patterns find in it: routes, commands, options with every name each has (`-v, --verbose`), screens, the environment variables it reads, tables and models, test names, exports. A file keeps its whole interface - seventy options are seventy - and a sample of the rest.
|
|
80
|
+
- the codebase's own files it imports
|
|
81
|
+
|
|
82
|
+
The patterns cover common frameworks:
|
|
83
|
+
- **Python:** Flask, FastAPI, Django, click, typer, argparse
|
|
84
|
+
- **JavaScript and TypeScript:** Express, Fastify, NestJS, React Router, Vue Router, file-routed Next.js and SvelteKit, commander
|
|
85
|
+
- **Go:** net/http, gin, echo, chi, cobra
|
|
86
|
+
- **Java:** Spring, picocli
|
|
87
|
+
- **Rust:** axum, actix, clap
|
|
88
|
+
- **Ruby:** Rails
|
|
89
|
+
- **SQL:** tables in schema and migration files
|
|
90
|
+
|
|
91
|
+
A file no pattern fits is still on the map, by its size.
|
|
92
|
+
2. **The survey.** One agent is shown the map of the whole codebase, folded to its budget, with the manifests, the README and the standard library's catalogue. It names the parts: software on one stack each, like a backend and a frontend. For each part it gives:
|
|
93
|
+
- the stack - a `stdlib/` template only when the original agrees with it, otherwise written out as implementation reqs
|
|
94
|
+
- its conventions: what every feature does the same way and a user or a script relies on - how an error is written, the exit code or status of each kind of failure, what changes without a terminal. For software that talks to other software, also what reaches the other side on every call, whichever feature makes it: the headers it adds of its own, how bodies and header values are encoded - JSON's separators, non-ASCII escaped or not, the charset - and when a body is sent or read whole, streamed, or not read at all. No feature's writer looks at the wire. Each is settled from the code that does it, never from a declaration or a framework's default, and names the files that decide it. They go into the part's import module as implementation reqs, and every feature's agent is handed them as settled, so no two features decide an exit code differently.
|
|
95
|
+
- how its black-box tests run, from the original's own tests and the harness they run under: what standard input is, the environment, the servers they start - a conformance test run otherwise tests another program. Then what every test sets up so the software acts the same on every run and machine: what it fetches or checks on its own (an update check, telemetry) off or pointed at a local stand-in; a home and a configuration folder of the test's own; the terminal width fixed (`COLUMNS`) where its output wraps; a pseudo-terminal where it prompts on one; local servers, never the internet
|
|
96
|
+
- its core concepts
|
|
97
|
+
|
|
98
|
+
It also names what is not the software (vendored, generated, tooling). It may never leave out the original's tests, which are the evidence of what the software does.
|
|
99
|
+
3. **The conventions checked.** Before any writer is given them, an agent per part checks each convention against the code it names - the entry point, where errors are caught, written and exited, where a request is built and sent or a response written - and corrects what does not hold, saying why. Every feature follows them, so one that is wrong is wrong everywhere. A check that never holds leaves them as surveyed, and the report says so.
|
|
100
|
+
4. **The interface reference.** The interface is taken from the code as data, before any feature is outlined (`src/capture/interface.ts`, `genome/capture/reference.md`). The files where the map found it are given to agents, up to 4000 lines and 12 files each, and each agent lists every command, argument, option, route and environment variable they define - and any the map missed - as entries: the name exactly as the code has it, every other name, the command it belongs to, what it takes, its choices, its default, whether it repeats, is required or is hidden, its help word for word, a route's parameters, fields and statuses, and where it is defined. The harness checks each entry against the code with no model (`referenceProblems`): its `where` is a line of a file of the map, and every literal it gives - each name, alias, choice, default and the start of its help - is in that file or in the files it names as where one is worked out. A literal the code does not have sends the entry back, and so does any surface the map found in the files that is neither listed nor excluded with why. Then a fresh agent checks it against the code, as the conventions are - what checking literals cannot see: a help text cut to its first line, choices left out or worked out when the program runs, an environment variable read through a constant - and corrects or adds each, citing the line that shows it, its answer checked again as the first was; what it changed is in the report, to read first: a checker can be wrong too. The entries become the part's interface reference, `resources/interface/<part>.md`, linked from the part's interface concept, defined in what every module of the part imports: every functional spec that uses it carries the reference, whole, to its coding and conformance agents. A part none of whose entries held has no reference, and its writers work from the map, as do those of files whose agent never held.
|
|
101
|
+
5. **The split.** An area of more than 6000 lines (`TURRI_CAPTURE_LEAF_LINES`) goes to an agent that splits it into smaller areas by what they do. Each smaller area that is still too large is split again, so depth grows only slowly with size. The harness puts the areas in the order of their code: an area whose files import another's comes after it. The modules are gathered by concern and put in the order their behaviour is built in once the features are written (step 10).
|
|
102
|
+
6. **The outline.** An area that fits is outlined by one agent into features, in build order. Each feature is something a user can do, with the files where it is built. The agent sees the stack's templates too: infrastructure they settle - settings, logging, error bodies, middleware - is no feature, and is left out as settled by the stack, unless a user would notice the original does it differently.
|
|
103
|
+
7. **The features divided.** Once every area of a part is outlined, one agent sees all its features, area by area, with what each is about and where it is built, and gives each behaviour to one feature. The outlines are made area by area from each area's own files, so the same behaviour can be outlined twice - an option parsed in one area and acted on in another, a message printed in a third - and written twice it reads twice, in different words, and contradicts itself. Each feature that stays gets a line of what it alone owns; a feature that is a slice of another's behaviour is merged into it, its files the other's, and not written. A part outlined as one area is not divided: one agent saw all of it. A division that never holds leaves each feature owning what it was outlined for.
|
|
104
|
+
8. **The features, side by side.** One agent per feature, up to `--parallel` (8 by default) at once. Each is given the full text of the `stdlib/` templates its part is built on - the stack, its kind's `common`, its language's - as the default it never restates, the part's conventions, every feature of the part with what it owns, and the reference's entries in its feature's files, with what the map found there that the reference does not list: it captures what each piece its feature owns does, by its exact name, using the part's interface concept - what one takes, its choices, its default and its help left to the reference, said only where a behaviour turns on them and never otherwise - and never another feature's behaviour, even where its code or tests touch it. Each follows the feature's surfaces through the code, reads the original's tests of it, then writes:
|
|
105
|
+
- at most 8 functional specs
|
|
106
|
+
- the concepts they need beyond the part's
|
|
107
|
+
- its scenarios, mimicking the original's black-box tests - a test that runs the software through its interface, in its own process or the test's - and spent where those are densest: a functional spec the original tests twenty ways gets several, error cases no larger share than the original gives them. Where the original has no test of a spec, it gets scenarios only when it can fail silently, can be read two ways, or is costly when wrong. A feature may have 8 scenarios, and one more for every 50 lines of the original's tests in its files, up to 30; its agent is shown those test files, their lines and their tests' names. Each scenario expects what the original does under the test reqs: output that is not a terminal unless they give one, a local server rather than the internet - never a unit test that mocks a library, recast.
|
|
108
|
+
9. **The interface no feature captured.** Once every feature is written, the harness matches the interface - the reference's entries, and what the map found in the parts' files that the reference neither lists nor excludes - against the \*\*\*plain: an option, command or variable as a word of its own, a route by its path under any prefix, its parameters written any way. What no feature names goes to a writer of its own, as a feature added to the area whose files define it, up to 30 surfaces a writer. It captures each exactly - or, for one that is not the software's interface, such as a development script's option, names it in `dropped` with why - and is sent back until every one is settled. A capture leaves no interface out by accident.
|
|
109
|
+
10. **The modules, by concern and in build order** (`genome/capture/modules.md`). A module is a concern of its own - what a person looks for in one file: request sending, output formatting, sessions, downloads. One module that holds everything is as hard to read as the code, and every change to it regenerates all of it. The code's areas are gathered into modules by size alone (see [modules](#what-it-writes)), so a small codebase's every concern can land in one. And a module is built on the code of the modules before it, its scenarios run as soon as it is built, with nothing after it there - yet the areas are in the order of their code's imports, which is not the order behaviour is built in: the code that runs everything imports everything - httpie's request sending imports its output formatting and its sessions - so output formatting's scenarios, which send a request and print the answer, could not pass before it. So for each part of more than one feature, an agent is shown every feature, area by area, with what it owns, its functional specs and scenarios, and the modules as the areas make them, and gathers the features into modules by concern - a feature with another only when it is part of that concern, a concern past about 40 functional specs two modules - and puts them in the order they are built, naming for each the modules before it that its functional specs build on and its scenarios run. A scenario that needs a module after its own whatever the order - two modules each needing the other - is rewritten to check the same with only those before it, never merged away. The harness checks that every feature is in one module, that one module never holds a part larger than a module, that none holds more than twice that, and that each module needs only those before it. It runs once, before anything is done module by module; an answer that never holds leaves the modules as the areas make them, in the order of their code, and the report says so.
|
|
110
|
+
11. **Concepts reconciled.** A concept two features defined in different words is given one definition by an agent that sees the definitions and the specs that use it.
|
|
111
|
+
12. **The readability pass.** For each module, an agent reads its \*\*\*plain - each functional spec with its scenarios - and the stack's templates, never the code. It rewrites the functional specs that read as code, or restate the stack, an earlier spec, or a case one of their scenarios pins. It must keep every fact the stack and the scenarios do not keep - every interface fact, however obvious - and may never make a spec longer. Like the unit review, it improves; it is not a gate.
|
|
112
|
+
13. **The interface checked against the code.** For each module, an agent is given its \*\*\*plain - functional specs with their scenarios - the reference's entries in its features' files, and the options the \*\*\*plain names that the reference does not have, found mechanically, and checks every interface fact against the reference and the code that decides it: each option's names, value, choices and default; each route's method, path, fields and status codes; each message, format and exit code. It corrects what is wrong or left out, a functional spec's text or a scenario's, citing the code - over the readability pass, which never sees the code. A correction that never holds is not made.
|
|
113
|
+
14. **The scenarios tried on the original** (`src/capture/trial.ts`, `genome/capture/trial.md`). Every agent before this one read the original and never ran it, so a scenario can expect a terminal its test will not give, a site on the internet, output wrapped at a width nobody set, or a message the original never prints. For each module, a copy of the original - the files the map has, so none of its installed dependencies, nor turri's own config files, and the lock files beside its manifests, so it installs what the original pins - is made under `.turri/capture/trial/<module>/`, and agents with a shell on it, 20 scenarios each, one after another, install the original there and run each scenario as its conformance test will: from outside, through its interface, under the part's test reqs and its stack's conformance template. Their shell is a coding agent's - the command check, a home, temporary folder and package caches of its own, the OS sandbox and the audit - fenced to the copy. Each scenario comes back `held`, with what was run and what the original answered; `corrected` to what the original does, keeping what it checks - a local server for a site on the internet, the option that forces colour where the test's output is no terminal; `removed`, when nothing outside can check it; or `untried`, with why, when the original would not run here - kept as written. A functional spec the original contradicts is corrected with its scenario, and what every test must set up for the original to act as the scenarios say - `COLUMNS`, a configuration folder of its own, an update check off - joins the part's test reqs. What only some scenarios need - a file one sends, a server answering one exact body, a pseudo-terminal for one prompt - is never a test req, which every conformance test of every module is written under: those scenarios are corrected to say it themselves, and a test req that names a scenario or a functional spec is sent back. The harness checks that every scenario has one result and that each held or corrected one says what was run. The copy is removed once the module's agents are done. An agent that never holds leaves its scenarios as written, and the report says so.
|
|
114
|
+
15. **The files.** The modules, their scenarios, the interface references and the config are written, once.
|
|
115
|
+
16. **The testing scripts.** Capture first checks whether a reusable runner fits the surveyed setup. A single Python part with `requirements.txt` and ordinary pytest discovery can use the stock unit runner. Its external suite can use pytest or Bats, including a helper's build-folder and interpreter variables. For a standard installable `pyproject.toml` package, the pytest runner installs the staged package in its own venv so imports and console entry points work. It recognises the manifest's Black/isort/flake8/mypy toolset and `dev` extra. A custom invocation, installation or service setup still needs a writer. Reused scripts are copied into the project and named in its config without a model call. For each unmatched kind, `implement-unit-testing-script` or `implement-conformance-testing-script` writes the runner on the writing tier. The report says which runner was used, or why one could not be written.
|
|
116
|
+
17. **The check and the report.** The parser checks every module.
|
|
117
|
+
|
|
118
|
+
The harness checks every answer before keeping it, and sends it back with what is wrong, twice at most (`src/capture/checks.ts`). It checks:
|
|
119
|
+
- paths that are not in the codebase
|
|
120
|
+
- a convention that names no file deciding it
|
|
121
|
+
- ids that are not kebab-case
|
|
122
|
+
- concepts used and never defined
|
|
123
|
+
- a feature over its budget: functional specs, and scenarios past what the original's tests give it
|
|
124
|
+
- a line the parser would read as a heading
|
|
125
|
+
- a link, such as `<https://...>`: the parser refuses any link but one to a file of the project, so a URL is written as code
|
|
126
|
+
- a split that leaves files nowhere
|
|
127
|
+
- a division that leaves a feature with no owner, or merges one into itself, into nothing or into one merged too
|
|
128
|
+
- an entry of the interface reference with a literal the code it cites does not have, or a surface of the map neither listed nor excluded
|
|
129
|
+
- a writer of the interface no feature captured that leaves a surface neither captured nor dropped with why
|
|
130
|
+
- modules that leave a feature out or hold it twice, one module holding a part too large for one, or a module before one it needs
|
|
131
|
+
- a correction to a functional spec or scenario that is not there, or with no why
|
|
132
|
+
- a trial that leaves a scenario it was given with no result, says a scenario held or is corrected without saying what it ran against the original, or adds a test req that names a scenario or a functional spec - one scenario's setup, which its own text says
|
|
133
|
+
|
|
134
|
+
An answer that never holds does not stop the capture:
|
|
135
|
+
- **A split** falls back to an outline of the whole area.
|
|
136
|
+
- **A division** leaves each feature owning what it was outlined for.
|
|
137
|
+
- **An outline or a feature** is left uncaptured, and the report says so - a writer of the interface too, its surfaces then counted in the summary.
|
|
138
|
+
- **The modules by concern** stay as the code's areas make them, in the order of their code.
|
|
139
|
+
- **The conventions check, an interface correction or a trial** leaves what was there.
|
|
140
|
+
|
|
141
|
+
Only a survey that never holds stops the capture, before anything is written.
|
|
142
|
+
|
|
143
|
+
## What it writes
|
|
144
|
+
|
|
145
|
+
When a captured program itself uses Liquid templates, literal tags and expressions in its examples are emitted as literal text. Markdown backticks alone do not prevent Liquid from evaluating them before the module is parsed. This applies to shared requirements, functional specs and their scenarios.
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
my-app/
|
|
149
|
+
... the original - read only, never written
|
|
150
|
+
plain/
|
|
151
|
+
config.turri.yaml the config in use where the capture was started, conformance-tests: true, base-folder: assets
|
|
152
|
+
config.turri.<m>.yaml one per part, when there are several - where its testing scripts go
|
|
153
|
+
template/<part>-shared.plain what a part's modules share: the stack, test reqs, concepts used across modules
|
|
154
|
+
<module>.plain ... the modules, a concern each, in the order they are built, each requiring the one before it
|
|
155
|
+
tests/<module>/<func-id>.plain the scenarios of each functional spec that has them
|
|
156
|
+
test_scripts/ the unit and conformance testing scripts, written by turri's skills
|
|
157
|
+
resources/interface/<part>.md each part's interface reference, linked by its interface concept
|
|
158
|
+
assets/ the original's images, fonts and media, copied - the base folder
|
|
159
|
+
.gitignore keeps the regenerated code's histories out of the repo
|
|
160
|
+
.turri/capture/ state.json - what each agent answered - and report.md
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- **Modules.** Splitting decides what each agent sees; a module is a concern, what a person reads in one file. The code's areas make the modules an agent starts from: an area whose leaves hold 40 functional specs or fewer (`MODULE_SPECS`) is one module, named after the area, with its leaves' features in build order, and a larger area is its areas' modules, each worked out the same way. That is by size alone, so an agent then gathers the features into modules by concern and puts them in the order they are built (step 10): each module a concern, named for it, never one holding everything. Where its answer never holds, the modules stay as the areas make them.
|
|
164
|
+
- **Feature groups.** Each module's functional specs are grouped by feature, one feature's after another's, with no comment line between them.
|
|
165
|
+
- **Concepts.** A concept stays in the module that defines it when only that module uses it. A concept used across modules goes to the part's import module, along with every concept its definition uses.
|
|
166
|
+
- **The codebase is never written to.** Capture's agents only read it - read, grep, find, ls, and no shell - but for those that try the scenarios, which run the original in a copy of it, removed once they are done.
|
|
167
|
+
- **Assets.** The assets are copied rather than linked, so the original can be deleted without breaking anything. `base-folder: assets` puts them in the first module's code before its first pulse, at the paths they had.
|
|
168
|
+
- **The config.** Capture inherits `config.turri.yaml` from the project in which the chat or `turri capture` was started. That keeps the person's models, thinking, reviews and limits. With no config to inherit, capture writes the full `turri init-config` template. A named harness model selects its vendor's pair: for example, a global Bedrock Claude harness gets Haiku low for coding. `--coding-model` overrides that choice. A custom provider with no preset keeps its named model. The capture agents use their [own three tiers](#models).
|
|
169
|
+
- **Capture-specific settings.** Capture turns on `conformance-tests` and wires up the captured project's own unit and conformance runners. The original project's script paths, `module`, `base-folder` and `test-dir` do not carry over. In the chat, the current chat model and thinking and any coding model given at startup take precedence; on the command line, `--harness-model` and `--coding-model` do. A config that does not parse stops capture before anything is written ([details](config.md#a-config-that-does-not-parse)).
|
|
170
|
+
|
|
171
|
+
## The report
|
|
172
|
+
|
|
173
|
+
`plain/.turri/capture/report.md` replaces the questions a capture never asks. It lists:
|
|
174
|
+
|
|
175
|
+
- what was written
|
|
176
|
+
- the conventions every feature follows, with the files that decide each: wrong there, wrong everywhere - and what the check against the code changed
|
|
177
|
+
- what the check of each module's interface against the code corrected, and why
|
|
178
|
+
- the scenarios tried on the original: each one corrected to what the original does, removed or not tried, with why; the functional specs corrected with them; what was added to the test reqs. The summary says how many held as written.
|
|
179
|
+
- each part's modules by concern, in the order they are built, what each needs of those before it, and the scenarios rewritten to need only those before their own
|
|
180
|
+
- the features merged into others, and why
|
|
181
|
+
- the testing scripts: where each is, or why it was not written and which skill to ask for
|
|
182
|
+
- the parser's check
|
|
183
|
+
- what could not be captured
|
|
184
|
+
- features the original's tests cover that were captured with no scenario
|
|
185
|
+
- each part's interface reference: where it is, what it holds, what was left out of it and why, and what could not be taken
|
|
186
|
+
- the interface its \*\*\*plain still names nowhere - options, commands, routes, screens, environment variables - each with why its writer dropped it, or with none when no writer settled it. Those with no why are counted in the summary: a user could call them in the original and will not find them in what is regenerated.
|
|
187
|
+
- what was left out and why
|
|
188
|
+
- every assumption
|
|
189
|
+
- what the agents were unsure of
|
|
190
|
+
- what they dropped as incidental
|
|
191
|
+
- what to do next
|
|
192
|
+
|
|
193
|
+
Its first lines are the summary the command line and the chat show. In the chat, the report comes back once the capture ends, and the chat's agent passes it on.
|
|
194
|
+
|
|
195
|
+
## Stopped, finished, run again
|
|
196
|
+
|
|
197
|
+
- **Stopped part-way.** Every answer is saved in `state.json` as it comes. Running the capture again goes on from where it was and asks no agent twice. This covers a quit, a crash, or a provider down for good.
|
|
198
|
+
- **Finished.** A finished capture is never run over. To capture again, move `plain/` out of the way.
|
|
199
|
+
- **A folder that is not a capture.** Capture refuses a `plain/` that holds anything but its own state, and `--into <folder>` names another folder.
|
|
200
|
+
|
|
201
|
+
## Models
|
|
202
|
+
|
|
203
|
+
| Role | Work | Default |
|
|
204
|
+
| --- | --- | --- |
|
|
205
|
+
| `capture-exploration` | Gather facts from source for the public interface reference. | **Haiku, low** |
|
|
206
|
+
| `capture-analysis` | Check conventions, reference entries and the module's interface against the code, split and outline areas, divide features, and try draft scenarios against the original. | **Sonnet, low** |
|
|
207
|
+
| `capture` | Reason about the stack and requirements, write the specs, organise modules, reconcile concepts, revise the text and write custom testing scripts. | **Opus, medium** |
|
|
208
|
+
|
|
209
|
+
`init-config` writes all three entries as active configuration. For example, with Anthropic:
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
models:
|
|
213
|
+
capture-exploration: anthropic/claude-haiku-5-5:low
|
|
214
|
+
capture-analysis: anthropic/claude-sonnet-5-5:low
|
|
215
|
+
capture: anthropic/claude-opus-5-5:medium
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The three entries are independent, each overriding its tier's default. Headless capture resolves the same defaults without needing `init-config`; a Bedrock Claude harness uses its inference geography. A non-Claude harness keeps its configured provider models: coding for exploration and analysis, harness for writing. Capture prints the resolved models at startup, and each agent's elapsed time and cost at completion. Capture turns have ten minutes unless a role, `models.default` or `turn-limit` sets a limit; scenario trials get at least thirty minutes unless the limit is off.
|
|
219
|
+
|
|
220
|
+
`--harness-model` and `--coding-model` are also written into the new project's config, for the chat and the regeneration that follow.
|
|
221
|
+
|
|
222
|
+
## After a capture
|
|
223
|
+
|
|
224
|
+
1. **Read the \*\*\*plain and the report,** in turri opened in `plain/`. From now on the \*\*\*plain is the source of truth.
|
|
225
|
+
2. **Regenerate,** first module first: `/regenerate`. Its testing scripts are written already. Any the report says were not, ask turri for first (`implement-unit-testing-script`, `implement-conformance-testing-script`).
|
|
226
|
+
3. **Compare with the original** by hand: its own tests, the scenarios' conformance tests, a look at what is launched. Each difference becomes a \*\*\*plain change.
|
|
227
|
+
4. **Abandon the original** once you are satisfied.
|