@turri-dev/cli 0.1.4-next.fa9223b → 0.1.5-next.6df6879
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 +41 -127
- package/assets/jellyfish/dark-00.png +0 -0
- package/assets/jellyfish/dark-01.png +0 -0
- package/assets/jellyfish/dark-02.png +0 -0
- package/assets/jellyfish/dark-03.png +0 -0
- package/assets/jellyfish/dark-04.png +0 -0
- package/assets/jellyfish/dark-05.png +0 -0
- package/assets/jellyfish/dark-06.png +0 -0
- package/assets/jellyfish/dark-07.png +0 -0
- package/assets/jellyfish/dark-08.png +0 -0
- package/assets/jellyfish/dark-09.png +0 -0
- package/assets/jellyfish/dark-10.png +0 -0
- package/assets/jellyfish/dark-11.png +0 -0
- package/assets/jellyfish/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/brand.js +7 -7
- package/dist/cli-options.js +12 -6
- package/dist/config-edit.js +1 -0
- package/dist/config.js +22 -2
- package/dist/cultivate-cli.js +16 -23
- package/dist/extension.js +128 -108
- package/dist/init-config.js +5 -0
- package/dist/jellyfish.js +130 -0
- package/dist/loop-cli.js +16 -8
- package/dist/loop-tools.js +60 -21
- package/dist/module-report.js +5 -4
- package/dist/pi.js +76 -19
- package/dist/picture-row.js +3 -2
- package/dist/regenerate/activity.js +21 -0
- package/dist/regenerate/jobs.js +10 -5
- package/dist/regenerate/list-arguments.js +121 -0
- package/dist/regenerate/loop.js +66 -43
- package/dist/regenerate/panel-dock.js +7 -5
- 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 +79 -13
- 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 +26 -1
- package/dist/screen-padding.js +72 -0
- package/dist/stacks.js +3 -5
- package/dist/validate-cli.js +3 -8
- package/docs/README.md +5 -12
- package/docs/authoring-plain.md +37 -119
- package/docs/config.md +55 -178
- package/docs/deploy.md +21 -80
- package/docs/development.md +14 -41
- package/docs/headless.md +40 -129
- package/docs/images/how-turri-works.svg +29 -31
- package/docs/images/turri-banner.png +0 -0
- package/docs/images/turri-screenshot.png +0 -0
- package/docs/installation.md +13 -40
- package/docs/parser.md +15 -43
- package/docs/regenerating.md +231 -942
- package/docs/sandbox.md +38 -152
- package/docs/skills-and-gates.md +50 -173
- package/docs/theming.md +45 -46
- package/docs/using.md +68 -344
- 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 +4 -7
- package/genome/skills/implement-unit-testing-script/SKILL.md +2 -3
- package/genome/skills/init-plain-project/SKILL.md +1 -1
- 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
|
@@ -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
|
}
|
|
@@ -2,7 +2,7 @@ import { fixMethod } from "./prompt.js";
|
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { accessSync, constants, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { basename, delimiter, dirname, join, resolve, sep } from "node:path";
|
|
5
|
-
import { CONFIG_FILE, CONFIG_KEYS, projectConfigFile, readProjectConfig, stackConfigFileIn, stackOf } from "../config.js";
|
|
5
|
+
import { CONFIG_FILE, CONFIG_KEYS, projectConfigFile, readProjectConfig, stackConfigFile, stackConfigFileIn, stackOf, stacksOf } from "../config.js";
|
|
6
6
|
import { reportActivity, reportLogNote, reportNote } from "./activity.js";
|
|
7
7
|
import { ensureInModulesScratch, modulesScratchDir } from "./paths.js";
|
|
8
8
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
@@ -85,8 +85,14 @@ export function findTestScripts(root, plainFile, buildDir) {
|
|
|
85
85
|
const stack = stackOf(root);
|
|
86
86
|
const config = readProjectConfig(root, stack);
|
|
87
87
|
const file = stack !== undefined ? `${stackConfigFileIn(root, stack)} (over ${projectConfigFile(root)})` : projectConfigFile(root);
|
|
88
|
-
//
|
|
89
|
-
const
|
|
88
|
+
// A project of stacks with none chosen: its scripts are named in the stacks' files.
|
|
89
|
+
const stacks = stack === undefined ? stacksOf(root) : [];
|
|
90
|
+
// Where a script is named: the stack's file, once one is chosen - in a project of stacks, the one of the stack that builds it.
|
|
91
|
+
const nameIn = stack !== undefined
|
|
92
|
+
? stackConfigFileIn(root, stack)
|
|
93
|
+
: stacks.length > 0
|
|
94
|
+
? "the config.turri.<stack>.yaml of the stack that builds it"
|
|
95
|
+
: `${CONFIG_FILE} - or, for a project of several stacks, the stack's config.turri.<stack>.yaml`;
|
|
90
96
|
if (config.testingScriptsRunOn !== undefined)
|
|
91
97
|
found.runOn = config.testingScriptsRunOn;
|
|
92
98
|
for (const kind of Object.keys(SCRIPT_KEYS)) {
|
|
@@ -139,6 +145,22 @@ export function findTestScripts(root, plainFile, buildDir) {
|
|
|
139
145
|
}
|
|
140
146
|
}
|
|
141
147
|
}
|
|
148
|
+
// A project of stacks, none chosen: the scripts are likely in a stack's file - the note says which, and how to choose it.
|
|
149
|
+
if (stacks.length > 0) {
|
|
150
|
+
for (const kind of Object.keys(SCRIPT_KEYS)) {
|
|
151
|
+
if (found[kind] !== undefined)
|
|
152
|
+
continue;
|
|
153
|
+
const named = stacks.flatMap((each) => {
|
|
154
|
+
const script = kind === "unit" ? readProjectConfig(root, each).unittestsScript : readProjectConfig(root, each).conformanceTestsScript;
|
|
155
|
+
return script !== undefined ? [`${stackConfigFile(each)} names ${script.trim()}`] : [];
|
|
156
|
+
});
|
|
157
|
+
notes[kind] = [
|
|
158
|
+
...(notes[kind] !== undefined ? [notes[kind]] : []),
|
|
159
|
+
`No stack is chosen, so ${CONFIG_FILE} alone is read - this project's stacks are ${stacks.join(", ")}${named.length > 0 ? `, and ${named.join("; ")}` : ""}. ` +
|
|
160
|
+
"Choose the stack that builds this module: stack on regenerate, or /stack, in the chat; --stack <name> on the command line.",
|
|
161
|
+
].join(" ");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
142
164
|
if (Object.keys(notes).length > 0)
|
|
143
165
|
found.notes = notes;
|
|
144
166
|
return found;
|
|
@@ -297,6 +319,10 @@ export function setScriptTimeoutForTests(ms) {
|
|
|
297
319
|
* own paths start - and whether they run on the code in place (the default), rather than on a fresh copy
|
|
298
320
|
* (`testing-scripts-run-on: copy`).
|
|
299
321
|
*/
|
|
322
|
+
/** Whether the testing scripts run on the code in `buildDir` itself, not on a copy of it. */
|
|
323
|
+
export function scriptsRunInPlace(buildDir) {
|
|
324
|
+
return projectOfBuild(buildDir).inPlace;
|
|
325
|
+
}
|
|
300
326
|
function projectOfBuild(buildDir) {
|
|
301
327
|
const parts = resolve(buildDir).split(sep);
|
|
302
328
|
const index = parts.lastIndexOf("plain_modules");
|
|
@@ -401,30 +427,70 @@ const lastPassing = new Map();
|
|
|
401
427
|
export function lastPassingMs(buildDir, script) {
|
|
402
428
|
return lastPassing.get(`${resolve(buildDir)}\n${script}`);
|
|
403
429
|
}
|
|
430
|
+
/** Files changed in place for a run under way, and what each held: put back however the run ends - the process exiting too. */
|
|
431
|
+
const changedInPlace = new Map();
|
|
432
|
+
let restoreOnExit = false;
|
|
433
|
+
function putBack(path) {
|
|
434
|
+
const original = changedInPlace.get(path);
|
|
435
|
+
if (original === undefined)
|
|
436
|
+
return;
|
|
437
|
+
writeFileSync(path, original);
|
|
438
|
+
changedInPlace.delete(path);
|
|
439
|
+
}
|
|
404
440
|
/**
|
|
405
|
-
*
|
|
406
|
-
*
|
|
441
|
+
* `run` with `change` made to the code itself, and undone once it ends - passed, failed, timed out, thrown, or the process
|
|
442
|
+
* exiting. Killed outright, the change is left: the next unit of work starts from the last commit (lineage.ts startWork).
|
|
443
|
+
*/
|
|
444
|
+
async function withChangeInPlace(buildDir, change, run) {
|
|
445
|
+
const path = resolve(buildDir, change.file);
|
|
446
|
+
if (changedInPlace.has(path))
|
|
447
|
+
throw new Error(`${change.file} is being changed for another run already.`);
|
|
448
|
+
if (!restoreOnExit) {
|
|
449
|
+
restoreOnExit = true;
|
|
450
|
+
process.once("exit", () => {
|
|
451
|
+
for (const changed of [...changedInPlace.keys()])
|
|
452
|
+
putBack(changed);
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
changedInPlace.set(path, readFileSync(path));
|
|
456
|
+
try {
|
|
457
|
+
writeFileSync(path, change.text);
|
|
458
|
+
return await run();
|
|
459
|
+
}
|
|
460
|
+
finally {
|
|
461
|
+
putBack(path);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* A script that takes the code folder - the unit testing script - run where the testing scripts run. `change`: one file
|
|
466
|
+
* 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
467
|
*/
|
|
408
468
|
export async function runOnCode(buildDir, script, what, change,
|
|
409
469
|
/** A time limit of its own, in place of a test run's. */
|
|
410
470
|
limitMs) {
|
|
411
471
|
const project = projectOfBuild(buildDir);
|
|
472
|
+
const passed = (run, started) => {
|
|
473
|
+
if (change === undefined && run.exitCode === 0)
|
|
474
|
+
lastPassing.set(`${resolve(buildDir)}\n${script}`, Date.now() - started);
|
|
475
|
+
return run;
|
|
476
|
+
};
|
|
412
477
|
if (project.inPlace) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
478
|
+
const inPlace = () => runScript(project.root, script, [resolve(buildDir)], buildDir, limitMs !== undefined ? { limitMs } : {});
|
|
479
|
+
const started = Date.now();
|
|
480
|
+
if (change === undefined)
|
|
481
|
+
return passed(await inPlace(), started);
|
|
482
|
+
reportActivity(` changing ${change.file} in place for the ${what} - put back once it has run`);
|
|
483
|
+
return withChangeInPlace(buildDir, change, inPlace);
|
|
416
484
|
}
|
|
417
485
|
const staging = stagingFor(buildDir);
|
|
418
486
|
rmSync(staging.root, { recursive: true, force: true });
|
|
419
487
|
ensureInModulesScratch(buildDir, staging.root);
|
|
420
488
|
try {
|
|
421
489
|
reportActivity(` copying ${stageBuild(buildDir, staging.build)} files of the code for the ${what}`);
|
|
422
|
-
change
|
|
490
|
+
if (change !== undefined)
|
|
491
|
+
writeFileSync(join(staging.build, change.file), change.text);
|
|
423
492
|
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;
|
|
493
|
+
return passed(await runOnCopy(staging.root, script, [staging.build], buildDir, limitMs), started);
|
|
428
494
|
}
|
|
429
495
|
finally {
|
|
430
496
|
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
|
}
|
package/dist/review/live.js
CHANGED
|
@@ -79,7 +79,8 @@ export function createLiveReviewer(opts) {
|
|
|
79
79
|
pending.push(finding);
|
|
80
80
|
all.push(finding);
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
// No verdict - its turn stopped before it gave one - clears nothing: the scope is looked at again next pass.
|
|
83
|
+
if (captured !== undefined && violations.length === 0) {
|
|
83
84
|
cleared.push(scope);
|
|
84
85
|
}
|
|
85
86
|
else if (captured?.question) {
|
package/dist/run-report.js
CHANGED
|
@@ -22,6 +22,9 @@ const emptyTotals = () => ({
|
|
|
22
22
|
llm_calls: 0,
|
|
23
23
|
agent_turns: 0,
|
|
24
24
|
compactions: 0,
|
|
25
|
+
provider_retries: 0,
|
|
26
|
+
provider_stalls: 0,
|
|
27
|
+
turns_stopped: 0,
|
|
25
28
|
model_seconds: 0,
|
|
26
29
|
});
|
|
27
30
|
function addUsage(totals, usage) {
|
|
@@ -43,8 +46,14 @@ function addEvent(totals, event, tokens) {
|
|
|
43
46
|
}
|
|
44
47
|
else if (event.kind === "turn")
|
|
45
48
|
totals.agent_turns += 1;
|
|
46
|
-
else
|
|
49
|
+
else if (event.kind === "compaction")
|
|
47
50
|
totals.compactions += 1;
|
|
51
|
+
else if (event.kind === "provider_retry")
|
|
52
|
+
totals.provider_retries += 1;
|
|
53
|
+
else if (event.kind === "provider_stall")
|
|
54
|
+
totals.provider_stalls += 1;
|
|
55
|
+
else
|
|
56
|
+
totals.turns_stopped += 1;
|
|
48
57
|
}
|
|
49
58
|
function sumTotals(a, b) {
|
|
50
59
|
const sum = emptyTotals();
|
|
@@ -193,6 +202,20 @@ export function startRunReport(options) {
|
|
|
193
202
|
assumption: gap.assumption,
|
|
194
203
|
}));
|
|
195
204
|
});
|
|
205
|
+
/** Each request the provider failed and was waited out or stalled on, and each turn turri ended itself: why, and where. */
|
|
206
|
+
const turnIncidentsOf = () => events
|
|
207
|
+
.filter((event) => event.kind === "provider_retry" || event.kind === "provider_stall" || event.kind === "stopped")
|
|
208
|
+
.map((event) => ({
|
|
209
|
+
kind: event.kind,
|
|
210
|
+
pulse_id: event.job ?? null,
|
|
211
|
+
role: event.role ?? null,
|
|
212
|
+
model: event.model ?? null,
|
|
213
|
+
...(event.kind === "stopped"
|
|
214
|
+
? { reason: event.reason ?? null }
|
|
215
|
+
: event.kind === "provider_stall"
|
|
216
|
+
? { silent_seconds: Math.round((event.waitMs ?? 0) / 1000) }
|
|
217
|
+
: { error: event.error ?? null, attempt: event.attempt ?? null, of: event.of ?? null, wait_seconds: Math.round((event.waitMs ?? 0) / 100) / 10 }),
|
|
218
|
+
}));
|
|
196
219
|
const functionalitiesOf = (counts) => {
|
|
197
220
|
if (counts === undefined)
|
|
198
221
|
return null;
|
|
@@ -240,6 +263,7 @@ export function startRunReport(options) {
|
|
|
240
263
|
build_dir: options.buildDir !== undefined ? resolve(options.buildDir) : null,
|
|
241
264
|
conformance_tests: options.conformanceTests,
|
|
242
265
|
review: options.review ?? null,
|
|
266
|
+
mutation_testing: options.mutationTesting ?? null,
|
|
243
267
|
models: {
|
|
244
268
|
...Object.fromEntries(Object.entries(options.models).map(([role, choice]) => [role, { model: choice.model ?? null, thinking: choice.thinking ?? null }])),
|
|
245
269
|
observed: Object.fromEntries([...new Set(events.map((event) => event.role ?? "unknown"))].sort().map((role) => [role, [...new Set(events.filter((event) => (event.role ?? "unknown") === role).map((event) => event.model ?? "unknown"))].sort()])),
|
|
@@ -258,6 +282,7 @@ export function startRunReport(options) {
|
|
|
258
282
|
pulses: pulsesOf(jobs, now),
|
|
259
283
|
functionalities: functionalitiesOf(attempt(sources.completion)),
|
|
260
284
|
spec_gaps: specGapsOf(jobs),
|
|
285
|
+
turn_incidents: turnIncidentsOf(),
|
|
261
286
|
...(exitParts ?? {}),
|
|
262
287
|
logs: {
|
|
263
288
|
jobs_dir: fromProject(join(projectRoot, ".turri", "jobs")),
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { HStack, Spacer, VStack } from "@earendil-works/pi-tui";
|
|
2
|
+
/**
|
|
3
|
+
* Room around the whole of turri's screen: a row above and below, two columns either side - a cell is about twice as
|
|
4
|
+
* tall as it is wide.
|
|
5
|
+
*
|
|
6
|
+
* pi draws its screen one of two ways, and each is padded as it is drawn: full screen (pi's default), a layout - its
|
|
7
|
+
* root put in the middle of blank rows and columns; the regular screen, the lines its render gives - asked for in fewer
|
|
8
|
+
* columns, indented, with blank lines above and below. Overlays are laid over the whole terminal, so one that should
|
|
9
|
+
* keep to the padding is given it as its margin.
|
|
10
|
+
*/
|
|
11
|
+
export const SCREEN_PADDING = { top: 1, right: 2, bottom: 1, left: 2 };
|
|
12
|
+
/** The columns inside the padding. */
|
|
13
|
+
export function paddedColumns(columns) {
|
|
14
|
+
return Math.max(1, columns - SCREEN_PADDING.left - SCREEN_PADDING.right);
|
|
15
|
+
}
|
|
16
|
+
/** The rows inside the padding. */
|
|
17
|
+
export function paddedRows(rows) {
|
|
18
|
+
return Math.max(1, rows - SCREEN_PADDING.top - SCREEN_PADDING.bottom);
|
|
19
|
+
}
|
|
20
|
+
/** Each padded layout root, to what it pads. */
|
|
21
|
+
const content = new WeakMap();
|
|
22
|
+
/** What a layout root pads - the root itself when it is not padded. */
|
|
23
|
+
export function unpadded(root) {
|
|
24
|
+
return content.get(root) ?? root;
|
|
25
|
+
}
|
|
26
|
+
/** A blank column as wide as the padding on its side: the row gives it what it measures. */
|
|
27
|
+
const blankColumns = (columns) => ({ render: () => [" ".repeat(columns)], invalidate() { } });
|
|
28
|
+
function padded(root) {
|
|
29
|
+
const row = new HStack([
|
|
30
|
+
{ component: blankColumns(SCREEN_PADDING.left), basis: SCREEN_PADDING.left },
|
|
31
|
+
{ component: root, basis: 0, grow: 1 },
|
|
32
|
+
{ component: blankColumns(SCREEN_PADDING.right), basis: SCREEN_PADDING.right },
|
|
33
|
+
]);
|
|
34
|
+
const whole = new VStack([
|
|
35
|
+
{ component: new Spacer(SCREEN_PADDING.top), basis: SCREEN_PADDING.top },
|
|
36
|
+
// As pi lays out its own transcript: the rows the padding leaves, whatever it measures.
|
|
37
|
+
{ component: row, basis: 0, grow: 1, minSize: 1 },
|
|
38
|
+
{ component: new Spacer(SCREEN_PADDING.bottom), basis: SCREEN_PADDING.bottom },
|
|
39
|
+
]);
|
|
40
|
+
content.set(whole, root);
|
|
41
|
+
return whole;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* pi's screen drawn inside the padding, from its next frame - and every layout root it is given after, so the chat
|
|
45
|
+
* narrowed beside the docked panel (`narrowChat`) is padded too. Once a screen: pi starts a new one when it changes how
|
|
46
|
+
* it draws, which is padded when it is passed in.
|
|
47
|
+
*/
|
|
48
|
+
export function padScreen(tui) {
|
|
49
|
+
const screen = tui;
|
|
50
|
+
if (screen.turriPadded === true)
|
|
51
|
+
return;
|
|
52
|
+
if (typeof screen.setLayoutRoot === "function") {
|
|
53
|
+
// Full screen before pi has given it its layout: padded at a later frame.
|
|
54
|
+
if (screen.layoutRoot === undefined)
|
|
55
|
+
return;
|
|
56
|
+
screen.turriPadded = true;
|
|
57
|
+
const set = screen.setLayoutRoot;
|
|
58
|
+
screen.setLayoutRoot = function (root) {
|
|
59
|
+
set.call(this, root === undefined ? undefined : padded(unpadded(root)));
|
|
60
|
+
};
|
|
61
|
+
screen.setLayoutRoot(screen.layoutRoot);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
screen.turriPadded = true;
|
|
65
|
+
// Read from the prototype: the screen's own render, not one laid over it.
|
|
66
|
+
const render = Object.getPrototypeOf(tui).render;
|
|
67
|
+
const left = " ".repeat(SCREEN_PADDING.left);
|
|
68
|
+
screen.render = function (width) {
|
|
69
|
+
const lines = render.call(this, paddedColumns(width)).map((line) => `${left}${line}`);
|
|
70
|
+
return [...new Array(SCREEN_PADDING.top).fill(""), ...lines, ...new Array(SCREEN_PADDING.bottom).fill("")];
|
|
71
|
+
};
|
|
72
|
+
}
|
package/dist/stacks.js
CHANGED
|
@@ -7,9 +7,7 @@ import { readdirSync } from "node:fs";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
9
9
|
import { Type } from "typebox";
|
|
10
|
-
import { chooseStack, chosenStack, hasProjectConfig, stackConfigFile, stacksOf } from "./config.js";
|
|
11
|
-
/** The words that choose no stack: the project's config alone. */
|
|
12
|
-
const NONE = ["none", "off", "base", "-"];
|
|
10
|
+
import { chooseStack, chosenStack, hasProjectConfig, NO_STACK, stackConfigFile, stacksOf } from "./config.js";
|
|
13
11
|
/** The stacks of the projects here: the folder's own, and those of the projects one folder down (specs kept in plain/). */
|
|
14
12
|
export function knownStacks(root) {
|
|
15
13
|
const below = (() => {
|
|
@@ -29,7 +27,7 @@ export function knownStacks(root) {
|
|
|
29
27
|
export function switchStack(root, name) {
|
|
30
28
|
const stacks = knownStacks(root);
|
|
31
29
|
const wanted = name?.trim() ?? "";
|
|
32
|
-
if (wanted === "" ||
|
|
30
|
+
if (wanted === "" || NO_STACK.includes(wanted.toLowerCase())) {
|
|
33
31
|
chooseStack(undefined);
|
|
34
32
|
return "No stack chosen: everything is built with the project's config.turri.yaml alone, from now on.";
|
|
35
33
|
}
|
|
@@ -79,7 +77,7 @@ export function registerStacks(pi, cwd) {
|
|
|
79
77
|
"For the session; a pulse already running keeps the stack it started with. Without a name, says the stacks and the one chosen.",
|
|
80
78
|
promptSnippet: "choose the stack - its testing scripts and settings - that everything is built with",
|
|
81
79
|
promptGuidelines: [
|
|
82
|
-
"Switch the stack only when the user asks for it,
|
|
80
|
+
"Switch the stack only when the user asks for it, and say which you chose. To build a part of the project another stack builds - a backend's, a frontend's - pass that stack as stack to regenerate, conform or glimpse instead: it is pinned to that module's pulses, and the session's choice stays as it is.",
|
|
83
81
|
],
|
|
84
82
|
parameters: Type.Object({
|
|
85
83
|
name: Type.Optional(Type.String({ description: "The stack to choose, or none. Omitted: the stacks there are, and the one chosen" })),
|
package/dist/validate-cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { checkPlainTargets, formatCheckResults } from "./plain/check.js";
|
|
2
|
+
import { c } from "./module-report.js";
|
|
2
3
|
const USAGE = `usage: turri validate <file.plain | directory> [options]
|
|
3
4
|
|
|
4
5
|
Validates a ***plain specification statically: parses it, resolves its imports and
|
|
@@ -8,12 +9,6 @@ required modules, and reports every error without rendering anything.
|
|
|
8
9
|
--json machine-readable output
|
|
9
10
|
|
|
10
11
|
PLAIN_TEMPLATE_DIRS colon-separated template directories`;
|
|
11
|
-
const c = {
|
|
12
|
-
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
13
|
-
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
14
|
-
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
15
|
-
red: (s) => `\x1b[31m${s}\x1b[0m`,
|
|
16
|
-
};
|
|
17
12
|
const argv = process.argv.slice(2);
|
|
18
13
|
const templateDirs = [];
|
|
19
14
|
const positional = [];
|
|
@@ -43,10 +38,10 @@ if (json) {
|
|
|
43
38
|
else {
|
|
44
39
|
const output = formatCheckResults(results)
|
|
45
40
|
.split("\n")
|
|
46
|
-
.map((line) => line.startsWith("PASS") ? c.
|
|
41
|
+
.map((line) => line.startsWith("PASS") ? c.success(line) : line.startsWith("FAIL") ? c.error(line) : c.dim(line))
|
|
47
42
|
.join("\n");
|
|
48
43
|
console.log(output);
|
|
49
44
|
const failed = results.filter((r) => !r.ok).length;
|
|
50
|
-
console.log(`\n${failed === 0 ? c.
|
|
45
|
+
console.log(`\n${failed === 0 ? c.success(c.bold("all specs valid")) : c.error(c.bold(`${failed} of ${results.length} failed`))}`);
|
|
51
46
|
}
|
|
52
47
|
process.exit(results.every((r) => r.ok) ? 0 : 1);
|
package/docs/README.md
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
# turri documentation
|
|
2
2
|
|
|
3
|
-
turri implements regenerative software: the \*\*\*plain specs are the durable definition of
|
|
4
|
-
what a system does, and the code is generated from them, validated against them, and regenerated
|
|
5
|
-
as they change. The [project README](../README.md) says why, and how to install and start; these
|
|
6
|
-
pages go into each part.
|
|
3
|
+
turri implements regenerative software: the \*\*\*plain specs are the durable definition of what a system does, and the code is generated from them, validated against them, and regenerated as they change. The [project README](../README.md) says why, and how to install and start; these pages go into each part.
|
|
7
4
|
|
|
8
5
|
## Start here
|
|
9
6
|
|
|
10
|
-
1. [Installation](installation.md) - get a machine ready: `turri doctor`, and what turri needs of
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
3. [Authoring \*\*\*plain](authoring-plain.md) - writing the specs: what a spec is made of, the
|
|
15
|
-
authoring rules, the skills that write and fix specs.
|
|
16
|
-
4. [Rendering](regenerating.md) - turning the specs into code: what each build does, in which order,
|
|
17
|
-
and what has to pass before it moves on.
|
|
7
|
+
1. [Installation](installation.md) - get a machine ready: `turri doctor`, and what turri needs of this machine.
|
|
8
|
+
2. [Using turri](using.md) - the conversation, the skills and tools, background jobs and their logs, choosing the model that renders, the command line.
|
|
9
|
+
3. [Authoring \*\*\*plain](authoring-plain.md) - writing the specs: what a spec is made of, the authoring rules, the skills that write and fix specs.
|
|
10
|
+
4. [Rendering](regenerating.md) - turning the specs into code: what each build does, in which order, and what has to pass before it moves on.
|
|
18
11
|
|
|
19
12
|
## By question
|
|
20
13
|
|