@turri-dev/cli 0.2.4-next.240620d → 0.2.4-next.359b847

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 (134) hide show
  1. package/README.md +6 -7
  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 +10 -26
  11. package/dist/config-edit.d.ts +20 -8
  12. package/dist/config-edit.js +32 -24
  13. package/dist/config.d.ts +101 -58
  14. package/dist/config.js +265 -118
  15. package/dist/conform-cli.js +14 -3
  16. package/dist/conformance-switch.d.ts +7 -6
  17. package/dist/conformance-switch.js +19 -16
  18. package/dist/extension.d.ts +29 -3
  19. package/dist/extension.js +375 -351
  20. package/dist/genome.js +5 -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 +45 -21
  39. package/dist/loop-tools.js +152 -82
  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 +6 -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 +5 -3
  53. package/dist/regenerate/audit.js +9 -0
  54. package/dist/regenerate/base-folder.d.ts +2 -2
  55. package/dist/regenerate/base-folder.js +1 -1
  56. package/dist/regenerate/cases.js +7 -0
  57. package/dist/regenerate/chunk-plan.d.ts +5 -0
  58. package/dist/regenerate/chunk-plan.js +16 -1
  59. package/dist/regenerate/command-check.d.ts +7 -1
  60. package/dist/regenerate/command-check.js +43 -1
  61. package/dist/regenerate/delivery.d.ts +1 -1
  62. package/dist/regenerate/delivery.js +3 -3
  63. package/dist/regenerate/drift.d.ts +4 -0
  64. package/dist/regenerate/drift.js +26 -6
  65. package/dist/regenerate/job-panel.js +3 -1
  66. package/dist/regenerate/jobs.d.ts +2 -2
  67. package/dist/regenerate/jobs.js +10 -10
  68. package/dist/regenerate/launch.d.ts +154 -0
  69. package/dist/regenerate/{release.js → launch.js} +195 -51
  70. package/dist/regenerate/ledger.d.ts +33 -2
  71. package/dist/regenerate/lineage.d.ts +2 -0
  72. package/dist/regenerate/lineage.js +8 -0
  73. package/dist/regenerate/loop.d.ts +30 -10
  74. package/dist/regenerate/loop.js +166 -59
  75. package/dist/regenerate/model-names.d.ts +33 -0
  76. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  77. package/dist/regenerate/paths.d.ts +3 -3
  78. package/dist/regenerate/paths.js +4 -4
  79. package/dist/regenerate/records.d.ts +11 -0
  80. package/dist/regenerate/records.js +15 -0
  81. package/dist/regenerate/regenerate.js +4 -1
  82. package/dist/regenerate/renames.js +4 -4
  83. package/dist/regenerate/requires.d.ts +7 -0
  84. package/dist/regenerate/requires.js +24 -18
  85. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  86. package/dist/regenerate/scripts-being-written.js +3 -3
  87. package/dist/regenerate/spec-map.js +3 -3
  88. package/dist/regenerate/submit-work.d.ts +2 -0
  89. package/dist/regenerate/submit-work.js +8 -3
  90. package/dist/regenerate/test-scripts.d.ts +2 -1
  91. package/dist/regenerate/test-scripts.js +33 -23
  92. package/dist/regenerate/testing-steps.d.ts +6 -6
  93. package/dist/regenerate/testing-steps.js +8 -8
  94. package/dist/regenerate-cli.js +1 -1
  95. package/dist/self-invocation.d.ts +11 -0
  96. package/dist/self-invocation.js +36 -7
  97. package/dist/sentinel-check.d.ts +3 -3
  98. package/dist/sentinel-check.js +3 -3
  99. package/dist/sentinel.d.ts +18 -12
  100. package/dist/sentinel.js +72 -43
  101. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  102. package/dist/{config-command.js → settings.js} +155 -24
  103. package/dist/setup.d.ts +2 -2
  104. package/dist/setup.js +7 -7
  105. package/dist/turri-versions.js +2 -1
  106. package/docs/README.md +4 -4
  107. package/docs/chats.md +5 -6
  108. package/docs/claude-subscription.md +2 -2
  109. package/docs/config.md +58 -46
  110. package/docs/development.md +2 -2
  111. package/docs/headless.md +4 -4
  112. package/docs/hosting.md +20 -19
  113. package/docs/launch.md +67 -0
  114. package/docs/parser.md +2 -2
  115. package/docs/regenerating.md +21 -15
  116. package/docs/sandbox.md +3 -3
  117. package/docs/sentinel.md +26 -14
  118. package/docs/skills-and-gates.md +4 -4
  119. package/docs/using.md +19 -28
  120. package/genome/rules/project-model.md +2 -1
  121. package/genome/rules/turri-regeneration.md +5 -3
  122. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  123. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  124. package/package.json +1 -1
  125. package/dist/regenerate/engine.d.ts +0 -52
  126. package/dist/regenerate/release.d.ts +0 -121
  127. package/dist/release-agent.d.ts +0 -43
  128. package/dist/release-agent.js +0 -130
  129. package/dist/release-tools.d.ts +0 -44
  130. package/dist/release-tools.js +0 -170
  131. package/dist/stacks.d.ts +0 -13
  132. package/dist/stacks.js +0 -96
  133. package/docs/deploy.md +0 -48
  134. /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -32,6 +32,21 @@ export const REGENERATE_AGAIN = "regenerate_again";
