@turri-dev/cli 0.2.4-next.8422d0f → 0.2.4-next.d779410
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.
- package/README.md +7 -8
- package/dist/bedrock-region.js +3 -3
- package/dist/chat-idle.d.ts +2 -2
- package/dist/chat-idle.js +2 -2
- package/dist/chat-models.d.ts +1 -1
- package/dist/chat-models.js +1 -1
- package/dist/chat-scope.d.ts +1 -3
- package/dist/chat-skills.d.ts +1 -1
- package/dist/chat-skills.js +1 -1
- package/dist/chats.d.ts +44 -20
- package/dist/chats.js +125 -64
- package/dist/cli.js +12 -31
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +32 -26
- package/dist/config.d.ts +106 -78
- package/dist/config.js +267 -133
- package/dist/conform-cli.js +14 -3
- package/dist/conformance-switch.d.ts +13 -22
- package/dist/conformance-switch.js +37 -59
- package/dist/drift-cli.js +1 -1
- package/dist/extension.d.ts +17 -10
- package/dist/extension.js +435 -532
- package/dist/genome.js +10 -49
- package/dist/graph.js +3 -5
- package/dist/host-session.d.ts +11 -21
- package/dist/host-session.js +6 -8
- package/dist/host.d.ts +4 -4
- package/dist/host.js +4 -7
- package/dist/identity.js +2 -3
- package/dist/init-config.d.ts +1 -2
- package/dist/init-config.js +10 -17
- package/dist/installed-providers.d.ts +1 -1
- package/dist/installed-providers.js +1 -1
- package/dist/launch-agent.d.ts +51 -0
- package/dist/launch-agent.js +267 -0
- package/dist/{release-cli.js → launch-cli.js} +41 -24
- package/dist/launch-session.d.ts +68 -0
- package/dist/launch-session.js +217 -0
- package/dist/launch-tools.d.ts +28 -0
- package/dist/launch-tools.js +69 -0
- package/dist/launch-track.d.ts +125 -0
- package/dist/launch-track.js +320 -0
- package/dist/loop-cli.d.ts +4 -3
- package/dist/loop-cli.js +17 -15
- package/dist/loop-tools.d.ts +45 -21
- package/dist/loop-tools.js +155 -90
- package/dist/new-project.js +2 -2
- package/dist/notice.d.ts +7 -6
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +4 -1
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +12 -9
- package/dist/plain/check.d.ts +2 -9
- package/dist/plain/check.js +6 -39
- package/dist/plain-files.d.ts +2 -2
- package/dist/plain-files.js +7 -7
- package/dist/regenerate/activity.d.ts +0 -7
- package/dist/regenerate/activity.js +2 -20
- package/dist/regenerate/agent-env.d.ts +1 -1
- package/dist/regenerate/agent-env.js +3 -3
- package/dist/regenerate/agent-shell.js +5 -3
- package/dist/regenerate/audit.js +9 -0
- package/dist/regenerate/base-folder.d.ts +2 -2
- package/dist/regenerate/base-folder.js +1 -1
- package/dist/regenerate/cases.js +7 -0
- package/dist/regenerate/chunk-plan.d.ts +5 -0
- package/dist/regenerate/chunk-plan.js +16 -1
- package/dist/regenerate/command-check.d.ts +7 -1
- package/dist/regenerate/command-check.js +43 -1
- package/dist/regenerate/delivery.d.ts +1 -1
- package/dist/regenerate/delivery.js +3 -3
- package/dist/regenerate/drift.d.ts +4 -0
- package/dist/regenerate/drift.js +26 -6
- package/dist/regenerate/failure-reports.d.ts +28 -0
- package/dist/regenerate/failure-reports.js +79 -0
- package/dist/regenerate/job-panel.js +3 -1
- package/dist/regenerate/jobs-tree.js +1 -1
- package/dist/regenerate/jobs.d.ts +4 -2
- package/dist/regenerate/jobs.js +14 -10
- package/dist/regenerate/launch.d.ts +154 -0
- package/dist/regenerate/{release.js → launch.js} +195 -51
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +34 -16
- package/dist/regenerate/ledger.js +1 -1
- package/dist/regenerate/lineage.d.ts +2 -0
- package/dist/regenerate/lineage.js +8 -0
- package/dist/regenerate/loop.d.ts +54 -67
- package/dist/regenerate/loop.js +312 -148
- package/dist/regenerate/model-names.d.ts +33 -0
- package/dist/regenerate/{engine.js → model-names.js} +2 -28
- package/dist/regenerate/paths.d.ts +3 -3
- package/dist/regenerate/paths.js +4 -4
- package/dist/regenerate/records.d.ts +11 -0
- package/dist/regenerate/records.js +15 -0
- package/dist/regenerate/regenerate.d.ts +0 -2
- package/dist/regenerate/regenerate.js +4 -15
- package/dist/regenerate/renames.js +4 -4
- package/dist/regenerate/requires.d.ts +7 -0
- package/dist/regenerate/requires.js +24 -18
- package/dist/regenerate/scripts-being-written.d.ts +4 -4
- package/dist/regenerate/scripts-being-written.js +3 -3
- package/dist/regenerate/spec-map.js +3 -3
- package/dist/regenerate/standing.js +1 -1
- package/dist/regenerate/submit-work.d.ts +2 -0
- package/dist/regenerate/submit-work.js +8 -3
- package/dist/regenerate/test-scripts.d.ts +2 -1
- package/dist/regenerate/test-scripts.js +33 -23
- package/dist/regenerate/testing-steps.d.ts +16 -5
- package/dist/regenerate/testing-steps.js +28 -9
- package/dist/regenerate-cli.js +18 -9
- package/dist/self-invocation.d.ts +11 -0
- package/dist/self-invocation.js +36 -10
- package/dist/sentinel-check.d.ts +3 -3
- package/dist/sentinel-check.js +3 -3
- package/dist/sentinel.d.ts +18 -12
- package/dist/sentinel.js +75 -46
- package/dist/{config-command.d.ts → settings.d.ts} +13 -8
- package/dist/{config-command.js → settings.js} +155 -24
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +7 -7
- package/dist/skill.d.ts +0 -11
- package/dist/skill.js +0 -9
- package/dist/tools.js +2 -3
- package/dist/turri-versions.js +2 -1
- package/docs/README.md +4 -6
- package/docs/authoring-plain.md +3 -3
- package/docs/chats.md +6 -9
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +61 -51
- package/docs/development.md +4 -5
- package/docs/headless.md +7 -6
- package/docs/hosting.md +25 -24
- package/docs/launch.md +67 -0
- package/docs/parser.md +3 -3
- package/docs/regenerating.md +30 -22
- package/docs/sandbox.md +3 -3
- package/docs/sentinel.md +28 -16
- package/docs/skills-and-gates.md +6 -11
- package/docs/using.md +25 -42
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +7 -10
- package/genome/skills/convert-old-syntax/SKILL.md +5 -5
- package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
- package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
- package/package.json +1 -1
- package/dist/advisor-chat.d.ts +0 -63
- package/dist/advisor-chat.js +0 -290
- package/dist/change-plain-cli.js +0 -55
- package/dist/ledger-cli.d.ts +0 -1
- package/dist/ledger-cli.js +0 -50
- package/dist/ledger-tools.d.ts +0 -10
- package/dist/ledger-tools.js +0 -64
- package/dist/regenerate/advisor-records.d.ts +0 -93
- package/dist/regenerate/advisor-records.js +0 -110
- package/dist/regenerate/advisor-runs.d.ts +0 -87
- package/dist/regenerate/advisor-runs.js +0 -327
- package/dist/regenerate/engine.d.ts +0 -52
- package/dist/regenerate/release.d.ts +0 -121
- package/dist/regenerate/test-advisor.d.ts +0 -101
- package/dist/regenerate/test-advisor.js +0 -379
- package/dist/release-agent.d.ts +0 -43
- package/dist/release-agent.js +0 -130
- package/dist/release-cli.d.ts +0 -1
- package/dist/release-tools.d.ts +0 -44
- package/dist/release-tools.js +0 -170
- package/dist/spec-tools.d.ts +0 -36
- package/dist/spec-tools.js +0 -128
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
- package/docs/deploy.md +0 -48
- package/docs/test-advisor.md +0 -110
- /package/dist/{change-plain-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
|
|
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 `/
|
|
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
|
|
@@ -148,16 +148,15 @@ Then say what you want:
|
|
|
148
148
|
|
|
149
149
|
> A small API where people can register and sign in, in Python.
|
|
150
150
|
|
|
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
|
|
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 **`
|
|
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
|
-
- **`/
|
|
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
|
|
193
|
-
| [
|
|
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 |
|
package/dist/bedrock-region.js
CHANGED
|
@@ -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,
|
|
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
|
|
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), ...
|
|
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
|
}
|
package/dist/chat-idle.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import type { ChatLink } from "./chats.ts";
|
|
3
3
|
/**
|
|
4
|
-
* Whether a chat is busy, for what turri tells it of its own accord - a
|
|
5
|
-
*
|
|
4
|
+
* Whether a chat is busy, for what turri tells it of its own accord - a background skill run's end - and so waits: its
|
|
5
|
+
* agent working, or the person typing - or no session to tell yet. Nothing told so interrupts.
|
|
6
6
|
*/
|
|
7
7
|
export declare function chatBusy(link: ChatLink, context: () => ExtensionContext | undefined): boolean;
|
package/dist/chat-idle.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Whether a chat is busy, for what turri tells it of its own accord - a
|
|
3
|
-
*
|
|
2
|
+
* Whether a chat is busy, for what turri tells it of its own accord - a background skill run's end - and so waits: its
|
|
3
|
+
* agent working, or the person typing - or no session to tell yet. Nothing told so interrupts.
|
|
4
4
|
*/
|
|
5
5
|
export function chatBusy(link, context) {
|
|
6
6
|
const session = link.session();
|
package/dist/chat-models.d.ts
CHANGED
|
@@ -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,
|
|
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";
|
package/dist/chat-models.js
CHANGED
|
@@ -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,
|
|
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";
|
package/dist/chat-scope.d.ts
CHANGED
|
@@ -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
|
|
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
|
}
|
package/dist/chat-skills.d.ts
CHANGED
|
@@ -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
|
|
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: {
|
package/dist/chat-skills.js
CHANGED
|
@@ -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
|
|
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,16 +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
|
-
import type { AdvisorVerdict } from "./regenerate/advisor-runs.ts";
|
|
10
10
|
import { type ChatRole, type Conclusion, type Notice, type NoticeAnswer, type NoticeInput, type SentinelCheck } from "./notice.ts";
|
|
11
11
|
/**
|
|
12
12
|
* The chats of a turri session.
|
|
13
13
|
*
|
|
14
14
|
* One turri process is one session on one project, and holds up to MAX_CHATS chats: conversations, each with its own
|
|
15
|
-
* history, model, thinking level
|
|
15
|
+
* history, model, thinking level and questions, each working while another is shown. What they share is the
|
|
16
16
|
* session's: the one job registry and work loop the project's pulses run in - a pulse any chat starts is in every
|
|
17
|
-
* chat's side panel - the coding model, steering,
|
|
17
|
+
* chat's side panel - the coding model, steering, launches and the ledger.
|
|
18
18
|
*
|
|
19
19
|
* A chat is a pi session with turri's extension in it. The extension, built once for each, links itself to its chat
|
|
20
20
|
* here (`attach`); its tools, commands and handlers then run inside the chat's scope (chat-scope.ts), so a pulse knows
|
|
@@ -80,13 +80,19 @@ export interface TurriHost {
|
|
|
80
80
|
* not say it again in the conversation. Unset, it says both, as in the terminal.
|
|
81
81
|
*/
|
|
82
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;
|
|
83
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`. */
|
|
84
90
|
onNotice?(notice: Notice): void;
|
|
85
91
|
/** A notice is over - answered, dismissed, or superseded by a newer one about its module: the host takes its card down. */
|
|
86
92
|
onNoticeOver?(notice: Notice): void;
|
|
87
93
|
/**
|
|
88
94
|
* The sentinel's own tools beside turri's - a host's browser, say - and its surface: where the person watches it use
|
|
89
|
-
* them, in the host's words. Given, the sentinel tries
|
|
95
|
+
* them, in the host's words. Given, the sentinel tries what is launched with those tools, keeping its shell for what they
|
|
90
96
|
* cannot show; absent, the person does not watch it, and the tools are only to test with as well.
|
|
91
97
|
*/
|
|
92
98
|
sentinel?: {
|
|
@@ -110,14 +116,21 @@ export interface ChatInstance {
|
|
|
110
116
|
asked?: string;
|
|
111
117
|
focused?: string;
|
|
112
118
|
}): Promise<void>;
|
|
113
|
-
/**
|
|
114
|
-
* The sentinel's: functional specs a host asked it to check - the module released first, unless what runs is its last
|
|
115
|
-
* commit, then its agent told, in a conversation of its own for the check. Why not, when the release failed: then its
|
|
116
|
-
* agent is told nothing.
|
|
117
|
-
*/
|
|
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. */
|
|
118
120
|
briefCheck(check: SentinelCheck, context: {
|
|
119
121
|
focused?: string;
|
|
120
|
-
}): Promise<
|
|
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;
|
|
121
134
|
/** A notice put in the chat: drawn, and - in the terminal - put to the person once the chat is idle. */
|
|
122
135
|
notice(notice: Notice): void;
|
|
123
136
|
/** A notice is over: its dialog closed, if it is open. */
|
|
@@ -126,19 +139,12 @@ export interface ChatInstance {
|
|
|
126
139
|
concluded(conclusion: Conclusion): void;
|
|
127
140
|
/** The person answered a notice with something to do: the chat's agent started on it. */
|
|
128
141
|
act(task: string): void;
|
|
129
|
-
/**
|
|
130
|
-
* The test advisor's verdict: once the chat is idle - its agent done, nothing typed - a yes starts a turn that writes its
|
|
131
|
-
* scenarios, and a no is a line. Those that arrive meanwhile are delivered together.
|
|
132
|
-
*/
|
|
133
|
-
advised(verdict: AdvisorVerdict): void;
|
|
134
142
|
/** The jobs changed: what it draws of them is drawn again. */
|
|
135
143
|
jobsChanged(): void;
|
|
136
144
|
/** How hard the chat's model thinks now: sub-agents started from it think as hard. */
|
|
137
145
|
thinkingLevel(): string | undefined;
|
|
138
146
|
/** The chat's context, as its tools get it - for its model and its providers. */
|
|
139
147
|
context(): ExtensionContext | undefined;
|
|
140
|
-
/** Conformance tests turned on or off: the chat's tools switched to match - conform and evaluate_tests, or the tool that turns them on. */
|
|
141
|
-
conformanceSwitched?(): void;
|
|
142
148
|
}
|
|
143
149
|
/** A chat's extension, linked to its chat. */
|
|
144
150
|
export interface ChatLink {
|
|
@@ -230,6 +236,12 @@ export interface TurriCore {
|
|
|
230
236
|
showing(chat: ChatState): void;
|
|
231
237
|
/** For the extension: a pulse ended - told to the chat that asked for it, or, with the sentinel on, to the sentinel. */
|
|
232
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;
|
|
233
245
|
/** Whether finished pulses go to the sentinel now: it is on, and there is somewhere to open it. */
|
|
234
246
|
sentinelOn(): boolean;
|
|
235
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. */
|
|
@@ -248,8 +260,6 @@ export interface TurriCore {
|
|
|
248
260
|
} | {
|
|
249
261
|
refused: string;
|
|
250
262
|
};
|
|
251
|
-
/** The test advisor's verdict, for the chat the person looks at - held until there is one. Undefined: no chat to hand it to yet. */
|
|
252
|
-
advised(verdict: AdvisorVerdict): string | undefined;
|
|
253
263
|
/** The notices put to the person and not yet answered. */
|
|
254
264
|
notices(): Notice[];
|
|
255
265
|
/**
|
|
@@ -285,6 +295,20 @@ export interface CoreOptions {
|
|
|
285
295
|
setSentinel?: (on: boolean) => void;
|
|
286
296
|
/** The person ignored a notice for good: kept in the sentinel's guidance, for every conversation after. */
|
|
287
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>;
|
|
288
312
|
}
|
|
289
313
|
/** A chat's session, as stopping what it does reaches it. */
|
|
290
314
|
export type Stoppable = Pick<AgentSession, "isStreaming" | "isCompacting" | "isRetrying" | "isBashRunning" | "abort" | "abortBash">;
|
|
@@ -305,7 +329,7 @@ export declare function interruptChat<R>(session: Stoppable, asked: {
|
|
|
305
329
|
export declare function createChats(options: CoreOptions): TurriCore;
|
|
306
330
|
/**
|
|
307
331
|
* pi's extension API for a chat: every tool, command, shortcut and handler the extension registers runs inside the
|
|
308
|
-
* chat's scope - its
|
|
332
|
+
* chat's scope - its id on what it starts.
|
|
309
333
|
*/
|
|
310
334
|
export declare function scopedToChat(pi: ExtensionAPI, scope: ChatScope): ExtensionAPI;
|
|
311
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
|
|
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,
|
|
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
|
|
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. */
|
|
@@ -106,8 +108,6 @@ export function createChats(options) {
|
|
|
106
108
|
let consent = "unasked";
|
|
107
109
|
let asking;
|
|
108
110
|
const held = [];
|
|
109
|
-
/** The test advisor's verdicts that came with no chat of the person's to hand them to: handed on as one comes up. */
|
|
110
|
-
const unplaced = [];
|
|
111
111
|
const run = { run: randomUUID().slice(0, 8), pid: process.pid, started: new Date().toISOString(), chats: [] };
|
|
112
112
|
const changed = () => {
|
|
113
113
|
for (const listener of listeners) {
|
|
@@ -160,7 +160,7 @@ export function createChats(options) {
|
|
|
160
160
|
const id = randomUUID().slice(0, 8);
|
|
161
161
|
const chat = {
|
|
162
162
|
id,
|
|
163
|
-
scope: { id,
|
|
163
|
+
scope: { id, asking: new Set() },
|
|
164
164
|
...(title !== undefined ? { recordedTitle: title } : {}),
|
|
165
165
|
...(role !== undefined ? { role } : {}),
|
|
166
166
|
working: false,
|
|
@@ -187,8 +187,12 @@ export function createChats(options) {
|
|
|
187
187
|
chat.unread = true;
|
|
188
188
|
persist();
|
|
189
189
|
changed();
|
|
190
|
+
}
|
|
191
|
+
else if (event.type === "agent_settled") {
|
|
190
192
|
// Done with its pulse - or with what the person said to it: the next pulse waiting, in a conversation of its own.
|
|
191
|
-
|
|
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) {
|
|
192
196
|
checking = undefined;
|
|
193
197
|
toSentinel(() => nextWork(chat));
|
|
194
198
|
}
|
|
@@ -279,6 +283,7 @@ export function createChats(options) {
|
|
|
279
283
|
// Closed, the sentinel is let go with what it had to check: the next pulse that finishes opens it again.
|
|
280
284
|
if (chat.role === SENTINEL) {
|
|
281
285
|
checking = undefined;
|
|
286
|
+
paused = undefined;
|
|
282
287
|
// A check a host asked for ends all the same: it is told it was not done.
|
|
283
288
|
for (const work of waiting.splice(0))
|
|
284
289
|
if ("check" in work)
|
|
@@ -364,10 +369,6 @@ export function createChats(options) {
|
|
|
364
369
|
session: () => chat.session,
|
|
365
370
|
live: (instance) => {
|
|
366
371
|
chat.instance = instance;
|
|
367
|
-
// The advisor's verdicts that waited for a chat of the person's.
|
|
368
|
-
if (unplaced.length > 0 && personFacing() !== undefined)
|
|
369
|
-
for (const verdict of unplaced.splice(0))
|
|
370
|
-
core.advised(verdict);
|
|
371
372
|
},
|
|
372
373
|
};
|
|
373
374
|
},
|
|
@@ -398,6 +399,30 @@ export function createChats(options) {
|
|
|
398
399
|
}
|
|
399
400
|
toAsker(job);
|
|
400
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
|
+
},
|
|
401
426
|
check(prepare) {
|
|
402
427
|
if (driver === undefined)
|
|
403
428
|
return { refused: "There is nowhere to open the sentinel in this session." };
|
|
@@ -470,6 +495,10 @@ export function createChats(options) {
|
|
|
470
495
|
},
|
|
471
496
|
notices: () => open.filter((notice) => notice.state === "open"),
|
|
472
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 };
|
|
473
502
|
const job = conclusion.job !== undefined ? jobs.get(conclusion.job) : undefined;
|
|
474
503
|
const check = conclusion.check !== undefined ? checks.get(conclusion.check) : undefined;
|
|
475
504
|
const target = personFacing(chats.find((chat) => chat.id === job?.chat));
|
|
@@ -496,23 +525,6 @@ export function createChats(options) {
|
|
|
496
525
|
changed();
|
|
497
526
|
return target.id;
|
|
498
527
|
},
|
|
499
|
-
advised(verdict) {
|
|
500
|
-
const target = personFacing();
|
|
501
|
-
if (target?.instance === undefined) {
|
|
502
|
-
unplaced.push(verdict);
|
|
503
|
-
return undefined;
|
|
504
|
-
}
|
|
505
|
-
if (target.id !== shownId)
|
|
506
|
-
target.unread = true;
|
|
507
|
-
try {
|
|
508
|
-
target.instance.advised(verdict);
|
|
509
|
-
}
|
|
510
|
-
catch {
|
|
511
|
-
/* a chat let go as it was told: a yes stays undelivered in the advisor's file, for the next start */
|
|
512
|
-
}
|
|
513
|
-
changed();
|
|
514
|
-
return target.id;
|
|
515
|
-
},
|
|
516
528
|
answer(id, answer) {
|
|
517
529
|
const notice = open.find((candidate) => candidate.id === id);
|
|
518
530
|
if (notice === undefined)
|
|
@@ -740,29 +752,16 @@ export function createChats(options) {
|
|
|
740
752
|
core.notify(`The sentinel: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
741
753
|
});
|
|
742
754
|
}
|
|
743
|
-
/** 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. */
|
|
744
|
-
const sentinelBusy = (sentinel) => sentinel.session?.isStreaming === true;
|
|
745
755
|
/**
|
|
746
|
-
*
|
|
747
|
-
*
|
|
748
|
-
* 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.
|
|
749
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. */
|
|
750
761
|
function takeWork(sentinel, work) {
|
|
751
762
|
if (!sentinelBusy(sentinel))
|
|
752
763
|
return begin(sentinel, work);
|
|
753
|
-
|
|
754
|
-
waiting.push(work);
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
const job = work.pulse;
|
|
758
|
-
const sameModule = (other) => job.module !== undefined && "pulse" in other && other.pulse.module === job.module;
|
|
759
|
-
if (checking !== undefined && !checking.wrong && sameModule(checking.work) && "pulse" in checking.work)
|
|
760
|
-
return check(sentinel, job, checking.work.pulse);
|
|
761
|
-
const older = waiting.findIndex((other) => sameModule(other) && "pulse" in other && !wentWrong(other.pulse));
|
|
762
|
-
if (older !== -1)
|
|
763
|
-
waiting.splice(older, 1, work);
|
|
764
|
-
else
|
|
765
|
-
waiting.push(work);
|
|
764
|
+
waiting.push(work);
|
|
766
765
|
}
|
|
767
766
|
/** The sentinel free again: the next pulse or check that waits, taken. */
|
|
768
767
|
function nextWork(sentinel) {
|
|
@@ -775,13 +774,40 @@ export function createChats(options) {
|
|
|
775
774
|
function begin(sentinel, work) {
|
|
776
775
|
return "pulse" in work ? check(sentinel, work.pulse) : checkSpecs(sentinel, work.check);
|
|
777
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);
|
|
778
779
|
/**
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
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.
|
|
782
802
|
*/
|
|
783
803
|
async function checkSpecs(sentinel, check) {
|
|
784
|
-
|
|
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 } };
|
|
785
811
|
inChat(sentinel.scope, () => record({ kind: "sentinel.checking", module: check.module, check: check.id }, { project: cwd }));
|
|
786
812
|
const session = sentinel.session;
|
|
787
813
|
if (session !== undefined && (session.messages.length > 0 || session.isStreaming))
|
|
@@ -789,28 +815,29 @@ export function createChats(options) {
|
|
|
789
815
|
if (sentinel.id !== shownId)
|
|
790
816
|
sentinel.unread = true;
|
|
791
817
|
const where = personFacing();
|
|
792
|
-
let why;
|
|
793
818
|
try {
|
|
794
|
-
|
|
819
|
+
await sentinel.instance.briefCheck(check, where !== undefined ? { focused: titleFor(where) } : {});
|
|
795
820
|
}
|
|
796
821
|
catch (error) {
|
|
797
|
-
|
|
822
|
+
core.notify(`The sentinel could not be told of check ${check.id}: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
823
|
+
checking = undefined;
|
|
798
824
|
}
|
|
799
825
|
changed();
|
|
800
|
-
if (why === undefined)
|
|
801
|
-
return;
|
|
802
|
-
checking = undefined;
|
|
803
|
-
core.concluded({ check: check.id, module: check.module, verdict: "wrong", summary: `Not tested: ${check.module} could not be released - ${why}` });
|
|
804
|
-
await nextWork(sentinel);
|
|
805
826
|
}
|
|
806
827
|
/**
|
|
807
828
|
* The sentinel on a pulse, from scratch: a conversation of its own - its prompt, the project's guidance and this
|
|
808
|
-
* pulse's brief, nothing of the pulses before it -
|
|
829
|
+
* pulse's brief, nothing of the pulses before it - once what runs holds the pulse's commit (`readyFor`).
|
|
809
830
|
*/
|
|
810
|
-
async function check(sentinel, job
|
|
811
|
-
|
|
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 } };
|
|
812
839
|
const module = job.module;
|
|
813
|
-
inChat(sentinel.scope, () => record({ kind: "sentinel.checking", ...(module !== undefined ? { module } : {})
|
|
840
|
+
inChat(sentinel.scope, () => record({ kind: "sentinel.checking", ...(module !== undefined ? { module } : {}) }, { project: cwd, job: job.id }));
|
|
814
841
|
const session = sentinel.session;
|
|
815
842
|
if (session !== undefined && (session.messages.length > 0 || session.isStreaming))
|
|
816
843
|
await freshConversation(sentinel);
|
|
@@ -830,6 +857,40 @@ export function createChats(options) {
|
|
|
830
857
|
}
|
|
831
858
|
changed();
|
|
832
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
|
+
}
|
|
833
894
|
/**
|
|
834
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
|
|
835
896
|
* saved conversation deleted outside debug mode. The model and thinking it had carry over: what the person picked in
|
|
@@ -903,7 +964,7 @@ export function createChats(options) {
|
|
|
903
964
|
}
|
|
904
965
|
/**
|
|
905
966
|
* pi's extension API for a chat: every tool, command, shortcut and handler the extension registers runs inside the
|
|
906
|
-
* chat's scope - its
|
|
967
|
+
* chat's scope - its id on what it starts.
|
|
907
968
|
*/
|
|
908
969
|
export function scopedToChat(pi, scope) {
|
|
909
970
|
const within = (work) => work === undefined ? undefined : (...args) => inChat(scope, () => work(...args));
|