@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.bc1fc47

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 (112) hide show
  1. package/README.md +3 -3
  2. package/dist/chat-idle.d.ts +2 -2
  3. package/dist/chat-idle.js +2 -2
  4. package/dist/chats.d.ts +0 -10
  5. package/dist/chats.js +0 -23
  6. package/dist/cli.js +5 -7
  7. package/dist/config-edit.js +1 -3
  8. package/dist/config.d.ts +20 -22
  9. package/dist/config.js +49 -22
  10. package/dist/conform-cli.js +13 -2
  11. package/dist/conformance-switch.d.ts +7 -17
  12. package/dist/conformance-switch.js +24 -46
  13. package/dist/drift-cli.js +1 -1
  14. package/dist/extension.d.ts +8 -10
  15. package/dist/extension.js +188 -242
  16. package/dist/genome.js +9 -48
  17. package/dist/graph.js +3 -5
  18. package/dist/host-session.d.ts +4 -15
  19. package/dist/host-session.js +2 -4
  20. package/dist/host.d.ts +1 -3
  21. package/dist/host.js +1 -4
  22. package/dist/identity.js +0 -1
  23. package/dist/init-config.d.ts +0 -1
  24. package/dist/init-config.js +2 -9
  25. package/dist/installed-providers.d.ts +1 -1
  26. package/dist/installed-providers.js +1 -1
  27. package/dist/loop-cli.d.ts +4 -3
  28. package/dist/loop-cli.js +13 -11
  29. package/dist/loop-tools.d.ts +28 -5
  30. package/dist/loop-tools.js +87 -22
  31. package/dist/new-project.js +2 -2
  32. package/dist/pi-launch.js +1 -1
  33. package/dist/pi.js +9 -6
  34. package/dist/plain/check.d.ts +1 -8
  35. package/dist/plain/check.js +3 -38
  36. package/dist/regenerate/activity.d.ts +0 -7
  37. package/dist/regenerate/activity.js +2 -20
  38. package/dist/regenerate/agent-shell.js +3 -1
  39. package/dist/regenerate/audit.js +9 -0
  40. package/dist/regenerate/cases.js +7 -0
  41. package/dist/regenerate/chunk-plan.d.ts +5 -0
  42. package/dist/regenerate/chunk-plan.js +16 -1
  43. package/dist/regenerate/drift.d.ts +4 -0
  44. package/dist/regenerate/drift.js +26 -6
  45. package/dist/regenerate/failure-reports.d.ts +28 -0
  46. package/dist/regenerate/failure-reports.js +79 -0
  47. package/dist/regenerate/job-panel.js +3 -1
  48. package/dist/regenerate/jobs-tree.js +1 -1
  49. package/dist/regenerate/jobs.d.ts +2 -0
  50. package/dist/regenerate/jobs.js +4 -0
  51. package/dist/regenerate/ledger-view.d.ts +11 -24
  52. package/dist/regenerate/ledger-view.js +14 -60
  53. package/dist/regenerate/ledger.d.ts +1 -14
  54. package/dist/regenerate/ledger.js +1 -1
  55. package/dist/regenerate/loop.d.ts +46 -60
  56. package/dist/regenerate/loop.js +277 -116
  57. package/dist/regenerate/records.d.ts +11 -0
  58. package/dist/regenerate/records.js +15 -0
  59. package/dist/regenerate/regenerate.d.ts +0 -2
  60. package/dist/regenerate/regenerate.js +4 -15
  61. package/dist/regenerate/renames.js +4 -4
  62. package/dist/regenerate/requires.d.ts +7 -0
  63. package/dist/regenerate/requires.js +24 -18
  64. package/dist/regenerate/spec-map.js +3 -3
  65. package/dist/regenerate/standing.js +1 -1
  66. package/dist/regenerate/submit-work.d.ts +2 -0
  67. package/dist/regenerate/submit-work.js +8 -3
  68. package/dist/regenerate/testing-steps.d.ts +11 -0
  69. package/dist/regenerate/testing-steps.js +22 -3
  70. package/dist/regenerate-cli.js +18 -9
  71. package/dist/self-invocation.d.ts +11 -0
  72. package/dist/self-invocation.js +33 -7
  73. package/dist/sentinel.js +8 -5
  74. package/dist/skill.d.ts +0 -11
  75. package/dist/skill.js +0 -9
  76. package/dist/stacks.js +1 -1
  77. package/dist/tools.js +2 -3
  78. package/dist/turri-versions.js +2 -1
  79. package/docs/README.md +0 -2
  80. package/docs/authoring-plain.md +3 -3
  81. package/docs/chats.md +1 -3
  82. package/docs/config.md +11 -13
  83. package/docs/deploy.md +1 -1
  84. package/docs/development.md +2 -3
  85. package/docs/headless.md +6 -4
  86. package/docs/hosting.md +6 -6
  87. package/docs/parser.md +2 -2
  88. package/docs/regenerating.md +21 -13
  89. package/docs/sentinel.md +4 -4
  90. package/docs/skills-and-gates.md +4 -8
  91. package/docs/using.md +13 -21
  92. package/genome/rules/test-plain-files.md +15 -7
  93. package/genome/rules/turri-regeneration.md +4 -8
  94. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  95. package/package.json +1 -1
  96. package/dist/advisor-chat.d.ts +0 -63
  97. package/dist/advisor-chat.js +0 -290
  98. package/dist/change-plain-cli.d.ts +0 -1
  99. package/dist/change-plain-cli.js +0 -55
  100. package/dist/ledger-cli.d.ts +0 -1
  101. package/dist/ledger-cli.js +0 -50
  102. package/dist/ledger-tools.d.ts +0 -10
  103. package/dist/ledger-tools.js +0 -64
  104. package/dist/regenerate/advisor-records.d.ts +0 -93
  105. package/dist/regenerate/advisor-records.js +0 -110
  106. package/dist/regenerate/advisor-runs.d.ts +0 -87
  107. package/dist/regenerate/advisor-runs.js +0 -327
  108. package/dist/regenerate/test-advisor.d.ts +0 -101
  109. package/dist/regenerate/test-advisor.js +0 -379
  110. package/dist/spec-tools.d.ts +0 -36
  111. package/dist/spec-tools.js +0 -128
  112. package/docs/test-advisor.md +0 -110