32
32
  export function marksRegenerateAgain(item) {
33
33
  return typeof item === "object" && item !== null && item[REGENERATE_AGAIN] === true;
34
34
  }
35
+ /**
36
+ * A functional spec in the tests record marked to have its conformance tests written again: they are written, and are
37
+ * to be written anew all the same - `conform` with functional specs named, or a module's from scratch. Its code is
38
+ * untouched. The mark makes the tests record differ from what the tests are to be written for at that item, so the
39
+ * work loop plans a conformance pulse for it, and the pulse that writes them writes the item back without it.
40
+ */
41
+ export const CONFORM_AGAIN = "conform_again";
42
+ /** Whether a tests record's item is marked to have its conformance tests written again. */
43
+ export function marksConformAgain(item) {
44
+ return typeof item === "object" && item !== null && item[CONFORM_AGAIN] === true;
45
+ }
46
+ /** Whether a tests record's item is not written for the code as it is now: marked with its code to regenerate again, or to be written again. */
47
+ export function marksTestsAgain(item) {
48
+ return marksRegenerateAgain(item) || marksConformAgain(item);
49
+ }
35
50
  const itemsOf = (tree, heading) => (tree?.[heading] ?? []).slice();
36
51
  /** A tree without the sections it has nothing in, as the parser leaves them out. */
