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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +6 -7
  2. package/dist/bedrock-region.js +3 -3
  3. package/dist/chat-models.d.ts +1 -1
  4. package/dist/chat-models.js +1 -1
  5. package/dist/chat-scope.d.ts +1 -3
  6. package/dist/chat-skills.d.ts +1 -1
  7. package/dist/chat-skills.js +1 -1
  8. package/dist/chats.d.ts +44 -10
  9. package/dist/chats.js +125 -41
  10. package/dist/cli.js +10 -26
  11. package/dist/config-edit.d.ts +20 -8
  12. package/dist/config-edit.js +32 -24
  13. package/dist/config.d.ts +101 -58
  14. package/dist/config.js +265 -118
  15. package/dist/conform-cli.js +14 -3
  16. package/dist/conformance-switch.d.ts +7 -6
  17. package/dist/conformance-switch.js +19 -16
  18. package/dist/extension.d.ts +29 -3
  19. package/dist/extension.js +375 -351
  20. package/dist/genome.js +5 -1
  21. package/dist/host-session.d.ts +8 -7
  22. package/dist/host-session.js +4 -4
  23. package/dist/host.d.ts +3 -1
  24. package/dist/host.js +3 -3
  25. package/dist/identity.js +2 -2
  26. package/dist/init-config.d.ts +1 -1
  27. package/dist/init-config.js +8 -8
  28. package/dist/launch-agent.d.ts +51 -0
  29. package/dist/launch-agent.js +267 -0
  30. package/dist/{release-cli.js → launch-cli.js} +41 -24
  31. package/dist/launch-session.d.ts +68 -0
  32. package/dist/launch-session.js +217 -0
  33. package/dist/launch-tools.d.ts +28 -0
  34. package/dist/launch-tools.js +69 -0
  35. package/dist/launch-track.d.ts +125 -0
  36. package/dist/launch-track.js +320 -0
  37. package/dist/loop-cli.js +4 -4
  38. package/dist/loop-tools.d.ts +45 -21
  39. package/dist/loop-tools.js +152 -82
  40. package/dist/notice.d.ts +7 -6
  41. package/dist/parse-cli.js +2 -2
  42. package/dist/pi-launch.js +3 -0
  43. package/dist/pi-settings.d.ts +4 -0
  44. package/dist/pi-settings.js +39 -0
  45. package/dist/pi.js +6 -3
  46. package/dist/plain/check.d.ts +1 -1
  47. package/dist/plain/check.js +3 -1
  48. package/dist/plain-files.d.ts +2 -2
  49. package/dist/plain-files.js +7 -7
  50. package/dist/regenerate/agent-env.d.ts +1 -1
  51. package/dist/regenerate/agent-env.js +3 -3
  52. package/dist/regenerate/agent-shell.js +5 -3
  53. package/dist/regenerate/audit.js +9 -0
  54. package/dist/regenerate/base-folder.d.ts +2 -2
  55. package/dist/regenerate/base-folder.js +1 -1
  56. package/dist/regenerate/cases.js +7 -0
  57. package/dist/regenerate/chunk-plan.d.ts +5 -0
  58. package/dist/regenerate/chunk-plan.js +16 -1
  59. package/dist/regenerate/command-check.d.ts +7 -1
  60. package/dist/regenerate/command-check.js +43 -1
  61. package/dist/regenerate/delivery.d.ts +1 -1
  62. package/dist/regenerate/delivery.js +3 -3
  63. package/dist/regenerate/drift.d.ts +4 -0
  64. package/dist/regenerate/drift.js +26 -6
  65. package/dist/regenerate/job-panel.js +3 -1
  66. package/dist/regenerate/jobs.d.ts +2 -2
  67. package/dist/regenerate/jobs.js +10 -10
  68. package/dist/regenerate/launch.d.ts +154 -0
  69. package/dist/regenerate/{release.js → launch.js} +195 -51
  70. package/dist/regenerate/ledger.d.ts +33 -2
  71. package/dist/regenerate/lineage.d.ts +2 -0
  72. package/dist/regenerate/lineage.js +8 -0
  73. package/dist/regenerate/loop.d.ts +30 -10
  74. package/dist/regenerate/loop.js +166 -59
  75. package/dist/regenerate/model-names.d.ts +33 -0
  76. package/dist/regenerate/{engine.js → model-names.js} +2 -28
  77. package/dist/regenerate/paths.d.ts +3 -3
  78. package/dist/regenerate/paths.js +4 -4
  79. package/dist/regenerate/records.d.ts +11 -0
  80. package/dist/regenerate/records.js +15 -0
  81. package/dist/regenerate/regenerate.js +4 -1
  82. package/dist/regenerate/renames.js +4 -4
  83. package/dist/regenerate/requires.d.ts +7 -0
  84. package/dist/regenerate/requires.js +24 -18
  85. package/dist/regenerate/scripts-being-written.d.ts +4 -4
  86. package/dist/regenerate/scripts-being-written.js +3 -3
  87. package/dist/regenerate/spec-map.js +3 -3
  88. package/dist/regenerate/submit-work.d.ts +2 -0
  89. package/dist/regenerate/submit-work.js +8 -3
  90. package/dist/regenerate/test-scripts.d.ts +2 -1
  91. package/dist/regenerate/test-scripts.js +33 -23
  92. package/dist/regenerate/testing-steps.d.ts +6 -6
  93. package/dist/regenerate/testing-steps.js +8 -8
  94. package/dist/regenerate-cli.js +1 -1
  95. package/dist/self-invocation.d.ts +11 -0
  96. package/dist/self-invocation.js +36 -7
  97. package/dist/sentinel-check.d.ts +3 -3
  98. package/dist/sentinel-check.js +3 -3
  99. package/dist/sentinel.d.ts +18 -12
  100. package/dist/sentinel.js +72 -43
  101. package/dist/{config-command.d.ts → settings.d.ts} +13 -8
  102. package/dist/{config-command.js → settings.js} +155 -24
  103. package/dist/setup.d.ts +2 -2
  104. package/dist/setup.js +7 -7
  105. package/dist/turri-versions.js +2 -1
  106. package/docs/README.md +4 -4
  107. package/docs/chats.md +5 -6
  108. package/docs/claude-subscription.md +2 -2
  109. package/docs/config.md +58 -46
  110. package/docs/development.md +2 -2
  111. package/docs/headless.md +4 -4
  112. package/docs/hosting.md +20 -19
  113. package/docs/launch.md +67 -0
  114. package/docs/parser.md +2 -2
  115. package/docs/regenerating.md +21 -15
  116. package/docs/sandbox.md +3 -3
  117. package/docs/sentinel.md +26 -14
  118. package/docs/skills-and-gates.md +4 -4
  119. package/docs/using.md +19 -28
  120. package/genome/rules/project-model.md +2 -1
  121. package/genome/rules/turri-regeneration.md +5 -3
  122. package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
  123. package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
  124. package/package.json +1 -1
  125. package/dist/regenerate/engine.d.ts +0 -52
  126. package/dist/regenerate/release.d.ts +0 -121
  127. package/dist/release-agent.d.ts +0 -43
  128. package/dist/release-agent.js +0 -130
  129. package/dist/release-tools.d.ts +0 -44
  130. package/dist/release-tools.js +0 -170
  131. package/dist/stacks.d.ts +0 -13
  132. package/dist/stacks.js +0 -96
  133. package/docs/deploy.md +0 -48
  134. /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