@@ -9,16 +9,16 @@ import { llmChunkAgents, MAX_LINES_PER_JOB, MAX_SPECS_PER_JOB, planChunks, steps
9
9
  import { commitNotes, landWork, recordHistory, resetToLastCommit } from "./lineage.js";
10
10
  import { firstLine, record } from "./ledger.js";
11
11
  import { NOTES_FILE, recordPulse } from "./notes.js";
12
- import { createJobRegistry, formatDuration } from "./jobs.js";
12
+ import { formatDuration } from "./jobs.js";
13
13
  import { moduleLanes } from "./lanes.js";
14
- import { adoptDigests, chainTree, codeTree, conformanceTarget, marksRegenerateAgain, REGENERATE_AGAIN, inheritedRecord, isOldRecord, notBuilt, readRecord, RECORD_FILE, withResourceDigests, writeCodeRecord, writeTestsRecord, hasScenarios, identityOf, testedFuncIds, } from "./records.js";
14
+ import { adoptDigests, chainTree, codeTree, conformanceTarget, CONFORM_AGAIN, marksTestsAgain, REGENERATE_AGAIN, inheritedRecord, isOldRecord, notBuilt, readRecord, RECORD_FILE, withResourceDigests, writeCodeRecord, writeTestsRecord, hasScenarios, identityOf, testedFuncIds, } from "./records.js";
15
15
  import { describeSpecDiffConformance, renderSpecDiffConformance } from "./conform.js";
16
16
  import { conformanceDirFor } from "./conformance.js";
17
17
  import { modulesRoot, projectRootOf } from "./paths.js";
18
- import { configForSpec, stackForModule, stackPinned, testDirOf, withStack } from "../config.js";
18
+ import { configForSpec, stackForModule, testDirOf, withStack } from "../config.js";
19
19
  import { describeSpecChange } from "./prompt.js";
20
20
  import { resolveTemplateDirs } from "./paths.js";
21
- import { builtTips, copyRequiredCode, importingModules, isImportModule, newlyRequired, resolveRequiresChain, startFromScratch } from "./requires.js";
21
+ import { builtTips, copyRequiredCode, copyRequiredTests, importingModules, isImportModule, newlyRequired, resolveRequiresChain, startFromScratch } from "./requires.js";
22
22
  import { describeSpecDiff, renderSpecDiff, specFilesOf } from "./regenerate.js";
23
23
  import { locateDiffLines } from "./diff-view.js";
24
24
  import { agentChanges, changeDiffInFiles } from "./change-view.js";
@@ -28,12 +28,12 @@ import { changesBetween, parseTree, serializeTree } from "./spec-steps.js";
28
28
  import { hasFiles } from "./testing.js";
29
29
  import { makeRenames, pureRenames, renameText } from "./renames.js";
30
30
  import { casesOf, codeWork, stillWanted, whyNotWanted } from "./drift.js";
31
- import { testingGap } from "./testing-steps.js";
31
+ import { stepsToScenarios, testingGap } from "./testing-steps.js";
32
32
  import { baseFolderDrift, baseOfCodebase, seedFromBaseFolder } from "./base-folder.js";
33
33
  import { BASE_RECORD_FILE } from "./paths.js";
34
34
  import { onScriptRunEnded, scriptBeingWritten } from "./scripts-being-written.js";
35
35
  import { conformanceTestsOn } from "../conformance-switch.js";
36
- import { findTestScripts, projectRootFor } from "./test-scripts.js";
36
+ import { projectRootFor } from "./test-scripts.js";
37
37
  /** What is left to regenerate, as the conversation and the command line read it. */
38
38
  export function describeDrift(reports) {
39
39
  if (reports.length === 0)
@@ -208,8 +208,9 @@ export function codebaseCompletion(chain) {
208
208
  codebase.forEach((entry, index) => {
209
209
  const count = counts[index];
210
210
  const completed = entry.funcIds.filter((funcId) => !touched.has(`${entry.moduleName}:${funcId}`));
211
- // Tests marked to regenerate again were written against code since replaced: not conformance tested until rewritten.
212
- const tested = ownItems(testsRecord ?? undefined, entry.moduleName, entry.moduleName === tip.moduleName).filter((item) => item.id !== undefined && !marksRegenerateAgain(item) && reads(item) === specText(entry.moduleName, item.id));
211
+ // Tests marked to regenerate again were written against code since replaced, and those marked to be written again
212
+ // are to be written anew: not conformance tested until rewritten.
213
+ const tested = ownItems(testsRecord ?? undefined, entry.moduleName, entry.moduleName === tip.moduleName).filter((item) => item.id !== undefined && !marksTestsAgain(item) && reads(item) === specText(entry.moduleName, item.id));
213
214
  count.completed = completed.length;
214
215
  count.tested = completed.filter((funcId) => tested.some((item) => item.id === funcId));
215
216
  count.conformanceTested = count.tested.length;
@@ -294,13 +295,14 @@ export function createWorkLoop(options) {
294
295
  return testingGap({ moduleName: tip.moduleName, plainFile: tip.plainFile, tree: spec.tree, buildDir: tip.buildDir });
295
296
  };
296
297
  /**
297
- * Whether a codebase lacks a testing script of this kind that is being written in the background now: it waits for it,
298
- * rather than fail for want of it, and is looked at again once the run ends.
298
+ * Whether a testing script of this kind is being written for a codebase now - one it lacks, or one written over: it waits
299
+ * for it, rather than fail for want of it or run against the old one, and is looked at again once the run ends.
299
300
  */
300
301
  const awaitsScript = (state, kind) => {
301
302
  const tip = tipEntry(state);
302
303
  const root = projectRootFor(tip.plainFile, tip.buildDir);
303
- return scriptBeingWritten(root, kind, stackForModule(tip.plainFile)) && findTestScripts(root, tip.plainFile, tip.buildDir)[kind] === undefined;
304
+ // Lacking the script, or with one being written over: a pulse started now would run without it, or against the old one.
305
+ return scriptBeingWritten(root, kind, stackForModule(tip.plainFile));
304
306
  };
305
307
  /**
306
308
  * The base folder a codebase started from, as its status says it. Counting the files still there looks at each, and the
@@ -353,15 +355,96 @@ export function createWorkLoop(options) {
353
355
  }
354
356
  return narrowed;
355
357
  };
356
- /** The functional specs conform named - its own module's func-ids - and every functional spec as it reads now, to tell a change to one after. */
357
- const namedOnly = (state, funcIds) => {
358
+ /**
359
+ * The functional specs conform named - func-ids of `module` - and every functional spec as it reads now, to tell a
360
+ * change to one after. In a codebase built on `module`, they are among the functional specs it requires.
361
+ */
362
+ const namedOnly = (state, funcIds, module) => {
358
363
  const tree = chainSpec(state.chain).tree;
359
364
  const read = new Map();
360
365
  for (const section of [FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS]) {
361
366
  for (const item of tree[section] ?? [])
362
367
  read.set(identityOf(item), JSON.stringify(item));
363
368
  }
364
- return { specs: new Set(funcIds.map((id) => identityOf({ id }))), read };
369
+ const own = tipEntry(state).moduleName === module;
370
+ return { specs: new Set(funcIds.map((id) => identityOf(own ? { id } : { id, module }))), read };
371
+ };
372
+ /**
373
+ * Conformance tests written already, to be written again as conform names them - their code untouched: the functional
374
+ * specs named, func-ids of `self`, marked in the tests record of every codebase where its code lives - the tips of its
375
+ * chains, whose suite holds the chain's tests, among the functional specs required there for a module below - each
376
+ * committed. Refused while a pulse runs in one it marks. Says which functional specs were marked.
377
+ */
378
+ const conformAgain = (file, self, funcIds) => {
379
+ const codebases = [...new Map(chainsFor(file).map(tipOf).map((entry) => [entry.buildDir, entry])).values()];
380
+ // What is marked, worked out before anything is: a codebase that has none of them is not touched, nor refused.
381
+ const touching = codebases.flatMap((entry) => {
382
+ const testsDir = conformanceDirFor(entry.moduleName, modulesRoot(projectDirOf(entry.plainFile)));
383
+ const tests = readRecord(testsDir);
384
+ if (tests === null)
385
+ return [];
386
+ const section = entry.moduleName === self.moduleName ? FUNCTIONAL_REQUIREMENTS : REQUIRED_FUNCTIONAL_SPECS;
387
+ const items = tests[section] ?? [];
388
+ const funcIdOf = (item) => (section === FUNCTIONAL_REQUIREMENTS || item.module === self.moduleName ? (item.id ?? "") : "");
389
+ const taken = items.flatMap((item) => (funcIds.includes(funcIdOf(item)) ? [funcIdOf(item)] : []));
390
+ if (taken.length === 0)
391
+ return [];
392
+ const marked = items.map((item) => (funcIds.includes(funcIdOf(item)) ? { ...item, [CONFORM_AGAIN]: true } : item));
393
+ return [{ entry, testsDir, taken, record: { ...tests, [section]: marked } }];
394
+ });
395
+ for (const { entry } of touching) {
396
+ if (modules.get(entry.buildDir)?.running !== undefined)
397
+ throw new Error(`${entry.moduleName} has a pulse running: halt it, or ask again once it is done. Nothing was started.`);
398
+ }
399
+ const found = new Set();
400
+ for (const { entry, testsDir, taken, record } of touching) {
401
+ writeTestsRecord(testsDir, record);
402
+ recordHistory(entry.buildDir, `the conformance tests of ${namesOf(self.moduleName, taken)} to write again`);
403
+ for (const funcId of taken)
404
+ found.add(funcId);
405
+ const state = modules.get(entry.buildDir);
406
+ if (state === undefined)
407
+ continue;
408
+ state.conformancePlan = undefined;
409
+ state.conformanceHalted = undefined;
410
+ }
411
+ return [...found];
412
+ };
413
+ /**
414
+ * A module's conformance tests from scratch, where its code lives - the tip of each chain it is built in, as
415
+ * `fromScratch` regenerates its code there, never a codebase in the middle - the code untouched: each tip's tests folder
416
+ * taken out whole, committed so its history keeps it; then, `fromBelow`, the tests of the module the tip requires copied
417
+ * in, as the codebase started from them - its own tests written anew on them, those it inherits brought up to date.
418
+ * Without, nothing: every functional spec of the chain is written anew there. Nothing below a tip is touched. Refused
419
+ * while a pulse runs in one. Says which codebases' tests were taken out.
420
+ */
421
+ const testsFromScratch = (file, fromBelow) => {
422
+ const chains = chainsFor(file);
423
+ const tips = [...new Map(chains.map((chain) => [tipOf(chain).buildDir, chain])).values()].flatMap((chain) => {
424
+ const tip = tipOf(chain);
425
+ const testsDir = conformanceDirFor(tip.moduleName, modulesRoot(projectDirOf(tip.plainFile)));
426
+ // Nothing built and no tests: there is nothing to start again - they are written once the code is.
427
+ return started(tip) || existsSync(testsDir) ? [{ chain, tip, testsDir }] : [];
428
+ });
429
+ for (const { tip } of tips) {
430
+ if (modules.get(tip.buildDir)?.running !== undefined)
431
+ throw new Error(`${tip.moduleName} has a pulse running: halt it, or ask again once it is done. Nothing was started.`);
432
+ }
433
+ for (const { chain, tip, testsDir } of tips) {
434
+ rmSync(testsDir, { recursive: true, force: true });
435
+ const below = fromBelow ? chain.find((entry) => entry.moduleName === tip.requires) : undefined;
436
+ if (below !== undefined)
437
+ copyRequiredTests(below.buildDir, tip.buildDir, below.moduleName);
438
+ const why = below !== undefined ? `asked to be written again from scratch, starting from ${below.moduleName}'s` : "asked to be written again from scratch, with its whole chain's";
439
+ recordHistory(tip.buildDir, `conformance tests from scratch: ${why}`);
440
+ reportActivity(` ${tip.moduleName}: its conformance tests are taken out${below !== undefined ? `, and ${below.moduleName}'s copied in` : ""} - ${why}`);
441
+ const state = modules.get(tip.buildDir);
442
+ if (state === undefined)
443
+ continue;
444
+ state.conformancePlan = undefined;
445
+ state.conformanceHalted = undefined;
446
+ }
447
+ return tips.map(({ tip }) => tip.moduleName);
365
448
  };
366
449
  /** The work of a track, from where it is built from to what it is to be - for the conformance tests, as conform narrowed them unless `narrowed` is false. */
367
450
  const workOf = (track, from, state, spec, narrowed = true) => track === "code" ? codeWork(from, spec.tree) : changesBetween(serializeTree(from), serializeTree(conformanceOf(state, spec, from, narrowed)));
@@ -486,20 +569,18 @@ export function createWorkLoop(options) {
486
569
  options.registry.notify?.();
487
570
  }
488
571
  };
489
- /** A dry run's first jobs, by codebase: what each would start. */
490
- const firsts = new Map();
491
572
  const startJob = (state, spec, from, planned) => {
492
573
  // Halted while it was being planned: the plan is made, nothing starts.
493
574
  if (state.held !== undefined) {
494
575
  state.why = state.held.why;
495
576
  return;
496
577
  }
497
- const tip = tipEntry(state);
498
- if (options.dryRun === true) {
499
- firsts.set(tip.buildDir, { spec: planned.track === "conformance" ? spec : { ...spec, tree: planned.step.tree }, planned });
500
- state.why = `would start: ${planned.title}`;
578
+ // Looked ahead: the plan is kept, and its first pulse waits for the module to be asked for.
579
+ if (state.lookedAhead === true) {
580
+ state.why = LOOKED_AHEAD;
501
581
  return;
502
582
  }
583
+ const tip = tipEntry(state);
503
584
  const conformance = planned.track === "conformance";
504
585
  // A code job can be steered while it regenerates: its target moves with the spec, inside what it regenerates.
505
586
  const steering = conformance ? undefined : createSteering(planned.step.tree, tip.moduleName);
@@ -718,8 +799,8 @@ export function createWorkLoop(options) {
718
799
  * nothing running there - so the code is taken to be built from them, rather than everything linking one built again.
719
800
  */
720
801
  const hashResources = (state, spec) => {
721
- // A dry run only reads.
722
- if (options.dryRun === true)
802
+ // A look ahead only reads.
803
+ if (state.lookedAhead === true)
723
804
  return;
724
805
  const code = tipEntry(state).buildDir;
725
806
  for (const dir of [code, testsDirOf(state)]) {
@@ -749,11 +830,15 @@ export function createWorkLoop(options) {
749
830
  };
750
831
  // A testing script written in the background, or not: what waited for it is looked at again - started, or failed for want of it.
751
832
  onScriptRunEnded(() => {
752
- if (asked.size > 0 && options.dryRun !== true)
833
+ if (asked.size > 0 || ahead.size > 0)
753
834
  void tick();
754
835
  });
755
836
  /** The files asked for, each with how: what the loop brings up, worked out again each look. */
756
837
  const asked = new Map();
838
+ /** The files looked ahead at and not asked for since: their codebases are looked at, their pulses held. */
839
+ const ahead = new Map();
840
+ /** The codebases a look ahead is planning now: the only looks that plan a codebase held for one. */
841
+ const planningAhead = new Set();
757
842
  /**
758
843
  * The modules asked for whose plan is not made yet - their code being deleted, what is left being worked out, the
759
844
  * planner not started - by name, with since when: each shows as being planned from the moment it is asked for, not
@@ -776,10 +861,13 @@ export function createWorkLoop(options) {
776
861
  options.registry.notify?.();
777
862
  }
778
863
  };
779
- /** The codebases the requests bring up now - where each module's code lives, and what is to be built on it. */
780
- const active = () => {
864
+ /**
865
+ * The codebases the requests bring up now - where each module's code lives, and what is to be built on it - those
866
+ * asked for and, unless `requests` names others, those looked ahead at.
867
+ */
868
+ const active = (requests = [...asked, ...ahead]) => {
781
869
  const states = new Set();
782
- for (const [file, request] of asked) {
870
+ for (const [file, request] of requests) {
783
871
  let chains;
784
872
  try {
785
873
  chains = chainsFor(file);
@@ -805,6 +893,9 @@ export function createWorkLoop(options) {
805
893
  for (const file of [...asked.keys()])
806
894
  if (!existsSync(file))
807
895
  asked.delete(file);
896
+ for (const file of [...ahead.keys()])
897
+ if (!existsSync(file))
898
+ ahead.delete(file);
808
899
  for (const key of [...order]) {
809
900
  const state = modules.get(key);
810
901
  if (state.running === undefined && !existsSync(tipEntry(state).plainFile))
@@ -853,14 +944,6 @@ export function createWorkLoop(options) {
853
944
  }
854
945
  const specKey = keyOf(spec);
855
946
  state.seen = spec;
856
- if (options.onSpec !== undefined) {
857
- try {
858
- options.onSpec({ chain: state.chain, tree: spec.tree, built: builtOf(state) });
859
- }
860
- catch {
861
- /* what watches the spec never stops the loop */
862
- }
863
- }
864
947
  if (state.running !== undefined) {
865
948
  if (state.running.stopping === true)
866
949
  return;
@@ -947,8 +1030,10 @@ export function createWorkLoop(options) {
947
1030
  // A func-id or a scenario-id renamed, and nothing else with it: turri renames it in the records and relabels the tests
948
1031
  // itself, as one unit of work - no pulse, the code untouched. Failing, it is rolled back whole, and the codebase halts
949
1032
  // rather than build the functional spec anew.
950
- const renamed = options.dryRun === true || readRecord(tip.buildDir) === null ? undefined : pureRenames(readRecord(tip.buildDir), readRecord(testsDirOf(state)), spec.tree, tip.moduleName);
951
- if (renamed !== undefined && renamed.renames.length > 0) {
1033
+ // Looked ahead, they are not made - a look ahead writes nothing - and the code is planned from as they would leave it.
1034
+ const renamed = readRecord(tip.buildDir) === null ? undefined : pureRenames(readRecord(tip.buildDir), readRecord(testsDirOf(state)), spec.tree, tip.moduleName);
1035
+ const pending = state.lookedAhead === true && renamed !== undefined && renamed.renames.length > 0 && renamed.code !== null ? renamed.code : undefined;
1036
+ if (renamed !== undefined && renamed.renames.length > 0 && state.lookedAhead !== true) {
952
1037
  const made = makeRenames({ buildDir: tip.buildDir, testsDir: testsDirOf(state), moduleName: tip.moduleName, renamed, place: { project: projectRootOf(tip.buildDir), module: tip.moduleName } });
953
1038
  if (!made) {
954
1039
  state.halted = { why: `renaming ${renamed.renames.map(renameText).join(", ")} failed, and was rolled back - it is tried again once the spec changes, or the module is asked for again`, specKey };
@@ -959,8 +1044,10 @@ export function createWorkLoop(options) {
959
1044
  }
960
1045
  // The module's code first, every job of it; then its conformance tests - once, for the module as built, with one
961
1046
  // explorer and one run of the whole suite - and only then is anything built on it (waitingOn).
962
- const from = builtOf(state);
1047
+ const from = pending !== undefined ? codeTree(pending) : builtOf(state);
963
1048
  const codeLeft = codeWork(from, spec.tree).length > 0;
1049
+ // Held for a look ahead, a codebase is planned by a look ahead alone: a plan that no longer fits is dropped, not made again.
1050
+ const mayPlan = state.lookedAhead !== true || planningAhead.has(state);
964
1051
  if (state.conformanceHalted !== undefined && state.conformanceHalted.key !== conformanceKey(state))
965
1052
  state.conformanceHalted = undefined;
966
1053
  if (!codeLeft && conformanceWanted(state, spec) && state.conformanceHalted === undefined) {
@@ -971,6 +1058,11 @@ export function createWorkLoop(options) {
971
1058
  // Made again when the spec, the tests or the code it was planned against moved: what the tests are written for
972
1059
  // follows the code, and a plan made before a code pulse landed would test it as it was.
973
1060
  if (existing === undefined || existing.specKey !== specKey || existing.from !== testedKey || existing.codeKey !== codeKeyOf(state) || existing.jobs.length === 0) {
1061
+ if (!mayPlan) {
1062
+ state.conformancePlan = undefined;
1063
+ state.why = LOOK_AGAIN;
1064
+ return;
1065
+ }
974
1066
  state.conformancePlan = { specKey, from: testedKey, codeKey: codeKeyOf(state), jobs: (await planIdle(state, spec, tested, "conformance")).jobs };
975
1067
  }
976
1068
  const next = state.conformancePlan.jobs[0];
@@ -1000,6 +1092,11 @@ export function createWorkLoop(options) {
1000
1092
  const fromKey = serializeTree(from);
1001
1093
  const steeringKey = steeringKeyOf(state);
1002
1094
  if (state.plan === undefined || state.plan.specKey !== specKey || state.plan.from !== fromKey || state.plan.steeringKey !== steeringKey || state.plan.jobs.length === 0) {
1095
+ if (!mayPlan) {
1096
+ state.plan = undefined;
1097
+ state.why = LOOK_AGAIN;
1098
+ return;
1099
+ }
1003
1100
  const { jobs, notes } = await planIdle(state, spec, from, "code");
1004
1101
  state.plan = { specKey, from: fromKey, steeringKey, jobs, notes };
1005
1102
  if (jobs.length === 0) {
@@ -1015,6 +1112,17 @@ export function createWorkLoop(options) {
1015
1112
  startJob(state, spec, from, state.plan.jobs[0]);
1016
1113
  };
1017
1114
  const statusOf = (state) => describe(state).status;
1115
+ /** A planned row's codebase and its place there, from its id - `planned-<module>-N`, the longest module name it starts with, as a name may hold a hyphen. */
1116
+ const rowOf = (rowId) => {
1117
+ const state = order
1118
+ .map((key) => modules.get(key))
1119
+ .filter((candidate) => rowId.startsWith(`planned-${tipEntry(candidate).moduleName}-`))
1120
+ .sort((a, b) => tipEntry(b).moduleName.length - tipEntry(a).moduleName.length)[0];
1121
+ if (state === undefined)
1122
+ return undefined;
1123
+ const rest = rowId.slice(`planned-${tipEntry(state).moduleName}-`.length);
1124
+ return /^[1-9]\d*$/.test(rest) ? { state, index: Number(rest) } : undefined;
1125
+ };
1018
1126
  /** The modules asked for that the loop holds nothing of yet - turri just opened, say: their code being planned all the same. */
1019
1127
  const preparingAlone = () => {
1020
1128
  const held = new Set(order.map((key) => tipEntry(modules.get(key)).moduleName));
@@ -1104,9 +1212,9 @@ export function createWorkLoop(options) {
1104
1212
  };
1105
1213
  /**
1106
1214
  * Look after a codebase - its chain up to it - from now on; says its state. `pin`: its stack is worked out again - its
1107
- * tip's (`stackForModule`) - unless `keep`, and it has one: a spec change keeps the stack it was asked for with.
1215
+ * tip's (`stackForModule`).
1108
1216
  */
1109
- const track = (chain, askedFile, request, pin) => {
1217
+ const track = (chain, askedFile, request, pin = false) => {
1110
1218
  const tip = tipOf(chain);
1111
1219
  let state = modules.get(tip.buildDir);
1112
1220
  if (state === undefined) {
@@ -1121,9 +1229,7 @@ export function createWorkLoop(options) {
1121
1229
  }
1122
1230
  state.chain = chain;
1123
1231
  state.askedFile = askedFile;
1124
- // Kept only when it is a stack: a module pinned to none - built before its stack's file was there - takes its own.
1125
- const keep = pin?.keep === true && !stackPinned() && state.stack?.name !== undefined;
1126
- if (pin !== undefined && !keep)
1232
+ if (pin)
1127
1233
  state.stack = { name: stackForModule(tip.plainFile) };
1128
1234
  // Its model as its stack has it: a stack's file can name a coding model of its own.
1129
1235
  const model = request.model ?? inStack(state, () => options.modelFor?.(tip.plainFile));
@@ -1135,29 +1241,92 @@ export function createWorkLoop(options) {
1135
1241
  };
1136
1242
  const loop = {
1137
1243
  async bringUp(plainFile, given = {}) {
1138
- const now = async () => {
1139
- const { specChange, ...request } = given;
1244
+ // Asked for, it shows as being planned at once.
1245
+ return preparingFor(plainFile, async () => {
1140
1246
  const files = codebasesOf(resolve(options.cwd, plainFile));
1141
- for (const file of files)
1142
- asked.set(file, { ...asked.get(file), ...request });
1247
+ for (const file of files) {
1248
+ asked.set(file, { ...ahead.get(file), ...asked.get(file), ...given });
1249
+ ahead.delete(file);
1250
+ }
1143
1251
  // Asked for, it is built with its stack - the one the call names, its own, or the one chosen now - pinned, whatever
1144
- // is chosen later; a spec change keeps the one it was asked for with.
1145
- const pin = { keep: specChange === true };
1146
- const states = withParseCache(() => files.flatMap((file) => chainsFor(file).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, request, pin)))));
1147
- // Asked again, a halted codebase is tried again - one the person halted too, unless only its spec changed.
1252
+ // is chosen later.
1253
+ const states = withParseCache(() => files.flatMap((file) => chainsFor(file).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, given, true)))));
1254
+ // Asked again, a halted codebase is tried again - one the person halted too. Looked ahead at, its kept plan starts.
1148
1255
  for (const state of states) {
1149
1256
  state.halted = undefined;
1150
- if (specChange !== true)
1151
- state.held = undefined;
1257
+ state.held = undefined;
1258
+ state.lookedAhead = undefined;
1152
1259
  // Asked for again: its conformance tests are written for every functional spec with scenarios, not only those conform named.
1153
- if (specChange !== true)
1154
- state.conformanceOnly = undefined;
1260
+ state.conformanceOnly = undefined;
1155
1261
  }
1156
1262
  await tick();
1157
1263
  return [...new Set(states)].map(statusOf);
1158
- };
1159
- // Asked for, it shows as being planned at once; a spec change is looked at quietly, as every change is.
1160
- return given.specChange === true ? now() : preparingFor(plainFile, now);
1264
+ });
1265
+ },
1266
+ async lookAhead(plainFile, given = {}) {
1267
+ // Being planned, it shows so at once; what is planned is said once it is - not as being planned.
1268
+ const states = await preparingFor(plainFile, async () => {
1269
+ const files = codebasesOf(resolve(options.cwd, plainFile));
1270
+ for (const file of files)
1271
+ if (!asked.has(file))
1272
+ ahead.set(file, { ...ahead.get(file), ...given });
1273
+ // Its stack pinned as an ask pins it: the plan is made, and its pulses run, with the stack regenerate would use.
1274
+ const tracked = withParseCache(() => files.flatMap((file) => chainsFor(file).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, given, true)))));
1275
+ // A chain with a pulse running is being built as asked, and goes on; every other codebase is held - one asked for
1276
+ // earlier too, which would otherwise start the work the look ahead plans.
1277
+ const building = (state) => state.chain.some((entry) => modules.get(entry.buildDir)?.running !== undefined);
1278
+ for (const state of tracked) {
1279
+ if (!building(state))
1280
+ state.lookedAhead = true;
1281
+ planningAhead.add(state);
1282
+ }
1283
+ try {
1284
+ await tick();
1285
+ }
1286
+ finally {
1287
+ for (const state of tracked)
1288
+ planningAhead.delete(state);
1289
+ }
1290
+ return tracked;
1291
+ });
1292
+ return [...new Set(states)].map(statusOf);
1293
+ },
1294
+ async plannedPulse(rowId) {
1295
+ const found = rowOf(rowId);
1296
+ if (found === undefined)
1297
+ return undefined;
1298
+ const { state, index } = found;
1299
+ const { status, jobs } = describe(state);
1300
+ const entry = status.planned[index - 1];
1301
+ if (entry === undefined)
1302
+ return undefined;
1303
+ const tip = tipEntry(state);
1304
+ const pulse = { id: rowId, module: tip.moduleName, plainFile: tip.plainFile, title: entry.title, track: entry.track, cases: entry.cases, index, lookedAhead: state.lookedAhead === true };
1305
+ const job = jobs[index - 1];
1306
+ const why = (text) => ({ ...pulse, why: text });
1307
+ if (entry.planning === true)
1308
+ return why("It is being planned now: its prompt is built once the plan is made.");
1309
+ if (entry.afterCode === true || job === undefined)
1310
+ return why("It is not planned yet: the conformance tests are planned into pulses once the module's code is built, and their prompt is built from that code.");
1311
+ if (state.running !== undefined)
1312
+ return why(`Pulse ${state.running.jobId} is running in this codebase: what this pulse is given depends on what that one lands.`);
1313
+ if (index > 1)
1314
+ return why(`It follows ${index - 1} planned pulse${index === 2 ? "" : "s"} here: its prompt depends on what ${index === 2 ? "that one lands" : "they land"}, and is built when it starts.`);
1315
+ if (job.track === "conformance")
1316
+ return why("A conformance pulse's prompt is built from what the code it tests holds once it is built: it is not shown before.");
1317
+ // The plan as kept, and only while it fits the ***plain and the steering as they are now - else regenerate would plan again.
1318
+ let spec;
1319
+ try {
1320
+ spec = chainSpec(state.chain);
1321
+ }
1322
+ catch (error) {
1323
+ return why(`Its ***plain does not parse now: ${error instanceof Error ? error.message : String(error)}`);
1324
+ }
1325
+ if (state.plan === undefined || !state.plan.jobs.includes(job) || state.plan.specKey !== keyOf(spec) || state.plan.steeringKey !== steeringKeyOf(state)) {
1326
+ return why("The ***plain or the steering changed since it was planned: regenerate would plan it again. Look ahead again to see the new plan.");
1327
+ }
1328
+ const task = await inStack(state, () => promptOf({ plainFile: tip.plainFile, spec: { ...spec, tree: job.step.tree }, planned: job }));
1329
+ return task !== undefined ? { ...pulse, task } : why("It has no prompt to show.");
1161
1330
  },
1162
1331
  async regenerateAgain(plainFile, given, request = {}) {
1163
1332
  return preparingFor(plainFile, async () => {
@@ -1271,7 +1440,8 @@ export function createWorkLoop(options) {
1271
1440
  },
1272
1441
  async conformance(plainFile, request = {}) {
1273
1442
  const file = resolve(options.cwd, plainFile);
1274
- asked.set(file, { ...asked.get(file), ...(request.model !== undefined ? { model: request.model } : {}) });
1443
+ asked.set(file, { ...ahead.get(file), ...asked.get(file), ...(request.model !== undefined ? { model: request.model } : {}) });
1444
+ ahead.delete(file);
1275
1445
  const own = resolveRequiresChain(file, [], undefined, { allowNoFunctionalities: true });
1276
1446
  const self = tipOf(own);
1277
1447
  // What the person asks for comes first. Its tests are written in its own codebase, before anything is built on it:
@@ -1280,14 +1450,24 @@ export function createWorkLoop(options) {
1280
1450
  // it has, nothing is touched.
1281
1451
  if (!conformanceTestsOn(self.plainFile)) {
1282
1452
  throw new Error(`Conformance tests are off for ${self.moduleName} (conformance-tests: false, or unset): nothing is conformance tested. ` +
1283
- "They are turned on in the chat - by asking for them - or with conformance-tests: true in config.turri.yaml. Nothing was started.");
1453
+ "/conform in the chat turns them on, or conformance-tests: true in config.turri.yaml. Nothing was started.");
1284
1454
  }
1285
1455
  // Refused before anything is touched: a functional spec not there, nothing to test, or a step of adding tests skipped.
1286
1456
  const { named, spec: ownSpec, withScenarios } = conformanceAskedIn(own, request.funcIds);
1457
+ const scratch = request.fromScratch;
1458
+ if (scratch !== undefined && named !== undefined && named.length > 0) {
1459
+ throw new Error("Name functional specs or ask for the conformance tests from scratch, not both: from scratch writes every one of them again. Nothing was started.");
1460
+ }
1461
+ // Written already, and asked for again: the named ones written anew where they are tested; from scratch, the module's
1462
+ // tests folder taken out - and started again from the module it requires, unless the whole chain's are asked for.
1463
+ const again = named !== undefined && named.length > 0 ? conformAgain(file, self, named) : [];
1464
+ if (scratch !== undefined)
1465
+ testsFromScratch(file, scratch === "module");
1287
1466
  const tested = new Set((readRecord(conformanceDirFor(self.moduleName, modulesRoot(projectDirOf(self.plainFile))))?.[FUNCTIONAL_REQUIREMENTS] ?? []).map((item) => item.id));
1288
1467
  const toWrite = (named !== undefined && named.length > 0 ? named : withScenarios).some((funcId) => !tested.has(funcId));
1289
1468
  let wentBack = false;
1290
- if (readRecord(self.buildDir) !== null && toWrite) {
1469
+ // From scratch, the tests are written again at the tips, where they were: nothing built on the module is touched.
1470
+ if (scratch === undefined && readRecord(self.buildDir) !== null && toWrite) {
1291
1471
  const why = `${self.moduleName}'s conformance tests were asked for, and they come before anything is built on it`;
1292
1472
  for (const chain of builtTips(file)) {
1293
1473
  const above = chain.slice(chain.findIndex((entry) => entry.buildDir === self.buildDir) + 1);
@@ -1311,14 +1491,17 @@ export function createWorkLoop(options) {
1311
1491
  }
1312
1492
  }
1313
1493
  }
1314
- const tracked = withParseCache(() => (wentBack ? [own] : chainsFor(file)).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, request, {}))));
1494
+ const tracked = withParseCache(() => (wentBack ? [own] : chainsFor(file)).flatMap((chain) => toBuild(chain).map((entry) => track(chain.slice(0, chain.indexOf(entry) + 1), file, request, true))));
1315
1495
  // The module asked for, in its own codebase - and those below it: never the codebases built on it.
1316
1496
  const asking = tracked.find((state) => tipEntry(state).buildDir === self.buildDir);
1317
1497
  const states = asking !== undefined ? tracked.filter((state) => own.some((entry) => entry.buildDir === tipEntry(state).buildDir)) : tracked;
1318
1498
  const tip = asking ?? states.at(-1);
1499
+ // Asked for: what a look ahead held here goes on - the modules below with it, or the module waits for them for ever.
1500
+ for (const state of tracked)
1501
+ state.lookedAhead = undefined;
1319
1502
  const asks = named !== undefined && named.length > 0 ? named : undefined;
1320
1503
  // Its tests are written already, and a codebase built on it holds its code: nothing to write, nothing touched.
1321
- if (asking === undefined && asks !== undefined && tip !== undefined) {
1504
+ if (asking === undefined && asks !== undefined && tip !== undefined && again.length === 0) {
1322
1505
  throw new Error(`${self.moduleName}'s conformance tests for ${namesOf(self.moduleName, asks)} are written already. Nothing was started.`);
1323
1506
  }
1324
1507
  // Only the module asked for: one job for all of its tests, or one a functional spec, as this request asks; a halt cleared.
@@ -1328,7 +1511,7 @@ export function createWorkLoop(options) {
1328
1511
  state.conformancePlan = undefined;
1329
1512
  state.conformanceSeparately = separately;
1330
1513
  // Named: their tests alone - the others left as they are until the module is asked for again, or conform names none.
1331
- state.conformanceOnly = asks !== undefined ? namedOnly(state, asks) : undefined;
1514
+ state.conformanceOnly = asks !== undefined ? namedOnly(state, asks, self.moduleName) : undefined;
1332
1515
  state.conformancePlan = undefined;
1333
1516
  state.conformanceHalted = undefined;
1334
1517
  state.halted = undefined;
@@ -1468,12 +1651,15 @@ export function createWorkLoop(options) {
1468
1651
  let before = status.running?.jobId;
1469
1652
  if (before !== undefined)
1470
1653
  lastOf.set(tip.moduleName, before);
1654
+ // Looked ahead at: every row of it says it waits for the module to be asked for.
1655
+ const held = state.lookedAhead === true && state.running === undefined;
1471
1656
  const row = (id, summary, note, waitingOn, conformance = false) => ({
1472
1657
  id,
1473
1658
  kind: conformance ? "conformance" : "regenerate",
1474
1659
  summary,
1475
1660
  module: tip.moduleName,
1476
- note,
1661
+ note: held ? `${LOOKED_AHEAD_NOTE} ${note}` : note,
1662
+ ...(held ? { lookedAhead: true } : {}),
1477
1663
  ...(state.model !== undefined ? { model: state.model } : {}),
1478
1664
  status: "queued",
1479
1665
  sequence: sequence--,
@@ -1509,16 +1695,9 @@ export function createWorkLoop(options) {
1509
1695
  });
1510
1696
  })];
1511
1697
  },
1512
- firsts() {
1513
- return order.flatMap((key) => {
1514
- const first = firsts.get(key);
1515
- const tip = tipEntry(modules.get(key));
1516
- return first === undefined ? [] : [{ module: tip.moduleName, plainFile: tip.plainFile, buildDir: tip.buildDir, ...first }];
1517
- });
1518
- },
1519
1698
  mapPlan() {
1520
1699
  return {
1521
- files: [...asked.keys()],
1700
+ files: [...asked.keys(), ...[...ahead.keys()].filter((file) => !asked.has(file))],
1522
1701
  codebases: order.map((key) => {
1523
1702
  const state = modules.get(key);
1524
1703
  const tip = tipEntry(state);
@@ -1580,6 +1759,12 @@ function oldCodebases(chain) {
1580
1759
  const OLD_RECORDS_WHY = (codebases) => `${codebases.join(", ")} ${codebases.length === 1 ? "was" : "were"} built when functional specs were numbered, before they had func-ids: nothing more is built on ${codebases.length === 1 ? "it" : "them"} - the whole chain is regenerated from scratch once you agree`;
1581
1760
  /** Why nothing runs in a codebase whose code - and conformance tests, where they are wanted - is built from its spec as it is. */
1582
1761
  export const UP_TO_DATE = "built from the ***plain as it is";
1762
+ /** Why nothing starts in a codebase a look ahead planned: its pulses wait for the module to be asked for. */
1763
+ const LOOKED_AHEAD = "looked ahead - planned, and nothing starts until regenerate, conform or /regenerate asks for it";
1764
+ /** What a planned row of a codebase a look ahead planned says first. */
1765
+ const LOOKED_AHEAD_NOTE = "Planned by a look ahead: it waits for regenerate, conform or /regenerate to start it.";
1766
+ /** Why a codebase held for a look ahead has no plan: its ***plain or steering moved since, and only a look ahead plans it. */
1767
+ const LOOK_AGAIN = "looked ahead, and the ***plain or the steering changed since - look ahead again to plan it, or regenerate it";
1583
1768
  /** Why a codebase with work left has no plan: the planner found none. */
1584
1769
  /** Why a codebase waits for a testing script being written in the background. */
1585
1770
  const SCRIPT_BEING_WRITTEN = (what) => `waiting for its ${what}, which is being written`;
@@ -1625,6 +1810,7 @@ function conformanceLines(module, cases) {
1625
1810
  ...(spec.added.length > 0 ? [`${spec.added.length} added`] : []),
1626
1811
  ...(spec.changed.length > 0 ? [`${spec.changed.length} changed`] : []),
1627
1812
  ...(spec.removed.length > 0 ? [`${spec.removed.length} removed`] : []),
1813
+ ...(spec.rewritten.length > 0 ? [`written again from scratch - ${spec.rewritten.length} to write anew`] : []),
1628
1814
  ...(spec.codeChanged !== undefined ? [`${why[spec.codeChanged]} - ${spec.unchanged.length} to run on it`] : []),
1629
1815
  ];
1630
1816
  return parts.length > 0 ? parts.join(", ") : "its text changed";
@@ -1677,9 +1863,11 @@ function conformanceAskedIn(own, funcIds) {
1677
1863
  const named = funcIds === undefined ? undefined : funcIdsNamed(self.moduleName, [...new Set(funcIds)]);
1678
1864
  const spec = chainSpec(own).tree;
1679
1865
  const withScenarios = testedFuncIds(spec);
1866
+ // No scenarios: the steps still to take, from the first one missing - the test reqs and the script come before them.
1867
+ const toScenarios = () => stepsToScenarios({ moduleName: self.moduleName, plainFile: self.plainFile, tree: spec, buildDir: self.buildDir });
1680
1868
  if (withScenarios.length === 0) {
1681
- throw new Error(`No functional spec of ${self.moduleName} has scenarios - none has a test plain file - so there is nothing to test: ` +
1682
- "write the conformance or acceptance scenarios first, with change_plain, and their tests are written once the code is built. Nothing was started.");
1869
+ throw new Error(`No functional spec of ${self.moduleName} has scenarios - none has a test plain file - so there is nothing to test. ${toScenarios()} ` +
1870
+ "Their tests are written once the code is built. Nothing was started.");
1683
1871
  }
1684
1872
  if (named !== undefined && named.length > 0) {
1685
1873
  const items = spec[FUNCTIONAL_REQUIREMENTS] ?? [];
@@ -1688,8 +1876,8 @@ function conformanceAskedIn(own, funcIds) {
1688
1876
  throw new Error(`${self.moduleName} has no functional spec ${namesOf(self.moduleName, unknown)}. Nothing was started.`);
1689
1877
  const untested = named.filter((funcId) => !hasScenarios(items.find((item) => item.id === funcId)));
1690
1878
  if (untested.length > 0) {
1691
- throw new Error(`${namesOf(self.moduleName, untested)} ${untested.length === 1 ? "has" : "have"} no scenarios - no test plain file - so there is nothing to test: ` +
1692
- "write the conformance or acceptance scenarios first, with change_plain, and their tests are written once the code is built. Nothing was started.");
1879
+ throw new Error(`${namesOf(self.moduleName, untested)} ${untested.length === 1 ? "has" : "have"} no scenarios - no test plain file - so there is nothing to test. ${toScenarios()} ` +
1880
+ "Their tests are written once the code is built. Nothing was started.");
1693
1881
  }
1694
1882
  }
1695
1883
  // A step of adding tests skipped - its test reqs, or the conformance testing script for its stack: refused, naming it.
@@ -1723,54 +1911,24 @@ function casesText(cases) {
1723
1911
  ];
1724
1912
  return parts.length > 0 ? parts.join(", ") : "no functional spec - reqs or definitions only";
1725
1913
  }
1726
- /** The codebases the loop looks after, as the person reads them: what runs, what is planned after it, and why nothing does. */
1727
1914
  /**
1728
- * The coding agent's task for a dry run's first job, built as the render builds it - and all it did rolled back. Not for
1729
- * a conformance job: its prompt is built from what the code holds once it is built.
1915
+ * The coding agent's task for a planned code pulse, built as the pulse builds it - with `spec` the ***plain the pulse
1916
+ * would be given - and all it did rolled back. Not for a conformance pulse: its prompt is built from what the code holds
1917
+ * once it is built.
1730
1918
  */
1731
- export async function promptOf(first) {
1732
- if (first.planned.track !== "code")
1919
+ async function promptOf(next) {
1920
+ if (next.planned.track !== "code")
1733
1921
  return undefined;
1734
1922
  const result = await renderSpecDiff({
1735
- plainFile: first.plainFile,
1736
- diff: first.planned.step.textDiff,
1923
+ plainFile: next.plainFile,
1924
+ diff: next.planned.step.textDiff,
1737
1925
  applied: "already applied",
1738
- spec: first.spec,
1739
- cases: first.planned.cases,
1926
+ spec: next.spec,
1927
+ cases: next.planned.cases,
1740
1928
  dryRun: true,
1741
1929
  });
1742
1930
  return result.task;
1743
1931
  }
1744
- /**
1745
- * What bringing a spec's module up would start, in each codebase, and the prompt of each - planned on a loop of its own
1746
- * that starts nothing. A codebase `busy` says is running a job is left out: a dry run starts from its last commit, and
1747
- * what the next job there is given depends on what the running one lands.
1748
- */
1749
- export async function previewJobs(options) {
1750
- const loop = createWorkLoop({
1751
- registry: createJobRegistry(),
1752
- cwd: options.cwd,
1753
- dryRun: true,
1754
- ...(options.model !== undefined ? { modelFor: () => options.model } : {}),
1755
- ...(options.plannerModel !== undefined ? { plannerModel: options.plannerModel } : {}),
1756
- ...(options.steering !== undefined ? { steering: options.steering } : {}),
1757
- });
1758
- const statuses = await loop.bringUp(options.plainFile, options.model !== undefined ? { model: options.model } : {});
1759
- const previews = [];
1760
- const busy = [];
1761
- for (const first of loop.firsts()) {
1762
- if (options.busy?.(first.module) === true) {
1763
- busy.push(first.module);
1764
- continue;
1765
- }
1766
- const preview = { module: first.module, title: first.planned.title, track: first.planned.track, cases: first.planned.cases };
1767
- const task = await promptOf(first);
1768
- if (task !== undefined)
1769
- preview.task = task;
1770
- previews.push(preview);
1771
- }
1772
- return { statuses, previews, busy };
1773
- }
1774
1932
  /** Nothing runs, is planned or is waiting there, as its code is built from its spec as it is. */
1775
1933
  export function isUpToDate(status) {
1776
1934
  return status.why === UP_TO_DATE && status.running === undefined && status.planned.length === 0 && status.startOver === undefined;
@@ -1822,8 +1980,11 @@ export function describeModules(statuses, options = {}) {
1822
1980
  : ` ${index + 1}. ${job.track === "conformance" ? "conformance tests: " : ""}${job.title} - ${casesText(job.cases)}`));
1823
1981
  if (status.planNotes !== undefined)
1824
1982
  lines.push(" what the plan did not do as asked:", ...status.planNotes.map((note) => ` - ${note}`));
1983
+ // A look ahead from the command line keeps its plan only while the process lives: the run that starts it plans again.
1825
1984
  if (status.why !== undefined)
1826
- lines.push(` ${status.why}`);
1985
+ lines.push(options.for === "command line" && status.why === LOOKED_AHEAD
1986
+ ? ` looked ahead - planned, nothing started: turri regenerate ${basename(status.plainFile)} runs it, planning it again as it starts`
1987
+ : ` ${status.why}`);
1827
1988
  if (status.conformanceNote !== undefined)
1828
1989
  lines.push(` ${status.conformanceNote}`);
1829
1990
  lines.push(...startOver(status));