@turri-dev/cli 0.2.3 → 0.2.4-next.009bd0c

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 (175) hide show
  1. package/README.md +7 -8
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-idle.d.ts +2 -2
  4. package/dist/chat-idle.js +2 -2
  5. package/dist/chat-models.d.ts +1 -1
  6. package/dist/chat-models.js +1 -1
  7. package/dist/chat-scope.d.ts +1 -3
  8. package/dist/chat-skills.d.ts +1 -1
  9. package/dist/chat-skills.js +1 -1
  10. package/dist/chats.d.ts +44 -20
  11. package/dist/chats.js +125 -64
  12. package/dist/cli.js +12 -31
  13. package/dist/config-edit.d.ts +20 -8
  14. package/dist/config-edit.js +32 -26
  15. package/dist/config.d.ts +106 -78
  16. package/dist/config.js +267 -133
  17. package/dist/conform-cli.js +14 -3
  18. package/dist/conformance-switch.d.ts +13 -22
  19. package/dist/conformance-switch.js +37 -59
  20. package/dist/drift-cli.js +1 -1
  21. package/dist/extension.d.ts +17 -10
  22. package/dist/extension.js +425 -531
  23. package/dist/genome.js +10 -49
  24. package/dist/graph.js +3 -5
  25. package/dist/host-session.d.ts +11 -21
  26. package/dist/host-session.js +6 -8
  27. package/dist/host.d.ts +4 -4
  28. package/dist/host.js +4 -7
  29. package/dist/identity.js +2 -3
  30. package/dist/init-config.d.ts +1 -2
  31. package/dist/init-config.js +10 -17
  32. package/dist/installed-providers.d.ts +1 -1
  33. package/dist/installed-providers.js +1 -1
  34. package/dist/launch-agent.d.ts +41 -0
  35. package/dist/launch-agent.js +219 -0
  36. package/dist/{release-cli.js → launch-cli.js} +41 -24
  37. package/dist/launch-session.d.ts +58 -0
  38. package/dist/launch-session.js +195 -0
  39. package/dist/launch-tools.d.ts +28 -0
  40. package/dist/launch-tools.js +69 -0
  41. package/dist/launch-track.d.ts +120 -0
  42. package/dist/launch-track.js +298 -0
  43. package/dist/loop-cli.d.ts +4 -3
  44. package/dist/loop-cli.js +17 -15
  45. package/dist/loop-tools.d.ts +45 -21
  46. package/dist/loop-tools.js +155 -90
  47. package/dist/new-project.js +2 -2
  48. package/dist/notice.d.ts +7 -6
  49. package/dist/parse-cli.js +2 -2
  50. package/dist/pi-launch.js +4 -1
  51. package/dist/pi-settings.d.ts +4 -0
  52. package/dist/pi-settings.js +39 -0
  53. package/dist/pi.js +12 -9
  54. package/dist/plain/check.d.ts +2 -9
  55. package/dist/plain/check.js +6 -39
  56. package/dist/plain-files.d.ts +2 -2
  57. package/dist/plain-files.js +7 -7
  58. package/dist/regenerate/activity.d.ts +0 -7
  59. package/dist/regenerate/activity.js +2 -20
  60. package/dist/regenerate/agent-env.d.ts +1 -1
  61. package/dist/regenerate/agent-env.js +3 -3
  62. package/dist/regenerate/agent-shell.js +5 -3
  63. package/dist/regenerate/audit.js +9 -0
  64. package/dist/regenerate/base-folder.d.ts +2 -2
  65. package/dist/regenerate/base-folder.js +1 -1
  66. package/dist/regenerate/cases.js +7 -0
  67. package/dist/regenerate/chunk-plan.d.ts +5 -0
  68. package/dist/regenerate/chunk-plan.js +16 -1
  69. package/dist/regenerate/command-check.d.ts +1 -1
  70. package/dist/regenerate/command-check.js +1 -1
  71. package/dist/regenerate/delivery.d.ts +1 -1
  72. package/dist/regenerate/delivery.js +3 -3
  73. package/dist/regenerate/drift.d.ts +4 -0
  74. package/dist/regenerate/drift.js +26 -6
  75. package/dist/regenerate/failure-reports.d.ts +28 -0
  76. package/dist/regenerate/failure-reports.js +79 -0
  77. package/dist/regenerate/job-panel.js +3 -1
  78. package/dist/regenerate/jobs-tree.js +1 -1
  79. package/dist/regenerate/jobs.d.ts +4 -2
  80. package/dist/regenerate/jobs.js +14 -10
  81. package/dist/regenerate/launch.d.ts +126 -0
  82. package/dist/regenerate/{release.js → launch.js} +60 -48
  83. package/dist/regenerate/ledger-view.d.ts +11 -24
  84. package/dist/regenerate/ledger-view.js +14 -60
  85. package/dist/regenerate/ledger.d.ts +26 -16
  86. package/dist/regenerate/ledger.js +1 -1
  87. package/dist/regenerate/lineage.d.ts +2 -0
  88. package/dist/regenerate/lineage.js +8 -0
  89. package/dist/regenerate/loop.d.ts +54 -67
  90. package/dist/regenerate/loop.js +312 -148
  91. package/dist/regenerate/model-names.d.ts +33 -0
  92. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  93. package/dist/regenerate/paths.d.ts +3 -3
  94. package/dist/regenerate/paths.js +4 -4
  95. package/dist/regenerate/records.d.ts +11 -0
  96. package/dist/regenerate/records.js +15 -0
  97. package/dist/regenerate/regenerate.d.ts +0 -2
  98. package/dist/regenerate/regenerate.js +4 -15
  99. package/dist/regenerate/renames.js +4 -4
  100. package/dist/regenerate/requires.d.ts +7 -0
  101. package/dist/regenerate/requires.js +24 -18
  102. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  103. package/dist/regenerate/scripts-being-written.js +3 -3
  104. package/dist/regenerate/spec-map.js +3 -3
  105. package/dist/regenerate/standing.js +1 -1
  106. package/dist/regenerate/submit-work.d.ts +2 -0
  107. package/dist/regenerate/submit-work.js +8 -3
  108. package/dist/regenerate/test-scripts.d.ts +2 -1
  109. package/dist/regenerate/test-scripts.js +33 -23
  110. package/dist/regenerate/testing-steps.d.ts +16 -5
  111. package/dist/regenerate/testing-steps.js +28 -9
  112. package/dist/regenerate-cli.js +18 -9
  113. package/dist/self-invocation.d.ts +11 -0
  114. package/dist/self-invocation.js +36 -10
  115. package/dist/sentinel-check.d.ts +3 -3
  116. package/dist/sentinel-check.js +3 -3
  117. package/dist/sentinel.d.ts +17 -12
  118. package/dist/sentinel.js +75 -46
  119. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  120. package/dist/{config-command.js → settings.js} +155 -24
  121. package/dist/setup.d.ts +2 -2
  122. package/dist/setup.js +7 -7
  123. package/dist/skill.d.ts +0 -11
  124. package/dist/skill.js +0 -9
  125. package/dist/tools.js +2 -3
  126. package/dist/turri-versions.js +2 -1
  127. package/docs/README.md +4 -6
  128. package/docs/authoring-plain.md +3 -3
  129. package/docs/chats.md +6 -9
  130. package/docs/claude-subscription.md +2 -2
  131. package/docs/config.md +61 -51
  132. package/docs/development.md +4 -5
  133. package/docs/headless.md +7 -6
  134. package/docs/hosting.md +24 -23
  135. package/docs/launch.md +63 -0
  136. package/docs/parser.md +3 -3
  137. package/docs/regenerating.md +30 -22
  138. package/docs/sandbox.md +3 -3
  139. package/docs/sentinel.md +27 -16
  140. package/docs/skills-and-gates.md +6 -11
  141. package/docs/using.md +25 -42
  142. package/genome/rules/project-model.md +2 -1
  143. package/genome/rules/test-plain-files.md +15 -7
  144. package/genome/rules/turri-regeneration.md +7 -10
  145. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  146. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  147. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  148. package/package.json +1 -1
  149. package/dist/advisor-chat.d.ts +0 -63
  150. package/dist/advisor-chat.js +0 -290
  151. package/dist/change-plain-cli.js +0 -55
  152. package/dist/ledger-cli.d.ts +0 -1
  153. package/dist/ledger-cli.js +0 -50
  154. package/dist/ledger-tools.d.ts +0 -10
  155. package/dist/ledger-tools.js +0 -64
  156. package/dist/regenerate/advisor-records.d.ts +0 -93
  157. package/dist/regenerate/advisor-records.js +0 -110
  158. package/dist/regenerate/advisor-runs.d.ts +0 -87
  159. package/dist/regenerate/advisor-runs.js +0 -327
  160. package/dist/regenerate/engine.d.ts +0 -52
  161. package/dist/regenerate/release.d.ts +0 -121
  162. package/dist/regenerate/test-advisor.d.ts +0 -101
  163. package/dist/regenerate/test-advisor.js +0 -379
  164. package/dist/release-agent.d.ts +0 -43
  165. package/dist/release-agent.js +0 -130
  166. package/dist/release-cli.d.ts +0 -1
  167. package/dist/release-tools.d.ts +0 -44
  168. package/dist/release-tools.js +0 -170
  169. package/dist/spec-tools.d.ts +0 -36
  170. package/dist/spec-tools.js +0 -128
  171. package/dist/stacks.d.ts +0 -13
  172. package/dist/stacks.js +0 -96
  173. package/docs/deploy.md +0 -48
  174. package/docs/test-advisor.md +0 -110
  175. /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
