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

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 (76) hide show
  1. package/README.md +3 -4
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-models.d.ts +1 -1
  4. package/dist/chat-models.js +1 -1
  5. package/dist/chat-scope.d.ts +1 -3
  6. package/dist/chats.d.ts +2 -2
  7. package/dist/chats.js +3 -3
  8. package/dist/cli.js +6 -23
  9. package/dist/config-edit.d.ts +20 -8
  10. package/dist/config-edit.js +29 -21
  11. package/dist/config.d.ts +43 -50
  12. package/dist/config.js +122 -104
  13. package/dist/conform-cli.js +1 -1
  14. package/dist/conformance-switch.d.ts +7 -6
  15. package/dist/conformance-switch.js +16 -16
  16. package/dist/extension.d.ts +1 -1
  17. package/dist/extension.js +82 -200
  18. package/dist/host-session.d.ts +2 -2
  19. package/dist/host-session.js +2 -2
  20. package/dist/host.d.ts +1 -1
  21. package/dist/host.js +3 -3
  22. package/dist/init-config.js +1 -1
  23. package/dist/loop-tools.d.ts +9 -13
  24. package/dist/loop-tools.js +32 -37
  25. package/dist/parse-cli.js +2 -2
  26. package/dist/pi-launch.js +3 -0
  27. package/dist/pi-settings.d.ts +4 -0
  28. package/dist/pi-settings.js +39 -0
  29. package/dist/pi.js +3 -3
  30. package/dist/plain/check.d.ts +1 -1
  31. package/dist/plain/check.js +3 -1
  32. package/dist/plain-files.js +4 -4
  33. package/dist/regenerate/agent-env.d.ts +1 -1
  34. package/dist/regenerate/agent-env.js +3 -3
  35. package/dist/regenerate/agent-shell.js +2 -2
  36. package/dist/regenerate/base-folder.d.ts +2 -2
  37. package/dist/regenerate/base-folder.js +1 -1
  38. package/dist/regenerate/jobs.d.ts +2 -2
  39. package/dist/regenerate/jobs.js +10 -10
  40. package/dist/regenerate/ledger.d.ts +1 -1
  41. package/dist/regenerate/loop.d.ts +3 -3
  42. package/dist/regenerate/loop.js +27 -23
  43. package/dist/regenerate/model-names.d.ts +33 -0
  44. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  45. package/dist/regenerate/paths.d.ts +1 -1
  46. package/dist/regenerate/paths.js +2 -2
  47. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  48. package/dist/regenerate/scripts-being-written.js +3 -3
  49. package/dist/regenerate/test-scripts.d.ts +2 -1
  50. package/dist/regenerate/test-scripts.js +33 -23
  51. package/dist/regenerate/testing-steps.d.ts +6 -6
  52. package/dist/regenerate/testing-steps.js +8 -8
  53. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  54. package/dist/{config-command.js → settings.js} +155 -24
  55. package/dist/setup.d.ts +2 -2
  56. package/dist/setup.js +7 -7
  57. package/docs/README.md +2 -2
  58. package/docs/chats.md +3 -4
  59. package/docs/claude-subscription.md +2 -2
  60. package/docs/config.md +50 -38
  61. package/docs/development.md +1 -1
  62. package/docs/headless.md +1 -2
  63. package/docs/hosting.md +6 -6
  64. package/docs/parser.md +1 -1
  65. package/docs/regenerating.md +9 -9
  66. package/docs/sentinel.md +2 -2
  67. package/docs/skills-and-gates.md +1 -2
  68. package/docs/using.md +8 -17
  69. package/genome/rules/project-model.md +2 -1
  70. package/genome/rules/turri-regeneration.md +2 -1
  71. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  72. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  73. package/package.json +1 -1
  74. package/dist/regenerate/engine.d.ts +0 -52
  75. package/dist/stacks.d.ts +0 -13
  76. package/dist/stacks.js +0 -96
@@ -1,7 +1,7 @@
1
1
  import { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager } from "@earendil-works/pi-coding-agent";
2
2
  import { lastRun } from "./chat-records.js";
3
3
  import { interruptChat } from "./chats.js";
