@turri-dev/cli 0.1.3 → 0.1.4-next.172be6f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,7 +27,7 @@ npm install -g @turri-dev/cli # puts `turri` on your PATH
27
27
  turri doctor # checks the machine
28
28
  ```
29
29
 
30
- To work on turri itself, run it from a clone instead - see [installation](docs/installation.md#from-a-clone).
30
+ To follow `main` as it moves, or work on turri itself, run it [from a clone](#from-a-clone) instead.
31
31
 
32
32
  `doctor` checks for Node 22.19+, bash, the OS sandbox and a model provider for pi; in a project, the toolchains its
33
33
  modules need, what its testing scripts run against this machine, and that each model `config.turri.yaml` names
@@ -73,6 +73,27 @@ Rather not install Node and the rest? **turri** also runs in Docker, from one im
73
73
 
74
74
  Choosing models: [models](#models); what to do next: [use](#use).
75
75
 
76
+ ### From a clone
77
+
78
+ In place of the npm package - for the latest of `main`, or to change turri itself:
79
+
80
+ ```bash
81
+ git clone git@github.com:turri-oss/turri.git && cd turri
82
+ npm install
83
+ npm link # puts `turri` on your PATH, pointing at this clone
84
+ turri doctor
85
+ ```
86
+
87
+ The clone runs its TypeScript sources directly, so there is nothing to build. When new commits land:
88
+
89
+ ```bash
90
+ git pull
91
+ npm install # picks up any dependency that changed
92
+ ```
93
+
94
+ A **turri** already running keeps the code it started with - start it again to run what you pulled. More in
95
+ [installation](docs/installation.md#from-a-clone).
96
+
76
97
  ## Why
77
98
 
78
99
  In the age of coding agents, writing code is getting easy. The hard and important part is
package/dist/ask.js CHANGED
@@ -9,6 +9,9 @@ import { PANEL_KEY } from "./regenerate/job-panel.js";
9
9
  export const OTHER_OPTION = "Something else…";
10
10
  export const CHAT_OPTION = "Chat about this";
11
11
  export const DONE_OPTION = "Done — that's all of them";
12
+ /** An option's box in a question of several, ticked and not. */
13
+ export const TICKED = "☑";
14
+ export const UNTICKED = "☐";
12
15
  export const DISMISSED = "The user dismissed the question without answering.";
13
16
  /** How an answer that is no answer starts: the person chose to talk about the question first. */
14
17
  export const CHAT_PREFIX = "The user has not answered this question yet: they chose to talk about it first.";
@@ -107,32 +110,48 @@ export async function runAsk(asked, io) {
107
110
  return choice;
108
111
  }
109
112
  }
110
- // Pick several: keep offering what is left until they say they are done.
111
- const chosen = [];
112
- let remaining = [...options];
113
- while (remaining.length > 0) {
114
- const title = chosen.length === 0 ? request.question : `${request.question} [so far: ${chosen.join(", ")}]`;
115
- const choice = await io.select(title, [...remaining, ...extras, DONE_OPTION], context);
116
- if (choice === undefined)
117
- break;
118
- if (choice === DONE_OPTION)
113
+ // Pick several: every option a box, ticked and unticked as it is chosen, until they say they are done. What they type
114
+ // is one more box, ticked - and can be unticked too. Something else, Chat about this and Done are no boxes.
115
+ const listed = [...options];
116
+ const ticked = new Set();
117
+ const picked = () => listed.filter((option) => ticked.has(option));
118
+ let at = 0;
119
+ for (;;) {
120
+ const rows = listed.map((option) => `${ticked.has(option) ? TICKED : UNTICKED} ${option}`);
121
+ const choice = await io.select(request.question, [...rows, ...extras, DONE_OPTION], context, at);
122
+ if (choice === undefined || choice === DONE_OPTION)
119
123
  break;
120
124
  if (choice === OTHER_OPTION) {
125
+ at = listed.length;
121
126
  const typed = await typeInstead();
122
- if (!typedNothing(typed))
123
- chosen.push(typed.trim());
127
+ if (typedNothing(typed))
128
+ continue;
129
+ const option = typed.trim();
130
+ if (!listed.includes(option))
131
+ listed.push(option);
132
+ ticked.add(option);
133
+ at = listed.indexOf(option);
124
134
  continue;
125
135
  }
126
136
  if (choice === CHAT_OPTION) {
137
+ at = listed.length + extras.indexOf(CHAT_OPTION);
127
138
  const said = await chatAbout();
128
139
  if (typedNothing(said))
129
140
  continue;
130
- return chatAnswer(said, chosen);
141
+ return chatAnswer(said, picked());
131
142
  }
132
- chosen.push(choice);
133
- remaining = remaining.filter((option) => option !== choice);
143
+ // A row, or - where the answer is typed, on the command line - an option by its text, or one more of their own.
144
+ const row = rows.indexOf(choice);
145
+ const option = row !== -1 ? listed[row] : choice.trim();
146
+ if (!listed.includes(option))
147
+ listed.push(option);
148
+ if (ticked.has(option))
149
+ ticked.delete(option);
150
+ else
151
+ ticked.add(option);
152
+ at = listed.indexOf(option);
134
153
  }
135
- return chosen.length > 0 ? chosen.join(", ") : DISMISSED;
154
+ return ticked.size > 0 ? picked().join(", ") : DISMISSED;
136
155
  }
137
156
  /**
138
157
  * While a question is open, what catches ctrl+h on the terminal's input: pi gives an extension's shortcut only the keys
@@ -1,4 +1,4 @@
1
- import { conformanceOption, overrideConfig, reviewOption, splitModelSpec } from "./config.js";
1
+ import { booleanOption, conformanceOption, overrideConfig, splitModelSpec } from "./config.js";
2
2
  /**
3
3
  * The command line of turri's commands: their words, and the options that stand for the config's own keys - kept apart
4
4
  * from the commands that use them, so a light one (doctor) reads them as a regenerate does without loading it.
@@ -51,19 +51,24 @@ export function optionValue(options, name) {
51
51
  }
52
52
  /**
53
53
  * The options that stand for the config's own keys - `--harness-model`, `--coding-model` (`--model`), `--judge-model`
54
- * and, as asked, `--review` and `--conformance-tests` - read as if config.turri.yaml had them, in their place in the
54
+ * and, as asked, `--review`, `--mutation-testing` and `--conformance-tests` - read as if config.turri.yaml had them, in their place in the
55
55
  * order the config resolves them in (overrideConfig): a run, or doctor, with them is the same as one with them in the
56
56
  * file. Exits on a value it cannot read.
57
57
  */
58
58
  export function configKeyOptions(options, take = {}) {
59
+ const flag = (name) => {
60
+ const given = take.review === true ? optionValue(options, name) : undefined;
61
+ const value = given !== undefined ? booleanOption(given) : undefined;
62
+ if (given !== undefined && value === undefined)
63
+ failOption(`--${name} takes true or false, not ${given}`);
64
+ return value;
65
+ };
59
66
  const tests = take.conformance === true ? optionValue(options, "conformance-tests") : undefined;
60
67
  const setting = tests !== undefined ? conformanceOption(tests) : undefined;
61
68
  if (tests !== undefined && setting === undefined)
62
69
  failOption(`--conformance-tests takes all, chosen, module or false, not ${tests}`);
63
- const reviewed = take.review === true ? optionValue(options, "review") : undefined;
64
- const review = reviewed !== undefined ? reviewOption(reviewed) : undefined;
65
- if (reviewed !== undefined && review === undefined)
66
- failOption(`--review takes true or false, not ${reviewed}`);
70
+ const review = flag("review");
71
+ const mutationTesting = flag("mutation-testing");
67
72
  const model = (name, key) => {
68
73
  const spec = optionValue(options, name);
69
74
  return spec !== undefined ? { [key]: splitModelSpec(spec) } : {};
@@ -74,6 +79,7 @@ export function configKeyOptions(options, take = {}) {
74
79
  ...model("judge-model", "judgeModel"),
75
80
  ...(setting !== undefined ? { conformanceTests: setting } : {}),
76
81
  ...(review !== undefined ? { review } : {}),
82
+ ...(mutationTesting !== undefined ? { mutationTesting } : {}),
77
83
  });
78
84
  }
79
85
  function failOption(message) {
@@ -59,6 +59,7 @@ export function settings(rules = []) {
59
59
  { key: "conformance-tests", about: "which functional specs get conformance tests", kind: "choice", options: ["all", "chosen", "module", "false"], unset: "all, where a module has test reqs", effect: "next-plan" },
60
60
  { key: "conformance-budget", about: "under conformance-tests: chosen or module, how many may be chosen - a count or a share", kind: "budget", options: ["10%", "30%", "50%", "5", "10"], unset: "no limit", effect: "next-plan" },
61
61
  { key: "review", about: "whether the code and its tests are reviewed once they pass", kind: "boolean", unset: "true", effect: "next-pulse" },
62
+ { key: "mutation-testing", about: "whether the coding agent and the reviewer can put a bug in the code for one test run (can_it_fail)", kind: "boolean", unset: "true", effect: "next-pulse" },
62
63
  { key: "allow-to-stop-jobs", about: "whether turri stops a running pulse the spec has moved on from", kind: "boolean", unset: "true", effect: "now" },
63
64
  { key: "release-after-pulse", about: "whether every pulse that lands code releases it", kind: "boolean", unset: "false", effect: "next-landing" },
64
65
  { key: "unittests-script", about: "the unit testing script, by path from the project root", kind: "path", unset: "the one run_unittests*.sh found", effect: "next-test-run" },
package/dist/config.js CHANGED
@@ -21,6 +21,7 @@ import { projectDirOf } from "./regenerate/paths.js";
21
21
  * conformance-tests: chosen # all, chosen (those with acceptance tests, and those the chooser picks after each pulse), module (the chooser picks, and plans, once the module is regenerated) or false (default: false)
22
22
  * conformance-budget: 30% # under chosen or module: how many functional specs a module may have chosen, beside those with acceptance tests - a count or a share (default: no limit)
23
23
  * review: false # review the code and its tests once they pass (default: true)
24
+ * mutation-testing: false # give the coding agent and the reviewer can_it_fail (default: true)
24
25
  * allow-to-stop-jobs: false # stop a running job the spec moved on from (default: true)
25
26
  * release-after-pulse: true # release what each pulse lands, as its last stage, before the next pulse (default: false)
26
27
  * rules-off: [integrations] # ***plain rules to leave out of the prompts, by name (default: none)
@@ -331,6 +332,7 @@ export const CONFIG_KEYS = {
331
332
  conformanceTests: "conformance-tests",
332
333
  conformanceBudget: "conformance-budget",
333
334
  review: "review",
335
+ mutationTesting: "mutation-testing",
334
336
  allowToStopJobs: "allow-to-stop-jobs",
335
337
  releaseAfterPulse: "release-after-pulse",
336
338
  unittestsScript: "unittests-script",
@@ -416,8 +418,8 @@ export function overrideConfig(overrides) {
416
418
  export function conformanceOption(value) {
417
419
  return conformanceSetting(value);
418
420
  }
419
- /** `--review <value>`: the config's own, true or false. Undefined for anything else. */
420
- export function reviewOption(value) {
421
+ /** `--review <value>`, `--mutation-testing <value>`: the config's own, true or false. Undefined for anything else. */
422
+ export function booleanOption(value) {
421
423
  const word = value.trim().toLowerCase();
422
424
  return word === "true" ? true : word === "false" ? false : undefined;
423
425
  }
@@ -487,6 +489,7 @@ function readConfigFile(path) {
487
489
  conformanceTests: conformanceSetting(conformance),
488
490
  conformanceBudget: budgetSetting(raw[CONFIG_KEYS.conformanceBudget]),
489
491
  review: typeof raw[CONFIG_KEYS.review] === "boolean" ? raw[CONFIG_KEYS.review] : undefined,
492
+ mutationTesting: typeof raw[CONFIG_KEYS.mutationTesting] === "boolean" ? raw[CONFIG_KEYS.mutationTesting] : undefined,
490
493
  allowToStopJobs: typeof raw[CONFIG_KEYS.allowToStopJobs] === "boolean" ? raw[CONFIG_KEYS.allowToStopJobs] : undefined,
491
494
  releaseAfterPulse: typeof raw[CONFIG_KEYS.releaseAfterPulse] === "boolean" ? raw[CONFIG_KEYS.releaseAfterPulse] : undefined,
492
495
  unittestsScript: text(raw[CONFIG_KEYS.unittestsScript]),
package/dist/extension.js CHANGED
@@ -16,7 +16,7 @@ import { readScript, scriptAgainstMachine, stackOnMachine, toolchainsBlock } fro
16
16
  import { sandboxAvailable, sandboxSummary } from "./regenerate/os-sandbox.js";
17
17
  import { findTestScripts } from "./regenerate/test-scripts.js";
18
18
  import { createAskUserTool } from "./tools.js";
19
- import { asksFromScratch, driftTool, fromWorkingDir, haltTool, loopReply, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, WORKING_DIR_PARAM } from "./loop-tools.js";
19
+ import { asksFromScratch, asksWholeChain, driftTool, fromWorkingDir, haltTool, loopReply, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, WORKING_DIR_PARAM } from "./loop-tools.js";
20
20
  import { createWebTools } from "./regenerate/web.js";
21
21
  import { describeGates, interruptedRun, runSkill } from "./genome.js";
22
22
  import { skillStatus } from "./skill.js";
@@ -41,7 +41,7 @@ import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
41
41
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
42
42
  import { HISTORY_DIR, historyLog, historyShow } from "./regenerate/lineage.js";
43
43
  import { defaultBuildDir } from "./regenerate/paths.js";
44
- import { describeUsage } from "./regenerate/activity.js";
44
+ import { describeTurnIncident, describeUsage, onModelEvent } from "./regenerate/activity.js";
45
45
  import { describeSpecConflict } from "./regenerate/stop-report.js";
46
46
  import { inheritProviders, inheritThinkingLevel } from "./pi.js";
47
47
  import { beginCapture, captureConsole, describeCaptured, dropNoise } from "./quiet.js";
@@ -90,11 +90,12 @@ aside) {
90
90
  // The question, with what the asker gives to read for it - a brief to confirm - above it; what it said of its work
91
91
  // before asking is kept in its record, never put in the dialog.
92
92
  // A dialog of turri's own: a long brief scrolls above the question, and the options always show (question-dialog.ts).
93
- const dialog = (question, context, options) => ctx.ui.custom((tui, theme, _keybindings, done) => {
93
+ const dialog = (question, context, options, selected) => ctx.ui.custom((tui, theme, _keybindings, done) => {
94
94
  const shown = new QuestionDialog({
95
95
  question,
96
96
  ...(context !== undefined ? { context } : {}),
97
97
  ...(options !== undefined ? { options } : {}),
98
+ ...(selected !== undefined ? { selected } : {}),
98
99
  rows: () => tui.terminal.rows,
99
100
  style: { accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text) },
100
101
  done: (answer) => {
@@ -108,7 +109,7 @@ aside) {
108
109
  return shown;
109
110
  });
110
111
  const asking = (asked) => runAsk(asked, {
111
- select: (title, options, context) => dialog(title, context, options),
112
+ select: (title, options, context, at) => dialog(title, context, options, at),
112
113
  input: (title, context) => dialog(title, context),
113
114
  });
114
115
  const bare = { ...request, said: undefined };
@@ -327,6 +328,19 @@ export default function (pi) {
327
328
  };
328
329
  pi.on("agent_end", endTurnCapture);
329
330
  pi.on("agent_settled", endTurnCapture);
331
+ // A pulse's provider failing and waited out, or a turn turri ended itself: said in the chat as it happens - the job
332
+ // panel's activity holds it too, but scrolls by.
333
+ let stopTurnIncidents;
334
+ pi.on("session_start", (_event, ctx) => {
335
+ stopTurnIncidents?.();
336
+ if (!ctx.hasUI)
337
+ return;
338
+ stopTurnIncidents = onModelEvent((event) => {
339
+ const line = describeTurnIncident(event);
340
+ if (line !== undefined)
341
+ ctx.ui.notify(event.job !== undefined ? `${event.job}: ${line}` : line, "warning");
342
+ });
343
+ });
330
344
  // What a turri that was killed left running - its commands' process groups - stopped as this one starts.
331
345
  const orphans = sweepOrphanedGroups();
332
346
  let orphansSaid = orphans === 0;
@@ -548,7 +562,7 @@ export default function (pi) {
548
562
  loopTools: [
549
563
  regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named, work) => jobModel(ctx, work ?? "spec_changes", named, plainFile), wait: () => false }),
550
564
  driftTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx) }),
551
- haltTool({ jobs }),
565
+ haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop }),
552
566
  conformTool({ cwd, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, "spec_changes", named, plainFile), wait: () => false }),
553
567
  ],
554
568
  // The escalation becomes a real dialog in the TUI. Without dialog-capable
@@ -610,7 +624,7 @@ function registerRegenerate(pi, cwd, jobs) {
610
624
  // by the planner: one functional spec at a time, a few together or the whole module in one, as it judges. What
611
625
  // follows the module is guidance for that plan, in the person's words.
612
626
  pi.registerCommand("regenerate", {
613
- description: "Regenerate a module from its spec as it is now, in pulses the planner cuts - named functionalities though they did not change, or all of it from scratch: /regenerate [module | file.plain] [functionality ...] [from scratch] [how to cut the work]",
627
+ description: "Regenerate a module from its spec as it is now, in pulses the planner cuts - named functionalities though they did not change, or all of it from scratch, its whole chain too when asked: /regenerate [module | file.plain] [functionality ...] [from scratch [whole chain]] [how to cut the work]",
614
628
  handler: async (args, ctx) => {
615
629
  const command = `/regenerate ${args.trim()}`.trim();
616
630
  await echoCommand(pi, command);
@@ -652,13 +666,17 @@ function registerRegenerate(pi, cwd, jobs) {
652
666
  }
653
667
  // From scratch - started over, its code deleted - asked in the person's words: confirmed first, as it deletes.
654
668
  const scratch = asksFromScratch(guidance);
669
+ // The whole chain with it - "from scratch, the whole chain" - every module it requires built again from the bottom.
670
+ const chain = scratch && asksWholeChain(guidance);
655
671
  const module = basename(plainFile).replace(/\.plain$/, "");
656
672
  if (scratch && again.length > 0) {
657
673
  say("Name functionalities or ask for it from scratch, not both: from scratch regenerates every one of them.", "warning");
658
674
  return;
659
675
  }
660
676
  if (scratch && ctx.hasUI) {
661
- const agreed = await ctx.ui.confirm(`Regenerate ${module} from scratch?`, `Its code and conformance tests are deleted - committed first, so /lineage ${module} keeps them - and the whole module is regenerated from its spec.`);
677
+ const agreed = await ctx.ui.confirm(chain ? `Regenerate ${module} and its whole chain from scratch?` : `Regenerate ${module} from scratch?`, chain
678
+ ? `The code and conformance tests of ${module} and of every module it requires are deleted - committed first, so /lineage keeps them - and the whole chain is regenerated from its spec, from the bottom.`
679
+ : `Its code and conformance tests are deleted - committed first, so /lineage ${module} keeps them - and the whole module is regenerated from its spec.`);
662
680
  if (!agreed)
663
681
  return;
664
682
  }
@@ -668,14 +686,14 @@ function registerRegenerate(pi, cwd, jobs) {
668
686
  // Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
669
687
  // began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
670
688
  say(scratch
671
- ? `Deleting ${module}'s code, then planning all of it again…`
689
+ ? `Deleting ${module}'s code${chain ? " and its whole chain's" : ""}, then planning all of it again…`
672
690
  : again.length > 0