@@ -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);
@@ -24,6 +24,17 @@ export { RECORD_FILE } from "./paths.ts";
24
24
  export declare const REGENERATE_AGAIN = "regenerate_again";
25
25
  /** Whether a record's item is marked to regenerate again. */
26
26
  export declare function marksRegenerateAgain(item: unknown): boolean;
27
+ /**
28
+ * A functional spec in the tests record marked to have its conformance tests written again: they are written, and are
29
+ * to be written anew all the same - `conform` with functional specs named, or a module's from scratch. Its code is
30
+ * untouched. The mark makes the tests record differ from what the tests are to be written for at that item, so the
31
+ * work loop plans a conformance pulse for it, and the pulse that writes them writes the item back without it.
32
+ */
33
+ export declare const CONFORM_AGAIN = "conform_again";
34
+ /** Whether a tests record's item is marked to have its conformance tests written again. */
35
+ export declare function marksConformAgain(item: unknown): boolean;
36
+ /** 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. */
37
+ export declare function marksTestsAgain(item: unknown): boolean;
27
38
  /**
28
39
  * Whether a functional spec has scenarios - conformance or acceptance - and so is tested: one with an empty test plain
29
40
  * file is not.
@@ -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) {
@@ -10,8 +10,6 @@ import { type TestRemoval, type TestRun, type MissingToolchain } from "./testing
10
10
  * one that fits neither way is refused: rendering it would mean guessing.
11
11
  */