4
- import { reachable, ruleNames, settingCandidates } from "./config-command.js";
4
+ import { reachable, ruleNames, settingCandidates } from "./settings.js";
5
5
  import { settingOf } from "./config-edit.js";
6
6
  import { createTurriCore, sessionLoop, turnOnConformance } from "./extension.js";
7
7
  import { stopDeployed } from "./regenerate/release.js";
@@ -78,7 +78,7 @@ export async function createTurri(options = {}) {
78
78
  if (setting === undefined)
79
79
  return [];
80
80
  // The models from a chat's own context - the one shown, else any open: the registry the chats use, whether or not one
81
- // has run /turri-config.
81
+ // has run /settings.
82
82
  const context = () => {
83
83
  const shown = core.shownChat();
84
84
  const states = [shown, ...core.chats().map((chat) => core.session(chat.id)).map((session) => (session !== undefined ? core.chatOfSession(session) : undefined))];
package/dist/host.d.ts CHANGED
@@ -11,7 +11,7 @@ export type { CheckRequest } from "./sentinel-check.ts";
11
11
  export type { AskUserIO } from "./ask.ts";
12
12
  /** pi itself, as turri is built against it: a host's own extensions and UI are made with this one, not another copy. */
13
13
  export * as pi from "@earendil-works/pi-coding-agent";
14
- export { configForSpec, debugMode, DEFAULT_TEST_DIR, hasProjectConfig, modelSpec, projectModels, readProjectConfig, stacksOf, testDirOf, type ProjectConfig } from "./config.ts";
14
+ export { configForSpec, debugMode, DEFAULT_TEST_DIR, hasProjectConfig, modelSpec, projectModels, readProjectConfig, moduleConfigsOf, testDirOf, type ProjectConfig } from "./config.ts";
15
15
  export { MODULES_DIR, projectDirOf, resolveTemplateDirs } from "./regenerate/paths.ts";
16
16
  export { configSettings, currentValue, EFFECT_TEXT, overriddenBy, readConfigText, type Effect, type Setting, type SettingKind } from "./config-edit.ts";
17
17
  export { bedrockRegionFor, type BedrockRegion, type BedrockRegionSource } from "./bedrock-region.ts";
package/dist/host.js CHANGED
@@ -12,10 +12,10 @@ export { SENTINEL, SENTINEL_START } from "./notice.js";
12
12
  /** pi itself, as turri is built against it: a host's own extensions and UI are made with this one, not another copy. */
13
13
  export * as pi from "@earendil-works/pi-coding-agent";
14
14
  // The project and its settings.
15
- export { configForSpec, debugMode, DEFAULT_TEST_DIR, hasProjectConfig, modelSpec, projectModels, readProjectConfig, stacksOf, testDirOf } from "./config.js";
15
+ export { configForSpec, debugMode, DEFAULT_TEST_DIR, hasProjectConfig, modelSpec, projectModels, readProjectConfig, moduleConfigsOf, testDirOf } from "./config.js";
16
16
  export { MODULES_DIR, projectDirOf, resolveTemplateDirs } from "./regenerate/paths.js";
17
- // Every setting of config.turri.yaml as /turri-config knows it - what it takes, what it is unset, when a change takes
18
- // effect - and what the file has now: for a host that shows them all, changing each through /turri-config.
17
+ // Every setting of config.turri.yaml as /settings knows it - what it takes, what it is unset, when a change takes
18
+ // effect - and what the file has now: for a host that shows them all, changing each through /settings.
19
19
  export { configSettings, currentValue, EFFECT_TEXT, overriddenBy, readConfigText } from "./config-edit.js";
20
20
  // The AWS region a project's Bedrock models are called in, and where it comes from - what turri sets itself, as a host's
21
21
  // session starts, when the models need one and the person set none.
@@ -591,7 +591,7 @@ export async function initConfig(dir, options = {}) {
591
591
  return { written: false, message: chosen.problem };
592
592
  const { vendor, bedrock, models, given } = chosen;
593
593
  const folder = resolve(dir);
594
- // The old stacks' files, config.<stack>.yaml, copied to their new names; config.turri.yaml is written below.
594
+ // The modules' old files, config.<module>.yaml, copied to their new names; config.turri.yaml is written below.
595
595
  adoptLegacyConfig(folder, { projectFile: false });
596
596
  const path = join(folder, CONFIG_FILE);
597
597
  const existing = existsSync(path) && options.force !== true;
@@ -1,7 +1,6 @@
1
1
  import { type ExtensionContext, type ToolDefinition } from "@earendil-works/pi-coding-agent";
2
2
  import { Type } from "typebox";
3
3
  import { type ModuleStatus, type WorkLoop } from "./regenerate/loop.ts";
4
- import type { RenderWork } from "./regenerate/engine.ts";
5
4
  import { type Job, type JobRegistry } from "./regenerate/jobs.ts";
6
5
  /**
7
6
  * The tools that act on the work loop - `regenerate`, `drift` and `halt` - defined once, for the conversation and for the
@@ -13,18 +12,15 @@ type AnyTool = ToolDefinition<any, any, any>;
13
12
  export declare const GUIDANCE_PARAM: Type.TOptional<Type.TString>;
14
13
  export declare const WORKING_DIR_PARAM: Type.TOptional<Type.TString>;
15
14
  export declare const MODEL_PARAM: Type.TOptional<Type.TString>;
16
- export declare const STACK_PARAM: Type.TOptional<Type.TString>;
17
15
  /**
18
- * Why a module asked for with no stack named cannot be built: a project of stacks where it has no stack of its own and
19
- * none is chosen, and config.turri.yaml alone names no unit testing script - every pulse would stop for want of one.
20
- * The stacks and the script each names, and what to do. Undefined when it can be built.
16
+ * Why a module cannot be built with the config it would be built with: two of the modules it requires have a config
17
+ * file of their own (`configModuleFor`); or, in a project where modules have their own files, it has none - nor any
18
+ * module it requires - and config.turri.yaml alone names no unit testing script, so every pulse would stop for want of
19
+ * one. The files there are and the script each names, and what to do. Undefined when it can be built.
21
20
  */
22
- export declare function stacklessBuild(plainFile: string): string | undefined;
23
- /**
24
- * `work` with the stack a call names chosen for it - or, none named, as it is: each module is then built with its own
25
- * (`stackForModule`). A module that could not be built that way is refused before anything is planned (`stacklessBuild`).
26
- */
27
- export declare function withCallStack<T>(plainFile: string, named: string | undefined, work: () => T): T;
21
+ export declare function unbuildableConfig(plainFile: string): string | undefined;
22
+ /** `work`, once the module asked for can be built with the config it would be built with - refused before anything is planned otherwise (`unbuildableConfig`). */
23
+ export declare function whenBuildable<T>(plainFile: string, work: () => T): T;
28
24
  export declare const WAIT_PARAM: Type.TOptional<Type.TBoolean>;
29
25
  /**
30
26
  * A render tool's arguments as if turri had been started in `working_dir`: the .plain file
@@ -79,8 +75,8 @@ export interface LoopToolsOptions {
79
75
  jobs?: JobRegistry;
80
76
  /** The work loop the tools act on - the conversation's, for a call in it. */
81
77
  loop?: (ctx: ExtensionContext) => WorkLoop;
82
- /** The model a pulse of this call regenerates on: the one named, or the one chosen for the work. Default: the one named. */
83
- model?: (ctx: ExtensionContext, plainFile: string, named?: string, work?: RenderWork) => string | undefined;
78
+ /** The model a pulse of this call regenerates on: the one named, or the module's coding model. Default: the one named. */
79
+ model?: (ctx: ExtensionContext, plainFile: string, named?: string) => string | undefined;
84
80
  /** Whether a call waits for its work to finish, given what it asked. Default: only when it asked to. */
85
81
  wait?: (ctx: ExtensionContext, asked?: boolean) => boolean;
86
82
  }
@@ -3,7 +3,7 @@ import { refuseTestPlainFile } from "./test-plain-files.js";
3
3
  import { basename, relative, resolve } from "node:path";
4
4
  import { defineTool } from "@earendil-works/pi-coding-agent";
5
5
  import { Type } from "typebox";
6
- import { CONFIG_FILE, readProjectConfig, stackConfigFile, stackForModule, stackNamed, stacksOf, withStack } from "./config.js";
6
+ import { CONFIG_FILE, readProjectConfig, moduleConfigFile, configModuleFor, moduleConfigsOf, withConfigModule } from "./config.js";
7
7
  import { checkPlainFile, formatCheckResults } from "./plain/check.js";
8
8
  import { describeDrift, describeModules } from "./regenerate/loop.js";
9
9
  import { describeJob, pulseName } from "./regenerate/jobs.js";
@@ -26,43 +26,42 @@ export const WORKING_DIR_PARAM = Type.Optional(Type.String({
26
26
  }));
27
27
  export const MODEL_PARAM = Type.Optional(Type.String({
28
28
  description: "The model for the agents of this one call: a provider/model-id, or its name as the user said it. " +
29
- "Omitted: the model chosen for this kind of work with engine, else the conversation's. " +
30
- "To change it for every later pulse, use engine instead.",
31
- }));
32
- export const STACK_PARAM = Type.Optional(Type.String({
33
- description: "In a project of stacks: the stack that builds this module - its config.turri.<stack>.yaml over config.turri.yaml, " +
34
- "its testing scripts, toolchains and models - for every pulse of it, whatever stack is chosen later. \"none\": " +
35
- "config.turri.yaml alone. Omitted: the stack named after the module - config.turri.backend.yaml for backend.plain - " +
36
- "else the one chosen now.",
29
+ "Omitted: the coding model the module's config names, else the conversation's. " +
30
+ "To change it for every later pulse, set coding-model with settings instead.",
37
31
  }));
38
32
  /**
39
- * Why a module asked for with no stack named cannot be built: a project of stacks where it has no stack of its own and
40
- * none is chosen, and config.turri.yaml alone names no unit testing script - every pulse would stop for want of one.
41
- * The stacks and the script each names, and what to do. Undefined when it can be built.
33
+ * Why a module cannot be built with the config it would be built with: two of the modules it requires have a config
34
+ * file of their own (`configModuleFor`); or, in a project where modules have their own files, it has none - nor any
35
+ * module it requires - and config.turri.yaml alone names no unit testing script, so every pulse would stop for want of
36
+ * one. The files there are and the script each names, and what to do. Undefined when it can be built.
42
37
  */
43
- export function stacklessBuild(plainFile) {
38
+ export function unbuildableConfig(plainFile) {
44
39
  const root = projectDirOf(plainFile);
45
- const stacks = stacksOf(root);
46
- if (stacks.length === 0 || stackForModule(plainFile) !== undefined || findTestScripts(root).unit !== undefined)
40
+ let own;
41
+ try {
42
+ own = configModuleFor(plainFile);
43
+ }
44
+ catch (error) {
45
+ return error instanceof Error ? error.message : String(error);
46
+ }
47
+ const files = moduleConfigsOf(root);
48
+ if (files.length === 0 || own !== undefined || findTestScripts(root).unit !== undefined)
47
49
  return undefined;
48
- const scripts = stacks.map((each) => {
49
- const unit = withStack(each, () => findTestScripts(root).unit);
50
- return `${each}${unit !== undefined ? ` (${stackConfigFile(each)}: ${relative(root, unit)})` : ""}`;
50
+ const scripts = files.map((each) => {
51
+ const unit = withConfigModule(each, () => findTestScripts(root).unit);
52
+ return `${moduleConfigFile(each)}${unit !== undefined ? ` (${relative(root, unit)})` : ""}`;
51
53
  });
52
- return (`${basename(plainFile)} would be built with no stack - ${CONFIG_FILE} alone - and that names no unit testing script, so every ` +
53
- `pulse would stop. No stack is named after it, and none is chosen. The project's stacks: ${scripts.join(", ")}. Pass the ` +
54
- `stack that builds ${basename(plainFile)} as stack - or ask the user which, when the spec does not make it plain.`);
54
+ const name = basename(plainFile, ".plain");
55
+ return (`${basename(plainFile)} would be built with ${CONFIG_FILE} alone - it has no ${moduleConfigFile(name)}, and none of the ` +
56
+ `modules it requires has one - and that names no unit testing script, so every pulse would stop. The modules' own ` +
57
+ `files: ${scripts.join(", ")}. Name its testing scripts in its own file - the settings tool, with module ${basename(plainFile)} - ` +
58
+ `or ask the user which, when the ***plain does not make it plain.`);
55
59
  }
56
- /**
57
- * `work` with the stack a call names chosen for it - or, none named, as it is: each module is then built with its own
58
- * (`stackForModule`). A module that could not be built that way is refused before anything is planned (`stacklessBuild`).
59
- */
60
- export function withCallStack(plainFile, named, work) {
61
- if (named !== undefined)
62
- return withStack(stackNamed(projectDirOf(plainFile), named), work);
63
- const stackless = stacklessBuild(plainFile);
64
- if (stackless !== undefined)
65
- throw new Error(`Nothing was started: ${stackless}`);
60
+ /** `work`, once the module asked for can be built with the config it would be built with - refused before anything is planned otherwise (`unbuildableConfig`). */
61
+ export function whenBuildable(plainFile, work) {
62
+ const unbuildable = unbuildableConfig(plainFile);
63
+ if (unbuildable !== undefined)
64
+ throw new Error(`Nothing was started: ${unbuildable}`);
66
65
  return work();
67
66
  }
68
67
  export const WAIT_PARAM = Type.Optional(Type.Boolean({
@@ -237,7 +236,6 @@ export function regenerateTool(options) {
237
236
  "A change to a file the spec links - an API surface, a mapping document - is a change to the spec: regenerate sees it by itself, and regenerates every functional spec that uses what links it.",
238
237
  "Never stop pulses and start them again yourself to follow a spec change: regenerate does it.",
239
238
  "Set from_scratch only when the user asks for the module to be regenerated from scratch - started over, its code deleted - in this conversation, or agrees to it when a module's status says it has to start over: never to fix a pulse that did not land.",
240
- "In a project of stacks - a backend and a frontend, each with its config.turri.<stack>.yaml - a module is built with the stack named after it by itself: backend.plain with config.turri.backend.yaml. Pass stack only for a module whose stack has another name. It is pinned to the module's pulses: a backend and a frontend regenerate side by side, each with its own, without switching the stack chosen. What it says back names the stack each module is built with.",
241
239
  'from_scratch "module" takes out the code where the module is built; the modules below keep theirs, and the module starts from a copy of the code below it. "chain" takes out every codebase of its requires chain, the base\'s too, and builds all of it again from the bottom: use it after modules were split, merged or moved (refactor-module), or when the user asks for the whole chain.',
242
240
  ],
243
241
  parameters: Type.Object({
@@ -251,13 +249,12 @@ export function regenerateTool(options) {
251
249
  description: "Only when the user asks for it: the module's code and conformance tests deleted - committed first, so its lineage keeps them - and the whole module regenerated from its spec. " +
252
250
  '"chain": every module of its requires chain too, built again from the bottom',
253
251
  })),
254
- stack: STACK_PARAM,
255
252
  model: MODEL_PARAM,
256
253
  wait: WAIT_PARAM,
257
254
  }),
258
255
  async execute(_id, given, _signal, _onUpdate, ctx) {
259
256
  const plainFile = plainFileOf(options.cwd, given, "regenerate");
260
- return withCallStack(plainFile, given.stack, async () => {
257
+ return whenBuildable(plainFile, async () => {
261
258
  const check = checkPlainFile(plainFile);
262
259
  // The parser's message as it gives it, a test plain file out of place, and turri's next step for the old syntax.
263
260
  if (!check.ok)
@@ -265,9 +262,7 @@ export function regenerateTool(options) {
265
262
  const again = given.funcIds ?? [];
266
263
  if (again.length > 0 && given.from_scratch !== undefined)
267
264
  throw new Error("Name funcIds or set from_scratch, not both: from scratch regenerates every one of them.");
268
- // Named functionalities are work on functionalities, as engine chooses a model for it; the rest, spec changes.
269
- const work = again.length > 0 ? "functionalities" : "spec_changes";
270
- const model = options.model !== undefined ? options.model(ctx, plainFile, given.model, work) : given.model;
265
+ const model = options.model !== undefined ? options.model(ctx, plainFile, given.model) : given.model;
271
266
  const loop = options.loop(ctx);
272
267
  const request = { ...(model !== undefined ? { model } : {}), ...(given.guidance !== undefined ? { guidance: given.guidance } : {}) };
273
268
  const wait = options.wait !== undefined ? options.wait(ctx, given.wait) : given.wait === true;
package/dist/parse-cli.js CHANGED
@@ -5,8 +5,8 @@ const USAGE = `usage: turri parse <file.plain | directory> [options]
5
5
  Parses ***plain - its syntax and structure, never its code or tests: each module with its test plain files,
6
6
  its imports and required modules, every error reported without regenerating anything - and every test plain file
7
7
  outside its module's folder. A functional spec with no test plain file is not tested. A module whose
8
- functional specs have scenarios but which has no test reqs, or no conformance testing script for its
9
- stack, is a warning: its conformance tests are not written until it has them. A test plain file or
8
+ functional specs have scenarios but which has no test reqs, or no conformance testing script,
9
+ is a warning: its conformance tests are not written until it has them. A test plain file or
10
10
  test folder is refused: name its module.
11
11
 
12
12
  --template-dir <dir> extra template directory (repeatable)
package/dist/pi-launch.js CHANGED
@@ -14,6 +14,7 @@ import "./terminal-images.js";
14
14
  import { withoutResumeLine } from "./resume-line.js";
15
15
  import { lastRun } from "./chat-records.js";
16
16
  import { driveTerminal } from "./chat-terminal.js";
17
+ import { takeOverSettings } from "./pi-settings.js";
17
18
  import turri, { createTurriCore, processSession } from "./extension.js";
18
19
  /**
19
20
  * pi, started the way its own CLI starts it, for `turri`.
@@ -42,6 +43,8 @@ ProcessTerminal.prototype.setTitle = function (title) {
42
43
  // is answered for this run as `quietStartup` is; the line it prints instead, to resume the session, is left out too:
43
44
  // `turri --continue` opens the last run again.
44
45
  SettingsManager.prototype.getFullscreenExitOutput = () => "resume-hint";
46
+ // /settings is turri's, pi's own menu the last entry of it (pi-settings.ts).
47
+ takeOverSettings();
45
48
  const write = process.stdout.write.bind(process.stdout);
46
49
  process.stdout.write = ((chunk, ...rest) => write(typeof chunk === "string" ? withoutResumeLine(chunk) : chunk, ...rest));
47
50
  // pi's own keys stand: a new line is shift+enter or ctrl+j. turri's side panel is on ctrl+h (job-panel.ts PANEL_KEY).
@@ -0,0 +1,4 @@
1
+ /** Take pi's /settings over: once a process, every chat's screen. */
2
+ export declare function takeOverSettings(): void;
3
+ /** Open pi's own settings menu on the screen /settings was typed on. False where there is none - a host, print mode. */
4
+ export declare function openPiSettings(): boolean;
@@ -0,0 +1,39 @@
1
+ import { InteractiveMode } from "@earendil-works/pi-coding-agent";
2
+ let piMenu;
3
+ /** Take pi's /settings over: once a process, every chat's screen. */
4
+ export function takeOverSettings() {
5
+ if (piMenu !== undefined)
6
+ return;
7
+ const prototype = InteractiveMode.prototype;
8
+ const own = prototype.showSettingsSelector;
9
+ const conflicts = prototype.getBuiltInCommandConflictDiagnostics;
10
+ const completions = prototype.createBaseAutocompleteProvider;
11
+ const menu = { open: (screen) => own.call(screen) };
12
+ piMenu = menu;
13
+ // A bare /settings: turri's, when the extension has one - pi's menu otherwise, as it was.
14
+ prototype.showSettingsSelector = function () {
15
+ if (this.session.extensionRunner.getCommand("settings") === undefined)
16
+ return own.call(this);
17
+ menu.screen = this;
18
+ void this.session.prompt("/settings");
19
+ };
20
+ prototype.getBuiltInCommandConflictDiagnostics = function (runner) {
21
+ return conflicts.call(this, runner).filter((diagnostic) => !diagnostic.message.includes("'/settings'"));
22
+ };
23
+ // The completions: pi's /settings line gives way to turri's, which pi leaves out as a clash.
24
+ prototype.createBaseAutocompleteProvider = function () {
25
+ const provider = completions.call(this);
26
+ const turri = this.session.extensionRunner.getCommand("settings");
27
+ if (turri === undefined)
28
+ return provider;
29
+ provider.commands = provider.commands.map((command) => command.name === "settings" ? { name: "settings", description: turri.description, getArgumentCompletions: turri.getArgumentCompletions } : command);
30
+ return provider;
31
+ };
32
+ }
33
+ /** Open pi's own settings menu on the screen /settings was typed on. False where there is none - a host, print mode. */
34
+ export function openPiSettings() {
35
+ if (piMenu?.screen === undefined)
36
+ return false;
37
+ piMenu.open(piMenu.screen);
38
+ return true;
39
+ }
package/dist/pi.js CHANGED
@@ -3,7 +3,7 @@ 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";
@@ -803,11 +803,11 @@ export async function createExecutor(opts) {
803
803
  }
804
804
  return session;
805
805
  }
806
- /** 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. */
807
807
  function configForCwd(cwd) {
808
808
  try {
809
809
  const root = projectRootOf(cwd);
810
- return readProjectConfig(root, stackOf(root));
810
+ return readProjectConfig(root, configModuleOf(root));
811
811
  }
812
812
  catch {
813
813
  return {};
@@ -6,7 +6,7 @@
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;
@@ -1,6 +1,6 @@
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
5
  import { isImportModule } from "../regenerate/requires.js";
6
6
  import { testingGap } from "../regenerate/testing-steps.js";
@@ -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.
@@ -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) {
@@ -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);
@@ -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 = {
@@ -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)
@@ -46,8 +46,8 @@ export interface Job {
46
46
  note?: string;
47
47
  /** "provider/model-id" its agents run on, when known. */
48
48
  model?: string;
49
- /** The stack it is built with - its config.turri.<stack>.yaml over config.turri.yaml - as chosen when it was queued. */
50
- stack?: string;
49
+ /** The module whose config.turri.<module>.yaml it is built with, over config.turri.yaml - as worked out when it was queued. */
50
+ configModule?: string;
51
51
  /** The chat it was asked for in (chat-scope.ts): the one told how it went. */
52
52
  chat?: string;
53
53
  status: JobStatus;
@@ -5,7 +5,7 @@ import { describeEnvironmentError, EnvironmentError, missingCredentials } from "
5
5
  import { addAgentReport, describeAgents, JobStoppedError, withActivity } from "./activity.js";
6
6
  import { projectOfLanes, startJobLog } from "./job-log.js";
7
7
  import { firstLine, healing, record } from "./ledger.js";
8
- import { chosenStack, debugMode, withStack } from "../config.js";
8
+ import { debugMode, moduleConfigFile, pinnedConfigModule, withConfigModule } from "../config.js";
9
9
  import { currentChat } from "../chat-scope.js";
10
10
  import { pulseEnded, pulseWrote } from "./pulse-files.js";
11
11
  import { keepFailureReport } from "./failure-reports.js";
@@ -58,9 +58,9 @@ export function createJobRegistry(options) {
58
58
  },
59
59
  start(input) {
60
60
  const id = randomUUID().slice(0, 8);
61
- // The stack chosen as it is queued - or pinned for the work that queues it - not as it starts: a job that waits
62
- // for a slot is built with the stack it was asked for, whatever is chosen meanwhile.
63
- const stack = chosenStack();
61
+ // The config pinned for the work that queues it, as it is queued - not as it starts: a job that waits for a slot is
62
+ // built with the config it was planned with, whatever the files say meanwhile.
63
+ const configModule = pinnedConfigModule();
64
64
  const chat = currentChat()?.id;
65
65
  const claimed = [...new Set(input.lanes ?? [])];
66
66
  const blockers = [
@@ -82,7 +82,7 @@ export function createJobRegistry(options) {
82
82
  ...(input.diffWhere !== undefined ? { diffWhere: input.diffWhere } : {}),
83
83
  ...(input.cases !== undefined ? { cases: input.cases } : {}),
84
84
  model: input.model,
85
- ...(stack !== undefined ? { stack } : {}),
85
+ ...(configModule !== undefined ? { configModule } : {}),
86
86
  ...(chat !== undefined ? { chat } : {}),
87
87
  ...(input.follows !== undefined ? { follows: input.follows } : {}),
88
88
  status: blockers.length > 0 || (limit !== undefined && active >= limit) ? "queued" : "running",
@@ -108,7 +108,7 @@ export function createJobRegistry(options) {
108
108
  ...(input.pulse !== undefined ? { pulse: input.pulse } : {}),
109
109
  ...(input.title !== undefined ? { title: input.title } : {}),
110
110
  ...(input.model !== undefined ? { model: input.model } : {}),
111
- ...(stack !== undefined ? { stack } : {}),
111
+ ...(configModule !== undefined ? { configModule } : {}),
112
112
  ...(input.cases !== undefined ? { cases: input.cases } : {}),
113
113
  waitingOn: blockers,
114
114
  ...(input.follows !== undefined ? { follows: input.follows } : {}),
@@ -319,9 +319,9 @@ export function createJobRegistry(options) {
319
319
  // Its log is named only where it is kept: otherwise it goes as the pulse ends.
320
320
  const named = log !== undefined && project !== undefined && debugMode(project);
321
321
  record({ kind: "job.started", waitedMs: job.startedAt - job.queuedAt, ...(named ? { logFile: log.file } : {}) }, place);
322
- // What the job's agents start runs until it ends, and no longer (withPulse) - with the stack it was queued
323
- // with, whatever is chosen while it waits or runs.
324
- return withStack(stack, () => (guarded ? runGuarded() : runOnce()));
322
+ // What the job's agents start runs until it ends, and no longer (withPulse) - with the config it was queued
323
+ // with, whatever the files say while it waits or runs.
324
+ return withConfigModule(configModule, () => (guarded ? runGuarded() : runOnce()));
325
325
  })
326
326
  .then((outcome) => {
327
327
  // Asked to stop, it is stopped - whether its work threw as it unwound or returned what it had.
@@ -479,7 +479,7 @@ export function pulseName(job) {
479
479
  }
480
480
  /** What the agent is told when it checks on a job. */
481
481
  export function describeJob(job) {
482
- const name = `${pulseName(job)}${job.stack !== undefined ? ` (stack ${job.stack})` : ""}`;
482
+ const name = `${pulseName(job)}${job.configModule !== undefined ? ` (built with ${moduleConfigFile(job.configModule)})` : ""}`;
483
483
  if (job.status === "queued") {
484
484
  return `${name}: queued behind ${job.waitingOn.map((id) => `pulse ${id}`).join(" and ")}. It starts when that finishes.`;
485
485
  }
@@ -85,7 +85,7 @@ export type LedgerEvent = {
85
85
  pulse?: number;
86
86
  title?: string;
87
87
  model?: string;
88
- stack?: string;
88
+ configModule?: string;
89
89
  cases?: PulseCases;
90
90
  waitingOn: string[];
91
91
  follows?: string;
@@ -101,8 +101,8 @@ export interface ModuleStatus {
101
101
  codebases: string[];
102
102
  old?: true;
103
103
  };
104
- /** The stack it is built with - its config.turri.<stack>.yaml over config.turri.yaml - when one is. */
105
- stack?: string;
104
+ /** The module whose config.turri.<module>.yaml it is built with, over config.turri.yaml - its own, or one it requires - when one is. */
105
+ configModule?: string;
106
106
  /** Pure renames turri makes once the running pulse ends - a func-id or a scenario-id, nothing else with it: nothing regenerated. */
107
107
  renames?: string[];
108
108
  /**
@@ -152,7 +152,7 @@ export interface WorkLoop {
152
152
  guidance?: string;
153
153
  }): Promise<ModuleStatus[]>;
154
154
  /**
155
- * Plan a spec's module as `bringUp` would - the same codebases, its stack pinned, the steering and `guidance` given
155
+ * Plan a spec's module as `bringUp` would - the same codebases, its config pinned, the steering and `guidance` given
156
156
  * to the planner - and start nothing: the plans are kept, and its pulses held until regenerate, conform or /regenerate
157
157
  * asks for the module. Then the first pulse of the kept plan starts as it is, planned again only when the ***plain,
158
158
  * what it is built from or the steering changed since. A module the person halted stays halted, and a codebase whose