@turri-dev/cli 0.1.4-next.318a98a → 0.1.4-next.4342332

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.
Files changed (100) hide show
  1. package/.pi/themes/turri-dark.json +67 -66
  2. package/.pi/themes/turri-light.json +71 -73
  3. package/README.md +39 -127
  4. package/assets/jellyfish/dark-00.png +0 -0
  5. package/assets/jellyfish/dark-01.png +0 -0
  6. package/assets/jellyfish/dark-02.png +0 -0
  7. package/assets/jellyfish/dark-03.png +0 -0
  8. package/assets/jellyfish/dark-04.png +0 -0
  9. package/assets/jellyfish/dark-05.png +0 -0
  10. package/assets/jellyfish/dark-06.png +0 -0
  11. package/assets/jellyfish/dark-07.png +0 -0
  12. package/assets/jellyfish/dark-08.png +0 -0
  13. package/assets/jellyfish/dark-09.png +0 -0
  14. package/assets/jellyfish/dark-10.png +0 -0
  15. package/assets/jellyfish/dark-11.png +0 -0
  16. package/assets/jellyfish/dark-12.png +0 -0
  17. package/assets/jellyfish/dark-13.png +0 -0
  18. package/assets/jellyfish/dark-14.png +0 -0
  19. package/assets/jellyfish/light-00.png +0 -0
  20. package/assets/jellyfish/light-01.png +0 -0
  21. package/assets/jellyfish/light-02.png +0 -0
  22. package/assets/jellyfish/light-03.png +0 -0
  23. package/assets/jellyfish/light-04.png +0 -0
  24. package/assets/jellyfish/light-05.png +0 -0
  25. package/assets/jellyfish/light-06.png +0 -0
  26. package/assets/jellyfish/light-07.png +0 -0
  27. package/assets/jellyfish/light-08.png +0 -0
  28. package/assets/jellyfish/light-09.png +0 -0
  29. package/assets/jellyfish/light-10.png +0 -0
  30. package/assets/jellyfish/light-11.png +0 -0
  31. package/assets/jellyfish/light-12.png +0 -0
  32. package/assets/jellyfish/light-13.png +0 -0
  33. package/assets/jellyfish/light-14.png +0 -0
  34. package/dist/ask.js +34 -15
  35. package/dist/brand.js +7 -7
  36. package/dist/cli-options.js +12 -6
  37. package/dist/config-edit.js +1 -0
  38. package/dist/config.js +5 -2
  39. package/dist/cultivate-cli.js +16 -23
  40. package/dist/extension.js +41 -29
  41. package/dist/init-config.js +5 -0
  42. package/dist/loop-cli.js +19 -7
  43. package/dist/loop-tools.js +11 -5
  44. package/dist/module-report.js +5 -4
  45. package/dist/pi.js +76 -19
  46. package/dist/question-dialog.js +1 -0
  47. package/dist/regenerate/activity.js +21 -0
  48. package/dist/regenerate/list-arguments.js +121 -0
  49. package/dist/regenerate/loop.js +21 -8
  50. package/dist/regenerate/plain-palette.js +51 -36
  51. package/dist/regenerate/regenerate.js +4 -2
  52. package/dist/regenerate/self-check.js +13 -6
  53. package/dist/regenerate/side-panel.js +1 -1
  54. package/dist/regenerate/spec-map-view.js +9 -5
  55. package/dist/regenerate/test-scripts.js +54 -10
  56. package/dist/regenerate/unit-review.js +1 -1
  57. package/dist/regenerate-cli.js +11 -5
  58. package/dist/release-cli.js +3 -8
  59. package/dist/review/live.js +2 -1
  60. package/dist/run-report.js +39 -1
  61. package/dist/validate-cli.js +3 -8
  62. package/docs/README.md +5 -12
  63. package/docs/authoring-plain.md +37 -119
  64. package/docs/config.md +53 -178
  65. package/docs/deploy.md +21 -80
  66. package/docs/development.md +13 -41
  67. package/docs/headless.md +45 -121
  68. package/docs/images/how-turri-works.svg +29 -31
  69. package/docs/installation.md +13 -40
  70. package/docs/parser.md +15 -43
  71. package/docs/regenerating.md +229 -938
  72. package/docs/sandbox.md +38 -152
  73. package/docs/skills-and-gates.md +50 -171
  74. package/docs/theming.md +45 -46
  75. package/docs/using.md +69 -345
  76. package/genome/rules/bullet-continuation.md +5 -13
  77. package/genome/rules/concise-specs-examples.md +2 -4
  78. package/genome/rules/concise-specs-integration-examples.md +2 -6
  79. package/genome/rules/concise-specs.md +1 -2
  80. package/genome/rules/func-specs.md +1 -0
  81. package/genome/rules/integration-embedded-testing.md +1 -4
  82. package/genome/rules/integrations.md +1 -2
  83. package/genome/rules/project-model.md +14 -35
  84. package/genome/rules/stdlib.md +14 -49
  85. package/genome/rules/turri-regeneration.md +48 -0
  86. package/genome/skills/add-implementation-requirement/SKILL.md +1 -2
  87. package/genome/skills/analyze-if-func-spec-too-complex/SKILL.md +3 -8
  88. package/genome/skills/brood/SKILL.md +37 -127
  89. package/genome/skills/brood/references/intent.md +4 -12
  90. package/genome/skills/brood/references/product.md +24 -76
  91. package/genome/skills/brood/references/stack.md +7 -29
  92. package/genome/skills/brood/references/testing.md +11 -42
  93. package/genome/skills/bud/SKILL.md +32 -109
  94. package/genome/skills/bud/references/intent.md +4 -11
  95. package/genome/skills/implement-conformance-testing-script/SKILL.md +3 -6
  96. package/genome/skills/implement-unit-testing-script/SKILL.md +1 -2
  97. package/genome/skills/mature/SKILL.md +21 -69
  98. package/genome/skills/refactor-module/SKILL.md +24 -2
  99. package/genome/skills/spawn/SKILL.md +28 -113
  100. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