12
12
  export declare function applySpecDiff(diff: string, cwd: string): "applied" | "already applied";
13
- /** Undo a spec diff this process applied, when what it produced cannot be used. */
14
- export declare function revertSpecDiff(diff: string, cwd: string): void;
15
13
  /** The .plain files a diff writes to, relative to where it applies. */
16
14
  export declare function plainFilesOf(diff: string): string[];
17
15
  /** A module's .plain file and every one it imports, transitively - the files its spec is read from. */
@@ -88,20 +88,6 @@ export function applySpecDiff(diff, cwd) {
88
88
  written();
89
89
  }
90
90
  }
91
- /** Undo a spec diff this process applied, when what it produced cannot be used. */
92
- export function revertSpecDiff(diff, cwd) {
93
- const written = conversationWriting(plainFilesOf(diff).map((file) => resolve(cwd, file)));
94
- const dir = mkdtempSync(join(tmpdir(), "turri-diff-"));
95
- const patch = join(dir, "spec.diff");
96
- writeFileSync(patch, diff.endsWith("\n") ? diff : `${diff}\n`);
97
- try {
98
- spawnSync("git", ["apply", "--recount", "--reverse", patch], { cwd, encoding: "utf8" });
99
- }
100
- finally {
101
- rmSync(dir, { recursive: true, force: true });
102
- written();
103
- }
104
- }
105
91
  /** The .plain files a diff writes to, relative to where it applies. */
106
92
  export function plainFilesOf(diff) {
107
93
  const files = new Set();
@@ -584,11 +570,14 @@ export async function renderSpecDiff(options) {
584
570
  // Passing means the harness's own run of the unit testing script passed, last.
585
571
  const unitPassed = verified;
586
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();
587
576
  const base = {
588
577
  moduleName,
589
578
  buildDir,
590
579
  diff: applied,
591
- response,
580
+ response: account !== undefined && account !== "" ? account : response,
592
581
  runs,
593
582
  attempts,
594
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
  }
@@ -7,7 +7,7 @@ import { projectPlainFiles } from "./requires.js";
7
7
  export function projectStanding(projectDir, options = {}) {
8
8
  const root = resolve(projectDir);
9
9
  const files = (options.files ?? projectPlainFiles(root)).map((file) => resolve(root, file));
10
- const loop = options.loop ?? createWorkLoop({ registry: createJobRegistry(), cwd: root, dryRun: true });
10
+ const loop = options.loop ?? createWorkLoop({ registry: createJobRegistry(), cwd: root });
11
11
  return withParseCache(() => files.map((plainFile) => {
12
12
  const standing = { plainFile, module: basename(plainFile, PLAIN_SOURCE_FILE_EXTENSION) };
13
13
  try {
@@ -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;
@@ -39,3 +39,14 @@ export declare function testingGap(input: {
39
39
  tree: MarshalledPlainSource;
40
40
  buildDir?: string;
41
41
  }): TestingGap | undefined;
42
+ /**
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
+ * its conformance testing script, the scenarios - from the first one missing. What is said when conform
45
+ * finds no scenarios: the whole way there, not the last step alone.
46
+ */
47
+ export declare function stepsToScenarios(input: {
48
+ moduleName: string;
49
+ plainFile: string;
50
+ tree: MarshalledPlainSource;
51
+ buildDir?: string;
52
+ }): string;