673
691
  ? `Planning ${module}'s functionalit${again.length === 1 ? "y" : "ies"} ${again.join(", ")} again…`
674
692
  : `Planning ${module}'s pulses…`, "info");
675
693
  await nextFrame();
676
694
  try {
677
695
  const statuses = scratch
678
- ? await loop.fromScratch(plainFile, request)
696
+ ? await loop.fromScratch(plainFile, { ...request, chain })
679
697
  : again.length > 0
680
698
  ? await loop.regenerateAgain(plainFile, again, request)
681
699
  : await loop.bringUp(plainFile, request);
@@ -1419,25 +1437,37 @@ function registerJobTools(pi, jobs, cwd) {
1419
1437
  // The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
1420
1438
  // list, finished jobs included, put in the transcript where it stays.
1421
1439
  pi.registerCommand("halt", {
1422
- description: "Halt a queued or running pulse, or what activate started: /halt [pulse id | activated <name>]",
1440
+ description: "Halt a queued or running pulse, a module's planned pulses, or what activate started: /halt [pulse id | module | activated <name>]",
1423
1441
  handler: async (args, ctx) => {
1424
1442
  if (!ctx.hasUI)
1425
1443
  return;
1426
1444
  const live = jobs.list().filter((job) => job.status === "running" || job.status === "queued");
1427
1445
  const deployed = runningDeployed();
1446
+ const loop = workLoops.get(jobs)?.loop;
1447
+ // A module's planned pulses, one line a module: halting one halts the module.
1448
+ const plannedRows = loop?.planned() ?? [];
1449
+ const planned = [...new Set(plannedRows.map((row) => row.module ?? ""))].filter((module) => module !== "");
1428
1450
  let id = args.trim();
1429
1451
  if (id === "") {
1430
- if (live.length === 0 && deployed.length === 0)
1431
- return ctx.ui.notify("Nothing is regenerating or queued.", "info");
1452
+ if (live.length === 0 && deployed.length === 0 && planned.length === 0)
1453
+ return ctx.ui.notify("Nothing is regenerating, queued or planned.", "info");
1432
1454
  const label = (job) => `${job.id} ${job.status.padEnd(8)} ${pulseName(job)}`;
1433
- const labels = [...live.map(label), ...deployed.map((item) => deployedLabel(item.name, item.url ?? item.command))];
1455
+ const plannedLabel = (module) => {
1456
+ const rows = plannedRows.filter((row) => row.module === module);
1457
+ const waiting = rows.find((row) => row.id.endsWith("-waiting"));
1458
+ return `${module} ${waiting !== undefined ? waiting.summary : `${rows.length} planned`} - halts the module`;
1459
+ };
1460
+ const labels = [...live.map(label), ...planned.map(plannedLabel), ...deployed.map((item) => deployedLabel(item.name, item.url ?? item.command))];
1434
1461
  const picked = await ctx.ui.select("Halt which?", labels);
1435
1462
  const job = live.find((candidate) => picked !== undefined && label(candidate) === picked);
1463
+ const module = planned.find((name) => picked !== undefined && plannedLabel(name) === picked);
1436
1464
  const server = deployed.find((item) => picked !== undefined && deployedLabel(item.name, item.url ?? item.command) === picked);
1437
1465
  if (server !== undefined)
1438
1466
  id = `activated ${server.name}`;
1439
1467
  else if (job !== undefined)
1440
1468
  id = job.id;
1469
+ else if (module !== undefined)
1470
+ id = module;
1441
1471
  else
1442
1472
  return;
1443
1473
  }
@@ -1446,7 +1476,7 @@ function registerJobTools(pi, jobs, cwd) {
1446
1476
  const stopped = await stopDeployed({ name });
1447
1477
  return shownAfterCommand(pi, ctx, `/halt ${id}`, stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running as ${name}.`, "info");
1448
1478
  }
1449
- ctx.ui.notify(stopJob(jobs, id), "info");
1479
+ ctx.ui.notify(stopJob(jobs, id, undefined, loop), "info");
1450
1480
  },
1451
1481
  });
1452
1482
  // Debug mode, for the render agents started from now on - see debug-log.ts.
@@ -2037,6 +2067,7 @@ function registerDeploy(pi, cwd, jobs, state) {
2037
2067
  cwd,
2038
2068
  state,
2039
2069
  jobs,
2070
+ workLoop: () => workLoops.get(jobs)?.loop,
2040
2071
  defaultPlainFile: () => readProjectConfig(cwd).module,
2041
2072
  });
2042
2073
  for (const tool of tools)
package/dist/genome.js CHANGED
@@ -185,7 +185,7 @@ export async function runSkill(opts) {
185
185
  // Built renders were lost with the process; queue what the specs hold that is not built.
186
186
  if (resumed !== undefined && opts.renderQueue !== undefined) {
187
187
  for (const file of plainFilesIn(opts.cwd))
188
- void opts.renderQueue.bringUp(file).catch(() => undefined);
188
+ void opts.renderQueue.bringUp(file, { specChange: true }).catch(() => undefined);
189
189
  }
190
190
  if (liveStep !== undefined && liveProxy !== undefined) {
191
191
  const continuous = liveStep.gate.continuous;
@@ -110,6 +110,7 @@ export function withModels(text, lines) {
110
110
  export const DEFAULTS = {
111
111
  conformanceTests: false,
112
112
  review: false,
113
+ mutationTesting: true,
113
114
  allowToStopJobs: true,
114
115
  releaseAfterPulse: false,
115
116
  testingScriptsRunOn: "in-place",
@@ -143,6 +144,10 @@ export function quickStartConfig(vendor = "other", bedrock) {
143
144
  "# Whether the code and its tests are reviewed once they pass - two reviews at most, the second weighed by the arbiter.",
144
145
  `review: ${DEFAULTS.review}`,
145
146
  "",
147
+ "# Whether the coding agent and the reviewer can put a bug in the code for one run of the unit tests (can_it_fail),",
148
+ "# to see that a test catches it - on a copy of the code, or in place and put back after.",
149
+ `mutation-testing: ${DEFAULTS.mutationTesting}`,
150
+ "",
146
151
  "# Whether turri stops a running pulse the spec has moved on from. false: it lands, the change regenerated on top.",
147
152
  `allow-to-stop-jobs: ${DEFAULTS.allowToStopJobs}`,
148
153
  "",
package/dist/loop-cli.js CHANGED
@@ -4,6 +4,7 @@ import { resolve, sep } from "node:path";
4
4
  import { configForSpec, inheritModel, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, ROLE_THINKING, splitModelSpec, } from "./config.js";
5
5
  import { PACKAGE_ROOT } from "./environment.js";
6
6
  import { c } from "./module-report.js";
7
+ import { describeTurnIncident, onModelEvent } from "./regenerate/activity.js";
7
8
  import { tryItCommand } from "./regenerate/delivery.js";
8
9
  import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
9
10
  import { createJobRegistry, pulseName } from "./regenerate/jobs.js";
@@ -51,6 +52,7 @@ export async function runLoop(options) {
51
52
  ...(buildDir !== undefined ? { buildDir } : {}),
52
53
  conformanceTests: conformanceLabel(project.conformanceTests),
53
54
  review: project.review === true,
55
+ mutationTesting: project.mutationTesting !== false,
54
56
  models: reportModels(project, model),
55
57
  })
56
58
  : undefined;
@@ -85,9 +87,19 @@ async function runLoopReporting(options) {
85
87
  console.log(`${mark} ${job.id} ${pulseName(job)} - ${job.status}`);
86
88
  if (job.status !== "succeeded")
87
89
  console.log(c.dim((job.announce ?? job.report ?? job.error ?? "").trim()));
90
+ // Its report is not printed when it succeeds, and nobody is asked here: the spec gaps its agents met are said.
91
+ else
92
+ for (const gap of job.details?.specGaps ?? [])
93
+ console.log(c.yellow(` spec gap: ${gap.question}`), c.dim(`Meanwhile: ${gap.assumption}`));
88
94
  report?.write();
89
95
  },
90
96
  });
97
+ // A provider failing and waited out, a turn turri ended itself: said as they happen, not left in the job logs alone.
98
+ onModelEvent((event) => {
99
+ const line = describeTurnIncident(event);
100
+ if (line !== undefined)
101
+ console.log(c.yellow(` ${event.job !== undefined ? `${event.job}: ` : ""}${line}`));
102
+ });
91
103
  const planner = modelSpec(projectModels(project).harness);
92
104
  const loop = createWorkLoop({
93
105
  registry,
@@ -236,7 +248,7 @@ function reportModels(project, model) {
236
248
  }
237
249
  /**
238
250
  * The options every command that regenerates takes for a headless run: `--report` and `--build-dir`, and the config's
239
- * own keys (configKeyOptions) - `--harness-model`, `--coding-model` (`--model`), `--judge-model`, `--review` and, where
251
+ * own keys (configKeyOptions) - `--harness-model`, `--coding-model` (`--model`), `--judge-model`, `--review`, `--mutation-testing` and, where
240
252
  * `conformance` is true, `--conformance-tests` - read as if config.turri.yaml had them. Exits on a value it cannot read.
241
253
  */
242
254
  export function headlessOptions(options, conformance) {
@@ -70,7 +70,11 @@ export async function loopReply(loop, statuses, wait) {
70
70
  return { content: [{ type: "text", text }], details: { jobIds } };
71
71
  }
72
72
  /** Halt a pulse by its id, or the start of it: what it was, and what moves up behind it. `reason`: why, kept with it. */
73
- export function stopJob(jobs, named, reason) {
73
+ export function stopJob(jobs, named, reason, loop) {
74
+ // A planned row, or a module by its name: the module is halted - its rows are planned again from the spec each look.
75
+ const module = /^planned-/.test(named.trim()) || !jobs.list().some((job) => job.id.startsWith(named.trim())) ? loop?.halt(named, reason) : undefined;
76
+ if (module !== undefined)
77
+ return module;
74
78
  const matches = jobs.list().filter((job) => job.id.startsWith(named.trim()));
75
79
  if (matches.length === 0)
76
80
  return `No pulse ${named}. /pulses shows them.`;
@@ -106,6 +110,10 @@ function plainFileOf(cwd, given, what) {
106
110
  export function asksFromScratch(words) {
107
111
  return FROM_SCRATCH.test(words);
108
112
  }
113
+ /** Whether a /regenerate asking for its module from scratch asks for its whole requires chain with it. */
114
+ export function asksWholeChain(words) {
115
+ return /\bchain\b|\bevery module\b|\ball (the )?modules\b/i.test(words);
116
+ }
109
117
  const FROM_SCRATCH = /\b(from (scratch|nothing|zero|the (start|beginning|ground up))|start(ing)? (it )?(over|afresh)|afresh|anew|clean slate|(delete|wipe|remove|drop|throw away)\b.{0,30}\b(module|code|codebase|everything|all of it))/i;
110
118
  /** regenerate: regenerate a module's code up to its spec as it is now. */
111
119
  export function regenerateTool(options) {
@@ -127,6 +135,7 @@ export function regenerateTool(options) {
127
135
  "A change to a file the spec links - an API surface, a mapping document - is a change to the spec: regenerate sees it by itself, and regenerates every functional spec that uses what links it.",
128
136
  "Never stop pulses and start them again yourself to follow a spec change: regenerate does it.",
129
137
  "Set from_scratch only when the user asks for the module to be regenerated from scratch - started over, its code deleted - in this conversation, or agrees to it when a module's status says it has to start over: never to fix a pulse that did not land.",
138
+ 'from_scratch "module" takes out the code where the module is built; the modules below keep theirs, and the module starts from a copy of the code below it. "chain" takes out every codebase of its requires chain, the base\'s too, and builds all of it again from the bottom: use it after modules were split, merged or moved (refactor-module), or when the user asks for the whole chain.',
130
139
  ],
131
140
  parameters: Type.Object({
132
141
  plain_file: Type.Optional(Type.String({ description: "Path to the .plain file. Omitted: the module the project's config.turri.yaml names" })),
@@ -135,8 +144,9 @@ export function regenerateTool(options) {
135
144
  functionalities: Type.Optional(Type.Array(Type.String(), {
136
145
  description: "Functional specs already built, by id, to regenerate though their spec did not change. Omitted: what the spec now differs from the code in",
137
146
  })),
138
- from_scratch: Type.Optional(Type.Boolean({
139
- description: "Only when the user asks for it: the module's code and conformance tests deleted - committed first, so its lineage keeps them - and the whole module regenerated from its spec",
147
+ from_scratch: Type.Optional(Type.Union([Type.Literal("module"), Type.Literal("chain")], {
148
+ description: "Only when the user asks for it: the module's code and conformance tests deleted - committed first, so its lineage keeps them - and the whole module regenerated from its spec. " +
149
+ '"chain": every module of its requires chain too, built again from the bottom',
140
150
  })),
141
151
  model: MODEL_PARAM,
142
152
  wait: WAIT_PARAM,
@@ -147,15 +157,15 @@ export function regenerateTool(options) {
147
157
  if (!check.ok)
148
158
  throw new Error(`${relative(options.cwd, plainFile) || plainFile} does not parse, so nothing can be regenerated from it yet: ${check.error}`);
149
159
  const again = given.functionalities ?? [];
150
- if (again.length > 0 && given.from_scratch === true)
160
+ if (again.length > 0 && given.from_scratch !== undefined)
151
161
  throw new Error("Name functionalities or set from_scratch, not both: from scratch regenerates every one of them.");
152
162
  // Named functionalities are work on functionalities, as engine chooses a model for it; the rest, spec changes.
153
163
  const work = again.length > 0 ? "functionalities" : "spec_changes";
154
164
  const model = options.model !== undefined ? options.model(ctx, plainFile, given.model, work) : given.model;
155
165
  const loop = options.loop(ctx);
156
166
  const request = { ...(model !== undefined ? { model } : {}), ...(given.guidance !== undefined ? { guidance: given.guidance } : {}) };
157
- const statuses = given.from_scratch === true
158
- ? await loop.fromScratch(plainFile, request)
167
+ const statuses = given.from_scratch !== undefined
168
+ ? await loop.fromScratch(plainFile, { ...request, chain: given.from_scratch === "chain" })
159
169
  : again.length > 0
160
170
  ? await loop.regenerateAgain(plainFile, again, request)
161
171
  : await loop.bringUp(plainFile, request);
@@ -188,7 +198,7 @@ export function driftTool(options) {
188
198
  }
189
199
  const ACTIVATED_PARAM = Type.Optional(Type.String({ description: 'What activate started, by name - or "all" for every one' }));
190
200
  const HALT_PULSE_PARAMS = Type.Object({
191
- job_id: Type.Optional(Type.String({ description: "The pulse's id, or the start of it" })),
201
+ job_id: Type.Optional(Type.String({ description: "The pulse's id, or the start of it; a planned row's id (planned-<module>-...), or a module's name, halts the module" })),
192
202
  reason: Type.Optional(Type.String({ description: "Why it is halted, kept with it - what the spec now says that it did not, say" })),
193
203
  activated: ACTIVATED_PARAM,
194
204
  });
@@ -201,12 +211,21 @@ export function haltTool(options) {
201
211
  name: "halt",
202
212
  label: "Halt",
203
213
  description: jobs !== undefined
204
- ? "Halt a pulse, or what activate started. A pulse: a queued one never starts, a running one has its agent stopped at once, " +
205
- "and the pulses queued behind it move up - what a running pulse already changed is rolled back, and what it was regenerating " +
206
- "counts as not regenerated. What activate started: the one named, or every one."
214
+ ? "Halt a pulse, a module's planned pulses, or what activate started. A pulse: a queued one never starts, a running one has its " +
215
+ "agent stopped at once, and the pulses queued behind it move up - what a running pulse already changed is rolled back, and what " +
216
+ "it was regenerating counts as not regenerated. A planned row (planned-<module>-...) or a module's name halts the module: its " +
217
+ "running pulse stopped, none of its planned pulses started, and the modules built on it waiting - until it is asked for again " +
218
+ "with regenerate; a spec change does not start it. A module whose .plain file is gone is dropped. What activate started: the " +
219
+ "one named, or every one."
207
220
  : "Stop what activate started: the one named, or every one.",
208
221
  promptSnippet: jobs !== undefined ? "halt a pulse, or what activate started" : "stop a deployed server, or all of them",
209
- promptGuidelines: jobs !== undefined ? ["Halt a pulse only when the user asks, or your instructions say to. Name which one, and say which pulses were queued behind it - they will now run."] : [],
222
+ promptGuidelines: jobs !== undefined
223
+ ? [
224
+ "Halt a pulse only when the user asks, or your instructions say to. Name which one, and say which pulses were queued behind it - they will now run.",
225
+ "Halting a planned row halts its whole module - one planned pulse cannot be taken out alone, as the plan is made again from the spec. To build some of it later, or cut it differently, use steer; to drop work, change the spec.",
226
+ "A planned row for a module that is no longer in the project is halted the same way, and dropped.",
227
+ ]
228
+ : [],
210
229
  parameters: (jobs !== undefined ? HALT_PULSE_PARAMS : HALT_ACTIVATED_PARAMS),
211
230
  async execute(_id, params) {
212
231
  if (params.job_id === undefined && params.activated === undefined) {
@@ -214,7 +233,7 @@ export function haltTool(options) {
214
233
  }
215
234
  const lines = [];
216
235
  if (params.job_id !== undefined && jobs !== undefined)
217
- lines.push(stopJob(jobs, params.job_id, params.reason));
236
+ lines.push(stopJob(jobs, params.job_id, params.reason, options.workLoop?.()));
218
237
  if (params.activated !== undefined) {
219
238
  const stopped = await stopDeployed(params.activated === "all" ? {} : { name: params.activated });
220
239
  lines.push(stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running${params.activated === "all" ? "" : ` as ${params.activated}`}.`);