@turri-dev/cli 0.2.3-next.fea0bd9 → 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 (176) hide show
  1. package/README.md +57 -62
  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 +42 -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 +31 -12
  22. package/dist/extension.js +555 -556
  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 +2 -2
  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 +57 -65
  90. package/dist/regenerate/loop.js +354 -171
  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 +37 -11
  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 +8 -8
  131. package/docs/config.md +62 -52
  132. package/docs/development.md +4 -5
  133. package/docs/headless.md +7 -6
  134. package/docs/hosting.md +25 -24
  135. package/docs/installation.md +4 -0
  136. package/docs/launch.md +63 -0
  137. package/docs/parser.md +3 -3
  138. package/docs/regenerating.md +30 -22
  139. package/docs/sandbox.md +3 -3
  140. package/docs/sentinel.md +27 -16
  141. package/docs/skills-and-gates.md +6 -11
  142. package/docs/using.md +26 -42
  143. package/genome/rules/project-model.md +2 -1
  144. package/genome/rules/test-plain-files.md +15 -7
  145. package/genome/rules/turri-regeneration.md +7 -10
  146. package/genome/skills/convert-old-syntax/SKILL.md +5 -5
  147. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  148. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  149. package/package.json +1 -1
  150. package/dist/advisor-chat.d.ts +0 -63
  151. package/dist/advisor-chat.js +0 -290
  152. package/dist/change-plain-cli.js +0 -55
  153. package/dist/ledger-cli.d.ts +0 -1
  154. package/dist/ledger-cli.js +0 -50
  155. package/dist/ledger-tools.d.ts +0 -10
  156. package/dist/ledger-tools.js +0 -64
  157. package/dist/regenerate/advisor-records.d.ts +0 -93
  158. package/dist/regenerate/advisor-records.js +0 -110
  159. package/dist/regenerate/advisor-runs.d.ts +0 -87
  160. package/dist/regenerate/advisor-runs.js +0 -327
  161. package/dist/regenerate/engine.d.ts +0 -52
  162. package/dist/regenerate/release.d.ts +0 -121
  163. package/dist/regenerate/test-advisor.d.ts +0 -101
  164. package/dist/regenerate/test-advisor.js +0 -379
  165. package/dist/release-agent.d.ts +0 -43
  166. package/dist/release-agent.js +0 -130
  167. package/dist/release-cli.d.ts +0 -1
  168. package/dist/release-tools.d.ts +0 -44
  169. package/dist/release-tools.js +0 -170
  170. package/dist/spec-tools.d.ts +0 -36
  171. package/dist/spec-tools.js +0 -128
  172. package/dist/stacks.d.ts +0 -13
  173. package/dist/stacks.js +0 -96
  174. package/docs/deploy.md +0 -48
  175. package/docs/test-advisor.md +0 -110
  176. /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/pi.js CHANGED
@@ -3,12 +3,12 @@ import { fileURLToPath } from "node:url";
3
3
  import { createAgentSession, DefaultResourceLoader, getAgentDir, ModelRegistry, SessionManager, } from "@earendil-works/pi-coding-agent";
4
4
  import { installedProviders, runtimeWithProviders } from "./installed-providers.js";
5
5
  import { loadRules, renderRulesBlock } from "./rules.js";
6
- import { debugMode, inheritModel, stackOf, readProjectConfig, ROLE_THINKING, roleModel, roleTurnLimitMs, splitModelSpec } from "./config.js";
6
+ import { debugMode, inheritModel, configModuleOf, readProjectConfig, ROLE_THINKING, roleModel, roleTurnLimitMs, splitModelSpec } from "./config.js";
7
7
  import { maskToolResults } from "./regenerate/masking.js";
8
8
  import { withListArguments } from "./regenerate/list-arguments.js";
9
9
  import { checkAgainstScript, ENVIRONMENT_ERROR_TOOL, EnvironmentError, environmentErrorTool, sandboxGapOf } from "./regenerate/environment-error.js";
10
10
  import { MODULES_DIR, projectRootOf, sessionsDir } from "./regenerate/paths.js";
11
- import { currentStopSignal, describeToolCall, describeToolResult, JobStoppedError, shownName, reportActivity, reportNow, reportAgent, reportTranscript, reportModelEvent, reportUsage, } from "./regenerate/activity.js";
11
+ import { currentStopSignal, describeToolCall, describeToolResult, JobStoppedError, reportActivity, reportNow, reportAgent, reportTranscript, reportModelEvent, reportUsage, } from "./regenerate/activity.js";
12
12
  import { debugLogOf, startDebugLog } from "./regenerate/debug-log.js";
13
13
  import { firstLine, record } from "./regenerate/ledger.js";
14
14
  let thinkingSource;
@@ -317,6 +317,9 @@ async function askOnce(session, text, onDelta) {
317
317
  reportNow("thinking");
318
318
  }
319
319
  else if (update.type === "text_start") {
320
+ // Each message of the turn its own paragraph: the agent's words between tool calls never run into each other.
321
+ if (out !== "" && !/\s$/.test(out))
322
+ out += "\n\n";
320
323
  reportNow("writing");
321
324
  }
