@turri-dev/cli 0.2.4-next.bc1fc47 → 0.2.4-next.d779410

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 (115) hide show
  1. package/README.md +5 -6
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-models.d.ts +1 -1
  4. package/dist/chat-models.js +1 -1
  5. package/dist/chat-scope.d.ts +1 -3
  6. package/dist/chat-skills.d.ts +1 -1
  7. package/dist/chat-skills.js +1 -1
  8. package/dist/chats.d.ts +44 -10
  9. package/dist/chats.js +125 -41
  10. package/dist/cli.js +7 -24
  11. package/dist/config-edit.d.ts +20 -8
  12. package/dist/config-edit.js +32 -24
  13. package/dist/config.d.ts +90 -60
  14. package/dist/config.js +224 -117
  15. package/dist/conform-cli.js +1 -1
  16. package/dist/conformance-switch.d.ts +7 -6
  17. package/dist/conformance-switch.js +16 -16
  18. package/dist/extension.d.ts +10 -1
  19. package/dist/extension.js +263 -306
  20. package/dist/genome.js +1 -1
  21. package/dist/host-session.d.ts +8 -7
  22. package/dist/host-session.js +4 -4
  23. package/dist/host.d.ts +3 -1
  24. package/dist/host.js +3 -3
  25. package/dist/identity.js +2 -2
  26. package/dist/init-config.d.ts +1 -1
  27. package/dist/init-config.js +8 -8
  28. package/dist/launch-agent.d.ts +51 -0
  29. package/dist/launch-agent.js +267 -0
  30. package/dist/{release-cli.js → launch-cli.js} +41 -24
  31. package/dist/launch-session.d.ts +68 -0
  32. package/dist/launch-session.js +217 -0
  33. package/dist/launch-tools.d.ts +28 -0
  34. package/dist/launch-tools.js +69 -0
  35. package/dist/launch-track.d.ts +125 -0
  36. package/dist/launch-track.js +320 -0
  37. package/dist/loop-cli.js +4 -4
  38. package/dist/loop-tools.d.ts +17 -16
  39. package/dist/loop-tools.js +69 -69
  40. package/dist/notice.d.ts +7 -6
  41. package/dist/parse-cli.js +2 -2
  42. package/dist/pi-launch.js +3 -0
  43. package/dist/pi-settings.d.ts +4 -0
  44. package/dist/pi-settings.js +39 -0
  45. package/dist/pi.js +3 -3
  46. package/dist/plain/check.d.ts +1 -1
  47. package/dist/plain/check.js +3 -1
  48. package/dist/plain-files.d.ts +2 -2
  49. package/dist/plain-files.js +7 -7
  50. package/dist/regenerate/agent-env.d.ts +1 -1
  51. package/dist/regenerate/agent-env.js +3 -3
  52. package/dist/regenerate/agent-shell.js +2 -2
  53. package/dist/regenerate/base-folder.d.ts +2 -2
  54. package/dist/regenerate/base-folder.js +1 -1
  55. package/dist/regenerate/command-check.d.ts +7 -1
  56. package/dist/regenerate/command-check.js +43 -1
  57. package/dist/regenerate/delivery.d.ts +1 -1
  58. package/dist/regenerate/delivery.js +3 -3
  59. package/dist/regenerate/jobs.d.ts +2 -2
  60. package/dist/regenerate/jobs.js +10 -10
  61. package/dist/regenerate/launch.d.ts +154 -0
  62. package/dist/regenerate/{release.js → launch.js} +195 -51
  63. package/dist/regenerate/ledger.d.ts +33 -2
  64. package/dist/regenerate/lineage.d.ts +2 -0
  65. package/dist/regenerate/lineage.js +8 -0
  66. package/dist/regenerate/loop.d.ts +9 -8
  67. package/dist/regenerate/loop.js +43 -40
  68. package/dist/regenerate/model-names.d.ts +33 -0
  69. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  70. package/dist/regenerate/paths.d.ts +3 -3
  71. package/dist/regenerate/paths.js +4 -4
  72. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  73. package/dist/regenerate/scripts-being-written.js +3 -3
  74. package/dist/regenerate/test-scripts.d.ts +2 -1
  75. package/dist/regenerate/test-scripts.js +33 -23
  76. package/dist/regenerate/testing-steps.d.ts +6 -6
  77. package/dist/regenerate/testing-steps.js +8 -8
  78. package/dist/self-invocation.js +7 -7
  79. package/dist/sentinel-check.d.ts +3 -3
  80. package/dist/sentinel-check.js +3 -3
  81. package/dist/sentinel.d.ts +18 -12
  82. package/dist/sentinel.js +68 -42
  83. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  84. package/dist/{config-command.js → settings.js} +155 -24
  85. package/dist/setup.d.ts +2 -2
  86. package/dist/setup.js +7 -7
  87. package/docs/README.md +4 -4
  88. package/docs/chats.md +5 -6
  89. package/docs/claude-subscription.md +2 -2
  90. package/docs/config.md +58 -46
  91. package/docs/development.md +2 -2
  92. package/docs/headless.md +2 -3
  93. package/docs/hosting.md +20 -19
  94. package/docs/launch.md +67 -0
  95. package/docs/parser.md +2 -2
  96. package/docs/regenerating.md +12 -12
  97. package/docs/sandbox.md +3 -3
  98. package/docs/sentinel.md +26 -14
  99. package/docs/skills-and-gates.md +4 -5
  100. package/docs/using.md +15 -24
  101. package/genome/rules/project-model.md +2 -1
  102. package/genome/rules/turri-regeneration.md +3 -2
  103. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  104. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  105. package/package.json +1 -1
  106. package/dist/regenerate/engine.d.ts +0 -52
  107. package/dist/regenerate/release.d.ts +0 -121
  108. package/dist/release-agent.d.ts +0 -43
  109. package/dist/release-agent.js +0 -130
  110. package/dist/release-tools.d.ts +0 -44
  111. package/dist/release-tools.js +0 -170
  112. package/dist/stacks.d.ts +0 -13
  113. package/dist/stacks.js +0 -96
  114. package/docs/deploy.md +0 -48
  115. /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -6,7 +6,7 @@ import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, FUNCTIONAL_REQUIREMENTS, REQUIRED_
