@turri-dev/cli 0.4.3-next.3fc888b → 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/dist/capture/agents.d.ts +21 -6
- package/dist/capture/agents.js +49 -8
- package/dist/capture/assemble.d.ts +4 -14
- package/dist/capture/assemble.js +19 -18
- package/dist/capture/capture.d.ts +3 -3
- package/dist/capture/capture.js +67 -33
- package/dist/capture/checks.js +7 -1
- package/dist/capture/config.d.ts +1 -1
- package/dist/capture/config.js +16 -10
- package/dist/capture/interface.js +1 -1
- package/dist/capture/map.d.ts +0 -2
- package/dist/capture/map.js +1 -1
- package/dist/capture/models.d.ts +4 -0
- package/dist/capture/models.js +16 -0
- package/dist/capture/plan.d.ts +2 -3
- package/dist/capture/plan.js +9 -9
- package/dist/capture/progress.d.ts +3 -1
- package/dist/capture/progress.js +28 -2
- package/dist/capture/python-interface.d.ts +3 -0
- package/dist/capture/python-interface.js +17 -0
- package/dist/capture/report.js +2 -2
- package/dist/capture/runners.d.ts +6 -0
- package/dist/capture/runners.js +59 -0
- package/dist/capture/scripts.d.ts +1 -1
- package/dist/capture/scripts.js +5 -0
- package/dist/capture/state.d.ts +11 -0
- package/dist/capture-cli.js +4 -4
- package/dist/chat-tab-header.d.ts +3 -2
- package/dist/chat-tab-header.js +22 -9
- package/dist/chat-terminal.js +22 -4
- package/dist/chats.d.ts +3 -0
- package/dist/chats.js +14 -2
- package/dist/config-edit.js +4 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +8 -7
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +40 -16
- package/dist/init-config.d.ts +4 -1
- package/dist/init-config.js +31 -6
- package/dist/pi.d.ts +2 -2
- package/dist/pi.js +2 -2
- package/dist/question-dialog.d.ts +2 -2
- package/dist/question-dialog.js +10 -6
- package/dist/regenerate/agent-env.js +5 -1
- package/dist/terminal-notifications.d.ts +8 -2
- package/dist/terminal-notifications.js +45 -15
- package/docs/capture.md +31 -11
- package/docs/chats.md +3 -1
- package/docs/config.md +4 -3
- package/docs/sandbox.md +2 -0
- package/docs/sentinel.md +1 -1
- package/genome/capture/check-reference.md +1 -0
- package/genome/capture/modules.md +2 -0
- package/genome/capture/python-interface.py +111 -0
- package/genome/capture/runners/python-requirements.sh +67 -0
- package/genome/capture/survey.md +2 -0
- package/genome/capture/trial.md +1 -1
- package/package.json +1 -1
package/dist/capture/checks.js
CHANGED
|
@@ -121,7 +121,7 @@ function leftOutProblems(map, leftOut, within) {
|
|
|
121
121
|
return [`Left out ${item.path}: not in your area.`];
|
|
122
122
|
// The tests show what someone cared about: what scenarios are written from, never left behind.
|
|
123
123
|
const files = filesOf(map, [item.path]);
|
|
124
|
-
if (files.
|
|
124
|
+
if (files.some((file) => file.kind === "test"))
|
|
125
125
|
return [`Left out ${item.path}: it holds the original's tests, the evidence of what the software does - keep them with the code they test.`];
|
|
126
126
|
return [];
|
|
127
127
|
});
|
|
@@ -321,12 +321,18 @@ export function referenceProblems(map, root, given, answer) {
|
|
|
321
321
|
return texts.get(path);
|
|
322
322
|
};
|
|
323
323
|
const seen = new Set();
|
|
324
|
+
const commands = new Set(answer.entries.filter(entry => entry.kind === "command").map(entry => entry.name));
|
|
324
325
|
answer.entries.forEach((entry, at) => {
|
|
325
326
|
const what = `Entry ${at + 1}, \`${entry.name || "(no name)"}\``;
|
|
326
327
|
if (!INTERFACE_KINDS_TAKEN.has(entry.kind))
|
|
327
328
|
problems.push(`${what}: its kind is command, argument, option, route, env or other.`);
|
|
328
329
|
if (entry.name.trim() === "")
|
|
329
330
|
problems.push(`${what}: give its name, exactly as the code has it.`);
|
|
331
|
+
if (entry.command && !commands.has(entry.command)) {
|
|
332
|
+
const owners = entry.command.split(/,\s*|\s+and\s+/).map(name => name.trim());
|
|
333
|
+
if (owners.length > 1 && owners.every(name => commands.has(name)))
|
|
334
|
+
problems.push(`${what}: ${entry.command} is a list of commands, not one command. Give a separate entry under each command that accepts it.`);
|
|
335
|
+
}
|
|
330
336
|
const key = `${entry.kind} ${entry.command ?? ""} ${entry.name}`;
|
|
331
337
|
if (seen.has(key))
|
|
332
338
|
problems.push(`${what}: listed twice.`);
|
package/dist/capture/config.d.ts
CHANGED
package/dist/capture/config.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
-
import { CONFIG_FILE, CONFIG_KEYS, configFileProblem, projectConfigFile,
|
|
4
|
-
import {
|
|
3
|
+
import { CONFIG_FILE, CONFIG_KEYS, configFileProblem, projectConfigFile, splitModelSpec } from "../config.js";
|
|
4
|
+
import { quickStartForCapture } from "../init-config.js";
|
|
5
|
+
import { currentValue, shownValue, withSetting } from "../config-edit.js";
|
|
5
6
|
import { isProjectDir } from "../regenerate/paths.js";
|
|
6
7
|
/**
|
|
7
8
|
* The captured project's config. It starts as the config in use where the capture was started - the person's models,
|
|
@@ -35,22 +36,27 @@ export function configInUseProblem(file) {
|
|
|
35
36
|
* config.yaml - without what was the original project's own, conformance tests on, and the models given for the capture
|
|
36
37
|
* where the config in use says otherwise.
|
|
37
38
|
*/
|
|
38
|
-
export function startingConfig(source, given) {
|
|
39
|
+
export async function startingConfig(source, given) {
|
|
39
40
|
const carried = source !== undefined && basename(source) === CONFIG_FILE && existsSync(source) ? readFileSync(source, "utf8") : "";
|
|
40
|
-
let text = carried;
|
|
41
|
+
let text = carried || await quickStartForCapture(splitModelSpec(given.harnessModel).model, splitModelSpec(given.codingModel).model);
|
|
41
42
|
for (const key of ORIGINAL_ONLY)
|
|
42
43
|
text = withSetting(text, key, undefined);
|
|
43
44
|
text = withSetting(text, CONFIG_KEYS.conformanceTests, true);
|
|
44
|
-
const models = projectModels(source !== undefined && carried !== "" ? readConfigFile(source) : {});
|
|
45
45
|
// A model given - the chat's own, or one named on the command line - is written where the config in use says another:
|
|
46
46
|
// under models: when it names the role there, which wins over the key.
|
|
47
|
-
const set = (role, key, value
|
|
48
|
-
if (value === undefined
|
|
47
|
+
const set = (role, key, value) => {
|
|
48
|
+
if (value === undefined)
|
|
49
49
|
return;
|
|
50
|
-
|
|
50
|
+
const target = currentValue(text, `models.${role}`) !== undefined ? `models.${role}` : key;
|
|
51
|
+
// Naming the same model without a level keeps its configured thinking; an explicit level wins.
|
|
52
|
+
const current = shownValue(currentValue(text, target));
|
|
53
|
+
const spec = splitModelSpec(value);
|
|
54
|
+
if (current === value || (spec.thinking === undefined && splitModelSpec(current).model === spec.model))
|
|
55
|
+
return;
|
|
56
|
+
text = withSetting(text, target, value);
|
|
51
57
|
};
|
|
52
|
-
set("chat", CONFIG_KEYS.harnessModel, given.harnessModel
|
|
53
|
-
set("coding", CONFIG_KEYS.codingModel, given.codingModel
|
|
58
|
+
set("chat", CONFIG_KEYS.harnessModel, given.harnessModel);
|
|
59
|
+
set("coding", CONFIG_KEYS.codingModel, given.codingModel);
|
|
54
60
|
const header = [
|
|
55
61
|
"# Written by turri capture.",
|
|
56
62
|
...(carried !== "" ? [`# It started as the config in use where the capture was started - ${source} - without what was that project's own:`, "# its module, testing scripts, base folder and test folder."] : []),
|
|
@@ -115,7 +115,7 @@ function entryLines(entry) {
|
|
|
115
115
|
];
|
|
116
116
|
return [
|
|
117
117
|
`- ${quoted(entry.name)}${facts.length > 0 ? ` - ${facts.join("; ")}` : ""}`,
|
|
118
|
-
...(entry.help !== undefined && entry.help.trim() !== "" ? [` - help: ${entry.help
|
|
118
|
+
...(entry.help !== undefined && entry.help.trim() !== "" ? [` - help: ${entry.help}`] : []),
|
|
119
119
|
...entry.details.map((detail) => ` - ${detail}`),
|
|
120
120
|
];
|
|
121
121
|
}
|
package/dist/capture/map.d.ts
CHANGED
|
@@ -23,8 +23,6 @@ export interface MapFile {
|
|
|
23
23
|
path: string;
|
|
24
24
|
kind: FileKind;
|
|
25
25
|
lines: number;
|
|
26
|
-
/** Size on disk for a readable text file. */
|
|
27
|
-
bytes?: number;
|
|
28
26
|
surfaces: Surface[];
|
|
29
27
|
/** The codebase's files it imports, as paths like its own. */
|
|
30
28
|
imports: string[];
|
package/dist/capture/map.js
CHANGED
|
@@ -215,7 +215,7 @@ export function buildMap(root, options = {}) {
|
|
|
215
215
|
const lines = countLines(text);
|
|
216
216
|
if (size <= MAX_SCANNED_BYTES && (kind === "source" || kind === "test" || kind === "contract"))
|
|
217
217
|
texts.set(path, text);
|
|
218
|
-
return { path, kind, lines,
|
|
218
|
+
return { path, kind, lines, surfaces: [], imports: [] };
|
|
219
219
|
});
|
|
220
220
|
const resolver = importResolver(absoluteRoot, paths);
|
|
221
221
|
for (const file of files) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ModelChoice } from "../config.ts";
|
|
2
|
+
export type CaptureRole = "capture-exploration" | "capture-analysis" | "capture";
|
|
3
|
+
/** One set of defaults for init-config and capture, including headless captures with no project config. */
|
|
4
|
+
export declare function captureDefaults(harness?: string, coding?: string): Record<CaptureRole, ModelChoice>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { modelOnly } from "../config.js";
|
|
2
|
+
/** One set of defaults for init-config and capture, including headless captures with no project config. */
|
|
3
|
+
export function captureDefaults(harness, coding) {
|
|
4
|
+
const bedrock = process.env.AWS_BEARER_TOKEN_BEDROCK || process.env.AWS_PROFILE || process.env.CLAUDE_CODE_USE_BEDROCK === "1";
|
|
5
|
+
const model = modelOnly(harness).model ?? modelOnly(coding).model ?? (bedrock ? "amazon-bedrock/global.anthropic.claude-opus-5-5" : "anthropic/claude-opus-5-5");
|
|
6
|
+
// Keep the provider and Bedrock inference geography the person selected. Other vendors use their configured pair.
|
|
7
|
+
const prefix = model.match(/^(anthropic\/|claude-code\/|amazon-bedrock\/(?:(?:global|us|eu|jp|au)\.)?anthropic\.)claude-/)?.[1];
|
|
8
|
+
const fallback = modelOnly(coding).model ?? model;
|
|
9
|
+
// The Japanese inference geography serves Sonnet 5, but not 5.5.
|
|
10
|
+
const sonnet = prefix === "amazon-bedrock/jp.anthropic." ? "claude-sonnet-5" : "claude-sonnet-5-5";
|
|
11
|
+
return {
|
|
12
|
+
"capture-exploration": { model: prefix ? `${prefix}claude-haiku-5-5` : fallback, thinking: "low" },
|
|
13
|
+
"capture-analysis": { model: prefix ? `${prefix}${sonnet}` : fallback, thinking: "low" },
|
|
14
|
+
capture: { model: prefix ? `${prefix}claude-opus-5-5` : model, thinking: "medium" },
|
|
15
|
+
};
|
|
16
|
+
}
|
package/dist/capture/plan.d.ts
CHANGED
|
@@ -3,6 +3,5 @@ export interface CapturePlan {
|
|
|
3
3
|
kind: "compact" | "staged";
|
|
4
4
|
reason: string;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare function capturePlan(map: CodeMap, leafLines: number): CapturePlan;
|
|
6
|
+
/** Stage when any size limit is exceeded. Once the reference is known, use its coverage instead of the map's estimate. */
|
|
7
|
+
export declare function capturePlan(map: CodeMap, discoveredInterfaces?: number): CapturePlan;
|
package/dist/capture/plan.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { INTERFACE_KINDS } from "./map.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
/** Choose the pipeline from the map, without a planning agent. The survey, reference or writer may later uncover more work. */
|
|
6
|
-
export function capturePlan(map, leafLines) {
|
|
2
|
+
const LIMIT = { files: 64, lines: 4000, interfaces: 24 };
|
|
3
|
+
/** Stage when any size limit is exceeded. Once the reference is known, use its coverage instead of the map's estimate. */
|
|
4
|
+
export function capturePlan(map, discoveredInterfaces) {
|
|
7
5
|
const files = map.files.filter((file) => file.kind === "source" || file.kind === "test" || file.kind === "contract");
|
|
8
6
|
const lines = files.reduce((n, file) => n + file.lines, 0);
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const interfaces = discoveredInterfaces ?? files.reduce((n, file) => n + (file.kind === "test" ? 0 : file.surfaces.filter((surface) => INTERFACE_KINDS.has(surface.kind)).length), 0);
|
|
8
|
+
const staged = files.length > LIMIT.files || lines > LIMIT.lines || interfaces > LIMIT.interfaces;
|
|
9
|
+
return {
|
|
10
|
+
kind: staged ? "staged" : "compact",
|
|
11
|
+
reason: `${files.length}/${LIMIT.files} source, test and contract files, ${lines}/${LIMIT.lines} lines, ${interfaces}/${LIMIT.interfaces} ${discoveredInterfaces === undefined ? "mapped" : "discovered"} interface entries - ${staged ? "at least one limit exceeded" : "within all three limits"}`,
|
|
12
|
+
};
|
|
13
13
|
}
|
|
@@ -29,6 +29,8 @@ export interface CaptureAgentStatus {
|
|
|
29
29
|
}
|
|
30
30
|
/** A capture's phases, as its first line names them: what each stage is part of (`phaseOf`). */
|
|
31
31
|
export declare const CAPTURE_PHASES: string[];
|
|
32
|
+
/** A model's account is one short line of prose in the transcript, even if its reply ran long. */
|
|
33
|
+
export declare function findingLine(text: string): string;
|
|
32
34
|
/** The phase a stage is part of, by its place in CAPTURE_PHASES. */
|
|
33
35
|
export declare function phaseOf(stage: CaptureStage): number;
|
|
34
36
|
export interface CaptureStatus {
|
|
@@ -69,7 +71,7 @@ export declare class CaptureTracker {
|
|
|
69
71
|
/** The features outlined and done, counted from the state as it is now. */
|
|
70
72
|
counted(state: CaptureState): void;
|
|
71
73
|
/** An agent's watch: it shows while the agent works, with what it did last. */
|
|
72
|
-
agent(label: string): AgentWatch;
|
|
74
|
+
agent(label: string, assignment: string): AgentWatch;
|
|
73
75
|
private changed;
|
|
74
76
|
}
|
|
75
77
|
/** Features outlined so far, across every area - those merged into others not among them - and how many of them are done. */
|
package/dist/capture/progress.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { basename, sep } from "node:path";
|
|
2
|
+
import { stripVTControlCharacters } from "node:util";
|
|
2
3
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
3
4
|
import { skillProgressLine } from "../skill-progress.js";
|
|
4
5
|
import { featureKey, isMerged } from "./assemble.js";
|
|
5
6
|
/** A capture's phases, as its first line names them: what each stage is part of (`phaseOf`). */
|
|
6
7
|
export const CAPTURE_PHASES = ["survey", "outline", "features", "concepts", "readability", "interface", "trial", "scripts"];
|
|
7
8
|
const COMPACT_PHASES = ["survey", "features", "interface", "trial", "scripts"];
|
|
9
|
+
/** A model's account is one short line of prose in the transcript, even if its reply ran long. */
|
|
10
|
+
export function findingLine(text) {
|
|
11
|
+
const line = stripVTControlCharacters(text).replace(/\s+/g, " ").trim();
|
|
12
|
+
return line.length <= 280 ? line : `${line.slice(0, 279).trimEnd()}…`;
|
|
13
|
+
}
|
|
8
14
|
/** The phase a stage is part of, by its place in CAPTURE_PHASES. */
|
|
9
15
|
export function phaseOf(stage) {
|
|
10
16
|
switch (stage) {
|
|
@@ -69,18 +75,28 @@ export class CaptureTracker {
|
|
|
69
75
|
this.changed();
|
|
70
76
|
}
|
|
71
77
|
/** An agent's watch: it shows while the agent works, with what it did last. */
|
|
72
|
-
agent(label) {
|
|
78
|
+
agent(label, assignment) {
|
|
73
79
|
const root = this.status.root;
|
|
74
80
|
let shown;
|
|
81
|
+
let dollars = 0;
|
|
82
|
+
let planShown = false;
|
|
83
|
+
const plan = (line) => {
|
|
84
|
+
if (shown === undefined || planShown)
|
|
85
|
+
return;
|
|
86
|
+
planShown = true;
|
|
87
|
+
this.said(`${label} · plan: ${findingLine(line ?? "") || assignment}`);
|
|
88
|
+
};
|
|
75
89
|
return {
|
|
76
90
|
started: () => {
|
|
77
91
|
shown = { label, since: Date.now() };
|
|
78
92
|
this.status.agents.push(shown);
|
|
79
93
|
this.changed();
|
|
80
94
|
},
|
|
95
|
+
plan,
|
|
81
96
|
did: (line) => {
|
|
82
97
|
if (shown === undefined)
|
|
83
98
|
return;
|
|
99
|
+
plan();
|
|
84
100
|
shown.did = activityLine(line, root);
|
|
85
101
|
this.changed();
|
|
86
102
|
},
|
|
@@ -94,13 +110,23 @@ export class CaptureTracker {
|
|
|
94
110
|
this.changed();
|
|
95
111
|
},
|
|
96
112
|
spent: (cost) => {
|
|
113
|
+
dollars += cost;
|
|
97
114
|
this.status.cost += cost;
|
|
98
115
|
this.changed();
|
|
99
116
|
},
|
|
117
|
+
finding: (text) => {
|
|
118
|
+
plan();
|
|
119
|
+
const line = findingLine(text);
|
|
120
|
+
if (line)
|
|
121
|
+
this.said(`${label}: ${line}`);
|
|
122
|
+
},
|
|
100
123
|
ended: () => {
|
|
124
|
+
plan();
|
|
125
|
+
const since = shown?.since;
|
|
101
126
|
this.status.agents = this.status.agents.filter((agent) => agent !== shown);
|
|
102
127
|
shown = undefined;
|
|
103
|
-
|
|
128
|
+
if (since !== undefined)
|
|
129
|
+
this.said(`${label} · ${duration(Date.now() - since)} · $${dollars.toFixed(2)}`);
|
|
104
130
|
},
|
|
105
131
|
};
|
|
106
132
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { PACKAGE_ROOT } from "../environment.js";
|
|
4
|
+
import { filesOf } from "./area.js";
|
|
5
|
+
/** Literal import names, callable signatures and result fields, taken from syntax without importing the original. */
|
|
6
|
+
export function pythonInterface(map, paths) {
|
|
7
|
+
const files = filesOf(map, paths).filter(f => f.path.endsWith(".py"));
|
|
8
|
+
if (!files.some(f => f.path.endsWith("/__init__.py")))
|
|
9
|
+
return undefined;
|
|
10
|
+
const script = join(PACKAGE_ROOT, "genome", "capture", "python-interface.py");
|
|
11
|
+
for (const bin of ["python3", "python"]) {
|
|
12
|
+
const result = spawnSync(bin, ["-I", "-S", script], { cwd: map.root, input: JSON.stringify(files.map(f => f.path)), encoding: "utf8", timeout: 15000, maxBuffer: 2 * 1024 * 1024 });
|
|
13
|
+
if (result.status === 0)
|
|
14
|
+
return result.stdout.trim() || undefined;
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
package/dist/capture/report.js
CHANGED
|
@@ -47,7 +47,7 @@ export function referenceLines(state) {
|
|
|
47
47
|
};
|
|
48
48
|
const held = [...count("command", "command"), ...count("argument", "argument"), ...count("option", "option"), ...count("route", "route"), ...count("env", "environment variable"), ...count("other", "other piece", "other pieces")];
|
|
49
49
|
return [
|
|
50
|
-
...(entries.length > 0 ? [`${part.name}: \`${referencePath(part.name)}\`, linked by ${interfaceConcept(part.name)} - ${held.join(", ")}`] : [`${part.name}: no interface reference - the writers took its interface from the map alone`]),
|
|
50
|
+
...(entries.length > 0 || state.pythonInterfaces?.[part.name] ? [`${part.name}: \`${referencePath(part.name)}\`, linked by ${interfaceConcept(part.name)} - ${[...held, ...(state.pythonInterfaces?.[part.name] ? ["public Python imports and signatures"] : [])].join(", ")}`] : [`${part.name}: no interface reference - the writers took its interface from the map alone`]),
|
|
51
51
|
...excluded.map((item) => `${part.name}: \`${item.name}\` (${item.path}) left out of it - ${item.why}`),
|
|
52
52
|
...Object.values(state.interfaces?.[part.name] ?? {}).flatMap((batch) => "entries" in batch && batch.checked !== undefined
|
|
53
53
|
? "failed" in batch.checked
|
|
@@ -164,7 +164,7 @@ function scriptLines(state) {
|
|
|
164
164
|
return Object.entries(state.scripts ?? {}).map(([key, outcome]) => {
|
|
165
165
|
const [part, kind] = key.split(":");
|
|
166
166
|
const { skill, what } = testingScriptSkill(kind);
|
|
167
|
-
return "written" in outcome ? `${part}, the ${what}: \`${outcome.written}
|
|
167
|
+
return "written" in outcome ? `${part}, the ${what}: \`${outcome.written}\`${outcome.finding ? ` - ${outcome.finding}` : ""}` : `${part}, the ${what}: not written - ${outcome.failed}. Ask turri for it: \`${skill}\`.`;
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
export function renderReport(input) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CodeMap } from "./map.ts";
|
|
2
|
+
import type { Part, ScriptOutcome } from "./state.ts";
|
|
3
|
+
import type { ScriptKind } from "../regenerate/test-scripts.ts";
|
|
4
|
+
export declare function runnerChoices(value: unknown): Part["runners"];
|
|
5
|
+
/** A surveyed match plus evidence on disk. Anything else uses the normal script-writing skill. */
|
|
6
|
+
export declare function reuseRunner(plainDir: string, map: CodeMap, part: Part, kind: ScriptKind, configModule?: string): ScriptOutcome | undefined;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join, posix } from "node:path";
|
|
3
|
+
import { PACKAGE_ROOT } from "../environment.js";
|
|
4
|
+
import { writeSetting } from "../config-edit.js";
|
|
5
|
+
import { filesOf } from "./area.js";
|
|
6
|
+
/** These substitutions are identifiers, never shell code. Keep the runner's own environment out of reach. */
|
|
7
|
+
function binding(value) {
|
|
8
|
+
return value === undefined || (typeof value === "string" && /^(?:PYTHON|[A-Z][A-Z0-9_]*_(?:DIR|ROOT|FOLDER|PYTHON|INTERPRETER))$/.test(value) && !/^(?:BASH|TMP|LD_|DYLD_|BATS_|GIT_|PYTHON[A-Z_])/.test(value));
|
|
9
|
+
}
|
|
10
|
+
export function runnerChoices(value) {
|
|
11
|
+
if (value === null || typeof value !== "object")
|
|
12
|
+
return undefined;
|
|
13
|
+
const { unit, conformance, build_dir_env, python_env } = value;
|
|
14
|
+
const buildDirEnv = build_dir_env === "" ? undefined : build_dir_env;
|
|
15
|
+
const pythonEnv = python_env === "" ? undefined : python_env;
|
|
16
|
+
const runners = {};
|
|
17
|
+
if (unit === "pytest")
|
|
18
|
+
runners.unit = unit;
|
|
19
|
+
if ((conformance === "bats" || conformance === "pytest") && binding(buildDirEnv) && binding(pythonEnv) && (!buildDirEnv || buildDirEnv !== pythonEnv)) {
|
|
20
|
+
Object.assign(runners, { conformance, buildDirEnv, pythonEnv });
|
|
21
|
+
}
|
|
22
|
+
return runners;
|
|
23
|
+
}
|
|
24
|
+
/** A surveyed match plus evidence on disk. Anything else uses the normal script-writing skill. */
|
|
25
|
+
export function reuseRunner(plainDir, map, part, kind, configModule) {
|
|
26
|
+
const choice = part.runners?.[kind];
|
|
27
|
+
if (!choice || configModule)
|
|
28
|
+
return undefined;
|
|
29
|
+
const files = filesOf(map, part.paths);
|
|
30
|
+
// The survey can list a single part's packages rather than ".". Its dependency manifest still belongs to the root.
|
|
31
|
+
const pyproject = map.files.some(f => f.path === "pyproject.toml");
|
|
32
|
+
const manifest = pyproject ? readFileSync(join(map.root, "pyproject.toml"), "utf8") : "";
|
|
33
|
+
// A standard pip-installable PEP 621 package with pytest, no custom build/test plugins. A pytest.ini in the
|
|
34
|
+
// *external* suite only sets discovery for that suite and does not change the package installation.
|
|
35
|
+
const packaged = pyproject && choice === "pytest" && /^\[project\]\s*$/m.test(manifest) && /^\[build-system\]\s*$/m.test(manifest) && /^build-backend\s*=\s*["'](?:hatchling\.build|setuptools\.build_meta|flit_core\.buildapi)["']/m.test(manifest) && !/^(?:backend-path|addopts|required_plugins|dynamic)\s*=/m.test(manifest);
|
|
36
|
+
if (pyproject ? !packaged : !map.files.some((f) => f.path === "requirements.txt"))
|
|
37
|
+
return undefined;
|
|
38
|
+
if (map.files.some((f) => /^(?:setup\.(?:cfg|py)|tox\.ini|pytest\.ini|Pipfile|environment\.ya?ml)$/.test(f.path)))
|
|
39
|
+
return undefined;
|
|
40
|
+
if (choice === "bats" ? !files.some((f) => f.path.endsWith(".bats")) : !files.some((f) => f.kind === "test" && f.path.endsWith(".py")))
|
|
41
|
+
return undefined;
|
|
42
|
+
const name = kind === "unit" ? "run_unittests_python.sh" : `run_conformance_tests_${choice}.sh`;
|
|
43
|
+
const relative = posix.join("test_scripts", name);
|
|
44
|
+
const dest = join(plainDir, "test_scripts", name);
|
|
45
|
+
if (existsSync(dest))
|
|
46
|
+
return undefined;
|
|
47
|
+
const template = readFileSync(join(PACKAGE_ROOT, "genome", "capture", "runners", "python-requirements.sh"), "utf8");
|
|
48
|
+
const { buildDirEnv, pythonEnv } = part.runners;
|
|
49
|
+
if (!binding(buildDirEnv) || !binding(pythonEnv))
|
|
50
|
+
return undefined;
|
|
51
|
+
const dev = manifest.split(/^\[project\.optional-dependencies\][ \t]*$/m)[1]?.split(/^\[/m)[0] ?? "";
|
|
52
|
+
const packageExtra = packaged && /^dev\s*=/m.test(dev) ? ".[dev]" : ".";
|
|
53
|
+
const black = packaged && /^\[tool\.black\]/m.test(manifest) && /^\[tool\.isort\]/m.test(manifest) && ["black", "flake8", "isort", "mypy"].every(tool => dev.includes(`"${tool}`));
|
|
54
|
+
const body = template.replace("@MODE@", kind === "unit" ? "unit" : choice).replace("@BUILD_VAR@", buildDirEnv ?? "").replace("@PYTHON_VAR@", pythonEnv ?? "").replace("@INSTALL@", packaged ? "package" : "requirements").replace("@EXTRA@", packageExtra).replaceAll("@CHECKS@", black ? "black" : "ruff");
|
|
55
|
+
mkdirSync(join(plainDir, "test_scripts"), { recursive: true });
|
|
56
|
+
writeFileSync(dest, body, { mode: 0o755, flag: "wx" });
|
|
57
|
+
writeSetting(plainDir, kind === "unit" ? "unittests-script" : "conformance-tests-script", relative);
|
|
58
|
+
return { written: relative, finding: `Reused the Python ${packaged ? "pyproject.toml" : "requirements.txt"} / ${choice} runner.` };
|
|
59
|
+
}
|
|
@@ -21,6 +21,6 @@ export interface ScriptRequest {
|
|
|
21
21
|
signal?: AbortSignal;
|
|
22
22
|
}
|
|
23
23
|
/** Writes a testing script of a part, or throws why it could not. */
|
|
24
|
-
export type ScriptWriter = (request: ScriptRequest) => Promise<void>;
|
|
24
|
+
export type ScriptWriter = (request: ScriptRequest) => Promise<string | void>;
|
|
25
25
|
/** A part's testing script, written by turri's skill for it. */
|
|
26
26
|
export declare const writeTestingScript: ScriptWriter;
|
package/dist/capture/scripts.js
CHANGED
|
@@ -5,6 +5,7 @@ import { runSkill } from "../genome.js";
|
|
|
5
5
|
import { skillRunDir } from "../regenerate/paths.js";
|
|
6
6
|
import { testingScriptSkill } from "../regenerate/test-scripts.js";
|
|
7
7
|
import { discoverSkills } from "../skills.js";
|
|
8
|
+
import { CAPTURE_PLAN_NOTE } from "./agents.js";
|
|
8
9
|
const QUIET = { step: () => { }, artifact: () => { }, gate: () => { }, judge: () => { }, outcome: () => { } };
|
|
9
10
|
/** A part's testing script, written by turri's skill for it. */
|
|
10
11
|
export const writeTestingScript = async (request) => {
|
|
@@ -16,6 +17,8 @@ export const writeTestingScript = async (request) => {
|
|
|
16
17
|
`It is for ${request.module}.plain${request.configModule !== undefined ? `, built with ${moduleConfigFile(request.configModule)} over ${CONFIG_FILE}` : ""}.`,
|
|
17
18
|
`This project was captured just now from the codebase at ${request.root}, which the code regenerated from its ***plain replaces. Its ***plain says what the code is built on${request.part.stdlibStack !== undefined ? ` - ${request.part.stdlibStack}` : ""}; the original's manifests in that folder show the tools it used, where the ***plain leaves one open.`,
|
|
18
19
|
BACKGROUND_NOTE,
|
|
20
|
+
CAPTURE_PLAN_NOTE,
|
|
21
|
+
"In your final reply, give one short sentence for the capture trace: name the runner you wrote and what it checks, or the concrete reason you could not write it.",
|
|
19
22
|
].join("\n\n");
|
|
20
23
|
const result = await withConfigModule(request.configModule, () => runSkill({
|
|
21
24
|
skillDir: skill.dir,
|
|
@@ -30,4 +33,6 @@ export const writeTestingScript = async (request) => {
|
|
|
30
33
|
}));
|
|
31
34
|
if (!result.ok)
|
|
32
35
|
throw new Error("its skill stopped at a review gate, with no approved script");
|
|
36
|
+
// An ungated skill's output can include its opening text as well as its final reply. The trace already showed the plan.
|
|
37
|
+
return result.output.replace(/^\s*Plan:[^\r\n]*(?:\r?\n|$)/i, "").trim();
|
|
33
38
|
};
|
package/dist/capture/state.d.ts
CHANGED
|
@@ -42,8 +42,16 @@ export interface Part {
|
|
|
42
42
|
conventions?: Convention[];
|
|
43
43
|
testReqs: string[];
|
|
44
44
|
definitions: Definition[];
|
|
45
|
+
/** Stock runners whose complete invocation matches this part, selected in the survey. */
|
|
46
|
+
runners?: {
|
|
47
|
+
unit?: "pytest";
|
|
48
|
+
conformance?: "pytest" | "bats";
|
|
49
|
+
buildDirEnv?: string;
|
|
50
|
+
pythonEnv?: string;
|
|
51
|
+
};
|
|
45
52
|
}
|
|
46
53
|
export interface Survey {
|
|
54
|
+
separateConcerns?: string;
|
|
47
55
|
parts: Part[];
|
|
48
56
|
leftOut: LeftOut[];
|
|
49
57
|
assumptions: string[];
|
|
@@ -251,6 +259,8 @@ export interface CaptureState {
|
|
|
251
259
|
interfaces?: Record<string, Record<string, InterfaceBatch>>;
|
|
252
260
|
/** Parts whose interface reference is whole: every batch answered - and its concept defined. */
|
|
253
261
|
interfaceTaken?: string[];
|
|
262
|
+
/** Public import signatures found without a model, keyed by the survey's part. */
|
|
263
|
+
pythonInterfaces?: Record<string, string>;
|
|
254
264
|
/** Each part's conventions checked against the code, by part: what the check changed and why, or why it did not hold. */
|
|
255
265
|
conventionsChecked?: Record<string, {
|
|
256
266
|
changes: string[];
|
|
@@ -286,6 +296,7 @@ export interface CaptureState {
|
|
|
286
296
|
/** A testing script a capture had written: where it is in the project, or why there is none. */
|
|
287
297
|
export type ScriptOutcome = {
|
|
288
298
|
written: string;
|
|
299
|
+
finding?: string;
|
|
289
300
|
} | {
|
|
290
301
|
failed: string;
|
|
291
302
|
};
|
package/dist/capture-cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { relative, resolve } from "node:path";
|
|
2
|
-
import { CaptureError, runCapture } from "./capture/capture.js";
|
|
2
|
+
import { CaptureError, DEFAULT_PARALLEL, runCapture } from "./capture/capture.js";
|
|
3
3
|
import { c } from "./module-report.js";
|
|
4
4
|
/**
|
|
5
5
|
* `turri capture [path] [--harness-model <m>] [--coding-model <m>] [--into <folder>] [--parallel <n>]`: capture the
|
|
@@ -13,10 +13,10 @@ const USAGE = [
|
|
|
13
13
|
"what capture decided, left out or could not capture is in plain/.turri/capture/report.md. Run it again to go on",
|
|
14
14
|
"with a capture that was stopped.",
|
|
15
15
|
"",
|
|
16
|
-
" --harness-model <m> the model
|
|
17
|
-
" --coding-model <m> the model
|
|
16
|
+
" --harness-model <m> the project's harness model; Claude capture defaults to Haiku low / Sonnet low / Opus medium",
|
|
17
|
+
" --coding-model <m> the project's coding model; set models.capture-exploration, capture-analysis and capture to override capture's tiers",
|
|
18
18
|
" --into <folder> where the ***plain goes, instead of <path>/plain",
|
|
19
|
-
|
|
19
|
+
` --parallel <n> how many agents work at once (default: ${DEFAULT_PARALLEL})`,
|
|
20
20
|
].join("\n");
|
|
21
21
|
function option(args, name) {
|
|
22
22
|
const at = args.findIndex((arg) => arg === name || arg.startsWith(`${name}=`));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Component, type Container, type ScrollView, type TUI } from "@earendil-works/pi-tui";
|
|
2
2
|
import type { ChatTabs } from "./chat-tabs.ts";
|
|
3
|
+
export declare const BANNER_ENTRY = "turri_banner";
|
|
3
4
|
export interface ChatScreen {
|
|
4
5
|
fullscreenLayoutRoot: Component;
|
|
5
6
|
documentContainer: Container;
|
|
@@ -8,8 +9,8 @@ export interface ChatScreen {
|
|
|
8
9
|
}
|
|
9
10
|
/** The inline tabs are a sibling of the banner in the transcript. A single fixed row takes over when they scroll
|
|
10
11
|
* off the top (or a resumed conversation has no banner). The banner itself scrolls normally. */
|
|
11
|
-
export declare function chatTabHeader(tabs: ChatTabs): {
|
|
12
|
+
export declare function chatTabHeader(tabs: ChatTabs, tabsOnly: () => boolean): {
|
|
12
13
|
mount(screen: ChatScreen, components: Component[]): Component[];
|
|
13
|
-
afterBanner(chat: Container, entry: unknown): void;
|
|
14
|
+
afterBanner(chat: Container, entry: unknown, visible: () => boolean): void;
|
|
14
15
|
watch(screen: ChatScreen, tui: TUI): () => void;
|
|
15
16
|
};
|
package/dist/chat-tab-header.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { VStack } from "@earendil-works/pi-tui";
|
|
2
2
|
import { terminalPointer } from "./pointer-hover.js";
|
|
3
|
+
export const BANNER_ENTRY = "turri_banner";
|
|
3
4
|
/** Where pi drew a child. Use the row counts its Container already measured for mouse dispatch: the width of the
|
|
4
5
|
* chat, the banner's image and any wrapped warnings all affect where the divider lands. */
|
|
5
6
|
function rowOf(parent, child) {
|
|
@@ -16,11 +17,17 @@ function rowOf(parent, child) {
|
|
|
16
17
|
}
|
|
17
18
|
/** The inline tabs are a sibling of the banner in the transcript. A single fixed row takes over when they scroll
|
|
18
19
|
* off the top (or a resumed conversation has no banner). The banner itself scrolls normally. */
|
|
19
|
-
export function chatTabHeader(tabs) {
|
|
20
|
+
export function chatTabHeader(tabs, tabsOnly) {
|
|
20
21
|
let pinned = true;
|
|
22
|
+
// Once the welcome is gone, only the fixed tab row is needed.
|
|
23
|
+
const inline = {
|
|
24
|
+
render: (width) => tabsOnly() ? [] : tabs.render(width),
|
|
25
|
+
handleMouse: (event) => tabs.handleMouse?.(event),
|
|
26
|
+
invalidate() { },
|
|
27
|
+
};
|
|
21
28
|
const sticky = {
|
|
22
|
-
render: (width) => pinned ? tabs.render(width) : [],
|
|
23
|
-
handleMouse: (event) => pinned ? tabs.handleMouse?.(event) : undefined,
|
|
29
|
+
render: (width) => pinned || tabsOnly() ? tabs.render(width) : [],
|
|
30
|
+
handleMouse: (event) => pinned || tabsOnly() ? tabs.handleMouse?.(event) : undefined,
|
|
24
31
|
invalidate() { },
|
|
25
32
|
};
|
|
26
33
|
return {
|
|
@@ -30,12 +37,16 @@ export function chatTabHeader(tabs) {
|
|
|
30
37
|
screen.fullscreenLayoutRoot = new VStack([sticky, { component: screen.fullscreenLayoutRoot, basis: 0, grow: 1, minSize: 1 }]);
|
|
31
38
|
return [sticky, ...components];
|
|
32
39
|
},
|
|
33
|
-
afterBanner(chat, entry) {
|
|
34
|
-
if (chat.children.includes(tabs))
|
|
35
|
-
return;
|
|
40
|
+
afterBanner(chat, entry, visible) {
|
|
36
41
|
const at = chat.children.findIndex((child) => child.entry === entry);
|
|
37
|
-
if (at
|
|
38
|
-
|
|
42
|
+
if (at === -1)
|
|
43
|
+
return;
|
|
44
|
+
// Hide pi's whole entry (including its spacer), but keep the neighbouring tabs and their mouse targets.
|
|
45
|
+
const banner = chat.children[at];
|
|
46
|
+
const render = banner.render.bind(banner);
|
|
47
|
+
banner.render = (width) => visible() ? render(width) : [];
|
|
48
|
+
if (!chat.children.includes(inline))
|
|
49
|
+
chat.children.splice(at + 1, 0, inline);
|
|
39
50
|
},
|
|
40
51
|
watch(screen, tui) {
|
|
41
52
|
if (tui.mode !== "fullscreen") {
|
|
@@ -48,8 +59,10 @@ export function chatTabHeader(tabs) {
|
|
|
48
59
|
const update = view.updateLayout;
|
|
49
60
|
view.updateLayout = function (height, viewport, redraw) {
|
|
50
61
|
update.call(this, height, viewport, redraw);
|
|
62
|
+
if (tabsOnly())
|
|
63
|
+
return;
|
|
51
64
|
const chat = rowOf(screen.documentContainer, screen.chatContainer);
|
|
52
|
-
const tab = rowOf(screen.chatContainer,
|
|
65
|
+
const tab = rowOf(screen.chatContainer, inline);
|
|
53
66
|
const row = chat === undefined || tab === undefined ? -1 : chat + tab;
|
|
54
67
|
const next = row < this.scrollTop || row >= this.scrollTop + viewport;
|
|
55
68
|
if (next !== pinned) {
|
package/dist/chat-terminal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentSessionRuntime, InteractiveMode, SessionManager } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { chatTabHeader } from "./chat-tab-header.js";
|
|
2
|
+
import { BANNER_ENTRY, chatTabHeader } from "./chat-tab-header.js";
|
|
3
3
|
import { chatTabs, closeTerminalChat } from "./chat-tabs.js";
|
|
4
4
|
import { showWaitingMessages } from "./chat-waiting.js";
|
|
5
5
|
import { buttonLabel } from "./pointer-hover.js";
|
|
@@ -78,12 +78,30 @@ export function driveTerminal(core, options = {}) {
|
|
|
78
78
|
const panel = core.shownChat()?.instance?.plainPanel;
|
|
79
79
|
return { notifications: core.notifications.count, open: panel?.open() === true, busy: panel?.busy() === true };
|
|
80
80
|
});
|
|
81
|
-
const header = chatTabHeader(tabs)
|
|
81
|
+
const header = chatTabHeader(tabs, () => {
|
|
82
|
+
const id = core.shown();
|
|
83
|
+
return id !== undefined && !core.welcomeVisible(id);
|
|
84
|
+
});
|
|
85
|
+
// pi dispatches slash commands before the extension's input event. Catch the submission before either path.
|
|
86
|
+
const setupSubmit = prototype.setupEditorSubmitHandler;
|
|
87
|
+
prototype.setupEditorSubmitHandler = function () {
|
|
88
|
+
setupSubmit.call(this);
|
|
89
|
+
const editor = this.defaultEditor;
|
|
90
|
+
const submit = editor.onSubmit;
|
|
91
|
+
editor.onSubmit = (text) => {
|
|
92
|
+
if (text.trim())
|
|
93
|
+
core.dismissWelcome();
|
|
94
|
+
return submit.call(editor, text);
|
|
95
|
+
};
|
|
96
|
+
};
|
|
82
97
|
const addEntry = prototype.addCustomEntryToChat;
|
|
83
98
|
prototype.addCustomEntryToChat = function (entry) {
|
|
84
99
|
addEntry.call(this, entry);
|
|
85
|
-
if (entry.customType ===
|
|
86
|
-
header.afterBanner(this.chatContainer, entry)
|
|
100
|
+
if (entry.customType === BANNER_ENTRY)
|
|
101
|
+
header.afterBanner(this.chatContainer, entry, () => {
|
|
102
|
+
const chat = core.chatOfSession(this.session);
|
|
103
|
+
return chat !== undefined && core.welcomeVisible(chat.id);
|
|
104
|
+
});
|
|
87
105
|
};
|
|
88
106
|
let stopWatchingTabs;
|
|
89
107
|
const mount = prototype.mountInteractiveTui;
|
package/dist/chats.d.ts
CHANGED
|
@@ -205,6 +205,9 @@ export interface TurriCore {
|
|
|
205
205
|
readonly canOpen: boolean;
|
|
206
206
|
/** Whether the chats are the terminal's, switched between with /chat and its keys. */
|
|
207
207
|
readonly terminal: boolean;
|
|
208
|
+
/** Only the first terminal chat shows the welcome, until a non-empty submission anywhere in the session. */
|
|
209
|
+
welcomeVisible(chat: string): boolean;
|
|
210
|
+
dismissWelcome(): void;
|
|
208
211
|
chats(): ChatInfo[];
|
|
209
212
|
/** The chat's pi session. */
|
|
210
213
|
session(id: string): AgentSession | undefined;
|