322
325
  else if (update.type === "toolcall_start") {
@@ -330,20 +333,20 @@ async function askOnce(session, text, onDelta) {
330
333
  lastCallReport = now;
331
334
  const block = update.partial.content[update.contentIndex];
332
335
  const size = callChars >= 1000 ? `${(callChars / 1000).toFixed(1)}k` : `${callChars}`;
333
- reportNow(`writing ${block?.name !== undefined ? shownName(block.name) : "a tool"} call · ${size} chars`, { keepSince: true });
336
+ reportNow(`writing ${block?.name ?? "a tool"} call · ${size} chars`, { keepSince: true });
334
337
  }
335
338
  }
336
339
  }
337
340
  if (event.type === "tool_execution_start") {
338
341
  toolStarted.set(event.toolCallId, Date.now());
339
342
  const args = JSON.stringify(event.args ?? {});
340
- transcript({ kind: "tool", text: `${shownName(event.toolName)} ${clipText(args, MAX_TOOL_ARGS)}`, full: `${shownName(event.toolName)} ${args}` });
343
+ transcript({ kind: "tool", text: `${event.toolName} ${clipText(args, MAX_TOOL_ARGS)}`, full: `${event.toolName} ${args}` });
341
344
  const took = Date.now() - stepStarted;
342
345
  // Which agent made the call, by its role: several work in one pulse.
343
346
  const role = agentRoles.get(session);
344
347
  const line = `${role !== undefined ? `(${role}) ` : ""}${describeToolCall(event.toolName, event.args)}`;
345
348
  reportActivity(took >= 1000 ? `${line} (model ${seconds(took)})` : line);
346
- reportNow(`running ${shownName(event.toolName)}`);
349
+ reportNow(`running ${event.toolName}`);
347
350
  }
348
351
  if (event.type === "tool_execution_end") {
349
352
  failing = event.isError ? (event.toolName === failingTool ? failing + 1 : 1) : 0;
@@ -352,9 +355,9 @@ async function askOnce(session, text, onDelta) {
352
355
  // A call its tool refuses never reaches the tool, so no guard on the tools sees it: an agent can
353
356
  // make the same bad call, worded a little differently, thousands of times. Its turn ends here, and
354
357
  // the harness goes on from there, as after any turn.
355
- reportActivity(` stopped the agent's turn: ${failing} ${shownName(event.toolName)} calls failed in a row`);
358
+ reportActivity(` stopped the agent's turn: ${failing} ${event.toolName} calls failed in a row`);
356
359
  debugLogOf(session)?.note(`turn stopped: ${failing} ${event.toolName} calls failed in a row`);
357
- stopTurn(session, `${failing} ${shownName(event.toolName)} calls failed in a row`);
360
+ stopTurn(session, `${failing} ${event.toolName} calls failed in a row`);
358
361
  }
359
362
  const output = resultText(event.result);
360
363
  const started = toolStarted.get(event.toolCallId);
@@ -800,11 +803,11 @@ export async function createExecutor(opts) {
800
803
  }
801
804
  return session;
802
805
  }