6
6
  import { testPlainFilesOf } from "../test-plain-files.js";
7
7
  import { reportActivity, reportStage } from "./activity.js";
8
8
  import { llmChunkAgents, MAX_LINES_PER_JOB, MAX_SPECS_PER_JOB, planChunks, stepsOf } from "./chunk-plan.js";
9
- import { commitNotes, landWork, recordHistory, resetToLastCommit } from "./lineage.js";
9
+ import { commitNotes, landWork, lastCommit, recordHistory, resetToLastCommit } from "./lineage.js";
10
10
  import { firstLine, record } from "./ledger.js";
11
11
  import { NOTES_FILE, recordPulse } from "./notes.js";
12
12
  import { formatDuration } from "./jobs.js";
@@ -15,7 +15,7 @@ import { adoptDigests, chainTree, codeTree, conformanceTarget, CONFORM_AGAIN, ma
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, testDirOf, withStack } from "../config.js";
18
+ import { configForSpec, configModuleFor, moduleConfigFile, testDirOf, withConfigModule } from "../config.js";
19
19
  import { describeSpecChange } from "./prompt.js";
20
20
  import { resolveTemplateDirs } from "./paths.js";
21
21
  import { builtTips, copyRequiredCode, copyRequiredTests, importingModules, isImportModule, newlyRequired, resolveRequiresChain, startFromScratch } from "./requires.js";
@@ -241,8 +241,8 @@ export function createWorkLoop(options) {
241
241
  const tip = tipEntry(state);
242
242
  return { project: projectRootOf(tip.buildDir), module: tip.moduleName, job };
243
243
  };
244
- /** `work` with the codebase's stack chosen - the one it was asked for with - when it has one pinned. */
245
- const inStack = (state, work) => (state.stack !== undefined ? withStack(state.stack.name, work) : work());
244
+ /** `work` with the codebase's config pinned - its module's own file, or one it requires - once it is worked out. */
245
+ const withModuleConfig = (state, work) => (state.configModule !== undefined ? withConfigModule(state.configModule.name, work) : work());
246
246
  const keyOf = (spec) => serializeTree(codeTree(spec.tree));
247
247
  /** What a codebase is built from: its record, or - nothing built - what it starts from, the code of the module it requires. */
248
248
  const builtOf = (state) => {
@@ -287,7 +287,7 @@ export function createWorkLoop(options) {
287
287
  (spec.tree[TEST_REQUIREMENTS] ?? []).length > 0 && readRecord(tipEntry(state).buildDir) !== null && gapOf(state, spec) === undefined;
288
288
  /**
289
289
  * The step of adding tests a codebase skipped - its functional specs have scenarios, and it has no test reqs or no
290
- * conformance testing script for its stack: no conformance pulse of it starts, in the loop or from conform, and it
290
+ * conformance testing script: no conformance pulse of it starts, in the loop or from conform, and it
291
291
  * waits on that step until the spec or the scripts change.
292
292
  */
293
293
  const gapOf = (state, spec) => {
@@ -302,7 +302,7 @@ export function createWorkLoop(options) {
302
302
  const tip = tipEntry(state);
303
303
  const root = projectRootFor(tip.plainFile, tip.buildDir);
304
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));
305
+ return scriptBeingWritten(root, kind, configModuleFor(tip.plainFile));
306
306
  };
307
307
  /**
308
308
  * The base folder a codebase started from, as its status says it. Counting the files still there looks at each, and the
@@ -630,7 +630,7 @@ export function createWorkLoop(options) {
630
630
  }
631
631
  // Nothing here yet, and nothing below: the codebase starts from its base folder, when the config names one.
632
632
  if (tip.requires === null && !started(tip))
633
- inStack(state, () => seedFromBaseFolder(tip.buildDir, tip.plainFile, tip.moduleName));
633
+ withModuleConfig(state, () => seedFromBaseFolder(tip.buildDir, tip.plainFile, tip.moduleName));
634
634
  // A conformance job is shown the spec whole - its test reqs and scenarios are its to write from.
635
635
  const result = await (conformance ? runConformance : run)({
636
636
  plainFile: tip.plainFile,
@@ -642,26 +642,11 @@ export function createWorkLoop(options) {
642
642
  cwd: options.cwd,
643
643
  ...(steering !== undefined ? { steering } : {}),
644
644
  }, onDelta);
645
- const report = result.report;
646
- // Released as its last stage, when the config says so: the module's next pulse starts on what is released.
647
- let released;
648
- if (result.landed && options.release !== undefined && configForSpec(tip.plainFile).releaseAfterPulse === true) {
649
- reportStage(`module ${tip.moduleName}: releasing what this pulse landed (release-after-pulse)`);
650
- try {
651
- released = `Released after the pulse: ${(await options.release({ plainFile: tip.plainFile, moduleName: tip.moduleName, title: planned.title, onDelta })).trim()}`;
652
- }
653
- catch (error) {
654
- // What landed stays landed: a release that fails is said, and the next pulse goes on.
655
- released = `The release after the pulse failed: ${error instanceof Error ? error.message : String(error)}`;
656
- }
657
- reportActivity(` ${released.split("\n")[0]}`);
658
- }
659
645
  return {
660
- report: released !== undefined ? `${report}\n\n${released}` : report,
646
+ report: result.report,
661
647
  details: {
662
648
  passed: result.landed,
663
649
  landed: result.landed,
664
- ...(released !== undefined ? { released: true } : {}),
665
650
  ...(result.story !== undefined ? { story: result.story } : {}),
666
651
  // The spec gaps its agents met, for a headless run to say - in the chat the report puts them to the person.
667
652
  ...(result.specGaps !== undefined && result.specGaps.length > 0 ? { specGaps: result.specGaps } : {}),
@@ -769,6 +754,20 @@ export function createWorkLoop(options) {
769
754
  // What it did, in the notes every agent after reads - once anything it did not land is rolled back, so the line stays.
770
755
  if (running !== undefined)
771
756
  notePulse(state, running, settled, landed);
757
+ // Landed: the commit it ends on, its line in the notes amended in - told before the codebase's next pulse starts.
758
+ if (running !== undefined && settled !== undefined && landed) {
759
+ const tip = tipEntry(state);
760
+ const commit = lastCommit(tip.buildDir);
761
+ if (commit !== undefined) {
762
+ settled.details = { ...settled.details, commit };
763
+ try {
764
+ options.landed?.({ job: settled, plainFile: tip.plainFile, moduleName: tip.moduleName, commit, title: running.planned.title });
765
+ }
766
+ catch {
767
+ /* what is done with a landing is not the loop's to fail on */
768
+ }
769
+ }
770
+ }
772
771
  void tick();
