@turri-dev/cli 0.1.4-next.318a98a → 0.1.4-next.5a8c6e5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pi/themes/turri-dark.json +67 -66
- package/.pi/themes/turri-light.json +71 -73
- package/README.md +40 -128
- package/assets/jellyfish/dark-00.png +0 -0
- package/assets/jellyfish/dark-01.png +0 -0
- package/assets/jellyfish/dark-02.png +0 -0
- package/assets/jellyfish/dark-03.png +0 -0
- package/assets/jellyfish/dark-04.png +0 -0
- package/assets/jellyfish/dark-05.png +0 -0
- package/assets/jellyfish/dark-06.png +0 -0
- package/assets/jellyfish/dark-07.png +0 -0
- package/assets/jellyfish/dark-08.png +0 -0
- package/assets/jellyfish/dark-09.png +0 -0
- package/assets/jellyfish/dark-10.png +0 -0
- package/assets/jellyfish/dark-11.png +0 -0
- package/assets/jellyfish/light-00.png +0 -0
- package/assets/jellyfish/light-01.png +0 -0
- package/assets/jellyfish/light-02.png +0 -0
- package/assets/jellyfish/light-03.png +0 -0
- package/assets/jellyfish/light-04.png +0 -0
- package/assets/jellyfish/light-05.png +0 -0
- package/assets/jellyfish/light-06.png +0 -0
- package/assets/jellyfish/light-07.png +0 -0
- package/assets/jellyfish/light-08.png +0 -0
- package/assets/jellyfish/light-09.png +0 -0
- package/assets/jellyfish/light-10.png +0 -0
- package/assets/jellyfish/light-11.png +0 -0
- package/dist/ask.js +34 -15
- package/dist/brand.js +7 -7
- package/dist/cli-options.js +12 -6
- package/dist/config-edit.js +1 -0
- package/dist/config.js +5 -2
- package/dist/cultivate-cli.js +16 -23
- package/dist/extension.js +59 -67
- package/dist/init-config.js +5 -0
- package/dist/jellyfish.js +130 -0
- package/dist/loop-cli.js +19 -7
- package/dist/loop-tools.js +11 -5
- package/dist/module-report.js +5 -4
- package/dist/pi.js +76 -19
- package/dist/question-dialog.js +1 -0
- package/dist/regenerate/activity.js +21 -0
- package/dist/regenerate/list-arguments.js +121 -0
- package/dist/regenerate/loop.js +21 -8
- package/dist/regenerate/plain-palette.js +52 -37
- package/dist/regenerate/regenerate.js +4 -2
- package/dist/regenerate/self-check.js +13 -6
- package/dist/regenerate/side-panel.js +1 -1
- package/dist/regenerate/spec-map-view.js +9 -5
- package/dist/regenerate/test-scripts.js +54 -10
- package/dist/regenerate/unit-review.js +1 -1
- package/dist/regenerate-cli.js +11 -5
- package/dist/release-cli.js +3 -8
- package/dist/review/live.js +2 -1
- package/dist/run-report.js +39 -1
- package/dist/validate-cli.js +3 -8
- package/docs/README.md +5 -12
- package/docs/authoring-plain.md +37 -119
- package/docs/config.md +53 -178
- package/docs/deploy.md +21 -80
- package/docs/development.md +13 -41
- package/docs/headless.md +45 -121
- package/docs/images/how-turri-works.svg +29 -31
- package/docs/images/turri-banner.png +0 -0
- package/docs/installation.md +13 -40
- package/docs/parser.md +15 -43
- package/docs/regenerating.md +229 -938
- package/docs/sandbox.md +38 -152
- package/docs/skills-and-gates.md +50 -171
- package/docs/theming.md +45 -46
- package/docs/using.md +69 -345
- package/genome/rules/bullet-continuation.md +5 -13
- package/genome/rules/concise-specs-examples.md +2 -4
- package/genome/rules/concise-specs-integration-examples.md +2 -6
- package/genome/rules/concise-specs.md +1 -2
- package/genome/rules/func-specs.md +1 -0
- package/genome/rules/integration-embedded-testing.md +1 -4
- package/genome/rules/integrations.md +1 -2
- package/genome/rules/project-model.md +14 -35
- package/genome/rules/stdlib.md +14 -49
- package/genome/rules/turri-regeneration.md +48 -0
- package/genome/skills/add-implementation-requirement/SKILL.md +1 -2
- package/genome/skills/analyze-if-func-spec-too-complex/SKILL.md +3 -8
- package/genome/skills/brood/SKILL.md +37 -127
- package/genome/skills/brood/references/intent.md +4 -12
- package/genome/skills/brood/references/product.md +24 -76
- package/genome/skills/brood/references/stack.md +7 -29
- package/genome/skills/brood/references/testing.md +11 -42
- package/genome/skills/bud/SKILL.md +32 -109
- package/genome/skills/bud/references/intent.md +4 -11
- package/genome/skills/implement-conformance-testing-script/SKILL.md +3 -6
- package/genome/skills/implement-unit-testing-script/SKILL.md +1 -2
- package/genome/skills/mature/SKILL.md +21 -69
- package/genome/skills/refactor-module/SKILL.md +24 -2
- package/genome/skills/spawn/SKILL.md +28 -113
- package/package.json +1 -1
- package/assets/jellyfish/dark-12.png +0 -0
- package/assets/jellyfish/dark-13.png +0 -0
- package/assets/jellyfish/dark-14.png +0 -0
- package/assets/jellyfish/fallback.txt +0 -252
- package/assets/jellyfish/light-12.png +0 -0
- package/assets/jellyfish/light-13.png +0 -0
- package/assets/jellyfish/light-14.png +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2
|
+
/** The tool's arguments that take a list of objects. */
|
|
3
|
+
function listArguments(schema) {
|
|
4
|
+
const required = new Set(schema.required ?? []);
|
|
5
|
+
return Object.entries(schema.properties ?? {})
|
|
6
|
+
.filter(([, property]) => property.type === "array" && property.items?.type === "object")
|
|
7
|
+
.map(([name, property]) => ({ name, required: required.has(name), item: property.items }));
|
|
8
|
+
}
|
|
9
|
+
/** JSON text, fenced or not, as what it holds; anything else as it is. */
|
|
10
|
+
function parsed(value) {
|
|
11
|
+
if (typeof value !== "string")
|
|
12
|
+
return value;
|
|
13
|
+
const text = value
|
|
14
|
+
.trim()
|
|
15
|
+
.replace(/^```(?:json)?\s*/i, "")
|
|
16
|
+
.replace(/\s*```$/, "");
|
|
17
|
+
if (!/^[[{]/.test(text))
|
|
18
|
+
return value;
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(text);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const escaped = (name) => name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
27
|
+
/**
|
|
28
|
+
* Arguments the model wrote inside another argument's text - `answer</a>\n<b>[...]</b>\n<c>...` - taken out of it and
|
|
29
|
+
* given as their own, where they were not given already. Which argument each was found in, for the refusal.
|
|
30
|
+
*/
|
|
31
|
+
function untucked(args, names) {
|
|
32
|
+
const out = { ...args };
|
|
33
|
+
const foundIn = new Map();
|
|
34
|
+
const anyTag = names.map(escaped).join("|");
|
|
35
|
+
for (const [key, value] of Object.entries(args)) {
|
|
36
|
+
if (typeof value !== "string")
|
|
37
|
+
continue;
|
|
38
|
+
let cut = value.search(new RegExp(`</${escaped(key)}>`));
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
if (name === key || (out[name] !== undefined && out[name] !== ""))
|
|
41
|
+
continue;
|
|
42
|
+
const match = new RegExp(`<${escaped(name)}>([\\s\\S]*?)(?:</${escaped(name)}>|(?=<(?:${anyTag})>)|$)`).exec(value);
|
|
43
|
+
if (match === null)
|
|
44
|
+
continue;
|
|
45
|
+
out[name] = match[1].trim();
|
|
46
|
+
foundIn.set(name, key);
|
|
47
|
+
cut = cut === -1 ? match.index : Math.min(cut, match.index);
|
|
48
|
+
}
|
|
49
|
+
if (cut !== -1)
|
|
50
|
+
out[key] = value.slice(0, cut).trim();
|
|
51
|
+
}
|
|
52
|
+
return { args: out, foundIn };
|
|
53
|
+
}
|
|
54
|
+
/** What an entry of the list looks like, as JSON: its fields, the optional ones marked. */
|
|
55
|
+
function shapeOf(item) {
|
|
56
|
+
const required = new Set(item.required ?? []);
|
|
57
|
+
const entries = Object.entries(item.properties ?? {});
|
|
58
|
+
const fields = entries.map(([name, field]) => `"${name}"${required.has(name) ? "" : "?"}: ${field.type ?? "value"}`).join(", ");
|
|
59
|
+
const sample = (field) => (field.type === "number" || field.type === "integer" ? "1" : field.type === "boolean" ? "true" : field.type === "string" ? '"..."' : "...");
|
|
60
|
+
const example = entries
|
|
61
|
+
.filter(([name]) => required.has(name))
|
|
62
|
+
.map(([name, field]) => `"${name}": ${sample(field)}`)
|
|
63
|
+
.join(", ");
|
|
64
|
+
return { fields: `{${fields}}`, example: `{${example}}` };
|
|
65
|
+
}
|
|
66
|
+
/** Why a list argument is not one, said so a model can make the call right next time - or undefined when it is. */
|
|
67
|
+
function problemOf(list, value, foundIn) {
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
return list.required ? "you left it out" : undefined;
|
|
70
|
+
if (!Array.isArray(value)) {
|
|
71
|
+
if (foundIn !== undefined)
|
|
72
|
+
return `you wrote it inside \`${foundIn}\``;
|
|
73
|
+
return typeof value === "string" ? "you sent it as text, not a list" : `you sent ${isObject(value) ? "an object" : `a ${typeof value}`}, not a list`;
|
|
74
|
+
}
|
|
75
|
+
const bad = value.findIndex((entry) => !isObject(entry));
|
|
76
|
+
if (bad === -1)
|
|
77
|
+
return undefined;
|
|
78
|
+
return `entry ${bad + 1} is ${typeof value[bad] === "string" ? "text" : `a ${typeof value[bad]}`}, not an object`;
|
|
79
|
+
}
|
|
80
|
+
/** The arguments with their lists made lists where they plainly are; refused, saying what is wanted, where they are not. */
|
|
81
|
+
export function prepareListArguments(toolName, schema, raw) {
|
|
82
|
+
const lists = listArguments(schema);
|
|
83
|
+
if (lists.length === 0 || !isObject(raw))
|
|
84
|
+
return raw;
|
|
85
|
+
const { args, foundIn } = untucked(raw, Object.keys(schema.properties ?? {}));
|
|
86
|
+
const problems = [];
|
|
87
|
+
for (const list of lists) {
|
|
88
|
+
let value = parsed(args[list.name]);
|
|
89
|
+
if (isObject(value))
|
|
90
|
+
value = [value];
|
|
91
|
+
if (Array.isArray(value))
|
|
92
|
+
value = value.map(parsed);
|
|
93
|
+
if (value !== undefined)
|
|
94
|
+
args[list.name] = value;
|
|
95
|
+
const problem = problemOf(list, value, foundIn.get(list.name));
|
|
96
|
+
if (problem === undefined)
|
|
97
|
+
continue;
|
|
98
|
+
const { fields, example } = shapeOf(list.item);
|
|
99
|
+
problems.push(`- \`${list.name}\`: ${problem}. It is a list of objects, each ${fields} - e.g. "${list.name}": [${example}].`);
|
|
100
|
+
}
|
|
101
|
+
if (problems.length === 0)
|
|
102
|
+
return args;
|
|
103
|
+
throw new Error([
|
|
104
|
+
`${toolName} was not run - its arguments are not in the shape it takes:`,
|
|
105
|
+
...problems,
|
|
106
|
+
"Each argument is a field of its own in the call, at the top level: a list is a JSON array of objects, never text, and never written inside another argument's text.",
|
|
107
|
+
].join("\n"));
|
|
108
|
+
}
|
|
109
|
+
/** The tools, each that takes a list of objects preparing its arguments so before they are checked. */
|
|
110
|
+
export function withListArguments(tools) {
|
|
111
|
+
return tools.map((tool) => {
|
|
112
|
+
const schema = tool.parameters;
|
|
113
|
+
if (listArguments(schema).length === 0)
|
|
114
|
+
return tool;
|
|
115
|
+
const before = tool.prepareArguments;
|
|
116
|
+
return {
|
|
117
|
+
...tool,
|
|
118
|
+
prepareArguments: (args) => prepareListArguments(tool.name, schema, before !== undefined ? before(args) : args),
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
package/dist/regenerate/loop.js
CHANGED
|
@@ -597,7 +597,14 @@ export function createWorkLoop(options) {
|
|
|
597
597
|
}
|
|
598
598
|
return {
|
|
599
599
|
report: released !== undefined ? `${report}\n\n${released}` : report,
|
|
600
|
-
details: {
|
|
600
|
+
details: {
|
|
601
|
+
passed: result.landed,
|
|
602
|
+
landed: result.landed,
|
|
603
|
+
...(released !== undefined ? { released: true } : {}),
|
|
604
|
+
...(result.story !== undefined ? { story: result.story } : {}),
|
|
605
|
+
// The spec gaps its agents met, for a headless run to say - in the chat the report puts them to the person.
|
|
606
|
+
...(result.specGaps !== undefined && result.specGaps.length > 0 ? { specGaps: result.specGaps } : {}),
|
|
607
|
+
},
|
|
601
608
|
};
|
|
602
609
|
},
|
|
603
610
|
});
|
|
@@ -1240,17 +1247,21 @@ export function createWorkLoop(options) {
|
|
|
1240
1247
|
startAgain(entry, `it now requires ${requires.join(", ")}, which its code was not built on`);
|
|
1241
1248
|
return loop.bringUp(plainFile, request);
|
|
1242
1249
|
},
|
|
1243
|
-
async fromScratch(plainFile, request = {}) {
|
|
1250
|
+
async fromScratch(plainFile, { chain, ...request } = {}) {
|
|
1244
1251
|
const file = resolve(options.cwd, plainFile);
|
|
1245
|
-
// Where its code lives: the tips its module is built in, or - none built yet - its own codebase.
|
|
1246
|
-
|
|
1252
|
+
// Where its code lives: the tips its module is built in, or - none built yet - its own codebase. The whole chain:
|
|
1253
|
+
// every codebase in those chains, bottom first - a tip taken back to nothing is otherwise started from a copy of
|
|
1254
|
+
// the code below it.
|
|
1255
|
+
const chains = chainsFor(file);
|
|
1256
|
+
const codebases = [...new Map((chain === true ? chains.flat() : chains.map(tipOf)).map((entry) => [entry.buildDir, entry])).values()];
|
|
1247
1257
|
for (const entry of codebases) {
|
|
1248
1258
|
if (modules.get(entry.buildDir)?.running !== undefined)
|
|
1249
1259
|
throw new Error(`${entry.moduleName} has a pulse running: halt it, or ask again once it is done.`);
|
|
1250
1260
|
}
|
|
1261
|
+
const why = chain === true ? "asked to be regenerated from scratch, with its whole chain" : "asked to be regenerated from scratch";
|
|
1251
1262
|
for (const entry of codebases)
|
|
1252
1263
|
if (started(entry))
|
|
1253
|
-
startAgain(entry,
|
|
1264
|
+
startAgain(entry, why);
|
|
1254
1265
|
return loop.bringUp(plainFile, request);
|
|
1255
1266
|
},
|
|
1256
1267
|
halt(target, reason) {
|
|
@@ -1511,7 +1522,7 @@ export function describeModules(statuses, options = {}) {
|
|
|
1511
1522
|
` Ask the user whether to start ${codebases.join(", ")} over, and say why: ${codebases.join(", ")} was built without ` +
|
|
1512
1523
|
`${requires.join(", ")}, so no change to its code can bring ${requires.join(", ")} in - its code and conformance ` +
|
|
1513
1524
|
"tests are taken out, kept in its history, and built again from the bottom of the chain. Only if they agree, " +
|
|
1514
|
-
`call regenerate with ${basename(status.plainFile)} and from_scratch.`,
|
|
1525
|
+
`call regenerate with ${basename(status.plainFile)} and from_scratch: "module".`,
|
|
1515
1526
|
];
|
|
1516
1527
|
};
|
|
1517
1528
|
return statuses
|
|
@@ -1565,7 +1576,7 @@ const defaultConformanceRunner = async (job, onDelta) => {
|
|
|
1565
1576
|
writeTestsRecord(result.conformanceDir, job.planned.step.tree);
|
|
1566
1577
|
recordHistory(job.buildDir, `conformance tests: ${job.planned.title}`);
|
|
1567
1578
|
}
|
|
1568
|
-
return { landed: result.passed, report: describeSpecDiffConformance(result) };
|
|
1579
|
+
return { landed: result.passed, report: describeSpecDiffConformance(result), ...(result.specGaps !== undefined ? { specGaps: result.specGaps } : {}) };
|
|
1569
1580
|
};
|
|
1570
1581
|
/** A job as a spec diff render, landed on its unit tests: conformance is a track of its own. */
|
|
1571
1582
|
const defaultRunner = async (job, onDelta) => {
|
|
@@ -1581,7 +1592,9 @@ const defaultRunner = async (job, onDelta) => {
|
|
|
1581
1592
|
onDelta,
|
|
1582
1593
|
});
|
|
1583
1594
|
// Landed code can be tried.
|
|
1584
|
-
return { landed: result.passed, report: withTryItLine(describeSpecDiff(result), result.passed && result.restructured !== true), story: codeStory(result)
|
|
1595
|
+
return { landed: result.passed, report: withTryItLine(describeSpecDiff(result), result.passed && result.restructured !== true), story: codeStory(result),
|
|
1596
|
+
...(result.specGaps !== undefined ? { specGaps: result.specGaps } : {}),
|
|
1597
|
+
};
|
|
1585
1598
|
};
|
|
1586
1599
|
/** How a code pulse went, for its line in the notes: the rounds it took, its test runs, what the debugger found. */
|
|
1587
1600
|
export function codeStory(result) {
|
|
@@ -1,45 +1,53 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* On a dark surface - turri-dark's abyss, #0a0f1a, pi's dark ones - in the design system's colours alone: a section's
|
|
3
|
+
* header in pink, a concept in neon, text in quotes or backticks in siesta tan. Every colour at least 7:1 on abyss and 4.8:1 on the blue whale fill
|
|
4
|
+
* of an added line; on the eggplant of a removed one, the design system's only fill of that warmth, its pinks and
|
|
5
|
+
* grauzone drop to 3.7:1.
|
|
6
|
+
*/
|
|
2
7
|
const DARK = {
|
|
3
8
|
roles: {
|
|
4
|
-
section: { colour: "#
|
|
5
|
-
concept: { colour: "#
|
|
6
|
-
link: { colour: "#
|
|
7
|
-
literal: { colour: "#
|
|
8
|
-
keyword: { colour: "#
|
|
9
|
-
module: { colour: "#
|
|
10
|
-
comment: { colour: "#
|
|
11
|
-
bullet: { colour: "#
|
|
9
|
+
section: { colour: "#ff7fa6", bold: true },
|
|
10
|
+
concept: { colour: "#5ce1e6" },
|
|
11
|
+
link: { colour: "#f4f7f9", underline: true },
|
|
12
|
+
literal: { colour: "#e9d8c8" },
|
|
13
|
+
keyword: { colour: "#f4f7f9", bold: true },
|
|
14
|
+
module: { colour: "#f4f7f9" },
|
|
15
|
+
comment: { colour: "#85a3b2", italic: true },
|
|
16
|
+
bullet: { colour: "#85a3b2" },
|
|
12
17
|
},
|
|
13
|
-
added: "#
|
|
14
|
-
removed: "#
|
|
15
|
-
addedFill: "#
|
|
16
|
-
removedFill: "#
|
|
17
|
-
muted: "#
|
|
18
|
+
added: "#5ce1e6",
|
|
19
|
+
removed: "#ff7fa6",
|
|
20
|
+
addedFill: "#1e3442",
|
|
21
|
+
removedFill: "#732553",
|
|
22
|
+
muted: "#85a3b2",
|
|
18
23
|
};
|
|
19
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* On a light surface - turri-light's white, pi's light ones - in the design system's deep colours, the only ones it has
|
|
26
|
+
* that read on white. Every colour at least 7:1 on white, and 5:1 on the neon hover and siesta tan fills.
|
|
27
|
+
*/
|
|
20
28
|
const LIGHT = {
|
|
21
29
|
roles: {
|
|
22
|
-
section: { colour: "#
|
|
23
|
-
concept: { colour: "#
|
|
24
|
-
link: { colour: "#
|
|
25
|
-
literal: { colour: "#
|
|
26
|
-
keyword: { colour: "#
|
|
27
|
-
module: { colour: "#
|
|
28
|
-
comment: { colour: "#
|
|
29
|
-
bullet: { colour: "#
|
|
30
|
+
section: { colour: "#3e5a6b", bold: true },
|
|
31
|
+
concept: { colour: "#732553" },
|
|
32
|
+
link: { colour: "#1e3442", underline: true },
|
|
33
|
+
literal: { colour: "#1e3442" },
|
|
34
|
+
keyword: { colour: "#0a0f1a", bold: true },
|
|
35
|
+
module: { colour: "#1e3442" },
|
|
36
|
+
comment: { colour: "#3e5a6b", italic: true },
|
|
37
|
+
bullet: { colour: "#3e5a6b" },
|
|
30
38
|
},
|
|
31
|
-
added: "#
|
|
32
|
-
removed: "#
|
|
33
|
-
addedFill: "#
|
|
34
|
-
removedFill: "#
|
|
35
|
-
muted: "#
|
|
39
|
+
added: "#1e3442",
|
|
40
|
+
removed: "#732553",
|
|
41
|
+
addedFill: "#8eebee",
|
|
42
|
+
removedFill: "#e9d8c8",
|
|
43
|
+
muted: "#3e5a6b",
|
|
36
44
|
};
|
|
37
45
|
const rgb = (hex) => {
|
|
38
46
|
const value = Number.parseInt(hex.slice(1), 16);
|
|
39
47
|
return [(value >> 16) & 255, (value >> 8) & 255, value & 255];
|
|
40
48
|
};
|
|
41
49
|
/** A colour's SGR parameters: 24-bit, or the nearest of the 256 where the terminal has no more. */
|
|
42
|
-
function sgr(hex, background, truecolor) {
|
|
50
|
+
export function sgr(hex, background, truecolor) {
|
|
43
51
|
const [r, g, b] = rgb(hex);
|
|
44
52
|
if (truecolor)
|
|
45
53
|
return `${background ? 48 : 38};2;${r};${g};${b}`;
|
|
@@ -57,17 +65,24 @@ const fillWith = (hex, text, truecolor) => {
|
|
|
57
65
|
return `${on}${text.replace(/\x1b\[(?:0|49)?m/g, (reset) => `${reset}${on}`)}\x1b[49m`;
|
|
58
66
|
};
|
|
59
67
|
/**
|
|
60
|
-
*
|
|
61
|
-
* on
|
|
62
|
-
* to white, 7.34:1 on brand black.
|
|
68
|
+
* Neon, for what is shown to do what its spec says - regen's ◆: the design system's colour for what can be followed,
|
|
69
|
+
* 12.2:1 on abyss. On a light surface, where neon is illegible (1.6:1 on white), blue whale, 12.9:1 on white.
|
|
63
70
|
*/
|
|
64
|
-
export const
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
export const BRAND_NEON = { light: "#1e3442", dark: "#5ce1e6" };
|
|
72
|
+
/**
|
|
73
|
+
* Pink, the one pink thing in a view - the banner's wordmark: 6.54:1 on abyss. On a light surface, where pink is
|
|
74
|
+
* too pale (2.9:1 on white), eggplant, 9.9:1 on white.
|
|
75
|
+
*/
|
|
76
|
+
export const BRAND_PINK = { light: "#732553", dark: "#ff5c8d" };
|
|
77
|
+
const brandInk = (colours) => (theme) => {
|
|
78
|
+
const colour = theme.appearance === "light" ? colours.light : colours.dark;
|
|
68
79
|
const truecolor = (theme.getColorMode?.() ?? "truecolor") === "truecolor";
|
|
69
80
|
return (text) => paintWith({ colour, bold: true }, text, truecolor);
|
|
70
|
-
}
|
|
81
|
+
};
|
|
82
|
+
/** Text in neon on a theme - blue whale on a light one - in as many colours as the terminal has. */
|
|
83
|
+
export const brandNeon = brandInk(BRAND_NEON);
|
|
84
|
+
/** Text in pink on a theme - eggplant on a light one - in as many colours as the terminal has. */
|
|
85
|
+
export const brandPink = brandInk(BRAND_PINK);
|
|
71
86
|
/** How a spec diff is painted on a theme: its palette by whether the theme is dark or light, in as many colours as the terminal has. */
|
|
72
87
|
export function plainPaint(theme) {
|
|
73
88
|
const palette = theme.appearance === "light" ? LIGHT : DARK;
|
|
@@ -281,9 +281,11 @@ export async function renderSpecDiff(options) {
|
|
|
281
281
|
const work = createWorkLedger();
|
|
282
282
|
// What it checks its own work with: the diff its reviewer is shown, and whether a test catches a bug - neither decides anything.
|
|
283
283
|
const gate = createUnitGate(buildDir, scripts.unit);
|
|
284
|
+
// can_it_fail, for the coding agent and its reviewer: on unless mutation-testing says otherwise.
|
|
285
|
+
const mutationTesting = scripts.unit !== undefined && configForSpec(tip.plainFile).mutationTesting !== false;
|
|
284
286
|
const selfChecks = [
|
|
285
287
|
createMyDiffTool({ dir: buildDir, what: "code" }),
|
|
286
|
-
...(
|
|
288
|
+
...(mutationTesting ? [createCanItFailTool({ buildDir, script: scripts.unit })] : []),
|
|
287
289
|
];
|
|
288
290
|
// A server it built, it can start and try from outside - stopped when it is done.
|
|
289
291
|
const services = createServiceTools({ dir: buildDir });
|
|
@@ -499,7 +501,7 @@ export async function renderSpecDiff(options) {
|
|
|
499
501
|
forChange: true,
|
|
500
502
|
...(options.cases !== undefined ? { cases: options.cases } : {}),
|
|
501
503
|
label: `${moduleName} spec change`,
|
|
502
|
-
...(
|
|
504
|
+
...(mutationTesting ? { unitScript: scripts.unit } : {}),
|
|
503
505
|
testingScript: { path: relative(root, scripts.unit), content: readFileSync(scripts.unit, "utf8") },
|
|
504
506
|
model: options.judgeModel ?? modelSpec(inheritModel(configForSpec(tip.plainFile).judgeModel, modelOnly(options.model))),
|
|
505
507
|
send: async (next) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { readFileSync
|
|
2
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { relative, resolve, sep } from "node:path";
|
|
3
3
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { Type } from "typebox";
|
|
5
5
|
import { workDiff } from "./lineage.js";
|
|
6
|
-
import { lastPassingMs, runOnCode } from "./test-scripts.js";
|
|
6
|
+
import { lastPassingMs, runOnCode, scriptsRunInPlace } from "./test-scripts.js";
|
|
7
7
|
/**
|
|
8
8
|
* Tools an agent checks its own work with, before the harness and the reviewer do: the diff the reviewer is shown, and
|
|
9
9
|
* whether a test catches a change to the code. Neither decides anything - the testing scripts, run by the harness, still do.
|
|
@@ -43,16 +43,23 @@ export function canItFailLimitMs(buildDir, script) {
|
|
|
43
43
|
*/
|
|
44
44
|
export function createCanItFailTool(options) {
|
|
45
45
|
let left = options.runs ?? CAN_IT_FAIL_RUNS;
|
|
46
|
+
// In place, the change is made to the code itself for the run, and undone after it: the scripts run on the code there.
|
|
47
|
+
const inPlace = scriptsRunInPlace(options.buildDir);
|
|
46
48
|
return defineTool({
|
|
47
49
|
name: "can_it_fail",
|
|
48
50
|
label: "Can it fail",
|
|
49
51
|
description: "Check that the unit tests catch a bug: give one change to the code that breaks a behaviour the specification " +
|
|
50
52
|
"states - a value or a status changed, a check taken out, a condition turned round where it cannot make a loop run for " +
|
|
51
53
|
"ever - and the unit testing script " +
|
|
52
|
-
|
|
54
|
+
(inPlace
|
|
55
|
+
? "runs with that change made to the code, which is put back as it was once the run ends, whatever its result. "
|
|
56
|
+
: "runs on a copy of the code with that change. The code itself is never touched. ") +
|
|
57
|
+
"The tests should fail; if they all " +
|
|
53
58
|
"pass, no test catches that bug. Make a change that still builds and runs: a failure only because it no longer " +
|
|
54
59
|
`compiles or imports says nothing about the tests. ${options.runs ?? CAN_IT_FAIL_RUNS} runs at most.`,
|
|
55
|
-
promptSnippet: "can_it_fail: whether the unit tests catch a bug you put in
|
|
60
|
+
promptSnippet: "can_it_fail: whether the unit tests catch a bug you put in the code for one run",
|
|
61
|
+
// Never beside another call: in place, an edit made while the bug is in would be undone with it.
|
|
62
|
+
executionMode: "sequential",
|
|
56
63
|
parameters: Type.Object({
|
|
57
64
|
file: Type.String({ description: "The code file to change, relative to the code folder" }),
|
|
58
65
|
find: Type.String({ description: "Text that is in the file exactly once - the code to change" }),
|
|
@@ -83,7 +90,7 @@ export function createCanItFailTool(options) {
|
|
|
83
90
|
left -= 1;
|
|
84
91
|
let run;
|
|
85
92
|
try {
|
|
86
|
-
run = await runOnCode(options.buildDir, options.script, "unit testing script, with the change",
|
|
93
|
+
run = await runOnCode(options.buildDir, options.script, "unit testing script, with the change", { file: relative(options.buildDir, path), text: text.slice(0, at) + replace + text.slice(at + find.length) }, canItFailLimitMs(options.buildDir, options.script));
|
|
87
94
|
}
|
|
88
95
|
catch (error) {
|
|
89
96
|
return say(error instanceof Error ? error.message : String(error));
|
|
@@ -16,7 +16,7 @@ export function createSidePanel(options) {
|
|
|
16
16
|
const backKeys = () => {
|
|
17
17
|
if (options.dock === undefined)
|
|
18
18
|
return [`esc or ${options.key} back to the chat`];
|
|
19
|
-
return options.dock.docked() ? [
|
|
19
|
+
return options.dock.docked() ? [`${options.key} or esc to the chat`, "ctrl+c close", "s full screen"] : ["s beside the chat", `esc or ${options.key} back to the chat`];
|
|
20
20
|
};
|
|
21
21
|
const waitingNote = () =>
|
|
22
22
|
// A question asked while it showed waits in the chat, unanswered: the person is told it is there.
|
|
@@ -52,7 +52,7 @@ export function tabBar(pages, shown, width, style, now) {
|
|
|
52
52
|
const text = `${mark}${tabName(page)}`;
|
|
53
53
|
if (page === shown)
|
|
54
54
|
return style.heading(`[${text}]`);
|
|
55
|
-
return regenerating ? style.accent(text) : page.stuck ? style
|
|
55
|
+
return regenerating ? style.accent(text) : page.stuck ? needs(style)(text) : style.muted(text);
|
|
56
56
|
};
|
|
57
57
|
const tabs = pages.map(label);
|
|
58
58
|
const at = Math.max(0, shown === undefined ? 0 : pages.indexOf(shown));
|
|
@@ -69,6 +69,8 @@ export function tabBar(pages, shown, width, style, now) {
|
|
|
69
69
|
}
|
|
70
70
|
return truncateToWidth(lineOf(from, to), width, "…");
|
|
71
71
|
}
|
|
72
|
+
/** What needs the person - a stuck page, its `!` - in the warning colour: it waits on them, nothing is broken. */
|
|
73
|
+
const needs = (style) => style.warning ?? style.error;
|
|
72
74
|
/** Strike text through. */
|
|
73
75
|
const strike = (text) => `\x1b[9m${text}\x1b[29m`;
|
|
74
76
|
/** How far a group, and what is in it, is indented under its module. */
|
|
@@ -121,7 +123,7 @@ function rungGlyph(rung, style, now) {
|
|
|
121
123
|
if (rung === "conform")
|
|
122
124
|
return green(LADDER.conform);
|
|
123
125
|
if (rung === "needsYou")
|
|
124
|
-
return style
|
|
126
|
+
return needs(style)(LADDER.needsYou);
|
|
125
127
|
if (rung === "takenOut")
|
|
126
128
|
return style.error(LADDER.takenOut);
|
|
127
129
|
if (rung === "toRegenerate")
|
|
@@ -486,7 +488,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
486
488
|
// The first item that needs the person says what for, and how to go about it - opened or closed.
|
|
487
489
|
if (page.stuck && !toldWhy && rungOf(item) === "needsYou") {
|
|
488
490
|
toldWhy = true;
|
|
489
|
-
for (const line of wrapped(needsLine(page), width, style
|
|
491
|
+
for (const line of wrapped(needsLine(page), width, needs(style)))
|
|
490
492
|
add(line, mark);
|
|
491
493
|
}
|
|
492
494
|
if (state.open.has(row.key)) {
|
|
@@ -515,7 +517,9 @@ function paintOf(mark, style) {
|
|
|
515
517
|
return style.success ?? style.added;
|
|
516
518
|
if (mark === "regenerating" || mark === "planning")
|
|
517
519
|
return style.accent;
|
|
518
|
-
if (mark === "stuck"
|
|
520
|
+
if (mark === "stuck")
|
|
521
|
+
return needs(style);
|
|
522
|
+
if (mark === "removed")
|
|
519
523
|
return style.error;
|
|
520
524
|
return style.muted;
|
|
521
525
|
}
|
|
@@ -548,7 +552,7 @@ export function specMapHeader(page, width, style, waiting = "") {
|
|
|
548
552
|
const strip = progressStrip(page, style);
|
|
549
553
|
const count = total > 0 ? `${built} of ${total} ${total === 1 ? "functionality" : "functionalities"} built · ` : "";
|
|
550
554
|
// Short, never cut off: what for, and how, is under the first `!`.
|
|
551
|
-
const status = page.stuck ? style
|
|
555
|
+
const status = page.stuck ? needs(style)(`${LADDER.needsYou} needs you`) : page.status;
|
|
552
556
|
// The module's file heads its column, under this line.
|
|
553
557
|
return truncateToWidth(`${style.heading("regen")}${strip !== "" ? ` ${strip}` : ""} ${count}${status}${waiting}`, width);
|
|
554
558
|
}
|
|
@@ -297,6 +297,10 @@ export function setScriptTimeoutForTests(ms) {
|
|
|
297
297
|
* own paths start - and whether they run on the code in place (the default), rather than on a fresh copy
|
|
298
298
|
* (`testing-scripts-run-on: copy`).
|
|
299
299
|
*/
|
|
300
|
+
/** Whether the testing scripts run on the code in `buildDir` itself, not on a copy of it. */
|
|
301
|
+
export function scriptsRunInPlace(buildDir) {
|
|
302
|
+
return projectOfBuild(buildDir).inPlace;
|
|
303
|
+
}
|
|
300
304
|
function projectOfBuild(buildDir) {
|
|
301
305
|
const parts = resolve(buildDir).split(sep);
|
|
302
306
|
const index = parts.lastIndexOf("plain_modules");
|
|
@@ -401,30 +405,70 @@ const lastPassing = new Map();
|
|
|
401
405
|
export function lastPassingMs(buildDir, script) {
|
|
402
406
|
return lastPassing.get(`${resolve(buildDir)}\n${script}`);
|
|
403
407
|
}
|
|
408
|
+
/** Files changed in place for a run under way, and what each held: put back however the run ends - the process exiting too. */
|
|
409
|
+
const changedInPlace = new Map();
|
|
410
|
+
let restoreOnExit = false;
|
|
411
|
+
function putBack(path) {
|
|
412
|
+
const original = changedInPlace.get(path);
|
|
413
|
+
if (original === undefined)
|
|
414
|
+
return;
|
|
415
|
+
writeFileSync(path, original);
|
|
416
|
+
changedInPlace.delete(path);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* `run` with `change` made to the code itself, and undone once it ends - passed, failed, timed out, thrown, or the process
|
|
420
|
+
* exiting. Killed outright, the change is left: the next unit of work starts from the last commit (lineage.ts startWork).
|
|
421
|
+
*/
|
|
422
|
+
async function withChangeInPlace(buildDir, change, run) {
|
|
423
|
+
const path = resolve(buildDir, change.file);
|
|
424
|
+
if (changedInPlace.has(path))
|
|
425
|
+
throw new Error(`${change.file} is being changed for another run already.`);
|
|
426
|
+
if (!restoreOnExit) {
|
|
427
|
+
restoreOnExit = true;
|
|
428
|
+
process.once("exit", () => {
|
|
429
|
+
for (const changed of [...changedInPlace.keys()])
|
|
430
|
+
putBack(changed);
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
changedInPlace.set(path, readFileSync(path));
|
|
434
|
+
try {
|
|
435
|
+
writeFileSync(path, change.text);
|
|
436
|
+
return await run();
|
|
437
|
+
}
|
|
438
|
+
finally {
|
|
439
|
+
putBack(path);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
404
442
|
/**
|
|
405
|
-
* A script that takes the code folder - the unit testing script - run where the testing scripts
|
|
406
|
-
*
|
|
443
|
+
* A script that takes the code folder - the unit testing script - run where the testing scripts run. `change`: one file
|
|
444
|
+
* as it is for this run - made to the fresh copy, or, in place, to the code itself and undone once the run ends.
|
|
407
445
|
*/
|
|
408
446
|
export async function runOnCode(buildDir, script, what, change,
|
|
409
447
|
/** A time limit of its own, in place of a test run's. */
|
|
410
448
|
limitMs) {
|
|
411
449
|
const project = projectOfBuild(buildDir);
|
|
450
|
+
const passed = (run, started) => {
|
|
451
|
+
if (change === undefined && run.exitCode === 0)
|
|
452
|
+
lastPassing.set(`${resolve(buildDir)}\n${script}`, Date.now() - started);
|
|
453
|
+
return run;
|
|
454
|
+
};
|
|
412
455
|
if (project.inPlace) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
456
|
+
const inPlace = () => runScript(project.root, script, [resolve(buildDir)], buildDir, limitMs !== undefined ? { limitMs } : {});
|
|
457
|
+
const started = Date.now();
|
|
458
|
+
if (change === undefined)
|
|
459
|
+
return passed(await inPlace(), started);
|
|
460
|
+
reportActivity(` changing ${change.file} in place for the ${what} - put back once it has run`);
|
|
461
|
+
return withChangeInPlace(buildDir, change, inPlace);
|
|
416
462
|
}
|
|
417
463
|
const staging = stagingFor(buildDir);
|
|
418
464
|
rmSync(staging.root, { recursive: true, force: true });
|
|
419
465
|
ensureInModulesScratch(buildDir, staging.root);
|
|
420
466
|
try {
|
|
421
467
|
reportActivity(` copying ${stageBuild(buildDir, staging.build)} files of the code for the ${what}`);
|
|
422
|
-
change
|
|
468
|
+
if (change !== undefined)
|
|
469
|
+
writeFileSync(join(staging.build, change.file), change.text);
|
|
423
470
|
const started = Date.now();
|
|
424
|
-
|
|
425
|
-
if (change === undefined && run.exitCode === 0)
|
|
426
|
-
lastPassing.set(`${resolve(buildDir)}\n${script}`, Date.now() - started);
|
|
427
|
-
return run;
|
|
471
|
+
return passed(await runOnCopy(staging.root, script, [staging.build], buildDir, limitMs), started);
|
|
428
472
|
}
|
|
429
473
|
finally {
|
|
430
474
|
rmSync(staging.root, { recursive: true, force: true });
|
|
@@ -96,7 +96,7 @@ export function unitReviewTask(options) {
|
|
|
96
96
|
" assertion so loose any answer passes, an expected value computed the way the code computes it.",
|
|
97
97
|
...(options.canItFail === true
|
|
98
98
|
? [
|
|
99
|
-
"- A test you doubt can fail, check: can_it_fail puts a bug in
|
|
99
|
+
"- A test you doubt can fail, check: can_it_fail puts a bug in the code for one run - a condition turned round, a",
|
|
100
100
|
" value changed - and runs the unit tests on it. A test that still passes cannot fail: raise it as bad, with the",
|
|
101
101
|
` bug it missed. ${REVIEWER_CAN_IT_FAIL_RUNS} runs a session: spend them on the tests the work rests on.`,
|
|
102
102
|
]
|
package/dist/regenerate-cli.js
CHANGED
|
@@ -19,10 +19,15 @@ its conformance tests too when they are on.
|
|
|
19
19
|
--start-over start over, without asking, a codebase regenerated without a module it now requires -
|
|
20
20
|
with no terminal to ask and without it, the run stops there
|
|
21
21
|
--from-scratch delete the module's code and conformance tests (its lineage keeps them) and regenerate all of it
|
|
22
|
+
--from-scratch-chain the same for every module of its requires chain, built again from the bottom - after
|
|
23
|
+
modules were split or moved
|
|
22
24
|
--harness-model <p/id> config.turri.yaml's harness-model for this run: the planner and the conformance chooser
|
|
23
25
|
--coding-model <p/id> its coding-model, --model too: the agents that build; p/id:level for how hard a model thinks
|
|
24
26
|
--judge-model <p/id> its judge-model: the judge and the test review
|
|
25
27
|
--review <true|false> its review: whether the code and its tests are reviewed once they pass
|
|
28
|
+
--mutation-testing <true|false>
|
|
29
|
+
its mutation-testing: whether the coding agent and the reviewer can put a bug in the code
|
|
30
|
+
for one test run (can_it_fail), to see that a test catches it
|
|
26
31
|
--conformance-tests <all|chosen|module|false>
|
|
27
32
|
its conformance-tests: which conformance tests are written and run
|
|
28
33
|
--build-dir <dir> as the run ends, however it ends, export the code there: the furthest-built codebase's
|
|
@@ -31,7 +36,7 @@ its conformance tests too when they are on.
|
|
|
31
36
|
as it starts, as each pulse ends and as it exits (docs/headless.md)
|
|
32
37
|
|
|
33
38
|
PLAIN_TEMPLATE_DIRS colon-separated template directories`;
|
|
34
|
-
const { positional, options } = parseArgs(process.argv.slice(2), ["--dry-run", "--start-over", "--from-scratch"], USAGE, ["--build-dir", "--report", "--conformance-tests", "--harness-model", "--judge-model", "--review"]);
|
|
39
|
+
const { positional, options } = parseArgs(process.argv.slice(2), ["--dry-run", "--start-over", "--from-scratch", "--from-scratch-chain"], USAGE, ["--build-dir", "--report", "--conformance-tests", "--harness-model", "--judge-model", "--review", "--mutation-testing"]);
|
|
35
40
|
const { report, buildDir } = headlessOptions(options, true);
|
|
36
41
|
const named = positional[0] ?? readProjectConfig(process.cwd()).module;
|
|
37
42
|
// Functional specs named after the file: regenerated again though their spec did not change.
|
|
@@ -40,9 +45,10 @@ if (!named) {
|
|
|
40
45
|
console.error(`${USAGE}\n\nNo file given, and ${CONFIG_FILE} names no module.`);
|
|
41
46
|
process.exit(1);
|
|
42
47
|
}
|
|
48
|
+
const scratch = options["from-scratch-chain"] !== undefined ? "chain" : options["from-scratch"] !== undefined ? "module" : undefined;
|
|
43
49
|
// A dry run starts nothing, and from scratch deletes before it plans: the two do not go together.
|
|
44
|
-
if (
|
|
45
|
-
console.error(
|
|
50
|
+
if (scratch !== undefined && options["dry-run"] !== undefined) {
|
|
51
|
+
console.error(`--from-scratch${scratch === "chain" ? "-chain" : ""} deletes the code before anything is planned: it cannot be a dry run.`);
|
|
46
52
|
process.exit(1);
|
|
47
53
|
}
|
|
48
54
|
runLoop({
|
|
@@ -54,8 +60,8 @@ runLoop({
|
|
|
54
60
|
startOver: options["start-over"] !== undefined,
|
|
55
61
|
ask: (loop) => again.length > 0
|
|
56
62
|
? loop.regenerateAgain(named, again)
|
|
57
|
-
:
|
|
58
|
-
? loop.fromScratch(named)
|
|
63
|
+
: scratch !== undefined
|
|
64
|
+
? loop.fromScratch(named, { chain: scratch === "chain" })
|
|
59
65
|
: loop.bringUp(named),
|
|
60
66
|
}).catch((error) => {
|
|
61
67
|
console.error(error instanceof Error ? error.message : error);
|
package/dist/release-cli.js
CHANGED
|
@@ -4,6 +4,7 @@ import { configForSpec, modelSpec, projectModels, readProjectConfig } from "./co
|
|
|
4
4
|
import { createDeployState } from "./release-tools.js";
|
|
5
5
|
import { runReleaseAgent } from "./release-agent.js";
|
|
6
6
|
import { listDeployed, runningDeployed, stopDeployed } from "./regenerate/release.js";
|
|
7
|
+
import { c } from "./module-report.js";
|
|
7
8
|
const USAGE = `usage: turri release [file.plain] [options]
|
|
8
9
|
|
|
9
10
|
Releases the module on top of the spec's requires chain, which holds the code of the ones below, and
|
|
@@ -20,12 +21,6 @@ harness-model (the agent's model).
|
|
|
20
21
|
--in-module <module> the codebase to take, when modules built on this one branch
|
|
21
22
|
--guidance <text> how this project releases it: the scripts to run, in order
|
|
22
23
|
--model <provider/id> the agent's model (default: harness-model)`;
|
|
23
|
-
const c = {
|
|
24
|
-
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
25
|
-
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
26
|
-
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
27
|
-
cyan: (s) => `\x1b[36m${s}\x1b[0m`,
|
|
28
|
-
};
|
|
29
24
|
const PROBLEMS = "If you are having problems, use chat mode to deploy: run turri and ask to try it.";
|
|
30
25
|
function parseArgs(argv) {
|
|
31
26
|
const positional = [];
|
|
@@ -76,7 +71,7 @@ function followLogs() {
|
|
|
76
71
|
closeSync(fd);
|
|
77
72
|
offsets.set(item.log, size);
|
|
78
73
|
for (const line of buffer.toString("utf8").split("\n").filter((l) => l !== ""))
|
|
79
|
-
console.log(`${c.
|
|
74
|
+
console.log(`${c.accent(`[${item.name}]`)} ${line}`);
|
|
80
75
|
}
|
|
81
76
|
if (running.length === 0) {
|
|
82
77
|
clearInterval(timer);
|
|
@@ -119,7 +114,7 @@ async function main() {
|
|
|
119
114
|
console.log(`\n\n${c.dim(PROBLEMS)}`);
|
|
120
115
|
if (runningDeployed().length === 0)
|
|
121
116
|
process.exit(0);
|
|
122
|
-
console.log(c.
|
|
117
|
+
console.log(c.success(c.bold("\nRunning - Ctrl-C stops it.")) + c.dim(" Its output follows.\n"));
|
|
123
118
|
await followLogs();
|
|
124
119
|
process.exit(0);
|
|
125
120
|
}
|