package/README.md CHANGED
@@ -121,11 +121,11 @@ That is what regenerative software asks of software, and what **turri** does:
121
121
  | Every cell can become another, and it is still the same jellyfish. | Every line of code can be replaced, and it is still the same software - because what it is never lived in the code. |
122
122
  | It can do it again and again, for as long as it lives. | The code can be regenerated whenever \*\*\*plain changes or a model gets better, for as long as \*\*\*plain is kept. |
123
123
 
124
- So the tools speak its language: **`regenerate`** regenerates the code from \*\*\*plain as it is now - or the functionalities you name, though nothing changed, or all of it from scratch - **`drift`** says how far the code has moved from it, and **`lineage`** shows every generation of a module and what each was regenerated from.
124
+ So the tools speak its language: **`regenerate`** regenerates the code from \*\*\*plain as it is now - or the functionalities you name, though nothing changed, or all of it from scratch - **`drift`** says how far the code has moved from it, and **`/lineage`** shows every generation of a module and what each was regenerated from.
125
125
 
126
126
  ## Models
127
127
 
128
- `init-config`'s models are only a starting point. **turri** is built on [pi](https://pi.dev), so any model [pi](https://pi.dev) supports works - Anthropic, OpenAI, Google, Amazon Bedrock, OpenRouter, a local one. A model is reached as [pi](https://pi.dev) reaches it - `/login`, in `turri` as in `pi`, the provider's API key in the environment (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, ...), or a cloud account - and named as [pi](https://pi.dev) names it, `provider/model-id`, with `:high`, `:low` and so on for how hard it thinks. It uses three: the **harness** model you talk to, which writes \*\*\*plain and plans the work - worth a capable one - and the **coding** and **judge** models its agents build and judge with, which can be smaller and cheaper, such as GPT-6 Luna or Gemini 3.1 Flash Lite. `turri --harness-model` and `--coding-model` choose them for a session, and [pi](https://pi.dev)'s `/model` switches the one you talk to as you go; to keep them for the project, set them with `/turri-config harness-model`, `/turri-config coding-model` and so on - each role's too, as `models.<role>` - or write them in its `config.turri.yaml`:
128
+ `init-config`'s models are only a starting point. **turri** is built on [pi](https://pi.dev), so any model [pi](https://pi.dev) supports works - Anthropic, OpenAI, Google, Amazon Bedrock, OpenRouter, a local one. A model is reached as [pi](https://pi.dev) reaches it - `/login`, in `turri` as in `pi`, the provider's API key in the environment (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, ...), or a cloud account - and named as [pi](https://pi.dev) names it, `provider/model-id`, with `:high`, `:low` and so on for how hard it thinks. It uses three: the **harness** model you talk to, which writes \*\*\*plain and plans the work - worth a capable one - and the **coding** and **judge** models its agents build and judge with, which can be smaller and cheaper, such as GPT-6 Luna or Gemini 3.1 Flash Lite. `turri --harness-model` and `--coding-model` choose them for a session, and [pi](https://pi.dev)'s `/model` switches the one you talk to as you go; to keep them for the project, set them with `/settings harness-model`, `/settings coding-model` and so on - each role's too, as `models.<role>` - or write them in its `config.turri.yaml`:
129
129
 
130
130
  ```yaml
131
131
  harness-model: anthropic/claude-opus-5-5 # the model you talk to: a capable one
@@ -151,13 +151,12 @@ Then say what you want:
151
151
  In a new project **turri** starts it itself, without asking how: it chooses the stack - the one you name, else a standard library stack this machine can build - writes the module and its unit testing script (and the conformance tests' when you ask for them, or - conformance tests on - it judges a functional spec needs them), regenerates the smallest thing that runs at once, then the main thing you described, and says what it chose and what it would write next. Every change after is yours to ask for: **turri** writes it as \*\*\*plain and regenerates it. While it works:
152
152
 
153
153
  - the **panel** above the input shows every build - its stage, what its agents are doing, its model and cost - and the queue behind it;
154
- - ask to try it at any time - "let me try it" - and **`release`** puts what is built so far in `dist/<module>` and **`activate`** starts it, installing what it needs - nothing to approve;
154
+ - ask to try it at any time - "let me try it" - and **`launch`** puts what is built so far in `dist/<module>` and starts it in the background, installing what it needs - nothing to approve;
155
155
  - the **side panel** (`ctrl+h`) takes the screen and opens on **regen** - \*\*\*plain, every item marked planned, working, regenerated, validating, conform or needs you - and `p` turns it to the **pulses** (`/pulses`) - every pulse, running, queued and finished, and what each regenerates; what its agents did is in each pulse's log in `.turri/jobs/`, kept with `--debug` (`debug: true`);
156
156
  - **`/halt`** halts a pulse, **`/lineage`** shows every generation of a module, and the **`drift`** tool says what is left to regenerate;
157
157
  - **`/btw <question>`** asks turri something on the side - answered at once, even while a question waits for you (typed as the answer, under "Something else…"), and left out of the conversation;
158
- - **`/turri-config`** changes any setting of the project's `config.turri.yaml` - the models, review, how many pulses at once - and says when it takes effect: now, at your next message, or at the next pulse. No restart: `/turri-config review false`, or `/turri-config` alone to pick from the list;
158
+ - **`/settings`** changes any setting of the project's `config.turri.yaml` - the models, review, how many pulses at once - and says when it takes effect: now, at your next message, or at the next pulse. No restart: `/settings review false`, or `/settings` alone to pick from the list - [pi](https://pi.dev)'s own settings the last entry. Or just ask: "regenerate with gpt 5.5 from now on";
159
159
  - **`/sentinel`** says whether the sentinel checks every pulse that finishes: `ask` (you are asked before it first opens), `on` or `off`;
160
- - **`/stack`** chooses the stack to build with, in a project whose backend and frontend each have their own testing scripts in `config.turri.<stack>.yaml` - `/stack backend`, `/stack none` - for the session (`--stack <name>` on the command line). The chat's model builds each part with its own stack by itself, pinned to that module's pulses.
161
160
 
162
161
  Other things to ask for:
163
162
 
@@ -189,8 +188,8 @@ Start at the [documentation index](docs/README.md), or go straight to a page:
189
188
  | [Installation](docs/installation.md) | doctor, what turri needs of this machine, **turri** and `pi`, environment variables |
190
189
  | [Examples](examples/README.md) | projects to build with turri step by step: guestbook - a backend and a frontend in minutes - a CLI, and a backend service tested where it matters |
191
190
  | [Using **turri**](docs/using.md) | the conversation, skills, tools, pulses and regen, choosing models, the command line |
192
- | [The project config](docs/config.md) | `config.turri.yaml` and each stack's `config.turri.<stack>.yaml`: every key, models and their inheritance, conformance, the testing scripts, stacks and choosing one, the old `config.yaml` |
193
- | [Deploy](docs/deploy.md) | trying what is built: the last commit in `dist/<module>`, started on your machine, nothing installed without asking |
191
+ | [The project config](docs/config.md) | `config.turri.yaml` and a module's own `config.turri.<module>.yaml`: every key, models and their inheritance, conformance, the testing scripts, which file builds a module, the old `config.yaml` |
192
+ | [Launch](docs/launch.md) | trying what is built: a commit in `dist/<module>`, started on your machine in the background - after every pulse too - nothing installed without asking |
194
193
  | [Running unattended](docs/headless.md) | regenerating \*\*\*plain overnight or in CI: the command, keeping it running, the results, resuming, rebuilding one functionality |
195
194
  | [Authoring \*\*\*plain](docs/authoring-plain.md) | what \*\*\*plain is made of, the authoring rules, the skills that write and fix it, checking it |
196
195
  | [Regenerating](docs/regenerating.md) | what each build does and in which order: functionalities, modules, regeneration, changes to \*\*\*plain, conformance and acceptance tests, working notes, what the code is built from |
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
- import { readProjectConfig, stacksOf } from "./config.js";
4
+ import { readProjectConfig, moduleConfigsOf } from "./config.js";
5
5
  import { bedrockAwsRegion, bedrockNeedsAwsRegion, bedrockPlaceOf } from "./init-config.js";
6
6
  import { modelsInUse } from "./model-check.js";
7
7
  /** The variable turri marks its own AWS_REGION with, so the pi it starts - and a reload - tells it from the person's. */
@@ -52,9 +52,9 @@ export function profileRegion(profile, env = process.env) {
52
52
  }
53
53
  return undefined;
54
54
  }
55
- /** The Bedrock models a project uses: every model its config names - each stack's too - and those given. */
55
+ /** The Bedrock models a project uses: every model its config names - each module's own file's too - and those given. */
56
56
  function bedrockModels(projectDir, also) {
57
- const configs = [readProjectConfig(projectDir), ...stacksOf(projectDir).map((stack) => readProjectConfig(projectDir, stack))];
57
+ const configs = [readProjectConfig(projectDir), ...moduleConfigsOf(projectDir).map((module) => readProjectConfig(projectDir, module))];
58
58
  const specs = [...configs.flatMap((config) => modelsInUse(config).map((used) => used.spec)), ...also];
59
59
  return [...new Set(specs.filter((spec) => spec.startsWith("amazon-bedrock/")))];
60
60
  }
@@ -6,7 +6,7 @@ import { type ProjectConfig } from "./config.ts";
6
6
  * is another name for, or else `harness-model:` in config.turri.yaml. The coding model is the one
7
7
  * every render runs on: `--coding-model`, or else `coding-model:` in config.turri.yaml - pi knows
8
8
  * nothing of it, so it reaches the extension through the environment. Either can still be
9
- * changed in the conversation: pi's /model, engine.
9
+ * changed in the conversation: pi's /model, and the settings tool or /settings for the coding model.
10
10
  */
11
11
  /** The environment variable a chat's --coding-model reaches the extension through. */
12
12
  export declare const CODING_MODEL_ENV = "TURRI_CODING_MODEL";
@@ -6,7 +6,7 @@ import { modelSpec, projectModels } from "./config.js";
6
6
  * is another name for, or else `harness-model:` in config.turri.yaml. The coding model is the one
7
7
  * every render runs on: `--coding-model`, or else `coding-model:` in config.turri.yaml - pi knows
8
8
  * nothing of it, so it reaches the extension through the environment. Either can still be
9
- * changed in the conversation: pi's /model, engine.
9
+ * changed in the conversation: pi's /model, and the settings tool or /settings for the coding model.
10
10
  */
11
11
  /** The environment variable a chat's --coding-model reaches the extension through. */
12
12
  export const CODING_MODEL_ENV = "TURRI_CODING_MODEL";
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * The chat a piece of work runs for: its tools, its commands, its event handlers - and what they start, a pulse
3
3
  * queued from them among it. A turri session holds several chats (chats.ts); what each keeps for itself rides along
4
- * with its work here: its id, which pulses and the ledger's events carry, and the stack it chose.
4
+ * with its work here: its id, which pulses and the ledger's events carry.
5
5
  */
6
6
  export interface ChatScope {
7
7
  id: string;
8
- /** The stack this chat chose with /stack or the stack tool - none: the project's config alone. */
9
- stack: string | undefined;
10
8
  /** The questions it asks now, each with what declines it: a host declines them with `Turri.decline`. */
11
9
  readonly asking: Set<() => void>;
12
10
  }
@@ -8,7 +8,7 @@
8
8
  * runs its own skills, and the project's, with `cultivate`, steps and gates and all. A skill the chat followed by hand
9
9
  * instead would skip those gates, and one from another tool may say otherwise than turri's rules. So the conversation
10
10
  * is offered neither: no skill turri runs itself, and none about ***plain. A skill about anything else - a commit
11
- * message, a deploy - is offered as pi offers it.
11
+ * message, a launch - is offered as pi offers it.
12
12
  */
13
13
  /** Whether turri has what a pi skill offers: it runs a skill of that name itself, or the skill is about ***plain. */
14
14
  export declare function supersededByTurri(skill: {
@@ -8,7 +8,7 @@
8
8
  * runs its own skills, and the project's, with `cultivate`, steps and gates and all. A skill the chat followed by hand
9
9
  * instead would skip those gates, and one from another tool may say otherwise than turri's rules. So the conversation
10
10
  * is offered neither: no skill turri runs itself, and none about ***plain. A skill about anything else - a commit
11
- * message, a deploy - is offered as pi offers it.
11
+ * message, a launch - is offered as pi offers it.
12
12
  */
13
13
  /** What a skill says it is about, that turri covers: ***plain specs and their testing scripts. */
14
14
  const ABOUT_PLAIN = /\*\*\*plain|\\\*\\\*\\\*plain|\.plain\b|functional specs?\b|testing scripts?\b|run_unittests|run_conformance_tests/i;
package/dist/chats.d.ts CHANGED
@@ -5,15 +5,16 @@ import { type ChatUi } from "./chat-ui.ts";
5
5
  import { type SentinelSetting } from "./config.ts";
6
6
  import type { AskUserIO } from "./ask.ts";
7
7
  import type { Job, JobRegistry } from "./regenerate/jobs.ts";
8
+ import type { Launch } from "./launch-track.ts";
8
9
  import type { ToolDefinition } from "@earendil-works/pi-coding-agent";
9
10
  import { type ChatRole, type Conclusion, type Notice, type NoticeAnswer, type NoticeInput, type SentinelCheck } from "./notice.ts";
10
11
  /**
11
12
  * The chats of a turri session.
12
13
  *
13
14
  * One turri process is one session on one project, and holds up to MAX_CHATS chats: conversations, each with its own
14
- * history, model, thinking level, stack and questions, each working while another is shown. What they share is the
15
+ * history, model, thinking level and questions, each working while another is shown. What they share is the
15
16
  * session's: the one job registry and work loop the project's pulses run in - a pulse any chat starts is in every
16
- * chat's side panel - the coding model, steering, releases and the ledger.
17
+ * chat's side panel - the coding model, steering, launches and the ledger.
17
18
  *
18
19
  * A chat is a pi session with turri's extension in it. The extension, built once for each, links itself to its chat
19
20
  * here (`attach`); its tools, commands and handlers then run inside the chat's scope (chat-scope.ts), so a pulse knows
@@ -79,13 +80,19 @@ export interface TurriHost {
79
80
  * not say it again in the conversation. Unset, it says both, as in the terminal.
80
81
  */
81
82
  pulseEndsShown?: boolean;
83
+ /**
84
+ * A launch was asked for, started, or ended (docs/launch.md): what the host shows of what runs is drawn again. One that
85
+ * ended with a newer launch waiting has `replacedBy` - stopped the next moment - and one whose servers were halted on
86
+ * request comes again, `stopped`.
87
+ */
88
+ onLaunch?(launch: Launch): void;
82
89
  /** What the sentinel puts to the person - and, `kind: "sentinel-start"`, whether to start it: the host draws it in the chat it names, and answers it with `answer`. */
83
90
  onNotice?(notice: Notice): void;
84
91
  /** A notice is over - answered, dismissed, or superseded by a newer one about its module: the host takes its card down. */
85
92
  onNoticeOver?(notice: Notice): void;
86
93
  /**
87
94
  * The sentinel's own tools beside turri's - a host's browser, say - and its surface: where the person watches it use
88
- * them, in the host's words. Given, the sentinel tries a release with those tools, keeping its shell for what they
95
+ * them, in the host's words. Given, the sentinel tries what is launched with those tools, keeping its shell for what they
89
96
  * cannot show; absent, the person does not watch it, and the tools are only to test with as well.
90
97
  */
91
98
  sentinel?: {
@@ -109,14 +116,21 @@ export interface ChatInstance {
109
116
  asked?: string;
110
117
  focused?: string;
111
118
  }): Promise<void>;
112
- /**
113
- * The sentinel's: functional specs a host asked it to check - the module released first, unless what runs is its last
114
- * commit, then its agent told, in a conversation of its own for the check. Why not, when the release failed: then its
115
- * agent is told nothing.
116
- */
119
+ /** The sentinel's: functional specs a host asked it to check - its agent told, in a conversation of its own for the check, in what is launched of the module. */
117
120
  briefCheck(check: SentinelCheck, context: {
118
121
  focused?: string;
119
- }): Promise<string | undefined>;
122
+ }): Promise<void>;
123
+ /**
124
+ * The sentinel's: its check of a pulse - or a host's check - paused while the codebase was launched again, carried on in
125
+ * the launch that holds it: its agent told so, in the conversation it was in. Throws when what runs no longer holds it.
126
+ */
127
+ resume(work: {
128
+ job: Job;
129
+ } | {
130
+ check: SentinelCheck;
131
+ }): Promise<void>;
132
+ /** A launch this chat is to hear of ended - one it asked for, or one after a pulse of its with the sentinel off: its agent told how it went. */
133
+ launched(launch: Launch): void;
120
134
  /** A notice put in the chat: drawn, and - in the terminal - put to the person once the chat is idle. */
121
135
  notice(notice: Notice): void;
122
136
  /** A notice is over: its dialog closed, if it is open. */
@@ -222,6 +236,12 @@ export interface TurriCore {
222
236
  showing(chat: ChatState): void;
223
237
  /** For the extension: a pulse ended - told to the chat that asked for it, or, with the sentinel on, to the sentinel. */
224
238
  jobFinished(job: Job): void;
239
+ /**
240
+ * For the extension: a launch started, or ended. Started, the sentinel's check of a pulse or a check of its codebase is
241
+ * paused, to carry on once the codebase's launches are settled. Ended, one after a pulse, with the sentinel off: told to
242
+ * the chat that asked for the pulse, or the one shown.
243
+ */
244
+ launchChanged(launch: Launch): void;
225
245
  /** Whether finished pulses go to the sentinel now: it is on, and there is somewhere to open it. */
226
246
  sentinelOn(): boolean;
227
247
  /** A notice put to the person, in the chat they look at - the sentinel's, or turri's own. Undefined: no chat to put it in. */
@@ -275,6 +295,20 @@ export interface CoreOptions {
275
295
  setSentinel?: (on: boolean) => void;
276
296
  /** The person ignored a notice for good: kept in the sentinel's guidance, for every conversation after. */
277
297
  ignored?: (notice: Notice) => void;
298
+ /** The launch track, as the sentinel waits on it (docs/sentinel.md). Not given: the sentinel waits for nothing. */
299
+ launches?: SentinelLaunches;
300
+ }
301
+ /**
302
+ * What the sentinel waits on of the launch track: a pulse is tested only in a launch whose commit holds the pulse's, and
303
+ * a check only in what runs of its module - each told once its codebase's launches are settled.
304
+ */
305
+ export interface SentinelLaunches {
306
+ /** Resolves once what runs can be tested for the pulse, or there is nothing running to test it in. Throws when what runs cannot hold it - turri got it wrong. */
307
+ readyFor(job: Job): Promise<void>;
308
+ /** Resolves once what runs of the check's module is settled. Throws when nothing of it runs. */
309
+ readyForCheck(check: SentinelCheck): Promise<void>;
310
+ /** Resolves once nothing of the codebase's is launching or waiting to. */
311
+ settled(codebase: string): Promise<void>;
278
312
  }
279
313
  /** A chat's session, as stopping what it does reaches it. */
280
314
  export type Stoppable = Pick<AgentSession, "isStreaming" | "isCompacting" | "isRetrying" | "isBashRunning" | "abort" | "abortBash">;
@@ -295,7 +329,7 @@ export declare function interruptChat<R>(session: Stoppable, asked: {
295
329
  export declare function createChats(options: CoreOptions): TurriCore;
296
330
  /**
297
331
  * pi's extension API for a chat: every tool, command, shortcut and handler the extension registers runs inside the
298
- * chat's scope - its stack, and its id on what it starts.
332
+ * chat's scope - its id on what it starts.
299
333
  */
300
334
  export declare function scopedToChat(pi: ExtensionAPI, scope: ChatScope): ExtensionAPI;
301
335
  /** A chat's stand-in for the screen, for the terminal's driver. */
package/dist/chats.js CHANGED
@@ -4,15 +4,15 @@ import { currentChat, inChat } from "./chat-scope.js";
4
4
  import { adoptRun, forgetChat, forgetSessionFile, recordRun } from "./chat-records.js";
5
5
  import { createChatUi } from "./chat-ui.js";
6
6
  import { debugMode } from "./config.js";
7
- import { record } from "./regenerate/ledger.js";
7
+ import { firstLine, record } from "./regenerate/ledger.js";
8
8
  import { newNotice, noticeTask, SENTINEL, sentinelStartChoice, wentWrong } from "./notice.js";
9
9
  /**
10
10
  * The chats of a turri session.
11
11
  *
12
12
  * One turri process is one session on one project, and holds up to MAX_CHATS chats: conversations, each with its own
13
- * history, model, thinking level, stack and questions, each working while another is shown. What they share is the
13
+ * history, model, thinking level and questions, each working while another is shown. What they share is the
14
14
  * session's: the one job registry and work loop the project's pulses run in - a pulse any chat starts is in every
15
- * chat's side panel - the coding model, steering, releases and the ledger.
15
+ * chat's side panel - the coding model, steering, launches and the ledger.
16
16
  *
17
17
  * A chat is a pi session with turri's extension in it. The extension, built once for each, links itself to its chat
18
18
  * here (`attach`); its tools, commands and handlers then run inside the chat's scope (chat-scope.ts), so a pulse knows
@@ -91,8 +91,10 @@ export function createChats(options) {
91
91
  let notices = [];
92
92
  /** What the sentinel put to the person, and turri itself, this session: open until answered or superseded. */
93
93
  const open = [];
94
- /** The work the sentinel's conversation is on, from its brief until its agent is done: a newer pulse of the same module replaces a check of one that went well. */
94
+ /** The work the sentinel's conversation is on, from its brief until its agent is done - `concluded` once it said so. */
95
95
  let checking;
96
+ /** Its check paused while its codebase is launched again: carried on once the codebase's launches are settled. */
97
+ let paused;
96
98
  /** Pulses that finished, and checks asked for, while the sentinel was at work: each taken in turn, in a conversation of its own. */
97
99
  const waiting = [];
98
100
  /** The checks hosts asked for this session, by id: what a notice or a conclusion about one is about. */
@@ -158,7 +160,7 @@ export function createChats(options) {
158
160
  const id = randomUUID().slice(0, 8);
159
161
  const chat = {
160
162
  id,
161
- scope: { id, stack: process.env.TURRI_STACK?.trim() || undefined, asking: new Set() },
163
+ scope: { id, asking: new Set() },
162
164
  ...(title !== undefined ? { recordedTitle: title } : {}),
163
165
  ...(role !== undefined ? { role } : {}),
164
166
  working: false,
@@ -185,8 +187,12 @@ export function createChats(options) {
185
187
  chat.unread = true;
186
188
  persist();
187
189
  changed();
190
+ }
191
+ else if (event.type === "agent_settled") {
188
192
  // Done with its pulse - or with what the person said to it: the next pulse waiting, in a conversation of its own.
189
- if (chat.role === SENTINEL && event.willRetry !== true) {
193
+ // Settled, not at agent_end: pi's session still streams while agent_end's listeners run, and a retry comes after
194
+ // it. Paused for a launch, it is not done: it carries on once the launch is settled.
195
+ if (chat.role === SENTINEL && paused === undefined) {
190
196
  checking = undefined;
191
197
  toSentinel(() => nextWork(chat));
192
198
  }
@@ -277,6 +283,7 @@ export function createChats(options) {
277
283
  // Closed, the sentinel is let go with what it had to check: the next pulse that finishes opens it again.
278
284
  if (chat.role === SENTINEL) {
279
285
  checking = undefined;
286
+ paused = undefined;
280
287
  // A check a host asked for ends all the same: it is told it was not done.
281
288
  for (const work of waiting.splice(0))
282
289
  if ("check" in work)
@@ -392,6 +399,30 @@ export function createChats(options) {
392
399
  }
393
400
  toAsker(job);
394
401
  },
402
+ launchChanged(launch) {
403
+ if (launch.status === "running") {
404
+ pauseFor(launch);
405
+ return;
406
+ }
407
+ // One after a pulse, ended, with the sentinel off: its chat is told - the sentinel, on, tests it with the pulse. One a
408
+ // newer launch replaced as it ended is not: what it started is stopped the next moment, and the newer one is told.
409
+ if (!("pulse" in launch.cause) || (launch.status !== "launched" && launch.status !== "failed") || launch.replacedBy !== undefined || core.sentinelOn())
410
+ return;
411
+ const job = jobs.get(launch.cause.pulse);
412
+ const asked = chats.find((chat) => chat.id === job?.chat && chat.role !== SENTINEL && chat.instance !== undefined);
413
+ const where = asked ?? personFacing();
414
+ if (where === undefined)
415
+ return;
416
+ if (where.id !== shownId)
417
+ where.unread = true;
418
+ try {
419
+ where.instance?.launched(launch);
420
+ }
421
+ catch {
422
+ /* a chat let go as it ended: the host still hears of it */
423
+ }
424
+ changed();
425
+ },
395
426
  check(prepare) {
396
427
  if (driver === undefined)
397
428
  return { refused: "There is nowhere to open the sentinel in this session." };
@@ -464,6 +495,10 @@ export function createChats(options) {
464
495
  },
465
496
  notices: () => open.filter((notice) => notice.state === "open"),
466
497
  concluded(conclusion) {
498
+ // The sentinel's work concluded: a launch from now on does not pause it - it is only saying so.
499
+ const work = checking?.work;
500
+ if (work !== undefined && ("pulse" in work ? conclusion.job === work.pulse.id : conclusion.check === work.check.id))
501
+ checking = { ...checking, concluded: true };
467
502
  const job = conclusion.job !== undefined ? jobs.get(conclusion.job) : undefined;
468
503
  const check = conclusion.check !== undefined ? checks.get(conclusion.check) : undefined;
469
504
  const target = personFacing(chats.find((chat) => chat.id === job?.chat));
@@ -717,29 +752,16 @@ export function createChats(options) {
717
752
  core.notify(`The sentinel: ${error instanceof Error ? error.message : String(error)}`, "warning");
718
753
  });
719
754
  }
720
- /** Whether the sentinel is at work: on a pulse - its turn starts as it is told of one - or on what the person said to it. */
721
- const sentinelBusy = (sentinel) => sentinel.session?.isStreaming === true;
722
755
  /**
723
- * A finished pulse or a host's check, for the sentinel: taken now when it is free. Busy, a newer pulse of a module
724
- * replaces a check of the module's last pulse that went well - and a pulse of it that went well and waits - and one that
725
- * went wrong is looked into to its end; the rest, checks among them, wait their turn.
756
+ * Whether the sentinel is at work: on a pulse - its turn starts as it is told of one - or on what the person said to it;
757
+ * or its check is paused while its codebase is launched again.
726
758
  */
759
+ const sentinelBusy = (sentinel) => sentinel.session?.isStreaming === true || paused !== undefined;
760
+ /** A finished pulse or a host's check, for the sentinel: taken now when it is free, else after what waits - every one, in order. */
727
761
  function takeWork(sentinel, work) {
728
762
  if (!sentinelBusy(sentinel))
729
763
  return begin(sentinel, work);
730
- if (!("pulse" in work)) {
731
- waiting.push(work);
732
- return;
733
- }
734
- const job = work.pulse;
735
- const sameModule = (other) => job.module !== undefined && "pulse" in other && other.pulse.module === job.module;
736
- if (checking !== undefined && !checking.wrong && sameModule(checking.work) && "pulse" in checking.work)
737
- return check(sentinel, job, checking.work.pulse);
738
- const older = waiting.findIndex((other) => sameModule(other) && "pulse" in other && !wentWrong(other.pulse));
739
- if (older !== -1)
740
- waiting.splice(older, 1, work);
741
- else
742
- waiting.push(work);
764
+ waiting.push(work);
743
765
  }
744
766
  /** The sentinel free again: the next pulse or check that waits, taken. */
745
767
  function nextWork(sentinel) {
@@ -752,13 +774,40 @@ export function createChats(options) {
752
774
  function begin(sentinel, work) {
753
775
  return "pulse" in work ? check(sentinel, work.pulse) : checkSpecs(sentinel, work.check);
754
776
  }
777
+ /** The codebase a piece of the sentinel's work is tested in: the pulse's, or the check's module's. */
778
+ const codebaseOf = (work) => ("pulse" in work ? work.pulse.module : work.check.module);
755
779
  /**
756
- * The sentinel on a host's check, from scratch, as on a pulse: a conversation of its own, the module released first
757
- * unless what runs is its last commit. A release that fails ends the check - a conclusion of its own - and the next
758
- * waiting is taken.
780
+ * What runs cannot be tested for a pulse or a check: recorded, and concluded as unchecked; the next waiting taken. For a
781
+ * pulse turri got it wrong - what runs cannot hold its commit - and that is said as an error where the person is too. A
782
+ * host's check with nothing launched to test it in is an answer, not an error: its conclusion says it alone.
783
+ */
784
+ async function refuse(sentinel, work, why) {
785
+ const module = codebaseOf(work);
786
+ inChat(sentinel.scope, () => record({ kind: "sentinel.refused", ...(module !== undefined ? { module } : {}), ...("check" in work ? { check: work.check.id } : {}), why: firstLine(why, 300) }, { project: cwd, ...("pulse" in work ? { job: work.pulse.id } : {}) }));
787
+ if ("pulse" in work)
788
+ core.notify(`The sentinel cannot check pulse ${work.pulse.id}: ${why}`, "error");
789
+ core.concluded({
790
+ ...("pulse" in work ? { job: work.pulse.id } : { check: work.check.id }),
791
+ ...(module !== undefined ? { module } : {}),
792
+ verdict: "unchecked",
793
+ summary: `Not checked: ${why}`,
794
+ });
795
+ checking = undefined;
796
+ changed();
797
+ await nextWork(sentinel);
798
+ }
799
+ /**
800
+ * The sentinel on a host's check, from scratch, as on a pulse: a conversation of its own, once what runs of the module
801
+ * is settled - nothing launched for it, and the check ends unchecked.
759
802
  */
760
803
  async function checkSpecs(sentinel, check) {
761
- checking = { work: { check }, wrong: false };
804
+ try {
805
+ await options.launches?.readyForCheck(check);
806
+ }
807
+ catch (error) {
808
+ return refuse(sentinel, { check }, error instanceof Error ? error.message : String(error));
809
+ }
810
+ checking = { work: { check } };
762
811
  inChat(sentinel.scope, () => record({ kind: "sentinel.checking", module: check.module, check: check.id }, { project: cwd }));
763
812
  const session = sentinel.session;
764
813
  if (session !== undefined && (session.messages.length > 0 || session.isStreaming))
@@ -766,28 +815,29 @@ export function createChats(options) {
766
815
  if (sentinel.id !== shownId)
767
816
  sentinel.unread = true;
768
817
  const where = personFacing();
769
- let why;
770
818
  try {
771
- why = await sentinel.instance.briefCheck(check, where !== undefined ? { focused: titleFor(where) } : {});
819
+ await sentinel.instance.briefCheck(check, where !== undefined ? { focused: titleFor(where) } : {});
772
820
  }
773
821
  catch (error) {
774
- why = error instanceof Error ? error.message : String(error);
822
+ core.notify(`The sentinel could not be told of check ${check.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
823
+ checking = undefined;
775
824
  }
776
825
  changed();
777
- if (why === undefined)
778
- return;
779
- checking = undefined;
780
- core.concluded({ check: check.id, module: check.module, verdict: "wrong", summary: `Not tested: ${check.module} could not be released - ${why}` });
781
- await nextWork(sentinel);
782
826
  }
783
827
  /**
784
828
  * The sentinel on a pulse, from scratch: a conversation of its own - its prompt, the project's guidance and this
785
- * pulse's brief, nothing of the pulses before it - in place of the one it had, stopped when it was on `replacing`.
829
+ * pulse's brief, nothing of the pulses before it - once what runs holds the pulse's commit (`readyFor`).
786
830
  */
787
- async function check(sentinel, job, replacing) {
788
- checking = { work: { pulse: job }, wrong: wentWrong(job) };
831
+ async function check(sentinel, job) {
832
+ try {
833
+ await options.launches?.readyFor(job);
834
+ }
835
+ catch (error) {
836
+ return refuse(sentinel, { pulse: job }, error instanceof Error ? error.message : String(error));
837
+ }
838
+ checking = { work: { pulse: job } };
789
839
  const module = job.module;
790
- inChat(sentinel.scope, () => record({ kind: "sentinel.checking", ...(module !== undefined ? { module } : {}), ...(replacing !== undefined ? { replaced: replacing.id } : {}) }, { project: cwd, job: job.id }));
840
+ inChat(sentinel.scope, () => record({ kind: "sentinel.checking", ...(module !== undefined ? { module } : {}) }, { project: cwd, job: job.id }));
791
841
  const session = sentinel.session;
792
842
  if (session !== undefined && (session.messages.length > 0 || session.isStreaming))
793
843
  await freshConversation(sentinel);
@@ -807,6 +857,40 @@ export function createChats(options) {
807
857
  }
808
858
  changed();
809
859
  }
860
+ /**
861
+ * A launch of a codebase started while the sentinel checks a pulse or a check of it: its turn stopped - its conversation
862
+ * kept - until the codebase's launches are settled, then carried on in the launch that holds it.
863
+ */
864
+ function pauseFor(launch) {
865
+ const sentinel = sentinelChat();
866
+ const now = checking;
867
+ // Concluded, it is only saying so: nothing to carry on.
868
+ if (sentinel === undefined || now === undefined || now.concluded === true || paused !== undefined || codebaseOf(now.work) !== launch.codebase)
869
+ return;
870
+ paused = now;
871
+ inChat(sentinel.scope, () => record({ kind: "sentinel.paused", module: launch.codebase, launch: launch.id }, { project: cwd, ...("pulse" in now.work ? { job: now.work.pulse.id } : {}) }));
872
+ void sentinel.session?.abort().catch(() => undefined);
873
+ changed();
874
+ void (async () => {
875
+ await options.launches?.settled(launch.codebase);
876
+ // Let go meanwhile - closed, or given another conversation: nothing to carry on.
877
+ if (paused !== now || !chats.includes(sentinel) || sentinel.instance === undefined) {
878
+ if (paused === now)
879
+ paused = undefined;
880
+ return;
881
+ }
882
+ paused = undefined;
883
+ const resumed = "pulse" in now.work ? { job: now.work.pulse } : { check: now.work.check };
884
+ try {
885
+ await sentinel.instance.resume(resumed);
886
+ inChat(sentinel.scope, () => record({ kind: "sentinel.resumed", module: launch.codebase, launch: launch.id }, { project: cwd, ...("pulse" in now.work ? { job: now.work.pulse.id } : {}) }));
887
+ }
888
+ catch (error) {
889
+ toSentinel(() => refuse(sentinel, now.work, error instanceof Error ? error.message : String(error)));
890
+ }
891
+ changed();
892
+ })();
893
+ }
810
894
  /**
811
895
  * The sentinel's chat given a new session, under the same id: what it does now stopped, and what it said let go - its
812
896
  * saved conversation deleted outside debug mode. The model and thinking it had carry over: what the person picked in
@@ -880,7 +964,7 @@ export function createChats(options) {
880
964
  }
881
965
  /**
882
966
  * pi's extension API for a chat: every tool, command, shortcut and handler the extension registers runs inside the
883
- * chat's scope - its stack, and its id on what it starts.
967
+ * chat's scope - its id on what it starts.
884
968
  */
885
969
  export function scopedToChat(pi, scope) {
886
970
  const within = (work) => work === undefined ? undefined : (...args) => inChat(scope, () => work(...args));
package/dist/cli.js CHANGED
@@ -77,7 +77,7 @@ const COMMANDS = {
77
77
  conform: { module: "./conform-cli.ts", blurb: "write and run a module's conformance tests" },
78
78
  parse: { module: "./parse-cli.ts", blurb: "parse ***plain - its syntax and structure, never its code or tests - regenerating nothing" },
79
79
  lineage: { module: "./lineage-cli.ts", blurb: "a module's lineage: what was regenerated into it, and when" },
80
- release: { module: "./release-cli.ts", blurb: "release what is regenerated to dist/<module> and activate it on this machine" },
80
+ launch: { module: "./launch-cli.ts", blurb: "launch what is regenerated from dist/<module> on this machine" },
81
81
  cultivate: { module: "./cultivate-cli.ts", blurb: "run a gated skill" },
82
82
  };
83
83
  /** Getting the machine ready, and checking it is. */
@@ -109,8 +109,7 @@ const USAGE = [
109
109
  " turri <command> [args]",
110
110
  " turri --version turri's version, and pi's",
111
111
  "",
112
- ` ${"options".padEnd(12)} --harness-model <m> the model you chat with --coding-model <m> the model renders run on`,
113
- ` ${"".padEnd(12)} --stack <name> build with config.turri.<name>.yaml over config.turri.yaml - here and in every command`,
112
+ ` ${"options".padEnd(12)} --harness-model <m> the model you chat with --coding-model <m> the model that writes the code`,
114
113
  ` ${"".padEnd(12)} --debug keep what turri writes for debugging it - agents' logs and sessions - as debug: true does`,
115
114
  ` ${"".padEnd(12)} --use-theme <t> another theme than turri-dark - and every option of pi's own`,
116
115
  "",
@@ -125,37 +124,22 @@ const USAGE = [
125
124
  "specification, so that linked resources inside it resolve the way the parser expects.",
126
125
  ].join("\n");
127
126
  dropNoise();
128
- // --stack <name>, for any command and for the conversation: the stack everything is built with (stacks.ts), taken out
129
- // before the rest is read - a command never sees it. --debug too: TURRI_DEBUG for this run, and the pi it starts.
130
- const argv = await withoutStack(process.argv.slice(2));
127
+ // --debug, for any command and for the conversation: TURRI_DEBUG for this run, and the pi it starts - taken out before
128
+ // the rest is read, so a command never sees it.
129
+ const argv = withoutDebug(process.argv.slice(2));
131
130
  const [command, ...rest] = argv;
132
- async function withoutStack(args) {
131
+ function withoutDebug(args) {
133
132
  const kept = [];
134
- let stack;
135
- for (let at = 0; at < args.length; at += 1) {
136
- const arg = args[at];
137
- if (arg === "--stack")
138
- stack = args[++at] ?? "";
139
- else if (arg.startsWith("--stack="))
140
- stack = arg.slice("--stack=".length);
141
- else if (arg === "--debug")
133
+ for (const arg of args) {
134
+ if (arg === "--debug")
142
135
  process.env.TURRI_DEBUG = "1";
143
136
  else
144
137
  kept.push(arg);
145
138
  }
146
- if (stack === undefined)
147
- return kept;
148
- const { switchStack } = await import("./stacks.js");
149
- try {
150
- switchStack(process.cwd(), stack);
151
- }
152
- catch (error) {
153
- console.error(error instanceof Error ? error.message : String(error));
154
- process.exit(1);
155
- }
156
139
  return kept;
157
140
  }
158
- if (command === "-h" || command === "--help") {
141
+ // `turri help` too: the word people type first, which would otherwise be an unknown command.
142
+ if (command === "-h" || command === "--help" || command === "help") {
159
143
  console.log(USAGE);
160
144
  process.exit(0);
161
145
  }