37
52
  function withoutEmpty(tree) {
@@ -570,11 +570,14 @@ export async function renderSpecDiff(options) {
570
570
  // Passing means the harness's own run of the unit testing script passed, last.
571
571
  const unitPassed = verified;
572
572
  const files = diffFiles(digestsBefore, digestFiles(buildDir));
573
+ // The report is what the agent said it did, handed over with submit_work - not what it said along the way, which reads
574
+ // as a plan ("next I'll check...") when its last words came before its last tool calls. Without an account, its words.
575
+ const account = work.last()?.summary.trim();
573
576
  const base = {
574
577
  moduleName,
575
578
  buildDir,
576
579
  diff: applied,
577
- response,
580
+ response: account !== undefined && account !== "" ? account : response,
578
581
  runs,
579
582
  attempts,
580
583
  testRemovals,
@@ -4,7 +4,7 @@ import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, FUNCTIONAL_REQUIREMENTS, REQUIRED_
4
4
  import { reportActivity } from "./activity.js";
5
5
  import { record } from "./ledger.js";
6
6
  import { abandonWork, landWork, moduleDirOf, startWork } from "./lineage.js";
7
- import { hasScenarios, marksRegenerateAgain, writeCodeRecord, writeTestsRecord } from "./records.js";
7
+ import { hasScenarios, marksRegenerateAgain, marksTestsAgain, writeCodeRecord, writeTestsRecord } from "./records.js";
8
8
  import { listFiles } from "./testing.js";
9
9
  const SECTIONS = [REQUIRED_FUNCTIONAL_SPECS, FUNCTIONAL_REQUIREMENTS];
10
10
  const KINDS = [
@@ -24,7 +24,7 @@ function stable(value) {
24
24
  }
25
25
  /** What of a functional spec the code is built from, but its func-id: its text, its links. */
26
26
  function codeOf(item) {
27
- const { id: _id, [CONFORMANCE_TESTS]: _conformance, [ACCEPTANCE_TESTS]: _acceptance, regenerate_again: _again, ...rest } = item;
27
+ const { id: _id, [CONFORMANCE_TESTS]: _conformance, [ACCEPTANCE_TESTS]: _acceptance, regenerate_again: _again, conform_again: _conform, ...rest } = item;
28
28
  return stable({ ...rest, markdown: String(rest.markdown ?? "").trim() });
29
29
  }
30
30
  const scenariosOf = (item, key) => item?.[key] ?? [];
@@ -58,7 +58,7 @@ export function pureRenames(code, tests, spec, module) {
58
58
  for (const gone of built.filter((item) => !inSpec.has(key(item)) && !marksRegenerateAgain(item))) {
59
59
  const testedItem = tested.find((item) => key(item) === key(gone));
60
60
  // Its tests, when it has them, written for it as it is built: the same text, not marked to be written again.
61
- if (testedItem !== undefined && (marksRegenerateAgain(testedItem) || codeOf(testedItem) !== codeOf(gone)))
61
+ if (testedItem !== undefined && (marksTestsAgain(testedItem) || codeOf(testedItem) !== codeOf(gone)))
62
62
  continue;
63
63
  const match = fresh.find((item) => !taken.has(item) &&
64
64
  moduleOf(item) === moduleOf(gone) &&
@@ -83,7 +83,7 @@ export function pureRenames(code, tests, spec, module) {
83
83
  const testedNow = sectionOf(testsNow, heading).map((item) => {
84
84
  const current = nowByKey.get(key(item));
85
85
  const have = builtNow.get(key(item));
86
- if (current === undefined || have === undefined || marksRegenerateAgain(item) || marksRegenerateAgain(have))
86
+ if (current === undefined || have === undefined || marksTestsAgain(item) || marksRegenerateAgain(have))
87
87
  return item;
88
88
  if (codeOf(item) !== codeOf(current) || codeOf(have) !== codeOf(current))
89
89
  return item;
@@ -90,6 +90,13 @@ export declare function builtTips(plainFile: string, options?: {
90
90
  export declare function copyRequiredCode(from: string, to: string, toModule: string,
91
91
  /** The module the code comes from: its functional specs are what the new one inherits. */
92
92
  fromModule: string): string[];
93
+ /**
94
+ * Copy a required module's conformance tests beside a codebase's code - into its `tests` directory, beside the code -
95
+ * as a codebase built on that module starts from them: their files and notes, and what they are written for as what
96
+ * the module inherits - its conformance suite is the chain's, kept up to date there from then on. `from` and `to` are
97
+ * the two codebases' code folders. Nothing, when the required module has no tests.
98
+ */
99
+ export declare function copyRequiredTests(from: string, to: string, fromModule: string): void;
93
100
  /**
94
101
  * A module the chain requires now that a module built in it was not built on: one required for
95
102
  * the first time - a new module the specs were split into, say - and the built modules above it,
@@ -303,27 +303,33 @@ fromModule) {
303
303
  const at = head(from);
304
304
  const recordStart = () => recordHistory(to, `start from ${source}${at ? ` at ${at}` : ""}`);
305
305
  // So do the conformance tests: they check the code that was just copied, and the new
306
- // module's regression suite has to keep them passing. They sit beside the code, in the
307
- // module's `tests` directory.
306
+ // module's regression suite has to keep them passing.
307
+ copyRequiredTests(from, to, fromModule);
308
+ recordStart();
309
+ return copied;
310
+ }
311
+ /**
312
+ * Copy a required module's conformance tests beside a codebase's code - into its `tests` directory, beside the code -
313
+ * as a codebase built on that module starts from them: their files and notes, and what they are written for as what
314
+ * the module inherits - its conformance suite is the chain's, kept up to date there from then on. `from` and `to` are
315
+ * the two codebases' code folders. Nothing, when the required module has no tests.
316
+ */
317
+ export function copyRequiredTests(from, to, fromModule) {
308
318
  const testsFrom = join(dirname(from), "tests");
309
319
  const testsTo = join(dirname(to), "tests");
310
- if (existsSync(testsFrom)) {
311
- for (const file of listFiles(testsFrom)) {
312
- const target = join(testsTo, file);
313
- mkdirSync(dirname(target), { recursive: true });
314
- copyFileSync(join(testsFrom, file), target);
315
- }
316
- // And their notes, which listFiles leaves out as it does the code's.
317
- if (existsSync(notesPath(testsFrom)) && !existsSync(notesPath(testsTo)))
318
- copyFileSync(notesPath(testsFrom), notesPath(testsTo));
319
- // What they are written for comes with them, as what the new module inherits: its conformance suite is the chain's,
320
- // kept up to date here from now on.
321
- const tested = readRecord(testsFrom);
322
- if (tested !== null)
323
- writeTestsRecord(testsTo, inheritedTestsRecord(tested, fromModule));
320
+ if (!existsSync(testsFrom))
321
+ return;
322
+ for (const file of listFiles(testsFrom)) {
323
+ const target = join(testsTo, file);
324
+ mkdirSync(dirname(target), { recursive: true });
325
+ copyFileSync(join(testsFrom, file), target);
324
326
  }
325
- recordStart();
326
- return copied;
327
+ // And their notes, which listFiles leaves out as it does the code's.
328
+ if (existsSync(notesPath(testsFrom)) && !existsSync(notesPath(testsTo)))
329
+ copyFileSync(notesPath(testsFrom), notesPath(testsTo));
330
+ const tested = readRecord(testsFrom);
331
+ if (tested !== null)
332
+ writeTestsRecord(testsTo, inheritedTestsRecord(tested, fromModule));
327
333
  }
328
334
  /**
329
335
  * A module the chain requires now that a module built in it was not built on: one required for
@@ -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) {
@@ -9,7 +9,7 @@ import { conformanceDirFor } from "./conformance.js";
9
9
  import { chainSpec } from "./loop.js";
10
10
  import { modulesRoot, projectDirOf } from "./paths.js";
11
11
  import { HISTORY_DIR } from "./lineage.js";
12
- import { codeTree, hasScenarios, marksRegenerateAgain, readRecord, RECORD_FILE } from "./records.js";
12
+ import { codeTree, hasScenarios, marksTestsAgain, readRecord, RECORD_FILE } from "./records.js";
13
13
  import { pureRenames } from "./renames.js";
14
14
  import { specFilesOf } from "./regenerate.js";
15
15
  import { builtTips, resolveRequiresChain } from "./requires.js";
@@ -136,7 +136,7 @@ export function pageItems(input) {
136
136
  }
137
137
  // Conformance tests: of the functional specs, by func-id, those the tests record has as they read now - their text and
138
138
  // their scenarios - as they read before, or taken out. Tests marked to regenerate again were written against code since
139
- // replaced: written for an earlier build, not now.
139
+ // replaced, and those marked to be written again are to be written anew: written for an earlier build, not now.
140
140
  const testedItems = new Map(itemsOf(input.tested ?? null, FUNCTIONAL_REQUIREMENTS).map((item) => [item.id ?? "", item]));
141
141
  const asNow = new Map(itemsOf(now, FUNCTIONAL_REQUIREMENTS).map((item) => [item.id ?? "", item]));
142
142
  const reads = (item) => JSON.stringify({ markdown: item.markdown.trim(), scenarios: scenarioViews(item) });
@@ -150,7 +150,7 @@ export function pageItems(input) {
150
150
  if (item.state === "removed")
151
151
  item.tests = "removed";
152
152
  else
153
- item.tests = !marksRegenerateAgain(tested) && current !== undefined && reads(tested) === reads(current) ? "now" : "older";
153
+ item.tests = !marksTestsAgain(tested) && current !== undefined && reads(tested) === reads(current) ? "now" : "older";
154
154
  }
155
155
  return keyed(items);
156
156
  }
@@ -30,6 +30,8 @@ export interface WorkLedger {
30
30
  peek: () => WorkAccount[];
31
31
  /** What was handed over since the last take - and from now, nothing. */
32
32
  take: () => WorkAccount[];
33
+ /** The last account handed over, taken or not: what the agent last said it did. */
34
+ last: () => WorkAccount | undefined;
33
35
  }
34
36
  export declare function createWorkLedger(): WorkLedger;
35
37
  /** The problems, numbered from 1, that no account answered. */
@@ -5,7 +5,9 @@ export const SUBMIT_WORK_NOTE = [
5
5
  "When you are done with a turn - the work written and its tests passing - call submit_work, last: a short summary of",
6
6
  "what you did and why, and after a review, an answer for each problem it raised - fixed, or declined and why. Its",
7
7
  "reviewer gets your account beside the diff of what you changed, and checks the one against the other: say what you",
8
- "did, not what you meant to.",
8
+ "did, not what you meant to. It is also the pulse's report to the person: say what the code does now, and a check you",
9
+ "ran as the check it was - \"breaking the tie order on purpose made 4 tests fail\" - never a bug you planted and undid",
10
+ "as if it were in the code.",
9
11
  ];
10
12
  /** What the agent is told with a review's problems: how it answers them. */
11
13
  export const SUBMIT_AFTER_REVIEW = [
@@ -13,6 +15,7 @@ export const SUBMIT_AFTER_REVIEW = [
13
15
  ];
14
16
  export function createWorkLedger() {
15
17
  let accounts = [];
18
+ let last;
16
19
  const tool = defineTool({
17
20
  name: "submit_work",
18
21
  label: "Submit the work",
@@ -20,7 +23,7 @@ export function createWorkLedger() {
20
23
  "raised, by its number - fixed, or declined and why, and the files. The reviewer checks it against the diff.",
21
24
  promptSnippet: "hand the work over for review - what you did, and your answer to each problem raised",
22
25
  parameters: Type.Object({
23
- summary: Type.String({ description: "What you did in this turn and why, in a few sentences" }),
26
+ summary: Type.String({ description: "What you did in this turn and why, in a few sentences - the pulse's report: what the code does now, a check you ran said as a check" }),
24
27
  answers: Type.Optional(Type.Array(Type.Object({
25
28
  problem: Type.Number({ description: "The problem's number in the review's list" }),
26
29
  outcome: Type.Union([Type.Literal("fixed"), Type.Literal("declined")]),
@@ -29,13 +32,15 @@ export function createWorkLedger() {
29
32
  }), { description: "After a review: one answer for each problem it raised. Omit on a first turn." })),
30
33
  }),
31
34
  async execute(_id, params) {
32
- accounts.push({ summary: params.summary, answers: (params.answers ?? []) });
35
+ last = { summary: params.summary, answers: (params.answers ?? []) };
36
+ accounts.push(last);
33
37
  return { content: [{ type: "text", text: "Handed over." }], details: {}, terminate: true };
34
38
  },
35
39
  });
36
40
  return {
37
41
  tool,
38
42
  peek: () => [...accounts],
43
+ last: () => last,
39
44
  take() {
40
45
  const taken = accounts;
41
46
  accounts = [];
@@ -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) {
@@ -17,7 +17,7 @@ build when none is given), coding-model (the agents that build) and harness-mode
17
17
  for every functional spec's scenarios.
18
18
 
19
19
  --dry-run look ahead: plan the work as regenerate would and print the prompt of each codebase's
20
- next pulse, starting and writing nothing
20
+ next pulse, starting nothing and changing no code or tests
21
21
  --start-over start over, without asking, a codebase regenerated without a module it now requires -
22
22
  with no terminal to ask and without it, the run stops there
23
23
  --from-scratch delete the module's code and conformance tests (its lineage keeps them) and regenerate all of it
@@ -8,6 +8,7 @@
8
8
  * the same build directories. It is never the right call unless the person asked for the
9
9
  * command line, so the harness refuses it and names the tool to use instead.
10
10
  */
11
+ import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
11
12
  /**
12
13
  * What a shell command would run of turri or pi itself, if anything: the subcommand,
13
14
  * or "pi" for another pi. `turri parse`, `drift` and `lineage` are not in it - they start no
@@ -23,3 +24,13 @@ export declare function askedForCommandLine(message: string): boolean;
23
24
  export declare function refusal(what: string, surface?: string): string;
24
25
  /** The instruction that goes into the conversation's system prompt. */
25
26
  export declare const TOOLS_NOT_CLI: string;
27
+ type AnyTool = ToolDefinition<any, any, any>;
28
+ /** What a skill's agent is told when its shell would run turri or another pi. */
29
+ export declare function skillRefusal(what: string): string;
30
+ /**
31
+ * A skill's shell: pi's bash in the project, refusing what its agent never runs there - turri or another pi again
32
+ * (selfInvocation), and a change to the machine's toolchains or settings (machineChange). The conversation's own bash is
33
+ * held to the same by its tool_call guard; a skill runs in a session of its own, which that guard does not see.
34
+ */
35
+ export declare function skillShell(cwd: string): AnyTool;
36
+ export {};
@@ -8,12 +8,14 @@
8
8
  * the same build directories. It is never the right call unless the person asked for the
9
9
  * command line, so the harness refuses it and names the tool to use instead.
10
10
  */
11
+ import { createBashToolDefinition } from "@earendil-works/pi-coding-agent";
12
+ import { machineChange, machineChangeReason } from "./regenerate/command-check.js";
11
13
  /** The tool that does what a turri subcommand does, from inside the conversation. */
12
14
  const TOOL_FOR = {
13
15
  regenerate: "regenerate",
14
16
  conform: "conform",
15
17
  cultivate: "cultivate",
16
- release: "release",
18
+ launch: "launch",
17
19
  chat: "nothing - you are the conversation already",
18
20
  ask: "nothing - you are the conversation already",
19
21
  };
@@ -30,7 +32,7 @@ const ENTRY = {
30
32
  "regenerate-cli": "regenerate",
31
33
  "conform-cli": "conform",
32
34
  "cultivate-cli": "cultivate",
33
- "release-cli": "release",
35
+ "launch-cli": "launch",
34
36
  };
35
37
  /** Where a command starts: the start of the string, or after a separator. */
36
38
  const AT_COMMAND = String.raw `(?:^|[\s;&|()\x60$])`;
@@ -40,10 +42,10 @@ const AT_COMMAND = String.raw `(?:^|[\s;&|()\x60$])`;
40
42
  * agent - and neither are setup and doctor.
41
43
  */
42
44
  export function selfInvocation(command) {
43
- const cli = new RegExp(`${AT_COMMAND}(?:npx\\s+)?turri\\s+(regenerate|conform|cultivate|release)\\b`).exec(command);
45
+ const cli = new RegExp(`${AT_COMMAND}(?:npx\\s+)?turri\\s+(regenerate|conform|cultivate|launch)\\b`).exec(command);
44
46
  if (cli)
45
47
  return cli[1];
46
- const launcher = new RegExp(`(?:bin/turri\\.mjs|src/cli\\.ts)\\s+(regenerate|conform|cultivate|release)\\b`).exec(command);
48
+ const launcher = new RegExp(`(?:bin/turri\\.mjs|src/cli\\.ts)\\s+(regenerate|conform|cultivate|launch)\\b`).exec(command);
47
49
  if (launcher)
48
50
  return launcher[1];
49
51
  // turri alone, or with options, is the conversation - where a command starts, not a word an argument names (`which turri`).
@@ -80,7 +82,7 @@ const PI_CONFIGURES = new Set([
80
82
  export function askedForCommandLine(message) {
81
83
  const text = message.toLowerCase();
82
84
  return (/\b(headless|command[ -]line|cli|terminal|shell|in bash|via bash|through bash|npm run|nohup)\b/.test(text) ||
83
- /\bturri\s+(regenerate|conform|cultivate|release)\b/.test(text) ||
85
+ /\bturri\s+(regenerate|conform|cultivate|launch)\b/.test(text) ||
84
86
  /(^|\s)turri\s+-p\b/.test(text) ||
85
87
  /(^|\s)pi\s+-p\b/.test(text));
86
88
  }
@@ -98,11 +100,38 @@ export function refusal(what, surface) {
98
100
  export const TOOLS_NOT_CLI = [
99
101
  "<turri-tools>",
100
102
  "In this conversation, you do your work with your tools - regenerate, conform, cultivate and the rest - which run as",
101
- "background jobs the user can watch and halt. To try what is regenerated, release it - never by hand in plain_modules. Never",
102
- "run your own command line (turri regenerate, conform, cultivate, release, turri itself; npm run",
103
+ "background jobs the user can watch and halt. To try what is regenerated, launch it - never by hand in plain_modules. Never",
104
+ "run your own command line (turri regenerate, conform, cultivate, launch, turri itself; npm run",
103
105
  "regenerate and the like) or start another pi through bash:",
104
106
  "that is a separate headless run the user cannot see or stop. Only when the user explicitly asks for the",
105
107
  "command line, run it. Configuring pi itself - turri install, update, remove, list; pi install, update, list, config, auth; or its settings files -",
106
108
  "is fine; it starts no agent.",
107
109
  "</turri-tools>",
108
110
  ].join("\n");
111
+ /** What a skill's agent is told when its shell would run turri or another pi. */
112
+ export function skillRefusal(what) {
113
+ return (`Not run: that starts ${what === "pi" ? "another agent" : `turri ${what}`} from the shell - a separate, headless run outside the person's session, ` +
114
+ "its pulses and /halt, writing the same codebases as the work loop. A skill starts no pulse: finish your own work, and say in what you " +
115
+ "hand back what should run next - the conversation runs it.");
116
+ }
117
+ /**
118
+ * A skill's shell: pi's bash in the project, refusing what its agent never runs there - turri or another pi again
119
+ * (selfInvocation), and a change to the machine's toolchains or settings (machineChange). The conversation's own bash is
120
+ * held to the same by its tool_call guard; a skill runs in a session of its own, which that guard does not see.
121
+ */
122
+ export function skillShell(cwd) {
123
+ const bash = createBashToolDefinition(cwd);
124
+ return {
125
+ ...bash,
126
+ async execute(toolCallId, params, signal, onUpdate, ctx) {
127
+ const command = String(params.command ?? "");
128
+ const what = selfInvocation(command);
129
+ if (what !== undefined)
130
+ throw new Error(skillRefusal(what));
131
+ const changes = machineChange(command);
132
+ if (changes !== undefined)
133
+ throw new Error(machineChangeReason(changes));
134
+ return bash.execute(toolCallId, params, signal, onUpdate, ctx);
135
+ },
136
+ };
137
+ }
@@ -1,7 +1,7 @@
1
1
  import type { SentinelCheck } from "./notice.ts";
2
2
  /**
3
- * A check a host asks the sentinel for (docs/sentinel.md): functional specs of one module, tested in the module's release -
4
- * its own codebase's last commit, which holds the code of every module its requires chain builds on. Refused before it is
3
+ * A check a host asks the sentinel for (docs/sentinel.md): functional specs of one module, tested in what is launched of
4
+ * it - its own codebase's code, which holds the code of every module its requires chain builds on. Refused before it is
5
5
  * queued when there is nothing to test: a module that is not there or does not parse, a func-id it does not have, one
6
6
  * not built in its codebase as its ***plain has it now.
7
7
  */
@@ -10,7 +10,7 @@ export interface CheckRequest {
10
10
  module: string;
11
11
  /**
12
12
  * The functional specs to test, each `module:func-id` - of the module, or of any module its requires chain builds on,
13
- * whose code its release holds. A bare func-id is the module's own.
13
+ * whose code its codebase holds. A bare func-id is the module's own.
14
14
  */
15
15
  funcIds: string[];
16
16
  }