@turri-dev/cli 0.2.3-next.fea0bd9 → 0.2.4-next.009bd0c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -62
- 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 +42 -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 +31 -12
- package/dist/extension.js +555 -556
- 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 +2 -2
- package/dist/launch-agent.d.ts +41 -0
- package/dist/launch-agent.js +219 -0
- package/dist/{release-cli.js → launch-cli.js} +41 -24
- package/dist/launch-session.d.ts +58 -0
- package/dist/launch-session.js +195 -0
- package/dist/launch-tools.d.ts +28 -0
- package/dist/launch-tools.js +69 -0
- package/dist/launch-track.d.ts +120 -0
- package/dist/launch-track.js +298 -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 +1 -1
- package/dist/regenerate/command-check.js +1 -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 +126 -0
- package/dist/regenerate/{release.js → launch.js} +60 -48
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +26 -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 +57 -65
- package/dist/regenerate/loop.js +354 -171
- 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 +37 -11
- package/dist/sentinel-check.d.ts +3 -3
- package/dist/sentinel-check.js +3 -3
- package/dist/sentinel.d.ts +17 -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 +8 -8
- package/docs/config.md +62 -52
- package/docs/development.md +4 -5
- package/docs/headless.md +7 -6
- package/docs/hosting.md +25 -24
- package/docs/installation.md +4 -0
- package/docs/launch.md +63 -0
- package/docs/parser.md +3 -3
- package/docs/regenerating.md +30 -22
- package/docs/sandbox.md +3 -3
- package/docs/sentinel.md +27 -16
- package/docs/skills-and-gates.md +6 -11
- package/docs/using.md +26 -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/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));
|
package/dist/cli.js
CHANGED
|
@@ -73,14 +73,11 @@ function chat(args) {
|
|
|
73
73
|
}
|
|
74
74
|
const COMMANDS = {
|
|
75
75
|
regenerate: { module: "./regenerate-cli.ts", blurb: "regenerate a module and its chain from the spec as it is (with module:func-ids: regenerate those again)" },
|
|
76
|
-
glimpse: { module: "./regenerate-cli.ts", blurb: "plan the work and print the first job's prompt, starting nothing", args: ["--dry-run"] },
|
|
77
76
|
drift: { module: "./drift-cli.ts", blurb: "what is left to regenerate: how far the code has drifted from its spec" },
|
|
78
77
|
conform: { module: "./conform-cli.ts", blurb: "write and run a module's conformance tests" },
|
|
79
|
-
"change-plain": { module: "./change-plain-cli.ts", blurb: "apply a change to ***plain, given as a git diff, and regenerate it" },
|
|
80
78
|
parse: { module: "./parse-cli.ts", blurb: "parse ***plain - its syntax and structure, never its code or tests - regenerating nothing" },
|
|
81
79
|
lineage: { module: "./lineage-cli.ts", blurb: "a module's lineage: what was regenerated into it, and when" },
|
|
82
|
-
|
|
83
|
-
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" },
|
|
84
81
|
cultivate: { module: "./cultivate-cli.ts", blurb: "run a gated skill" },
|
|
85
82
|
};
|
|
86
83
|
/** Getting the machine ready, and checking it is. */
|
|
@@ -88,19 +85,38 @@ const SETUP_COMMANDS = {
|
|
|
88
85
|
"init-config": "write a quick start config.turri.yaml here, from the vendor you use: a strong model to talk to, a smaller one to write the code",
|
|
89
86
|
doctor: "check what turri needs - in a project, what it needs of this machine, and that its models answer",
|
|
90
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* pi's package commands, run by pi itself: someone who installs turri has no `pi` on the PATH - npm links only turri's
|
|
90
|
+
* own command - and turri reads the packages pi installs (installed-providers.ts). `update` updates packages only: pi's
|
|
91
|
+
* own `update` with no source updates pi, and turri's pi is a pinned dependency (`updatesPi`).
|
|
92
|
+
*/
|
|
93
|
+
const PACKAGE_COMMANDS = {
|
|
94
|
+
install: "install a pi package for every turri, -l for this project only - pi-claude-code for a Claude subscription, say",
|
|
95
|
+
update: "update a pi package, or --extensions for all of them",
|
|
96
|
+
remove: "remove a pi package `turri install` put in",
|
|
97
|
+
list: "the pi packages installed, yours and this project's",
|
|
98
|
+
};
|
|
99
|
+
/** Whether `update <args>` would update pi itself, as pi reads it: no package named, `self` or `pi`, `--self` or `--all`. */
|
|
100
|
+
function updatesPi(args) {
|
|
101
|
+
if (args.some((arg) => arg === "--self" || arg === "--all" || arg === "self" || arg === "pi"))
|
|
102
|
+
return true;
|
|
103
|
+
if (args.some((arg) => arg === "-h" || arg === "--help" || arg === "--extensions" || arg === "--extension" || arg === "--models"))
|
|
104
|
+
return false;
|
|
105
|
+
return !args.some((arg) => !arg.startsWith("-"));
|
|
106
|
+
}
|
|
91
107
|
const USAGE = [
|
|
92
108
|
"usage: turri [options] open the conversation here: pi, with turri's tools and themes loaded",
|
|
93
109
|
" turri <command> [args]",
|
|
94
110
|
" turri --version turri's version, and pi's",
|
|
95
111
|
"",
|
|
96
|
-
` ${"options".padEnd(12)} --harness-model <m> the model you chat with --coding-model <m> the model
|
|
97
|
-
` ${"".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`,
|
|
98
113
|
` ${"".padEnd(12)} --debug keep what turri writes for debugging it - agents' logs and sessions - as debug: true does`,
|
|
99
114
|
` ${"".padEnd(12)} --use-theme <t> another theme than turri-dark - and every option of pi's own`,
|
|
100
115
|
"",
|
|
101
116
|
...Object.entries(COMMANDS).map(([name, { blurb }]) => ` ${name.padEnd(12)} ${blurb}`),
|
|
102
117
|
"",
|
|
103
118
|
...Object.entries(SETUP_COMMANDS).map(([name, blurb]) => ` ${name.padEnd(12)} ${blurb}`),
|
|
119
|
+
...Object.entries(PACKAGE_COMMANDS).map(([name, blurb]) => ` ${name.padEnd(12)} ${blurb}`),
|
|
104
120
|
"",
|
|
105
121
|
"Run `turri <command> --help` for that command's options.",
|
|
106
122
|
"",
|
|
@@ -108,37 +124,22 @@ const USAGE = [
|
|
|
108
124
|
"specification, so that linked resources inside it resolve the way the parser expects.",
|
|
109
125
|
].join("\n");
|
|
110
126
|
dropNoise();
|
|
111
|
-
// --
|
|
112
|
-
//
|
|
113
|
-
const argv =
|
|
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));
|
|
114
130
|
const [command, ...rest] = argv;
|
|
115
|
-
|
|
131
|
+
function withoutDebug(args) {
|
|
116
132
|
const kept = [];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const arg = args[at];
|
|
120
|
-
if (arg === "--stack")
|
|
121
|
-
stack = args[++at] ?? "";
|
|
122
|
-
else if (arg.startsWith("--stack="))
|
|
123
|
-
stack = arg.slice("--stack=".length);
|
|
124
|
-
else if (arg === "--debug")
|
|
133
|
+
for (const arg of args) {
|
|
134
|
+
if (arg === "--debug")
|
|
125
135
|
process.env.TURRI_DEBUG = "1";
|
|
126
136
|
else
|
|
127
137
|
kept.push(arg);
|
|
128
138
|
}
|
|
129
|
-
if (stack === undefined)
|
|
130
|
-
return kept;
|
|
131
|
-
const { switchStack } = await import("./stacks.js");
|
|
132
|
-
try {
|
|
133
|
-
switchStack(process.cwd(), stack);
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
139
|
return kept;
|
|
140
140
|
}
|
|
141
|
-
|
|
141
|
+
// `turri help` too: the word people type first, which would otherwise be an unknown command.
|
|
142
|
+
if (command === "-h" || command === "--help" || command === "help") {
|
|
142
143
|
console.log(USAGE);
|
|
143
144
|
process.exit(0);
|
|
144
145
|
}
|
|
@@ -152,7 +153,7 @@ if (command === "-v" || command === "--version") {
|
|
|
152
153
|
// The AWS region the project's Bedrock models need, set before any model is called - here, and in the pi the chat starts,
|
|
153
154
|
// which inherits it - unless the person set one (bedrock-region.ts). The models named on the command line count too. A
|
|
154
155
|
// command that calls no model is left alone.
|
|
155
|
-
if (!["parse", "drift", "lineage", "
|
|
156
|
+
if (!["parse", "drift", "lineage", "init-config", ...Object.keys(PACKAGE_COMMANDS)].includes(command ?? "")) {
|
|
156
157
|
const { applyBedrockRegion } = await import("./bedrock-region.js");
|
|
157
158
|
const named = argv.flatMap((arg, at) => ["--harness-model", "--coding-model", "--model"].includes(arg) ? [argv[at + 1] ?? ""] : arg.startsWith("--harness-model=") || arg.startsWith("--coding-model=") || arg.startsWith("--model=") ? [arg.slice(arg.indexOf("=") + 1)] : []);
|
|
158
159
|
applyBedrockRegion(process.cwd(), { also: named.filter((model) => model !== "") });
|
|
@@ -169,6 +170,16 @@ if (command === "doctor") {
|
|
|
169
170
|
const { main } = await import("./setup.js");
|
|
170
171
|
process.exit(await main(rest));
|
|
171
172
|
}
|
|
173
|
+
// pi's own main answers them, as `pi install` would - into the same ~/.pi/agent turri reads - and exits.
|
|
174
|
+
if (Object.hasOwn(PACKAGE_COMMANDS, command)) {
|
|
175
|
+
if (command === "update" && updatesPi(rest)) {
|
|
176
|
+
console.error("turri update updates pi packages: name one (turri update <source>), or --extensions for all of them. pi is part of turri - npm install -g @turri-dev/cli@latest updates both.");
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
const { main } = await import("@earendil-works/pi-coding-agent");
|
|
180
|
+
await main(argv);
|
|
181
|
+
process.exit(process.exitCode ?? 0);
|
|
182
|
+
}
|
|
172
183
|
const entry = COMMANDS[command];
|
|
173
184
|
if (entry === undefined) {
|
|
174
185
|
console.error(`unknown command: ${command}\n\n${USAGE}`);
|
|
@@ -185,7 +196,7 @@ process.argv = [
|
|
|
185
196
|
// A headless run is stopped by a signal - SIGTERM, SIGHUP, Ctrl-C - whatever else listens for it: it exits, and what
|
|
186
197
|
// its agents left running goes with it (shell.ts kills every process group on exit). Left to the libraries' own
|
|
187
198
|
// handlers, one ran on for minutes after it was told to stop, building in the same codebase as the run after it.
|
|
188
|
-
if (!["parse", "drift", "lineage"
|
|
199
|
+
if (!["parse", "drift", "lineage"].includes(command)) {
|
|
189
200
|
for (const [signal, code] of [["SIGTERM", 143], ["SIGHUP", 129], ["SIGINT", 130]]) {
|
|
190
201
|
process.on(signal, () => {
|
|
191
202
|
console.error(`\nstopped (${signal})`);
|
package/dist/config-edit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `/
|
|
2
|
+
* `/settings`' and the chat's settings tool's side of config.turri.yaml: every setting turri reads, what it takes - a yes or no, one of a few words, a
|
|
3
3
|
* number, a model, a list - and when a change to it takes effect, so the person knows whether to wait for the next
|
|
4
4
|
* pulse or not at all. A change is written into the file line by line, its comments and the commented-out examples
|
|
5
5
|
* kept; `models:` and `agent-env:`, which nest, are written again whole, their own comments lost.
|
|
@@ -20,14 +20,20 @@ export interface Setting {
|
|
|
20
20
|
options?: string[];
|
|
21
21
|
/** The least a number may be. */
|
|
22
22
|
min?: number;
|
|
23
|
-
/** Set in the project's config.turri.yaml only: a
|
|
23
|
+
/** Set in the project's config.turri.yaml only: a module's config.turri.<module>.yaml does not change it. */
|
|
24
24
|
projectOnly?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Changed by the person alone, with /settings: the chat's settings tool refuses it. What it decides is theirs - turning
|
|
27
|
+
* conformance tests on doubles each change - or it widens what the agents reach (credentials, folders past the
|
|
28
|
+
* sandbox), or it is a check on the chat's own work (the sentinel, the ***plain rules, the ledger).
|
|
29
|
+
*/
|
|
30
|
+
personOnly?: boolean;
|
|
25
31
|
}
|
|
26
32
|
/** What each effect is, said to the person. */
|
|
27
33
|
export declare const EFFECT_TEXT: Record<Effect, string>;
|
|
28
34
|
/** Every setting, in the order the list shows them. */
|
|
29
35
|
export declare function settings(rules?: string[]): Setting[];
|
|
30
|
-
/** Every setting, as a host is given them: rules-off offering turri's own rules, as /
|
|
36
|
+
/** Every setting, as a host is given them: rules-off offering turri's own rules, as /settings offers them. */
|
|
31
37
|
export declare function configSettings(): Setting[];
|
|
32
38
|
/** A setting by its key - `review`, `models.coding` - or nothing. */
|
|
33
39
|
export declare function settingOf(key: string, rules?: string[]): Setting | undefined;
|
|
@@ -58,13 +64,19 @@ export declare function currentValue(text: string, key: string): unknown;
|
|
|
58
64
|
export declare function shownValue(value: unknown): string;
|
|
59
65
|
/** The project's config.turri.yaml - or the config.yaml it is read from until it has one - its text, empty when there is neither. */
|
|
60
66
|
export declare function readConfigText(dir: string): string;
|
|
61
|
-
/** What a change does beside setting the value: the files and settings that win over it, said to the person. */
|
|
62
|
-
export declare function overriddenBy(dir: string, text: string, setting: Setting): string[];
|
|
63
67
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
68
|
+
* What a change does beside setting the value: the files and settings that win over it, said to the person. `module`:
|
|
69
|
+
* written into that module's own file - the project's file is the one it wins over, and nothing over it is said.
|
|
66
70
|
*/
|
|
67
|
-
export declare function
|
|
71
|
+
export declare function overriddenBy(dir: string, text: string, setting: Setting, module?: string): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Write a setting into the project's config.turri.yaml - or, with `module`, that module's config.turri.<module>.yaml -
|
|
74
|
+
* made when it is not there, from config.yaml and each module's file in the old naming when they are what the project
|
|
75
|
+
* is read from - and give back the file as written.
|
|
76
|
+
*/
|
|
77
|
+
export declare function writeSetting(dir: string, key: string, value: unknown, module?: string): string;
|
|
78
|
+
/** A module's own config.turri.<module>.yaml - or the config.<module>.yaml it is read from until the project has turri's files - its text, empty when there is none. */
|
|
79
|
+
export declare function readModuleConfigText(dir: string, module: string): string;
|
|
68
80
|
/** The files a path setting is offered: the testing scripts in the root and test_scripts/, the .plain files of the folder, or - the test folder - its folders. */
|
|
69
81
|
export declare function pathOptions(dir: string, key: string): string[];
|
|
70
82
|
/** The dotenv files of the project root, for agent-env.files. */
|