- import { readFileSync, writeFileSync } from "node:fs";
2
- import { join, relative, resolve, sep } from "node:path";
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
- "runs on a copy of the code with that change. The code itself is never touched. The tests should fail; if they all " +
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 a copy of the code",
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", (copy) => writeFileSync(join(copy, relative(options.buildDir, path)), text.slice(0, at) + replace + text.slice(at + find.length)), canItFailLimitMs(options.buildDir, options.script));
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() ? ["s full screen", "esc or ⌥⌘← to the chat", `${options.key} close`] : ["s beside the chat", `esc or ${options.key} back to the chat`];
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.error(text) : style.muted(text);
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.error(LADDER.needsYou);
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.error))
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" || mark === "removed")
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.error(`${LADDER.needsYou} needs you`) : page.status;
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
- * run. `change`: what to do to the fresh copy before it runs - only where there is a copy; never in place.
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
- if (change !== undefined)
414
- throw new Error("This runs only where the testing scripts run on a copy: here they run in place, on the code itself.");
415
- return runScript(project.root, script, [resolve(buildDir)], buildDir);
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?.(staging.build);
468
+ if (change !== undefined)
469
+ writeFileSync(join(staging.build, change.file), change.text);
423
470
  const started = Date.now();
424
- const run = await runOnCopy(staging.root, script, [staging.build], buildDir, limitMs);
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 a copy of the code - a condition turned round, a",
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
  ]
@@ -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 (options["from-scratch"] !== undefined && options["dry-run"] !== undefined) {
45
- console.error("--from-scratch deletes the module's code before anything is planned: it cannot be a dry run.");
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
- : options["from-scratch"] !== undefined
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);
@@ -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.cyan(`[${item.name}]`)} ${line}`);
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.green(c.bold("\nRunning - Ctrl-C stops it.")) + c.dim(" Its output follows.\n"));
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
  }
@@ -79,7 +79,8 @@ export function createLiveReviewer(opts) {
79
79
  pending.push(finding);
80
80
  all.push(finding);
81
81
  }
82
- if (violations.length === 0) {
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) {
@@ -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();
@@ -181,6 +190,32 @@ export function startRunReport(options) {
181
190
  list,
182
191
  };
183
192
  };
193
+ /** The spec gaps the pulses' agents met, in the order the pulses started: questions a person would want to decide. */
194
+ const specGapsOf = (jobs) => jobs.flatMap((job) => {
195
+ const details = job.details;
196
+ return (details?.specGaps ?? []).map((gap) => ({
197
+ module: job.module ?? null,
198
+ pulse: job.pulse ?? null,
199
+ pulse_id: job.id,
200
+ landed: job.status === "succeeded" && details?.landed === true,
201
+ question: gap.question,
202
+ assumption: gap.assumption,
203
+ }));
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
+ }));
184
219
  const functionalitiesOf = (counts) => {
185
220
  if (counts === undefined)
186
221
  return null;
@@ -228,6 +263,7 @@ export function startRunReport(options) {
228
263
  build_dir: options.buildDir !== undefined ? resolve(options.buildDir) : null,
229
264
  conformance_tests: options.conformanceTests,
230
265
  review: options.review ?? null,
266
+ mutation_testing: options.mutationTesting ?? null,
231
267
  models: {
232
268
  ...Object.fromEntries(Object.entries(options.models).map(([role, choice]) => [role, { model: choice.model ?? null, thinking: choice.thinking ?? null }])),
233
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()])),
@@ -245,6 +281,8 @@ export function startRunReport(options) {
245
281
  usage: usageOf(jobs),
246
282
  pulses: pulsesOf(jobs, now),
247
283
  functionalities: functionalitiesOf(attempt(sources.completion)),
284
+ spec_gaps: specGapsOf(jobs),
285
+ turn_incidents: turnIncidentsOf(),
248
286
  ...(exitParts ?? {}),
249
287
  logs: {
250
288
  jobs_dir: fromProject(join(projectRoot, ".turri", "jobs")),
@@ -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.green(line) : line.startsWith("FAIL") ? c.red(line) : c.dim(line))
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.green(c.bold("all specs valid")) : c.red(c.bold(`${failed} of ${results.length} failed`))}`);
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
- this machine.
12
- 2. [Using turri](using.md) - the conversation, the skills and tools, background jobs and
13
- their logs, choosing the model that renders, the command line.
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