773
772
  };
774
773
  /**
@@ -912,7 +911,7 @@ export function createWorkLoop(options) {
912
911
  // A codebase left behind - built on since - is not looked at, unless a job of it is still running; what it had
913
912
  // planned, or waited for, is no longer shown.
914
913
  if (now.has(state) || state.running !== undefined)
915
- await inStack(state, () => look(state));
914
+ await withModuleConfig(state, () => look(state));
916
915
  else {
917
916
  state.why = "left behind: the code is built on further up the chain, where changes to it are made";
918
917
  state.waitsFor = undefined;
@@ -1136,7 +1135,7 @@ export function createWorkLoop(options) {
1136
1135
  }));
1137
1136
  };
1138
1137
  /** A codebase's status, and beside each job it lists as planned, the planned job it is - none for one being planned or scheduled. */
1139
- const describe = (state) => inStack(state, () => describeIn(state));
1138
+ const describe = (state) => withModuleConfig(state, () => describeIn(state));
1140
1139
  const describeIn = (state) => {
1141
1140
  // What runs next: the code's jobs, then the conformance tests' - the module's, once its code is built - the running job first.
1142
1141
  const running = state.running?.planned;
@@ -1192,7 +1191,7 @@ export function createWorkLoop(options) {
1192
1191
  plainFile: tip.plainFile,
1193
1192
  ...(base !== undefined ? { base } : {}),
1194
1193
  ...(renames.length > 0 ? { renames: renames.map(renameText) } : {}),
1195
- ...(state.stack?.name !== undefined ? { stack: state.stack.name } : {}),
1194
+ ...(state.configModule?.name !== undefined ? { configModule: state.configModule.name } : {}),
1196
1195
  ...(state.running !== undefined
1197
1196
  ? {
1198
1197
  running: {
@@ -1211,10 +1210,10 @@ export function createWorkLoop(options) {
1211
1210
  return { status, jobs: shown.map((item) => item.job), ahead: shown.map((item) => (item.entry.afterCode === true ? { title: item.entry.title, specs: item.entry.specs ?? [] } : undefined)) };
1212
1211
  };
1213
1212
  /**
1214
- * Look after a codebase - its chain up to it - from now on; says its state. `pin`: its stack is worked out again - its
1215
- * tip's (`stackForModule`).
1213
+ * Look after a codebase - its chain up to it - from now on; says its state. Its config is worked out again - its tip's
1214
+ * (`configModuleFor`): `asked`, one that cannot be told refuses the ask; otherwise it keeps the one it had.
1216
1215
  */
1217
- const track = (chain, askedFile, request, pin = false) => {
1216
+ const track = (chain, askedFile, request, asked = false) => {
1218
1217
  const tip = tipOf(chain);
1219
1218
  let state = modules.get(tip.buildDir);
1220
1219
  if (state === undefined) {
@@ -1229,10 +1228,15 @@ export function createWorkLoop(options) {
1229
1228
  }
1230
1229
  state.chain = chain;
1231
1230
  state.askedFile = askedFile;
1232
- if (pin)
1233
- state.stack = { name: stackForModule(tip.plainFile) };
1234
- // Its model as its stack has it: a stack's file can name a coding model of its own.
1235
- const model = request.model ?? inStack(state, () => options.modelFor?.(tip.plainFile));
1231
+ try {
1232
+ state.configModule = { name: configModuleFor(tip.plainFile) };
1233
+ }
1234
+ catch (error) {
1235
+ if (asked)
1236
+ throw error;
1237
+ }
1238
+ // Its model as its config has it: a module's own file can name a coding model of its own.
1239
+ const model = request.model ?? withModuleConfig(state, () => options.modelFor?.(tip.plainFile));
1236
1240
  if (model !== undefined)
1237
1241
  state.model = model;
1238
1242
  if (request.guidance !== undefined && !state.guidance.includes(request.guidance))
@@ -1248,8 +1252,7 @@ export function createWorkLoop(options) {
1248
1252
  asked.set(file, { ...ahead.get(file), ...asked.get(file), ...given });
1249
1253
  ahead.delete(file);
1250
1254
  }
1251
- // Asked for, it is built with its stack - the one the call names, its own, or the one chosen now - pinned, whatever
1252
- // is chosen later.
1255
+ // Asked for, its config is worked out - its own file, or one of a module it requires - and pinned to its pulses.
1253
1256
  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
1257
  // Asked again, a halted codebase is tried again - one the person halted too. Looked ahead at, its kept plan starts.
1255
1258
  for (const state of states) {
@@ -1270,7 +1273,7 @@ export function createWorkLoop(options) {
1270
1273
  for (const file of files)
1271
1274
  if (!asked.has(file))
1272
1275
  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.
1276
+ // Its config pinned as an ask pins it: the plan is made, and its pulses run, with the config regenerate would use.
1274
1277
  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
1278
  // A chain with a pulse running is being built as asked, and goes on; every other codebase is held - one asked for
1276
1279
  // earlier too, which would otherwise start the work the look ahead plans.
@@ -1325,7 +1328,7 @@ export function createWorkLoop(options) {
1325
1328
  if (state.plan === undefined || !state.plan.jobs.includes(job) || state.plan.specKey !== keyOf(spec) || state.plan.steeringKey !== steeringKeyOf(state)) {
1326
1329
  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
1330
  }
1328
- const task = await inStack(state, () => promptOf({ plainFile: tip.plainFile, spec: { ...spec, tree: job.step.tree }, planned: job }));
1331
+ const task = await withModuleConfig(state, () => promptOf({ plainFile: tip.plainFile, spec: { ...spec, tree: job.step.tree }, planned: job }));
1329
1332
  return task !== undefined ? { ...pulse, task } : why("It has no prompt to show.");
1330
1333
  },
1331
1334
  async regenerateAgain(plainFile, given, request = {}) {
@@ -1384,7 +1387,7 @@ export function createWorkLoop(options) {
1384
1387
  const tip = tipOf(codebase);
1385
1388
  // The codebase as the loop knows it, or - never asked for - as its records have it.
1386
1389
  const state = modules.get(tip.buildDir) ?? { chain: codebase, askedFile: file, guidance: [] };
1387
- return inStack(state, () => {
1390
+ return withModuleConfig(state, () => {
1388
1391
  const report = { module: tip.moduleName, plainFile: tip.plainFile, code: undefined, conformance: undefined, ...(conformanceTestsOn(tip.plainFile) ? {} : { conformanceOff: true }) };
1389
1392
  let spec;
1390
1393
  try {
@@ -1880,7 +1883,7 @@ function conformanceAskedIn(own, funcIds) {
1880
1883
  "Their tests are written once the code is built. Nothing was started.");
1881
1884
  }
1882
1885
  }
1883
- // A step of adding tests skipped - its test reqs, or the conformance testing script for its stack: refused, naming it.
1886
+ // A step of adding tests skipped - its test reqs, or the conformance testing script: refused, naming it.
1884
1887
  const gap = testingGap({ moduleName: self.moduleName, plainFile: self.plainFile, tree: spec, buildDir: self.buildDir });
1885
1888
  if (gap !== undefined)
1886
1889
  throw new Error(`${gap.text} Nothing was started.`);
@@ -1964,7 +1967,7 @@ export function describeModules(statuses, options = {}) {
1964
1967
  // Nothing to do there: said in a sentence, not as a status.
1965
1968
  if (isUpToDate(status))
1966
1969
  return `${status.module} is up to date: its code is built from the ***plain as it is now in ${basename(status.plainFile)}, so there is nothing to regenerate.`;
1967
- const lines = [`${status.module} (${basename(status.plainFile)}${status.stack !== undefined ? `, stack ${status.stack}` : ""}):`];
1970
+ const lines = [`${status.module} (${basename(status.plainFile)}${status.configModule !== undefined ? `, built with ${moduleConfigFile(status.configModule)}` : ""}):`];
1968
1971
  if (status.running !== undefined) {
1969
1972
  lines.push(` running: pulse ${status.running.jobId} - ${status.running.title}`);
1970
1973
  // Steered, not stopped or planned again: what changed went to its agent.
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A model named as the person said it - "gpt 5.5", "gemini flash" - resolved to the one it means: for a pulse a call
3
+ * names a model for, and for a model written into the config with the settings tool.
4
+ *
5
+ * A name is resolved strictly. pi's own pattern matching picks its best guess and says nothing
6
+ * - "gpt-5" becomes a Bedrock model with no credentials, "flash" a GLM one - and a job on a
7
+ * guessed model is worse than a question. So an exact id is taken as it is, a looser name is
8
+ * taken only when it fits exactly one model that has credentials, and anything else comes back
9
+ * as a short list to ask the person about.
10
+ */
11
+ /** The part of pi's model registry this needs. */
12
+ export interface ModelCatalog {
13
+ getAll(): ReadonlyArray<CatalogModel>;
14
+ hasConfiguredAuth(model: CatalogModel): boolean;
15
+ }
16
+ export interface CatalogModel {
17
+ provider: string;
18
+ id: string;
19
+ name?: string;
20
+ }
21
+ export type ModelResolution = {
22
+ ok: true;
23
+ model: string;
24
+ name: string;
25
+ } | {
26
+ ok: false;
27
+ message: string;
28
+ candidates: string[];
29
+ };
30
+ /** Resolve what the person called a model to one this machine can run, or say why not. */
31
+ export declare function resolveModel(query: string, catalog: ModelCatalog): ModelResolution;
32
+ /** The resolution as text for the agent: the model, or why not and what to ask. */
33
+ export declare function describeResolution(resolution: ModelResolution): string;
@@ -1,10 +1,6 @@
1
1
  /**
2
- * Which model the agents of a job run on.
3
- *
4
- * By default, whatever the conversation is using. The person can say otherwise - "render spec
5
- * changes with Gemini Flash" - for one kind of work or for all of it, and that holds for the
6
- * rest of the session, for jobs started from a tool call and for jobs a skill queues alike. A
7
- * single tool call can also name a model for itself alone.
2
+ * A model named as the person said it - "gpt 5.5", "gemini flash" - resolved to the one it means: for a pulse a call
3
+ * names a model for, and for a model written into the config with the settings tool.
8
4
  *
9
5
  * A name is resolved strictly. pi's own pattern matching picks its best guess and says nothing
10
6
  * - "gpt-5" becomes a Bedrock model with no credentials, "flash" a GLM one - and a job on a
@@ -94,25 +90,3 @@ export function describeResolution(resolution) {
94
90
  return `${resolution.model} (${resolution.name})`;
95
91
  return [resolution.message, ...resolution.candidates.map((candidate) => `- ${candidate}`)].join("\n");
96
92
  }
97
- export const WORK_LABEL = {
98
- spec_changes: "spec changes",
99
- functionalities: "functionalities",
100
- all: "everything",
101
- };
102
- /** The model a job of this kind runs on: chosen for it, chosen for everything, or the chat's. */
103
- export function modelFor(choices, work, chat) {
104
- return choices[work] ?? choices.all ?? chat;
105
- }
106
- /**
107
- * Where each kind of work runs now, in a line each: chosen in this session, or the default coding
108
- * model - from `--coding-model` or config.turri.yaml, said which - or the conversation's.
109
- */
110
- export function describeChoices(choices, chat, project) {
111
- const fallback = project !== undefined ? `${project.model} (${project.from})` : `${chat ?? "pi's default model"} (the chat's model)`;
112
- return ["spec_changes", "functionalities"]
113
- .map((work) => {
114
- const chosen = choices[work] ?? choices.all;
115
- return `- ${WORK_LABEL[work]}: ${chosen ?? fallback}`;
116
- })
117
- .join("\n");
118
- }
@@ -30,7 +30,7 @@ export declare function defaultBuildDir(moduleName: string, cwd?: string): strin
30
30
  */
31
31
  /**
32
32
  * The project a spec belongs to: the nearest folder, from the spec's own up, that holds a
33
- * `config.turri.yaml`, a stack's `config.turri.<stack>.yaml`, the `config.yaml` turri read before it had a file of
33
+ * `config.turri.yaml`, a module's `config.turri.<module>.yaml`, the `config.yaml` turri read before it had a file of
34
34
  * its own, or a `plain_modules` - where its code is built, its config read, its testing scripts found. Without any, the
35
35
  * spec's own folder. So `plain/hubspot.plain`, beside `plain/config.turri.yaml` and `plain/plain_modules`, is built there,
36
36
  * wherever turri was started;
@@ -56,11 +56,11 @@ export declare function modulesRootOf(dir: string): string;
56
56
  export declare function modulesScratchDir(dir: string): string;
57
57
  /** Make `path` inside the modules' scratch, which ignores itself. Returns `path`. */
58
58
  export declare function ensureInModulesScratch(dir: string, path: string): string;
59
- /** Where the project keeps what `deploy` puts out: `dist/`, beside `plain_modules`. */
59
+ /** Where the project keeps what a launch puts out: `dist/`, beside `plain_modules`. */
60
60
  export declare const DIST_DIR = "dist";
61
61
  /**
62
62
  * Where a person tries a module: `<project>/dist/<module>`, the module's code as its last commit has
63
- * it. Outside `plain_modules`, so no agent can reach it, and replaced whole by every deploy.
63
+ * it. Outside `plain_modules`, so no agent can reach it, and replaced whole by every launch.
64
64
  */
65
65
  export declare function distDirFor(projectDir: string, moduleName: string): string;
66
66
  /**
@@ -37,7 +37,7 @@ export function defaultBuildDir(moduleName, cwd = process.cwd()) {
37
37
  */
38
38
  /**
39
39
  * The project a spec belongs to: the nearest folder, from the spec's own up, that holds a
40
- * `config.turri.yaml`, a stack's `config.turri.<stack>.yaml`, the `config.yaml` turri read before it had a file of
40
+ * `config.turri.yaml`, a module's `config.turri.<module>.yaml`, the `config.yaml` turri read before it had a file of
41
41
  * its own, or a `plain_modules` - where its code is built, its config read, its testing scripts found. Without any, the
42
42
  * spec's own folder. So `plain/hubspot.plain`, beside `plain/config.turri.yaml` and `plain/plain_modules`, is built there,
43
43
  * wherever turri was started;
@@ -56,7 +56,7 @@ export function projectDirOf(plainFile) {
56
56
  export function isProjectDir(dir) {
57
57
  return existsSync(join(dir, "config.yaml")) || existsSync(join(dir, MODULES_DIR)) || hasModuleConfig(dir);
58
58
  }
59
- /** Whether a folder holds a config file - config.turri.yaml, a stack's config.turri.<stack>.yaml, or one in the old naming - which makes it a project too. */
59
+ /** Whether a folder holds a config file - config.turri.yaml, a module's config.turri.<module>.yaml, or one in the old naming - which makes it a project too. */
60
60
  function hasModuleConfig(dir) {
61
61
  try {
62
62
  return readdirSync(dir).some((name) => /^config\..+\.yaml$/.test(name));
@@ -96,11 +96,11 @@ export function modulesScratchDir(dir) {
96
96
  export function ensureInModulesScratch(dir, path) {
97
97
  return ensureInScratch(modulesScratchDir(dir), path);
98
98
  }
99
- /** Where the project keeps what `deploy` puts out: `dist/`, beside `plain_modules`. */
99
+ /** Where the project keeps what a launch puts out: `dist/`, beside `plain_modules`. */
100
100
  export const DIST_DIR = "dist";
101
101
  /**
102
102
  * Where a person tries a module: `<project>/dist/<module>`, the module's code as its last commit has
103
- * it. Outside `plain_modules`, so no agent can reach it, and replaced whole by every deploy.
103
+ * it. Outside `plain_modules`, so no agent can reach it, and replaced whole by every launch.
104
104
  */
105
105
  export function distDirFor(projectDir, moduleName) {
106
106
  return join(projectDir, DIST_DIR, moduleName);
@@ -8,12 +8,12 @@ export interface ScriptBeingWritten {
8
8
  /** The project's folder. */
9
9
  project: string;
10
10
  kind: ScriptKind;
11
- /** The stack it is written for, when the run was for one. */
12
- stack?: string;
11
+ /** The module whose config file it is named in, when the run was for one: its own, or one it requires. */
12
+ configModule?: string;
13
13
  }
14
14
  /** A script being written from now: what it returns says it is no longer, written or not. */
15
15
  export declare function writingScript(run: ScriptBeingWritten): () => void;
16
- /** Whether a script of this kind is being written for a module of this project on this stack - one written for no stack is anyone's. */
17
- export declare function scriptBeingWritten(project: string, kind: ScriptKind, stack?: string): boolean;
16
+ /** Whether a script of this kind is being written for a module of this project built with this module's config file - one written for none is anyone's. */
17
+ export declare function scriptBeingWritten(project: string, kind: ScriptKind, configModule?: string): boolean;
18
18
  /** Told each time a run writing a script ends. Returns what stops it. */
19
19
  export declare function onScriptRunEnded(listener: () => void): () => void;
@@ -18,10 +18,10 @@ export function writingScript(run) {
18
18
  }
19
19
  };
20
20
  }
21
- /** Whether a script of this kind is being written for a module of this project on this stack - one written for no stack is anyone's. */
22
- export function scriptBeingWritten(project, kind, stack) {
21
+ /** Whether a script of this kind is being written for a module of this project built with this module's config file - one written for none is anyone's. */
22
+ export function scriptBeingWritten(project, kind, configModule) {
23
23
  const folder = resolve(project);
24
- return [...writing().runs].some((run) => run.project === folder && run.kind === kind && (run.stack === undefined || stack === undefined || run.stack === stack));
24
+ return [...writing().runs].some((run) => run.project === folder && run.kind === kind && (run.configModule === undefined || configModule === undefined || run.configModule === configModule));
25
25
  }
26
26
  /** Told each time a run writing a script ends. Returns what stops it. */
27
27
  export function onScriptRunEnded(listener) {
@@ -60,7 +60,8 @@ export declare function projectRootFor(plainFile: string, buildDir: string): str
60
60
  /**
61
61
  * The project's testing scripts, looked for in this order:
62
62
  *
63
- * 1. `config.turri.yaml` at the project root, with the chosen stack's `config.turri.<stack>.yaml` over it -
63
+ * 1. `config.turri.yaml` at the project root, with the module's own `config.turri.<module>.yaml` over it - or the one of a
64
+ * module it requires (`configModuleFor`) -
64
65
  * `unittests-script:` and `conformance-tests-script:`, paths from the root;
65
66
  * 2. the project root itself - the one `run_unittests*.sh` / `run_conformance_tests*.sh` there;
66
67
  * 3. `test_scripts/` - the one of each there.
@@ -2,7 +2,7 @@ import { fixMethod } from "./prompt.js";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { accessSync, constants, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  import { basename, delimiter, dirname, join, resolve, sep } from "node:path";
5
- import { CONFIG_FILE, CONFIG_KEYS, projectConfigFile, readProjectConfig, stackConfigFile, stackConfigFileIn, stackOf, stacksOf } from "../config.js";
5
+ import { CONFIG_FILE, CONFIG_KEYS, configModuleFor, configModuleOf, configModulePinned, moduleConfigFile, moduleConfigFileIn, moduleConfigsOf, projectConfigFile, readProjectConfig } from "../config.js";
6
6
  import { reportActivity, reportLogNote, reportNote } from "./activity.js";
7
7
  import { record, signatureHash } from "./ledger.js";
8
8
  import { ensureInModulesScratch, modulesScratchDir } from "./paths.js";
@@ -68,7 +68,8 @@ function onlyScriptIn(dir, kind) {
68
68
  /**
69
69
  * The project's testing scripts, looked for in this order:
70
70
  *
71
- * 1. `config.turri.yaml` at the project root, with the chosen stack's `config.turri.<stack>.yaml` over it -
71
+ * 1. `config.turri.yaml` at the project root, with the module's own `config.turri.<module>.yaml` over it - or the one of a
72
+ * module it requires (`configModuleFor`) -
72
73
  * `unittests-script:` and `conformance-tests-script:`, paths from the root;
73
74
  * 2. the project root itself - the one `run_unittests*.sh` / `run_conformance_tests*.sh` there;
74
75
  * 3. `test_scripts/` - the one of each there.
@@ -82,18 +83,18 @@ function onlyScriptIn(dir, kind) {
82
83
  export function findTestScripts(root, plainFile, buildDir) {
83
84
  const found = {};
84
85
  const notes = {};
85
- // The stack chosen, its file over the project's, when the project has one for it: its scripts.
86
- const stack = stackOf(root);
87
- const config = readProjectConfig(root, stack);
88
- const file = stack !== undefined ? `${stackConfigFileIn(root, stack)} (over ${projectConfigFile(root)})` : projectConfigFile(root);
89
- // A project of stacks with none chosen: its scripts are named in the stacks' files.
90
- const stacks = stack === undefined ? stacksOf(root) : [];
91
- // Where a script is named: the stack's file, once one is chosen - in a project of stacks, the one of the stack that builds it.
92
- const nameIn = stack !== undefined
93
- ? stackConfigFileIn(root, stack)
94
- : stacks.length > 0
95
- ? "the config.turri.<stack>.yaml of the stack that builds it"
96
- : `${CONFIG_FILE} - or, for a project of several stacks, the stack's config.turri.<stack>.yaml`;
86
+ // The module's own file over the project's - the one pinned, else the one of the module asked about: its scripts.
87
+ const own = configModulePinned() ? configModuleOf(root) : plainFile !== undefined ? moduleOfSpec(plainFile) : undefined;
88
+ const config = readProjectConfig(root, own);
89
+ const file = own !== undefined ? `${moduleConfigFileIn(root, own)} (over ${projectConfigFile(root)})` : projectConfigFile(root);
90
+ // Modules with files of their own, none of them this one's: its scripts are likely named in theirs.
91
+ const others = own === undefined ? moduleConfigsOf(root) : [];
92
+ // Where a script is named: the module's own file - or, where modules have their own, the one of the module that builds it.
93
+ const nameIn = own !== undefined
94
+ ? moduleConfigFileIn(root, own)
95
+ : others.length > 0
96
+ ? "the module's own config.turri.<module>.yaml"
97
+ : `${CONFIG_FILE} - or the module's own config.turri.<module>.yaml`;
97
98
  if (config.testingScriptsRunOn !== undefined)
98
99
  found.runOn = config.testingScriptsRunOn;
99
100
  for (const kind of Object.keys(SCRIPT_KEYS)) {
@@ -146,19 +147,19 @@ export function findTestScripts(root, plainFile, buildDir) {
146
147
  }
147
148
  }
148
149
  }
149
- // A project of stacks, none chosen: the scripts are likely in a stack's file - the note says which, and how to choose it.
150
- if (stacks.length > 0) {
150
+ // Modules with files of their own, none of them this one's: the note says which name a script, and where its own goes.
151
+ if (others.length > 0) {
151
152
  for (const kind of Object.keys(SCRIPT_KEYS)) {
152
153
  if (found[kind] !== undefined)
153
154
  continue;
154
- const named = stacks.flatMap((each) => {
155
+ const named = others.flatMap((each) => {
155
156
  const script = kind === "unit" ? readProjectConfig(root, each).unittestsScript : readProjectConfig(root, each).conformanceTestsScript;
156
- return script !== undefined ? [`${stackConfigFile(each)} names ${script.trim()}`] : [];
157
+ return script !== undefined ? [`${moduleConfigFile(each)} names ${script.trim()}`] : [];
157
158
  });
158
159
  notes[kind] = [
159
160
  ...(notes[kind] !== undefined ? [notes[kind]] : []),
160
- `No stack is chosen, so ${CONFIG_FILE} alone is read - this project's stacks are ${stacks.join(", ")}${named.length > 0 ? `, and ${named.join("; ")}` : ""}. ` +
161
- "Choose the stack that builds this module: stack on regenerate, or /stack, in the chat; --stack <name> on the command line.",
161
+ `No module config file applies here, so ${CONFIG_FILE} alone is read - the modules' own are ${others.map(moduleConfigFile).join(", ")}${named.length > 0 ? `, and ${named.join("; ")}` : ""}. ` +
162
+ "A module takes its own config.turri.<module>.yaml, else the one of a module it requires: name its scripts in its own file - in the chat, the settings tool with module.",
162
163
  ].join(" ");
163
164
  }
164
165
  }
@@ -199,7 +200,7 @@ export class MissingTestScriptError extends Error {
199
200
  "What to change in the project:",
200
201
  `- Add one with the \`${skill}\` skill: it writes \`${SCRIPTS_DIR}/${file}_<language>.sh\`.`,
201
202
  `- It is looked for in \`${CONFIG_FILE}\` at the project root (\`${SCRIPT_KEYS[kind]}: <path>\`) - or the module's own`,
202
- ` \`config.turri.<stack>.yaml\` beside it, the stack chosen with /stack or --stack, for a project of several stacks - then in the root,`,
203
+ ` \`config.turri.<module>.yaml\` beside it, or the one of a module it requires - then in the root,`,
203
204
  ` then in \`${SCRIPTS_DIR}/\` - one ${file}*.sh in either folder is used.`,
204
205
  "",
205
206
  "Then build again.",
@@ -332,8 +333,8 @@ function projectOfBuild(buildDir) {
332
333
  const parts = resolve(buildDir).split(sep);
333
334
  const index = parts.lastIndexOf("plain_modules");
334
335
  const root = index > 0 ? parts.slice(0, index).join(sep) : dirname(resolve(buildDir));
335
- // The stack chosen decides, when it says.
336
- return { root, inPlace: readProjectConfig(root, stackOf(root)).testingScriptsRunOn !== "copy" };
336
+ // The module's own file decides, when it says.
337
+ return { root, inPlace: readProjectConfig(root, configModuleOf(root)).testingScriptsRunOn !== "copy" };
337
338
  }
338
339
  /** The model providers' keys, kept out of what runs on this machine: the tests are agents' code. */
339
340
  const PROVIDER_KEY = /^(ANTHROPIC|OPENAI|AZURE_OPENAI|GEMINI|GOOGLE|GOOGLE_GENERATIVE_AI|MISTRAL|GROQ|XAI|OPENROUTER|DEEPSEEK|CEREBRAS|TOGETHER|FIREWORKS)_API_KEY$|^AWS_BEARER_TOKEN_BEDROCK$/;
@@ -812,3 +813,12 @@ export function failureSignature(run) {
812
813
  .replace(/\s+/g, " ");
813
814
  return [...new Set((telling.length > 0 ? telling : lines.slice(-20)).map(normal))].slice(0, 30).join("\n");
814
815
  }
816
+ /** The module whose config file builds a module, for finding its scripts - none when it cannot be told: the parse says why. */
817
+ function moduleOfSpec(plainFile) {
818
+ try {
819
+ return configModuleFor(plainFile);
820
+ }
821
+ catch {
822
+ return undefined;
823
+ }
824
+ }
@@ -2,7 +2,7 @@ import { type MarshalledPlainSource } from "../plain/spec.ts";
2
2
  /**
3
3
  * The steps of adding tests to a module, and the one it skipped. Nothing about testing exists until the person asks
4
4
  * for it; then, in order: its test reqs - the stack's conformance template, or its own - the conformance testing script
5
- * for its stack, and the scenarios in its test plain files. A module whose functional specs have scenarios but which
5
+ * for it, and the scenarios in its test plain files. A module whose functional specs have scenarios but which
6
6
  * skipped one of the first two has its conformance pulses refused - by the work loop and by `conform` alike - and
7
7
  * `parse` and the map say what is missing. A module with no scenarios skipped nothing: it is not tested.
8
8
  */
@@ -20,8 +20,8 @@ export interface TestingGap {
20
20
  */
21
21
  export declare function conformanceTemplateOf(plainFile: string): string | undefined;
22
22
  /**
23
- * The conformance testing script a module's tests would run with, looked for under its stack - the one pinned, else
24
- * the one `stackForModule` gives it - or nothing, with why when there is a why.
23
+ * The conformance testing script a module's tests would run with, looked for with its config - the one pinned, else the
24
+ * one `configModuleFor` gives it - or nothing, with why when there is a why.
25
25
  */
26
26
  export declare function conformanceScriptOf(plainFile: string, buildDir?: string): {
27
27
  script?: string;
@@ -29,9 +29,9 @@ export declare function conformanceScriptOf(plainFile: string, buildDir?: string
29
29
  };
30
30
  /**
31
31
  * The step of adding tests a module skipped, when its functional specs have scenarios: no test reqs - its own or
32
- * imported - or no conformance testing script for its stack. `tree` is what its conformance tests would be written from:
32
+ * imported - or no conformance testing script. `tree` is what its conformance tests would be written from:
33
33
  * the codebase's spec, the module's own sections with its imports in, and the functional specs it inherits. The script
34
- * is looked for under the module's stack - the one pinned, else the one `stackForModule` gives it.
34
+ * is looked for with the module's config - the one pinned, else the one `configModuleFor` gives it.
35
35
  */
36
36
  export declare function testingGap(input: {
37
37
  moduleName: string;
@@ -41,7 +41,7 @@ export declare function testingGap(input: {
41
41
  }): TestingGap | undefined;
42
42
  /**
43
43
  * The steps of adding tests a module still has to take before it has anything to test - in their order: its test reqs,
44
- * the conformance testing script for its stack, the scenarios - from the first one missing. What is said when conform
44
+ * its conformance testing script, the scenarios - from the first one missing. What is said when conform
45
45
  * finds no scenarios: the whole way there, not the last step alone.
46
46
  */
47
47
  export declare function stepsToScenarios(input: {
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { dirname, join, relative, resolve } from "node:path";
3
3
  import { conformanceTestsOn } from "../conformance-switch.js";
4
- import { stackForModule, stackPinned, testDirOf, withStack } from "../config.js";
4
+ import { configModuleFor, configModulePinned, testDirOf, withConfigModule } from "../config.js";
5
5
  import { IMPORT_DIRECTIVE, readPlainSourceMetadata } from "../plain/parser.js";
6
6
  import { FUNCTIONAL_REQUIREMENTS, REQUIRED_FUNCTIONAL_SPECS, TEST_REQUIREMENTS } from "../plain/spec.js";
7
7
  import { isStdlibModule, STDLIB_ROOT } from "../plain/stdlib.js";
@@ -50,16 +50,16 @@ export function conformanceTemplateOf(plainFile) {
50
50
  return conformance !== undefined && existsSync(join(STDLIB_ROOT, `${conformance}.plain`)) ? conformance : undefined;
51
51
  }
52
52
  /**
53
- * The conformance testing script a module's tests would run with, looked for under its stack - the one pinned, else
54
- * the one `stackForModule` gives it - or nothing, with why when there is a why.
53
+ * The conformance testing script a module's tests would run with, looked for with its config - the one pinned, else the
54
+ * one `configModuleFor` gives it - or nothing, with why when there is a why.
55
55
  */
56
56
  export function conformanceScriptOf(plainFile, buildDir) {
57
- const stack = stackPinned() ? undefined : stackForModule(plainFile);
57
+ const configModule = configModulePinned() ? undefined : configModuleFor(plainFile);
58
58
  const scripts = () => {
59
59
  const root = buildDir !== undefined ? projectRootFor(plainFile, buildDir) : projectDirOf(plainFile);
60
60
  return findTestScripts(root, plainFile, buildDir);
61
61
  };
62
- const found = stackPinned() ? scripts() : withStack(stack, scripts);
62
+ const found = configModulePinned() ? scripts() : withConfigModule(configModule, scripts);
63
63
  return { ...(found.conformance !== undefined ? { script: found.conformance } : {}), ...(found.notes?.conformance !== undefined ? { note: found.notes.conformance } : {}) };
64
64
  }
65
65
  /** The functional specs of a codebase's tree - its own, or ones it inherits - that have scenarios, as `module:func-id`, a module below's first. */
@@ -73,9 +73,9 @@ function named(specs) {
73
73
  }
74
74
  /**
75
75
  * The step of adding tests a module skipped, when its functional specs have scenarios: no test reqs - its own or
76
- * imported - or no conformance testing script for its stack. `tree` is what its conformance tests would be written from:
76
+ * imported - or no conformance testing script. `tree` is what its conformance tests would be written from:
77
77
  * the codebase's spec, the module's own sections with its imports in, and the functional specs it inherits. The script
78
- * is looked for under the module's stack - the one pinned, else the one `stackForModule` gives it.
78
+ * is looked for with the module's config - the one pinned, else the one `configModuleFor` gives it.
79
79
  */
80
80
  export function testingGap(input) {
81
81
  const { moduleName, plainFile } = input;
@@ -110,7 +110,7 @@ export function testingGap(input) {
110
110
  }
111
111
  /**
112
112
  * The steps of adding tests a module still has to take before it has anything to test - in their order: its test reqs,
113
- * the conformance testing script for its stack, the scenarios - from the first one missing. What is said when conform
113
+ * its conformance testing script, the scenarios - from the first one missing. What is said when conform
114
114
  * finds no scenarios: the whole way there, not the last step alone.
115
115
  */
116
116
  export function stepsToScenarios(input) {