803
- /** The config an agent working in `cwd` is under: the project's, with the chosen stack's over it. */
806
+ /** The config an agent working in `cwd` is under: the project's, with the pulse's module's own file over it. */
804
807
  function configForCwd(cwd) {
805
808
  try {
806
809
  const root = projectRootOf(cwd);
807
- return readProjectConfig(root, stackOf(root));
810
+ return readProjectConfig(root, configModuleOf(root));
808
811
  }
809
812
  catch {
810
813
  return {};
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Static validation of ***plain, using this repo's own parser - `turri parse`, the chat's `parse`, and the check
3
- * `change_plain` and `turri change-plain` run on what a change touched.
3
+ * `regenerate` runs on the module it is given.
4
4
  *
5
5
  * It parses each module with its test plain files, resolves its imports and required modules, and reports every error
6
6
  * the parser can see without generating anything. The parser's errors come one at a time, the first it meets, as the
7
7
  * reference gives them. turri's own checks list everything they find at once: every functional spec without a test
8
8
  * plain file, and every test plain file that is not where it belongs. A module whose functional specs have scenarios
9
- * but which has no test reqs, or no conformance testing script for its stack, passes with a warning.
9
+ * but which has no test reqs, or no conformance testing script, passes with a warning.
10
10
  */
11
11
  export interface CheckedFunctionalSpec {
12
12
  funcId: string;
@@ -55,13 +55,6 @@ export declare function resolvePlainTargets(target: string): string[];
55
55
  * project's test folder, once, at the end.
56
56
  */
57
57
  export declare function checkPlainTargets(target: string, templateDirs?: string[]): CheckResult[];
58
- /**
59
- * The check of what a ***plain change touched, shared by `change_plain` and `turri change-plain`: each module it
60
- * touched, an import module as the modules that import it read it, and each test plain file as its module - by its
61
- * folder - is parsed with its test plain files; a test plain file the change put where it does not belong is refused
62
- * as `parse` refuses it. A file the change deleted is checked through the module it belonged to.
63
- */
64
- export declare function checkTouchedPlain(paths: string[]): CheckResult[];
65
58
  /**
66
59
  * One line per file, plus the parser's message under any that failed and turri's next step, or every problem turri
67
60
  * found; a module that passed, its functional specs under it, each with its test plain file and its scenarios - and
@@ -1,13 +1,13 @@
1
1
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
2
  import { basename, extname, join, relative, resolve, sep } from "node:path";
3
- import { testDirOf } from "../config.js";
3
+ import { configModuleFor, testDirOf } from "../config.js";
4
4
  import { projectDirOf, resolveTemplateDirs } from "../regenerate/paths.js";
5
- import { importingModules, isImportModule } from "../regenerate/requires.js";
5
+ import { isImportModule } from "../regenerate/requires.js";
6
6
  import { testingGap } from "../regenerate/testing-steps.js";
7
7
  import { missingBaseFolder } from "../regenerate/base-folder.js";
8
8
  import { conformanceTestsOn } from "../conformance-switch.js";
9
9
  import { testedFuncIds } from "../regenerate/records.js";
10
- import { moduleOfTestPlainFile, projectModules, strayTestPlainFiles, testPlaceOf, testPlainFileRefusal } from "../test-plain-files.js";
10
+ import { projectModules, strayTestPlainFiles, testPlainFileRefusal } from "../test-plain-files.js";
11
11
  import { plainFileParser, PLAIN_SOURCE_FILE_EXTENSION, PREVIOUS_SYNTAX_HINT, readPlainSourceMetadata, REQUIRES_DIRECTIVE } from "./parser.js";
12
12
  import { ACCEPTANCE_TESTS, CONFORMANCE_TESTS, getFunctionalSpecs, TEST_PLAIN_FILES, } from "./spec.js";
13
13
  /** Whether a parser error is one the previous ***plain syntax makes. */
@@ -67,7 +67,7 @@ function testingGapsOf(moduleName, path, tree, projectDir, templateDirs) {
67
67
  if (!conformanceTestsOn(path)) {
68
68
  const tested = testedFuncIds(tree);
69
69
  return tested.length > 0
70
- ? [`its scenarios are not tested - ${tested.map((funcId) => `${moduleName}:${funcId}`).join(", ")}: conformance tests are off (conformance-tests: false, or unset). Asking for them in the chat turns them on, or conformance-tests: true in config.turri.yaml.`]
70
+ ? [`its scenarios are not tested - ${tested.map((funcId) => `${moduleName}:${funcId}`).join(", ")}: conformance tests are off (conformance-tests: false, or unset). /conform in the chat turns them on, or conformance-tests: true in config.turri.yaml.`]
71
71
  : [];
72
72
  }
73
73
  const tips = tipsAbove(moduleName, projectDir);
@@ -114,6 +114,8 @@ export function checkPlainFile(file, templateDirs = []) {
114
114
  testDir,
115
115
  requireTestPlainFiles: false,
116
116
  });
117
+ // Two config files among the modules it requires: which one builds it cannot be told - an error, as a syntax one is.
118
+ configModuleFor(path);
117
119
  // Scenarios with a step of adding tests skipped - the test reqs, or the conformance testing script: a warning, never a failure.
118
120
  const gaps = testingGapsOf(moduleName, path, tree, projectDir, templateDirs);
119
121
  // A codebase that requires nothing starts from its base folder: one named and not there stops its first pulse.
@@ -192,41 +194,6 @@ export function checkPlainTargets(target, templateDirs = []) {
192
194
  }
193
195
  return results;
194
196
  }
195
- /**
196
- * The check of what a ***plain change touched, shared by `change_plain` and `turri change-plain`: each module it
197
- * touched, an import module as the modules that import it read it, and each test plain file as its module - by its
198
- * folder - is parsed with its test plain files; a test plain file the change put where it does not belong is refused
199
- * as `parse` refuses it. A file the change deleted is checked through the module it belonged to.
200
- */
201
- export function checkTouchedPlain(paths) {
202
- const modules = new Set();
203
- const results = [];
204
- for (const given of paths) {
205
- const path = resolve(given);
206
- const place = testPlaceOf(path);
207
- if (place !== undefined && !place.directory) {
208
- const stray = strayTestPlainFiles(place.projectDir).find((found) => resolve(place.projectDir, found.file) === path);
209
- if (stray !== undefined) {
210
- results.push({ file: path, ok: false, errorType: "a test plain file outside its module's folder", problems: [`${stray.file} - ${stray.problem}`] });
211
- continue;
212
- }
213
- const owner = moduleOfTestPlainFile(path);
214
- if (owner?.plainFile !== undefined)
215
- modules.add(owner.plainFile);
216
- else if (owner !== undefined)
217
- results.push({ file: path, ok: false, errorType: "a test plain file outside a module's folder", problems: [`${shown(path, place.projectDir)} - no module ${owner.module}`] });
218
- continue;
219
- }
220
- if (!existsSync(path))
221
- continue;
222
- const importing = isImportModule(path) ? importingModules(path) : [];
223
- for (const module of importing.length > 0 ? importing : [path])
224
- modules.add(resolve(module));
225
- }
226
- for (const module of modules)
227
- results.push(checkPlainFile(module));
228
- return results;
229
- }
230
197
  /** Columns padded to their widest cell, each line indented under the module's. */
231
198
  function columns(rows) {
232
199
  const widths = rows.reduce((acc, row) => row.map((cell, index) => Math.max(acc[index] ?? 0, cell.length)), []);
@@ -1,7 +1,7 @@
1
1
  import { type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
2
  /**
3
3
  * The project's ***plain and what it is built with, and a digest of each: its .plain files, the resources they link,
4
- * its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a release,
4
+ * its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a launch,
5
5
  * what a running app writes. `also`: paths that were among them before, digested while they are there, so one a skill
6
6
  * stopped linking or naming is still seen if it changed it.
7
7
  */
@@ -11,7 +11,7 @@ export declare function changedFiles(before: Map<string, string>, after: Map<str
11
11
  /**
12
12
  * Why a skill's agent may not write a path, or nothing when it may. It writes the project's ***plain: a file of it
13
13
  * (`projectFiles`), or a new one - a resource it is about to link, a testing script - anywhere in the project but where
14
- * what is built, released or installed lives. Never an existing file that is not the ***plain's: the code, a release,
14
+ * what is built, launched or installed lives. Never an existing file that is not the ***plain's: the code, a launch,
15
15
  * what an app it started writes.
16
16
  */
17
17
  export declare function plainWriteRefusal(root: string, path: string): string | undefined;
@@ -2,14 +2,14 @@ import { createHash } from "node:crypto";
2
2
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { basename, isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { createEditToolDefinition, createWriteToolDefinition } from "@earendil-works/pi-coding-agent";
5
- import { readProjectConfig, stacksOf } from "./config.js";
5
+ import { readProjectConfig, moduleConfigsOf } from "./config.js";
6
6
  import { parseMarkdown } from "./plain/markdown.js";
7
7
  import { hasScheme, linksIn } from "./plain/parser.js";
8
8
  import { insideAny } from "./regenerate/confine.js";
9
9
  import { credentialRefusal, isCredentialFile } from "./regenerate/credentials.js";
10
10
  import { DIST_DIR, MODULES_DIR } from "./regenerate/paths.js";
11
11
  import { PREPARE_NAME, SCRIPTS_DIR, scriptKind } from "./regenerate/test-scripts.js";
12
- /** A config.turri.yaml, a stack's config.turri.<stack>.yaml - what the project's testing scripts are named in. */
12
+ /** A config.turri.yaml, a module's own config.turri.<module>.yaml - what the project's testing scripts are named in. */
13
13
  const TURRI_CONFIG_NAME = /^config\.turri(\.[^/]+)?\.yaml$/;
14
14
  /** Folders that hold what is built, installed or turri's own - never the project's ***plain. */
15
15
  function outsidePlain(path) {
@@ -18,7 +18,7 @@ function outsidePlain(path) {
18
18
  }
19
19
  /**
20
20
  * The project's ***plain and what it is built with, and a digest of each: its .plain files, the resources they link,
21
- * its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a release,
21
+ * its testing scripts and its config.turri*.yaml. Nothing else is a skill's to change - not the built code, a launch,
22
22
  * what a running app writes. `also`: paths that were among them before, digested while they are there, so one a skill
23
23
  * stopped linking or naming is still seen if it changed it.
24
24
  */
@@ -69,8 +69,8 @@ export function projectFiles(root, also = []) {
69
69
  }
70
70
  }
71
71
  // Scripts config.turri*.yaml names, whatever they are called.
72
- for (const stack of [undefined, ...stacksOf(root)]) {
73
- const config = readProjectConfig(root, stack);
72
+ for (const module of [undefined, ...moduleConfigsOf(root)]) {
73
+ const config = readProjectConfig(root, module);
74
74
  named(config.unittestsScript);
75
75
  named(config.conformanceTestsScript);
76
76
  named(config.prepareEnvironmentScript);
@@ -97,7 +97,7 @@ export function changedFiles(before, after) {
97
97
  /**
98
98
  * Why a skill's agent may not write a path, or nothing when it may. It writes the project's ***plain: a file of it
99
99
  * (`projectFiles`), or a new one - a resource it is about to link, a testing script - anywhere in the project but where
100
- * what is built, released or installed lives. Never an existing file that is not the ***plain's: the code, a release,
100
+ * what is built, launched or installed lives. Never an existing file that is not the ***plain's: the code, a launch,
101
101
  * what an app it started writes.
102
102
  */
103
103
  export function plainWriteRefusal(root, path) {
@@ -109,7 +109,7 @@ export function plainWriteRefusal(root, path) {
109
109
  const inProject = relative(resolve(root), absolute);
110
110
  if (outsidePlain(inProject)) {
111
111
  return (`${inProject} is not the project's ***plain - ${MODULES_DIR}/, ${DIST_DIR}/ and the hidden folders hold what is ` +
112
- "built, released and installed, and turri's own. A skill writes .plain files, the resources they link and the testing scripts.");
112
+ "built, launched and installed, and turri's own. A skill writes .plain files, the resources they link and the testing scripts.");
113
113
  }
114
114
  if (existsSync(absolute) && !projectFiles(root).has(inProject)) {
115
115
  return (`${inProject} is not the project's ***plain: no .plain file links it, and it is not a testing script or a ` +
@@ -205,11 +205,6 @@ export declare function onModelEvent(listener: (event: ModelEvent) => void): ()
205
205
  export declare function describeTurnIncident(event: ModelEvent): string | undefined;
206
206
  export declare function reportModelEvent(event: Omit<ModelEvent, "job">): void;
207
207
  export declare function withActivity<T>(sink: ActivitySink, run: () => Promise<T>): Promise<T>;
208
- /**
209
- * Run work for no job, whatever job the code that starts it runs for - and clear of any stop signal: the test
210
- * advisor's, started as the loop looks at a codebase, perhaps as a pulse ends. A pulse's panel, log and stop never reach it.
211
- */
212
- export declare function outsideJobs<T>(run: () => T): T;
213
208
  export declare function reportStage(label: string): void;
214
209
  export declare function reportActivity(line: string): void;
215
210
  /** Say something about the machinery under the work: shown as activity, and kept in the job's log, which the activity is not. */
@@ -226,8 +221,6 @@ export declare function reportNow(label: string | undefined, options?: {
226
221
  * the end of it.
227
222
  */
228
223
  export declare function withinModules(text: string): string;
229
- /** A tool's name as the person is shown it. */
230
- export declare function shownName(name: string): string;
231
224
  /** A tool call as one short line. Unknown tools still show up, by name. */
232
225
  export declare function describeToolCall(name: string, args: Record<string, unknown> | undefined): string;
233
226
  /** The outcome of a test run, or nothing for tools whose outcome is not worth a line. */
@@ -159,13 +159,6 @@ export function reportModelEvent(event) {
159
159
  export function withActivity(sink, run) {
160
160
  return store.run(sink, run);
161
161
  }
162
- /**
163
- * Run work for no job, whatever job the code that starts it runs for - and clear of any stop signal: the test
164
- * advisor's, started as the loop looks at a codebase, perhaps as a pulse ends. A pulse's panel, log and stop never reach it.
165
- */
166
- export function outsideJobs(run) {
167
- return store.exit(() => stops.exit(run));
168
- }
169
162
  export function reportStage(label) {
170
163
  store.getStore()?.stage(label);
171
164
  }
@@ -199,17 +192,6 @@ function clip(text) {
199
192
  export function withinModules(text) {
200
193
  return text.replace(/(?:(?:\/|~\/)(?:[^\s'"`/]+\/)*|(?<![\w.-]))plain_modules\//g, "");
201
194
  }
202
- /**
203
- * What the person is shown a tool as, where that is not the name its agent calls it by. The agent's name says
204
- * what the call takes - `change_plain` takes a diff of the spec - and the shown one speaks turri's language.
205
- */
206
- const SHOWN_AS = {
207
- change_plain: "mutate",
208
- };
209
- /** A tool's name as the person is shown it. */
210
- export function shownName(name) {
211
- return SHOWN_AS[name] ?? name;
212
- }
213
195
  /** A tool call as one short line. Unknown tools still show up, by name. */
214
196
  export function describeToolCall(name, args) {
215
197
  const text = (key) => (typeof args?.[key] === "string" ? withinModules(args[key]) : undefined);
@@ -253,13 +235,13 @@ export function describeToolCall(name, args) {
253
235
  return `? ask_explorer`;
254
236
  default:
255
237
  // A hand-over - submit_work, submit_review, a verdict - ends with a check; anything else, a dot.
256
- return `${/^submit_/.test(name) ? "✓" : "•"} ${shownName(name)}`;
238
+ return `${/^submit_/.test(name) ? "✓" : "•"} ${name}`;
257
239
  }
258
240
  }
259
241
  /** The outcome of a test run, or nothing for tools whose outcome is not worth a line. */
260
242
  export function describeToolResult(name, result, isError) {
261
243
  if (name !== "run_unit_tests" && name !== "run_conformance_tests") {
262
- return isError ? ` ✗ ${shownName(name)} failed` : undefined;
244
+ return isError ? ` ✗ ${name} failed` : undefined;
263
245
  }
264
246
  const exitCode = result?.details?.exitCode;
265
247
  if (typeof exitCode !== "number")
@@ -42,7 +42,7 @@ export declare function tidyCaches(scratch: string, keepMb: number): void;
42
42
  * JVMs' sockets beside it.
43
43
  */
44
44
  export declare const DARWIN_TEMP_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX";
45
- /** What `agent-env:` - the project's, with the chosen stack's added - passes, and what of it is not there. Reads only. */
45
+ /** What `agent-env:` - the project's, with the pulse's module's own file's added - passes, and what of it is not there. Reads only. */
46
46
  export declare function passedCredentials(module: string, hostEnv: NodeJS.ProcessEnv): {
47
47
  values: Record<string, string>;
48
48
  missing: MissingCredential[];
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { homedir } from "node:os";
4
4
  import { basename, join, resolve } from "node:path";
5
- import { DEFAULT_CACHE_KEEP_MB, readProjectConfig, stackOf } from "../config.js";
5
+ import { DEFAULT_CACHE_KEEP_MB, readProjectConfig, configModuleOf } from "../config.js";
6
6
  import { registerSecrets } from "./masking.js";
7
7
  import { projectRootOf, modulesScratchDir } from "./paths.js";
8
8
  /**
@@ -258,10 +258,10 @@ export const DARWIN_TEMP_SUFFIX = "DIRHELPER_USER_DIR_SUFFIX";
258
258
  function darwinTempSuffix(module, name) {
259
259
  return `turri-${name.replace(/[^\w.-]/g, "_")}-${createHash("sha256").update(resolve(module)).digest("hex").slice(0, 8)}`;
260
260
  }
261
- /** What `agent-env:` - the project's, with the chosen stack's added - passes, and what of it is not there. Reads only. */
261
+ /** What `agent-env:` - the project's, with the pulse's module's own file's added - passes, and what of it is not there. Reads only. */
262
262
  export function passedCredentials(module, hostEnv) {
263
263
  const root = projectRootOf(module);
264
- const setting = readProjectConfig(root, stackOf(root)).agentEnv;
264
+ const setting = readProjectConfig(root, configModuleOf(root)).agentEnv;
265
265
  const values = {};
266
266
  const missing = [];
267
267
  if (setting === undefined)
@@ -1,5 +1,5 @@
1
1
  import { dirname, join, resolve, sep } from "node:path";
2
- import { readProjectConfig, stackOf } from "../config.js";
2
+ import { readProjectConfig, configModuleOf } from "../config.js";
3
3
  import { reportNote } from "./activity.js";
4
4
  import { record } from "./ledger.js";
5
5
  import { agentEnvironment, DARWIN_TEMP_SUFFIX, packageCacheDir, TOOLCHAIN_VARIABLES } from "./agent-env.js";
@@ -32,7 +32,7 @@ export function agentShell(role, options = {}) {
32
32
  const project = projectRootOf(workdir);
33
33
  const { env } = agentEnvironment(moduleDir);
34
34
  const root = projectRootOf(moduleDir);
35
- const toolchains = readProjectConfig(root, stackOf(root)).toolchains ?? [];
35
+ const toolchains = readProjectConfig(root, configModuleOf(root)).toolchains ?? [];
36
36
  const machine = machineFor(env, TOOLCHAIN_VARIABLES, toolchains);
37
37
  const writable = writableFor(env, moduleDir);
38
38
  const commandFence = {
@@ -95,7 +95,9 @@ export function agentShell(role, options = {}) {
95
95
  const checked = checkCommand(command, commandFence);
96
96
  if (!checked.ok) {
97
97
  record({ kind: "command.refused", rule: checked.rule });
98
- reportNote(` refused an agent's command (${checked.rule}): ${command.length > 120 ? `${command.slice(0, 120)}...` : command}`);
98
+ // On one line: a note is a line of the job panel, and a command's newlines would break the screen around it.
99
+ const shown = command.replace(/\s+/g, " ").trim();
100
+ reportNote(` refused an agent's command (${checked.rule}): ${shown.length > 120 ? `${shown.slice(0, 120)}...` : shown}`);
99
101
  const output = `Not run: ${checked.reason}`;
100
102
  runOptions.onData?.(Buffer.from(output));
101
103
  return { exitCode: 126, output };
@@ -9,6 +9,8 @@ const SKIPPED = new Set([
9
9
  "node_modules", ".venv", "venv", "__pycache__", ".pytest_cache", ".mypy_cache", ".ruff_cache", ".tox", "target", "build",
10
10
  "dist", ".gradle", ".m2", ".cargo", ".next", "coverage", ".git", ".turri", ".plaingit", ".idea", ".vscode",
11
11
  ]);
12
+ /** How close to the command's start a file's time must be for its time and size alone not to be trusted. */
13
+ const RACY_MS = 1_000;
12
14
  /** A file kept whole before the command - at most this big. */
13
15
  const MAX_KEPT = 1024 * 1024;
14
16
  function stat(path) {
@@ -156,6 +158,13 @@ export function afterCommand(snapshot) {
156
158
  continue;
157
159
  changed.push(path);
158
160
  }
161
+ else if (seen.mtimeMs >= snapshot.at - RACY_MS) {
162
+ // Its time and size as before, but written around when the command started: rewritten to the same size within
163
+ // the same tick of the file system's clock would look the same. What it held before tells - where it was kept.
164
+ const kept = tree.kept?.get(path);
165
+ if (kept !== undefined && !readFileSync(path).equals(kept))
166
+ changed.push(path);
167
+ }
159
168
  }
160
169
  for (const path of tree.files.keys())
161
170
  if (!after.has(path))
@@ -1,7 +1,7 @@
1
1
  import { BASE_RECORD_FILE } from "./paths.ts";
2
2
  export { BASE_RECORD_FILE };
3
3
  /**
4
- * A base folder (`base-folder:` in config.turri.yaml, a stack's own in its file): what a codebase that requires no other
4
+ * A base folder (`base-folder:` in config.turri.yaml, a module's own in its file): what a codebase that requires no other
5
5
  * module starts from instead of nothing - an existing codebase to build on, files to use (images, animations, fonts), or
6
6
  * both. It is copied in once, before the codebase's first pulse, and never written to; what was copied is recorded beside
7
7
  * the code record, and goes up the chain with the code, so every coding agent of the chain is told where its codebase
@@ -21,7 +21,7 @@ export declare class MissingBaseFolderError extends Error {
21
21
  readonly moduleName: string;
22
22
  constructor(moduleName: string, named: string, path: string);
23
23
  }
24
- /** The base folder a module's codebase starts from - its stack's over the project's - as named and as a path; none when the config names none. */
24
+ /** The base folder a module's codebase starts from - its own file's over the project's - as named and as a path; none when the config names none. */
25
25
  export declare function baseFolderOf(plainFile: string): {
26
26
  named: string;
27
27
  path: string;
@@ -21,7 +21,7 @@ export class MissingBaseFolderError extends Error {
21
21
  this.moduleName = moduleName;
22
22
  }
23
23
  }
24
- /** The base folder a module's codebase starts from - its stack's over the project's - as named and as a path; none when the config names none. */
24
+ /** The base folder a module's codebase starts from - its own file's over the project's - as named and as a path; none when the config names none. */
25
25
  export function baseFolderOf(plainFile) {
26
26
  const named = configForSpec(plainFile).baseFolder;
27
27
  if (named === undefined)
@@ -80,6 +80,8 @@ function scenarioCasesLines(specs, module) {
80
80
  lines.push(` - added - write a test for each: ${labelled(spec, spec.added, module)}.`);
81
81
  if (spec.changed.length > 0)
82
82
  lines.push(` - changed - rewrite its tests to the scenario as it reads now: ${labelled(spec, spec.changed, module)}.`);
83
+ if (spec.rewritten.length > 0)
84
+ lines.push(` - written anew - delete every test labelled with it, then write its tests again from the scenario: ${labelled(spec, spec.rewritten, module)}.`);
83
85
  if (spec.removed.length > 0)
84
86
  lines.push(` - removed - delete every test labelled with it, and its label, and nothing else: ${labelled(spec, spec.removed, module)}.`);
85
87
  if (spec.unchanged.length > 0) {
@@ -91,6 +93,9 @@ function scenarioCasesLines(specs, module) {
91
93
  if (specs.some((spec) => spec.codeChanged !== undefined)) {
92
94
  lines.push("- Where the code changed under unchanged scenarios: their tests were written against the code it replaced. Run them", " against the new code. Those that pass are tests of the new code too - conformance tests are black box - and are", " not rewritten. Fix what fails against its scenario, read with the functional spec's text: what a failing test checks", " that the scenario says stays checked, the test changed only as the new code needs it reached; what it checks that", " the scenario and the specification leave open - a path, a field, a message, a format the old code chose - is the", " new code's choice now: rewrite that check to what the new code does, or take it out. No test may hold the new code", " to what only the old code did.");
93
95
  }
96
+ if (specs.some((spec) => spec.rewritten.length > 0)) {
97
+ lines.push("- Written anew: the person asked for these tests to be written again from scratch - their code did not change.", " Delete every test labelled with the scenario first, and what only those tests used, then write the scenario's", " tests from the scenario and the functional spec's text - never from the old tests, and never copying them back.", " A test that comes out as it was has not been written anew. Helpers the other tests use stay as they are.");
98
+ }
94
99
  lines.push("- The tests of every other functional spec stay as they are.");
95
100
  return lines;
96
101
  }
@@ -126,8 +131,10 @@ export function conformanceReviewCasesBlock(cases, module = "") {
126
131
  const kept = all((spec) => (spec.codeChanged === undefined ? spec.unchanged : []));
127
132
  const rerun = all((spec) => (spec.codeChanged !== undefined ? spec.unchanged : []));
128
133
  const removed = all((spec) => spec.removed);
134
+ const rewritten = all((spec) => spec.rewritten);
129
135
  return [
130
136
  "What this job does to the tests, scenario by scenario - hold it to that:",
137
+ ...(rewritten !== "" ? [`- Written anew, as the person asked - their old tests deleted and written again from the scenario, none left as it was: ${rewritten}.`] : []),
131
138
  ...(kept !== "" ? [`- Unchanged - their tests come out exactly as they were, not rewritten or reworded: ${kept}.`] : []),
132
139
  ...(rerun !== "" ? [`- Unchanged, the code changed under them - a test changed only where it failed on the new code, and only to what its scenario says: ${rerun}.`] : []),
133
140
  ...(removed !== "" ? [`- Removed - no test labelled with them is left: ${removed}.`] : []),
@@ -209,6 +209,11 @@ export declare function placeProblems(input: PlaceInput, answer: PlaceAnswer): s
209
209
  * spec it changes - else of its first change - and how many more it makes. Never the bare word.
210
210
  */
211
211
  export declare function editTitle(changes: SpecChange[]): string;
212
+ /**
213
+ * The title of the pulse that changes what is built, first: what it changes, by name - the functional specs' func-ids,
214
+ * else the kinds of item - so the person reads which, not "changes to what is built".
215
+ */
216
+ export declare function builtTitle(changes: SpecChange[]): string;
212
217
  export declare function planChunks(input: PlanInput, agents?: ChunkAgents, notes?: string[]): Promise<DraftJob[]>;
213
218
  export declare function groupPrompt(specs: NewSpec[], steering?: Steering[], maxSpecs?: number, built?: BuiltChange[]): string;
214
219
  export declare function placePrompt(input: PlaceInput): string;
@@ -358,6 +358,21 @@ export function editTitle(changes) {
358
358
  const more = `, and ${rest.length} more`;
359
359
  return `${shortTitle(line, TITLE_CHARS - more.length, TITLE_WORDS - 3).replace(/[.,;:]+$/, "")}${more}`;
360
360
  }
361
+ /**
362
+ * The title of the pulse that changes what is built, first: what it changes, by name - the functional specs' func-ids,
363
+ * else the kinds of item - so the person reads which, not "changes to what is built".
364
+ */
365
+ export function builtTitle(changes) {
366
+ const ids = [...new Set(changes.filter(isFunctionalSpec).map(funcIdOf).filter((id) => id !== undefined))];
367
+ if (ids.length > 0) {
368
+ const named = ids.slice(0, 2).join(", ");
369
+ const others = changes.length - changes.filter(isFunctionalSpec).length;
370
+ const more = ids.length - 2 + others;
371
+ return `Changes to ${named}${more > 0 ? `, and ${more} more` : ""}`;
372
+ }
373
+ const kinds = [...new Set(changes.map((change) => WHAT[change.section] ?? change.section))].map((kind) => `${kind}s`);
374
+ return `Changes to the ${kinds.length > 1 ? `${kinds.slice(0, -1).join(", ")} and ${kinds.at(-1)}` : kinds[0]}`;
375
+ }
361
376
  /** A change as the title agent is shown it: what it is, how it changes, its text now - and before, for a change. */
362
377
  function titleChangeOf(change) {
363
378
  return {
@@ -553,7 +568,7 @@ async function cut(input, agents, notes) {
553
568
  const bySpec = new Map(specs.map((change, index) => [index + 1, change]));
554
569
  const firstBuilt = () => builtChanges.filter((change) => (builtTo.get(change) ?? "first") === "first");
555
570
  const chunksFor = (list) => [
556
- ...(firstBuilt().length > 0 ? [{ title: "Changes to what is built", specs: [], definitions: [], reqs: [], built: firstBuilt() }] : []),
571
+ ...(firstBuilt().length > 0 ? [{ title: builtTitle(firstBuilt()), specs: [], definitions: [], reqs: [], built: firstBuilt() }] : []),
557
572
  ...list.map((group) => ({
558
573
  title: group.title,
559
574
  specs: group.specs.map((number) => bySpec.get(number)),
@@ -40,7 +40,7 @@ export declare function machineReadable(platform?: NodeJS.Platform): string[];
40
40
  * Why a command line changes the machine - installs software outside the project, or changes a setting of the
41
41
  * machine's or the person's environment - or nothing when it does not. The project's own dependencies, installed into
42
42
  * the project (npm install, a venv, mvn, cargo), change nothing of the machine's. turri changes the machine nowhere: not
43
- * an agent, not the chat, not a release - what the machine lacks is the person's to install, in their own words.
43
+ * an agent, not the chat, not a launch - what the machine lacks is the person's to install, in their own words.
44
44
  */
45
45
  export declare function machineChange(command: string): string | undefined;
46
46
  /** The .plain file a command line writes - a ***plain module or a test plain file - or nothing when it writes none. */
@@ -166,7 +166,7 @@ function systemSettingIn(segment) {
166
166
  * Why a command line changes the machine - installs software outside the project, or changes a setting of the
167
167
  * machine's or the person's environment - or nothing when it does not. The project's own dependencies, installed into
168
168
  * the project (npm install, a venv, mvn, cargo), change nothing of the machine's. turri changes the machine nowhere: not
169
- * an agent, not the chat, not a release - what the machine lacks is the person's to install, in their own words.
169
+ * an agent, not the chat, not a launch - what the machine lacks is the person's to install, in their own words.
170
170
  */
171
171
  export function machineChange(command) {
172
172
  if (PIPED_DOWNLOAD.test(command) || RUN_DOWNLOAD.test(command))
@@ -1,2 +1,2 @@
1
- /** A command-line run has no one to ask: the command that releases what it built. */
1
+ /** A command-line run has no one to ask: the command that launches what it built. */
2
2
  export declare function tryItCommand(plainFile: string): string;
@@ -1,12 +1,12 @@
1
1
  import { relative } from "node:path";
2
2
  /**
3
- * How a command-line run that landed code ends: the command that releases it to try.
3
+ * How a command-line run that landed code ends: the command that launches it to try.
4
4
  */
5
5
  function shortPath(buildDir) {
6
6
  const fromHere = relative(process.cwd(), buildDir);
7
7
  return fromHere === "" || fromHere.startsWith("..") ? buildDir : fromHere;
8
8
  }
9
- /** A command-line run has no one to ask: the command that releases what it built. */
9
+ /** A command-line run has no one to ask: the command that launches what it built. */
10
10
  export function tryItCommand(plainFile) {
11
- return `To try it: turri release ${shortPath(plainFile)}`;
11
+ return `To try it: turri launch ${shortPath(plainFile)}`;
12
12
  }
@@ -74,12 +74,16 @@ export interface ScenarioRef {
74
74
  * - `codeChanged`: the functional spec's code moved under its unchanged scenarios - its text or a file it links changed
75
75
  * (`text`), it was regenerated again (`again`), or a concept it uses changed (`concept`): their tests are run on the
76
76
  * new code, and those that fail are fixed against the scenario.
77
+ * - rewritten: its tests are to be written anew - `conform` named it, or asked for its module from scratch: every one
78
+ * labelled with the scenario deleted and written again from it. A functional spec marked so has every scenario it has
79
+ * now rewritten, and those it no longer has removed.
77
80
  */
78
81
  export interface ScenarioCases extends TouchedSpec {
79
82
  added: ScenarioRef[];
80
83
  changed: ScenarioRef[];
81
84
  removed: ScenarioRef[];
82
85
  unchanged: ScenarioRef[];
86
+ rewritten: ScenarioRef[];
83
87
  codeChanged?: "text" | "again" | "concept";
84
88
  }
85
89
  /**