@turri-dev/cli 0.4.2-next.a6867e8 → 0.4.3-next.3fc888b
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 +1 -0
- package/dist/background-skills.d.ts +4 -1
- package/dist/background-skills.js +9 -1
- package/dist/capture/agents.d.ts +391 -0
- package/dist/capture/agents.js +338 -0
- package/dist/capture/area.d.ts +58 -0
- package/dist/capture/area.js +197 -0
- package/dist/capture/assemble.d.ts +122 -0
- package/dist/capture/assemble.js +452 -0
- package/dist/capture/capture.d.ts +116 -0
- package/dist/capture/capture.js +1281 -0
- package/dist/capture/chat.d.ts +29 -0
- package/dist/capture/chat.js +94 -0
- package/dist/capture/checks.d.ts +142 -0
- package/dist/capture/checks.js +643 -0
- package/dist/capture/config.d.ts +13 -0
- package/dist/capture/config.js +60 -0
- package/dist/capture/interface.d.ts +71 -0
- package/dist/capture/interface.js +199 -0
- package/dist/capture/map.d.ts +58 -0
- package/dist/capture/map.js +530 -0
- package/dist/capture/plan.d.ts +8 -0
- package/dist/capture/plan.js +13 -0
- package/dist/capture/progress.d.ts +109 -0
- package/dist/capture/progress.js +240 -0
- package/dist/capture/report.d.ts +75 -0
- package/dist/capture/report.js +268 -0
- package/dist/capture/scripts.d.ts +26 -0
- package/dist/capture/scripts.js +33 -0
- package/dist/capture/state.d.ts +299 -0
- package/dist/capture/state.js +43 -0
- package/dist/capture/trial.d.ts +34 -0
- package/dist/capture/trial.js +89 -0
- package/dist/capture-cli.d.ts +1 -0
- package/dist/capture-cli.js +77 -0
- package/dist/chat-commands.d.ts +2 -10
- package/dist/chat-commands.js +3 -57
- package/dist/chat-tab-header.d.ts +15 -0
- package/dist/chat-tab-header.js +78 -0
- package/dist/chat-tabs.d.ts +26 -0
- package/dist/chat-tabs.js +100 -0
- package/dist/chat-terminal.js +57 -8
- package/dist/chat-waiting.d.ts +4 -1
- package/dist/chat-waiting.js +7 -4
- package/dist/chats.d.ts +12 -7
- package/dist/chats.js +35 -21
- package/dist/cli.js +32 -14
- package/dist/config-edit.js +4 -2
- package/dist/config.d.ts +15 -2
- package/dist/config.js +62 -4
- package/dist/extension.d.ts +1 -0
- package/dist/extension.js +262 -136
- package/dist/identity.js +3 -2
- package/dist/init-config.js +2 -0
- package/dist/loop-cli.js +5 -1
- package/dist/loop-tools.d.ts +2 -3
- package/dist/loop-tools.js +12 -13
- package/dist/new-project.d.ts +5 -0
- package/dist/new-project.js +11 -0
- package/dist/pi-launch.js +2 -0
- package/dist/pi-themes.d.ts +3 -0
- package/dist/pi-themes.js +21 -0
- package/dist/pi.js +2 -2
- package/dist/plain-code-blocks.d.ts +14 -0
- package/dist/plain-code-blocks.js +56 -0
- package/dist/pointer-hover.d.ts +12 -0
- package/dist/pointer-hover.js +48 -0
- package/dist/question-dialog.d.ts +5 -0
- package/dist/question-dialog.js +20 -1
- package/dist/regenerate/chunk-plan.d.ts +2 -11
- package/dist/regenerate/chunk-plan.js +9 -20
- package/dist/regenerate/command-check.d.ts +9 -0
- package/dist/regenerate/command-check.js +163 -14
- package/dist/regenerate/job-panel.d.ts +5 -107
- package/dist/regenerate/job-panel.js +4 -289
- package/dist/regenerate/jobs-tree.d.ts +1 -0
- package/dist/regenerate/jobs-tree.js +5 -1
- package/dist/regenerate/loop.d.ts +6 -14
- package/dist/regenerate/loop.js +51 -35
- package/dist/regenerate/side-panel.d.ts +6 -1
- package/dist/regenerate/side-panel.js +158 -22
- package/dist/regenerate/spec-map-view.d.ts +11 -3
- package/dist/regenerate/spec-map-view.js +22 -2
- package/dist/regenerate/test-scripts.d.ts +8 -0
- package/dist/regenerate/test-scripts.js +20 -5
- package/dist/reopen.d.ts +29 -0
- package/dist/reopen.js +47 -0
- package/dist/resume-line.d.ts +4 -1
- package/dist/resume-line.js +5 -2
- package/dist/sentinel-chat.js +7 -2
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +4 -2
- package/dist/setup.js +9 -1
- package/dist/terminal-notifications.d.ts +31 -0
- package/dist/terminal-notifications.js +134 -0
- package/docs/README.md +2 -0
- package/docs/capture.md +207 -0
- package/docs/chats.md +8 -7
- package/docs/config.md +18 -3
- package/docs/development.md +4 -1
- package/docs/hosting.md +2 -2
- package/docs/launch.md +2 -2
- package/docs/regenerating.md +9 -8
- package/docs/sandbox.md +3 -1
- package/docs/sentinel.md +11 -11
- package/docs/skills-and-gates.md +1 -1
- package/docs/theming.md +3 -3
- package/docs/using.md +12 -5
- package/genome/capture/capture.md +26 -0
- package/genome/capture/check-conventions.md +5 -0
- package/genome/capture/check-reference.md +11 -0
- package/genome/capture/compact.md +7 -0
- package/genome/capture/concepts.md +3 -0
- package/genome/capture/divide.md +9 -0
- package/genome/capture/feature.md +45 -0
- package/genome/capture/interface.md +9 -0
- package/genome/capture/modules.md +23 -0
- package/genome/capture/outline.md +11 -0
- package/genome/capture/readability.md +12 -0
- package/genome/capture/reference.md +10 -0
- package/genome/capture/split.md +9 -0
- package/genome/capture/survey.md +37 -0
- package/genome/capture/trial.md +18 -0
- package/genome/capture/verify.md +7 -0
- package/genome/rules/turri-regeneration.md +2 -2
- package/package.json +3 -3
- package/dist/regenerate/steer.d.ts +0 -34
- package/dist/regenerate/steer.js +0 -91
package/dist/extension.js
CHANGED
|
@@ -20,6 +20,12 @@ import { applyBedrockRegion } from "./bedrock-region.js";
|
|
|
20
20
|
import { bannerWarnings } from "./turri-versions.js";
|
|
21
21
|
import { CONFORMANCE_OFF_REFUSAL, conformanceBlock, conformanceTestsOn, conformanceTestsOnIn, turnOnConformanceTests } from "./conformance-switch.js";
|
|
22
22
|
import { BACKGROUND_NOTE, doneLine, failedTask, ownChanges, runDetails, skillRunDelivery, startedText } from "./background-skills.js";
|
|
23
|
+
import { runCapture } from "./capture/capture.js";
|
|
24
|
+
import { captureEnded, captureFailed, captureGoesOn, captureOpenQuestion, captureRefusal, captureStartedText, readReopenedAfterCapture, reopenedAfterCapture } from "./capture/chat.js";
|
|
25
|
+
import { reportFile as captureReportFile } from "./capture/state.js";
|
|
26
|
+
import { canReopen, REOPENED_AFTER_CAPTURE, reopenIn } from "./reopen.js";
|
|
27
|
+
import { captureStatusLines } from "./capture/progress.js";
|
|
28
|
+
import { highlightPlainCodeBlocks } from "./plain-code-blocks.js";
|
|
23
29
|
import { createAskUserTool } from "./tools.js";
|
|
24
30
|
import { asksFromScratch, asksWholeChain, driftTool, endWait, fromWorkingDir, haltLaunched, haltTool, loopReply, startWait, toldByWaitingCall, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, whenBuildable, WORKING_DIR_PARAM } from "./loop-tools.js";
|
|
25
31
|
import { createWebTools } from "./regenerate/web.js";
|
|
@@ -31,9 +37,8 @@ import { launchTool } from "./launch-tools.js";
|
|
|
31
37
|
import { createSessionLaunches, launchedDir, launchedNote, replacedNote } from "./launch-session.js";
|
|
32
38
|
import { describeLaunchLine, launchText } from "./launch-track.js";
|
|
33
39
|
import { checkedSpecs } from "./sentinel-check.js";
|
|
34
|
-
import { createSteeringStore, EVERY_MODULE, moduleNameOf, queueSectionOf, steeringFor } from "./regenerate/steer.js";
|
|
35
40
|
import { askedForCommandLine, refusal, selfInvocation, TOOLS_NOT_CLI } from "./self-invocation.js";
|
|
36
|
-
import { NEW_PROJECT } from "./new-project.js";
|
|
41
|
+
import { CAPTURE_HINT, NEW_PROJECT } from "./new-project.js";
|
|
37
42
|
import { describeResolution, resolveModel } from "./regenerate/model-names.js";
|
|
38
43
|
import { checkPlainFile, formatCheckResults } from "./plain/check.js";
|
|
39
44
|
import { checkPlainTool } from "./parse-tool.js";
|
|
@@ -43,7 +48,7 @@ import { didNotLand } from "./regenerate/failure-reports.js";
|
|
|
43
48
|
import { conformanceRefusal, createWorkLoop, TestingStepsMissing, describeModules, isUpToDate } from "./regenerate/loop.js";
|
|
44
49
|
import { brandNeon, brandPink, plainPaint } from "./regenerate/plain-palette.js";
|
|
45
50
|
import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_REST, JELLYFISH_SEQUENCE, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
|
|
46
|
-
import {
|
|
51
|
+
import { didNotPass, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
|
|
47
52
|
import { clickToFocus, dockedWidth, narrowChat, shade, shadeChat } from "./regenerate/panel-dock.js";
|
|
48
53
|
import { overPictureRow, PICTURE_AT } from "./picture-row.js";
|
|
49
54
|
import { padScreen, paddedColumns, paddedRows, SCREEN_PADDING } from "./screen-padding.js";
|
|
@@ -51,6 +56,7 @@ import { skillAboutLine, skillProgressLine } from "./skill-progress.js";
|
|
|
51
56
|
import { createSidePanel } from "./regenerate/side-panel.js";
|
|
52
57
|
import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
|
|
53
58
|
import { createSpecMapState } from "./regenerate/spec-map-view.js";
|
|
59
|
+
import { notificationView } from "./terminal-notifications.js";
|
|
54
60
|
import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
|
|
55
61
|
import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
|
|
56
62
|
import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
|
|
@@ -79,6 +85,7 @@ import { ignoredGuidance, keepGuidance, landedNote, pulseEndsBlock, SENTINEL, SE
|
|
|
79
85
|
import { noticeDialogs, registerSentinel } from "./sentinel-chat.js";
|
|
80
86
|
import { currentChat } from "./chat-scope.js";
|
|
81
87
|
import { registerChats } from "./chat-commands.js";
|
|
88
|
+
import { buttonLabel, terminalPointer } from "./pointer-hover.js";
|
|
82
89
|
import { turriIdentity } from "./environment.js";
|
|
83
90
|
import { answerSideQuestion, askWithAsides, BTW_HOW, runningSkill, skillRunStarted, skillSessionText, transcriptOf } from "./btw.js";
|
|
84
91
|
import { createJobRegistry, defaultParallelJobs, describeJob, formatDuration, pulseName, shouldWait, STOPPED_ON_REQUEST, } from "./regenerate/jobs.js";
|
|
@@ -295,12 +302,29 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
295
302
|
// The AWS region the project's Bedrock models need, before any model is called - a host has no shell to export it in.
|
|
296
303
|
applyBedrockRegion(cwd);
|
|
297
304
|
let core;
|
|
305
|
+
// One activity light for every chat. Only plan changes need to read the plan; streaming job updates do not.
|
|
306
|
+
let planning = false;
|
|
307
|
+
const running = new Set();
|
|
308
|
+
const busy = () => planning || running.size > 0;
|
|
309
|
+
const updateActivity = (job) => {
|
|
310
|
+
if (!core?.terminal)
|
|
311
|
+
return;
|
|
312
|
+
const before = busy();
|
|
313
|
+
if (!job)
|
|
314
|
+
planning = workLoops.get(jobs)?.loop.planned().some((row) => row.planning !== undefined) ?? false;
|
|
315
|
+
else if (job.status === "running" && (job.kind === "regenerate" || job.kind === "conformance"))
|
|
316
|
+
running.add(job.id);
|
|
317
|
+
else
|
|
318
|
+
running.delete(job.id);
|
|
319
|
+
if (busy() !== before)
|
|
320
|
+
core.changed();
|
|
321
|
+
};
|
|
298
322
|
// Finished work is announced twice, to two audiences, because pi treats them differently - see ChatInstance.announce:
|
|
299
323
|
// in the chat that asked for it, or the one shown when that is closed.
|
|
300
324
|
const jobs = createJobRegistry({
|
|
301
|
-
// The
|
|
325
|
+
// The planner can be at work before the registry has its first pulse.
|
|
302
326
|
onNotify: () => {
|
|
303
|
-
|
|
327
|
+
updateActivity();
|
|
304
328
|
host.onPlanChange?.();
|
|
305
329
|
},
|
|
306
330
|
// A job that fails is run once more; failing again, it and every job behind it fail, and the
|
|
@@ -322,16 +346,16 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
322
346
|
return diagnosis !== undefined ? describeDiagnosis(diagnosis) : undefined;
|
|
323
347
|
},
|
|
324
348
|
onChange: (job) => {
|
|
325
|
-
|
|
349
|
+
updateActivity(job);
|
|
326
350
|
host.onJobChange?.(job);
|
|
327
351
|
},
|
|
328
352
|
onFinish: (job) => {
|
|
329
|
-
|
|
353
|
+
updateActivity(job);
|
|
330
354
|
host.onJobChange?.(job);
|
|
331
355
|
// Queued again as another job: that one says how it went.
|
|
332
356
|
if (job.replacedBy !== undefined)
|
|
333
357
|
return;
|
|
334
|
-
// Gone wrong: the next ctrl+h opens on it
|
|
358
|
+
// Gone wrong: the next ctrl+h opens on it.
|
|
335
359
|
if (job.status === "failed" || job.status === "stopped" || didNotPass(job))
|
|
336
360
|
needsLooking.set(jobs, job.id);
|
|
337
361
|
core?.jobFinished(job);
|
|
@@ -344,7 +368,6 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
344
368
|
jobs,
|
|
345
369
|
model: (plainFile) => launchModel(workLoops.get(jobs)?.from.ctx, plainFile),
|
|
346
370
|
onChange: (launch) => {
|
|
347
|
-
core?.jobsChanged();
|
|
348
371
|
try {
|
|
349
372
|
host.onLaunch?.(launch);
|
|
350
373
|
}
|
|
@@ -360,7 +383,7 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
360
383
|
launches,
|
|
361
384
|
host,
|
|
362
385
|
jobs,
|
|
363
|
-
extension: (pi, link) => turriExtension(pi, core, link),
|
|
386
|
+
extension: (pi, link) => turriExtension(pi, core, link, busy),
|
|
364
387
|
// A finished pulse goes to the sentinel when the project wants one - read as each pulse finishes - the person asked
|
|
365
388
|
// first under `sentinel: ask`, and what they choose for the project written.
|
|
366
389
|
sentinel: () => sentinelSetting(cwd),
|
|
@@ -428,7 +451,7 @@ export function sessionLoop(session) {
|
|
|
428
451
|
* turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
|
|
429
452
|
* its id on the pulses it asks for - on the session's job registry and work loop.
|
|
430
453
|
*/
|
|
431
|
-
function turriExtension(api, session, link) {
|
|
454
|
+
function turriExtension(api, session, link, busy) {
|
|
432
455
|
const pi = scopedToChat(api, link.scope);
|
|
433
456
|
const { cwd, host, jobs } = session;
|
|
434
457
|
// The session's sentinel: its own prompt and tools - the project to read, notices, its guidance - and nothing that
|
|
@@ -443,8 +466,6 @@ function turriExtension(api, session, link) {
|
|
|
443
466
|
const dialogs = link.dialogs ?? host.dialogs;
|
|
444
467
|
// turri's own skills, and the project's - .turri/skills, .agents/skills (skills.ts).
|
|
445
468
|
const discoveredSkills = discoverSkills(PACKAGE_ROOT, cwd);
|
|
446
|
-
// What the background work is doing right now, drawn above the editor while it runs.
|
|
447
|
-
const panel = createJobPanel(() => shownJobs(jobs));
|
|
448
469
|
// The chat's context, as its tools and handlers were last given it: for its model and its providers.
|
|
449
470
|
let lastContext;
|
|
450
471
|
const contextNow = () => {
|
|
@@ -465,7 +486,8 @@ function turriExtension(api, session, link) {
|
|
|
465
486
|
// does what the project's guidance says to do then (launch what was built, say), or says
|
|
466
487
|
// what finished. In the chat that asked for the pulse, shown or not.
|
|
467
488
|
const announce = (job) => {
|
|
468
|
-
|
|
489
|
+
if (!session.terminal)
|
|
490
|
+
announceJob(pi, job);
|
|
469
491
|
// A pulse a call of this chat waits for is told in that call's reply: a turn of its own would say it again.
|
|
470
492
|
if (toldByWaitingCall(jobs, job) && job.specConflict === undefined)
|
|
471
493
|
return;
|
|
@@ -481,12 +503,13 @@ function turriExtension(api, session, link) {
|
|
|
481
503
|
catch {
|
|
482
504
|
/* a config that cannot be read launches nothing */
|
|
483
505
|
}
|
|
506
|
+
const quiet = session.terminal && job.status === "succeeded" && !didNotPass(job);
|
|
484
507
|
void pi.sendMessage({
|
|
485
508
|
customType: "turri_job",
|
|
486
|
-
content: pulseEndNote(job, { launching }),
|
|
509
|
+
content: pulseEndNote(job, { launching, quiet }),
|
|
487
510
|
display: false,
|
|
488
511
|
details: { jobId: job.id, status: job.status },
|
|
489
|
-
}, { triggerTurn: true, deliverAs: "followUp" });
|
|
512
|
+
}, quiet ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
|
|
490
513
|
};
|
|
491
514
|
// The sentinel's: what a pulse that ended is, told to its agent in a conversation of its own for the pulse. The hidden
|
|
492
515
|
// message is the conversation's first entry - a host splits the sentinel's work by pulse on it - so the pulse's end is
|
|
@@ -531,13 +554,14 @@ function turriExtension(api, session, link) {
|
|
|
531
554
|
// it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
|
|
532
555
|
// contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
|
|
533
556
|
const landed = (job, options = {}) => {
|
|
534
|
-
|
|
557
|
+
if (!session.terminal)
|
|
558
|
+
announceJob(pi, job);
|
|
535
559
|
if (job.specConflict !== undefined)
|
|
536
560
|
session.notice(specConflictNotice(job, specConflictTask(job.specConflict)));
|
|
537
561
|
if (options.tell !== true || toldByWaitingCall(jobs, job))
|
|
538
562
|
return;
|
|
539
563
|
// A host that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
|
|
540
|
-
const shown = host.pulseEndsShown === true;
|
|
564
|
+
const shown = session.terminal || host.pulseEndsShown === true;
|
|
541
565
|
let launching = false;
|
|
542
566
|
try {
|
|
543
567
|
launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
|
|
@@ -549,6 +573,18 @@ function turriExtension(api, session, link) {
|
|
|
549
573
|
};
|
|
550
574
|
const notices = noticeDialogs(pi, session, link, contextNow);
|
|
551
575
|
link.live({
|
|
576
|
+
plainPanel: {
|
|
577
|
+
busy,
|
|
578
|
+
open: () => sidePanelOf(session).visible(),
|
|
579
|
+
toggle: () => {
|
|
580
|
+
const panel = sidePanelOf(session);
|
|
581
|
+
if (panel.visible())
|
|
582
|
+
return panel.close();
|
|
583
|
+
const ctx = contextNow();
|
|
584
|
+
if (ctx?.hasUI)
|
|
585
|
+
panel.open(ctx, "map", "beside");
|
|
586
|
+
},
|
|
587
|
+
},
|
|
552
588
|
announce,
|
|
553
589
|
landed,
|
|
554
590
|
brief,
|
|
@@ -561,7 +597,6 @@ function turriExtension(api, session, link) {
|
|
|
561
597
|
act: (task) => {
|
|
562
598
|
void pi.sendMessage({ customType: "turri_notice_answer", content: task, display: false }, { triggerTurn: true, deliverAs: "followUp" });
|
|
563
599
|
},
|
|
564
|
-
jobsChanged: () => panel.refresh(),
|
|
565
600
|
thinkingLevel: () => pi.getThinkingLevel(),
|
|
566
601
|
context: contextNow,
|
|
567
602
|
});
|
|
@@ -613,7 +648,8 @@ function turriExtension(api, session, link) {
|
|
|
613
648
|
systemPrompt: conversationSystemPrompt(event.systemPrompt, host, [
|
|
614
649
|
TOOLS_NOT_CLI,
|
|
615
650
|
NEW_PROJECT,
|
|
616
|
-
|
|
651
|
+
CAPTURE_HINT,
|
|
652
|
+
pulseEndsBlock(session.sentinelOn(), session.terminal),
|
|
617
653
|
// Conformance tests - what they are, whether they are on here, and how they are turned on: every turn, read afresh.
|
|
618
654
|
conformanceBlock(conformanceTestsOnIn(cwd)),
|
|
619
655
|
projectConfigBlock(cwd),
|
|
@@ -705,31 +741,9 @@ function turriExtension(api, session, link) {
|
|
|
705
741
|
};
|
|
706
742
|
pi.on("agent_end", endTurnCapture);
|
|
707
743
|
pi.on("agent_settled", endTurnCapture);
|
|
708
|
-
pi.on("session_start", (_event, ctx) => {
|
|
709
|
-
if (!ctx.hasUI)
|
|
710
|
-
return;
|
|
711
|
-
panel.attach({
|
|
712
|
-
setWidget: (key, content, options) => {
|
|
713
|
-
try {
|
|
714
|
-
ctx.ui.setWidget(key, content, options);
|
|
715
|
-
}
|
|
716
|
-
catch {
|
|
717
|
-
/* rebuilt by pi since: its new extension draws the panel */
|
|
718
|
-
}
|
|
719
|
-
},
|
|
720
|
-
getToolsExpanded: () => {
|
|
721
|
-
try {
|
|
722
|
-
return ctx.ui.getToolsExpanded();
|
|
723
|
-
}
|
|
724
|
-
catch {
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
744
|
registerBranding(pi, discoveredSkills);
|
|
731
745
|
registerInterviewLog(pi);
|
|
732
|
-
registerJobTools(pi,
|
|
746
|
+
registerJobTools(pi, session);
|
|
733
747
|
// The skills the person starts themselves - a project's, marked command-only: each has its command, and cultivate starts it only
|
|
734
748
|
// once its command is typed, or picked among the options the conversation offers with ask_user.
|
|
735
749
|
const gate = createCommandGate();
|
|
@@ -745,7 +759,6 @@ function turriExtension(api, session, link) {
|
|
|
745
759
|
registerDrift(pi, cwd, jobs);
|
|
746
760
|
registerBind(pi, cwd, jobs, (plainFile) => turnOnConformance(session, plainFile));
|
|
747
761
|
registerLaunch(pi, cwd, jobs);
|
|
748
|
-
registerSteering(pi, cwd);
|
|
749
762
|
registerSideQuestions(pi, cwd, jobs);
|
|
750
763
|
// More chats beside this one, in the terminal: /chat, alt+n, alt+1…9 (chat-commands.ts).
|
|
751
764
|
if (session.terminal)
|
|
@@ -769,23 +782,60 @@ function turriExtension(api, session, link) {
|
|
|
769
782
|
// A skill that runs in the background: started, and the turn goes on; its end comes back to this chat once it is idle.
|
|
770
783
|
const skillRunEnds = skillRunDelivery(pi, link, contextNow);
|
|
771
784
|
pi.on("session_shutdown", (event) => {
|
|
772
|
-
if (event.reason
|
|
773
|
-
|
|
774
|
-
|
|
785
|
+
if (event.reason !== "quit")
|
|
786
|
+
return;
|
|
787
|
+
for (const waiting of backgroundSkillQueue.values())
|
|
788
|
+
for (const run of waiting.splice(0))
|
|
789
|
+
run.drop();
|
|
790
|
+
for (const controller of backgroundSkillRuns.values())
|
|
791
|
+
controller.abort();
|
|
775
792
|
});
|
|
793
|
+
// An existing codebase captured into ***plain, in the background: the person starts it, never the chat's agent.
|
|
794
|
+
registerCapture(pi, cwd, skillRunEnds);
|
|
776
795
|
const startInBackground = (skill, params, plainFile, ctx) => {
|
|
777
796
|
const key = `${cwd}\0${skill.name}`;
|
|
797
|
+
const kind = scriptKindOfSkill(skill.name);
|
|
798
|
+
const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
|
|
778
799
|
if (backgroundSkillRuns.has(key)) {
|
|
779
|
-
|
|
800
|
+
const waiting = backgroundSkillQueue.get(key) ?? [];
|
|
801
|
+
const runningFor = backgroundSkillFor.get(key);
|
|
802
|
+
// Another module's run waits its turn - its testing script counted as being written from now, so the modules that
|
|
803
|
+
// need it wait for it rather than start with another's. The same module's, or one for none, is the run under way.
|
|
804
|
+
if (plainFile === undefined || runningFor === undefined || runningFor === plainFile || waiting.some((run) => run.plainFile === plainFile)) {
|
|
805
|
+
return { text: `${skill.name} is running in the background already; what it does comes back to this chat when it ends. Nothing new was started.`, details: { background: true, started: false } };
|
|
806
|
+
}
|
|
807
|
+
const configModule = configModuleFor(plainFile);
|
|
808
|
+
const held = kind !== undefined ? writingScript({ project: projectDirOf(plainFile), kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
809
|
+
waiting.push({
|
|
810
|
+
plainFile,
|
|
811
|
+
// Started before the hold is let go: the module is never seen with no script being written in between.
|
|
812
|
+
start: () => {
|
|
813
|
+
try {
|
|
814
|
+
startInBackground(skill, params, plainFile, ctx);
|
|
815
|
+
}
|
|
816
|
+
catch (error) {
|
|
817
|
+
const why = `did not start: ${error instanceof Error ? error.message : String(error)}`;
|
|
818
|
+
skillRunEnds.put({ skill: skill.name, ok: false, line: `${skill.name} ${why}.`, task: failedTask(skill.name, why, undefined, kind), ...runDetails(kind, shown) });
|
|
819
|
+
}
|
|
820
|
+
finally {
|
|
821
|
+
held();
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
drop: held,
|
|
825
|
+
});
|
|
826
|
+
backgroundSkillQueue.set(key, waiting);
|
|
827
|
+
return {
|
|
828
|
+
text: `${skill.name} is running in the background for ${relative(cwd, runningFor) || basename(runningFor)}; the run for ${shown} starts once it ends, and what it does comes back to this chat then.${kind !== undefined ? ` Until it has written its ${kind === "unit" ? "unit testing script" : "conformance testing script"}, the modules that need it wait for it.` : ""} Do not start it again.`,
|
|
829
|
+
details: { background: true, ...runDetails(kind, shown) },
|
|
830
|
+
};
|
|
780
831
|
}
|
|
781
832
|
const model = skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx);
|
|
782
833
|
const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
|
|
783
|
-
const kind = scriptKindOfSkill(skill.name);
|
|
784
|
-
const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
|
|
785
834
|
// While it writes a testing script, the modules that need it wait for it rather than fail for want of it.
|
|
786
835
|
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
787
836
|
const controller = new AbortController();
|
|
788
837
|
backgroundSkillRuns.set(key, controller);
|
|
838
|
+
backgroundSkillFor.set(key, plainFile);
|
|
789
839
|
const context = [
|
|
790
840
|
conversationContext(ctx, params.context),
|
|
791
841
|
shown !== undefined ? `It is for ${shown}${configModule !== undefined ? `, built with ${moduleConfigFile(configModule)} over ${CONFIG_FILE}` : ""}.` : undefined,
|
|
@@ -829,6 +879,9 @@ function turriExtension(api, session, link) {
|
|
|
829
879
|
})
|
|
830
880
|
.finally(() => {
|
|
831
881
|
backgroundSkillRuns.delete(key);
|
|
882
|
+
backgroundSkillFor.delete(key);
|
|
883
|
+
// The next module's run, waiting its turn, starts before this one's hold is let go.
|
|
884
|
+
backgroundSkillQueue.get(key)?.shift()?.start();
|
|
832
885
|
written();
|
|
833
886
|
});
|
|
834
887
|
return {
|
|
@@ -1156,10 +1209,9 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1156
1209
|
wait: (ctx, asked) => shouldWait(ctx.mode, asked),
|
|
1157
1210
|
}));
|
|
1158
1211
|
// /regenerate: the same as the tool, from the person - a module brought up to its spec as it is now, cut into pulses
|
|
1159
|
-
// by the planner: one functional spec at a time, a few together or the whole module in one, as it judges.
|
|
1160
|
-
// follows the module is guidance for that plan, in the person's words.
|
|
1212
|
+
// by the planner: one functional spec at a time, a few together or the whole module in one, as it judges.
|
|
1161
1213
|
pi.registerCommand("regenerate", {
|
|
1162
|
-
description: "Regenerate a module from its ***plain as it is now, in pulses the planner cuts - named functional specs though they did not change, or all of it from scratch, its whole chain too when asked: /regenerate [module | file.plain] [module:func-id ...] [from scratch [whole chain]]
|
|
1214
|
+
description: "Regenerate a module from its ***plain as it is now, in pulses the planner cuts - named functional specs though they did not change, or all of it from scratch, its whole chain too when asked: /regenerate [module | file.plain] [module:func-id ...] [from scratch [whole chain]]",
|
|
1163
1215
|
handler: async (args, ctx) => {
|
|
1164
1216
|
const command = `/regenerate ${args.trim()}`.trim();
|
|
1165
1217
|
await echoCommand(pi, command);
|
|
@@ -1168,21 +1220,26 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1168
1220
|
if (picked === undefined)
|
|
1169
1221
|
return;
|
|
1170
1222
|
const { plainFile } = picked;
|
|
1171
|
-
// Functional specs named first, each as module:func-id, as on the command line
|
|
1172
|
-
const { funcIds: again, rest
|
|
1173
|
-
const
|
|
1223
|
+
// Functional specs named first, each as module:func-id, as on the command line.
|
|
1224
|
+
const { funcIds: again, rest } = funcIdsNamedFirst(picked.rest);
|
|
1225
|
+
const words = rest.join(" ").trim();
|
|
1174
1226
|
// From scratch - started over, its code deleted - asked in the person's words: started at once, as asked.
|
|
1175
|
-
const scratch = asksFromScratch(
|
|
1227
|
+
const scratch = asksFromScratch(words);
|
|
1176
1228
|
// The whole chain with it - "from scratch, the whole chain" - every module it requires built again from the bottom.
|
|
1177
|
-
const chain = scratch && asksWholeChain(
|
|
1229
|
+
const chain = scratch && asksWholeChain(words);
|
|
1178
1230
|
const module = basename(plainFile).replace(/\.plain$/, "");
|
|
1231
|
+
// Nothing but the functional specs and from scratch: the planner cuts the work as it judges, so other words are not dropped unsaid.
|
|
1232
|
+
if (words !== "" && !scratch) {
|
|
1233
|
+
say(`/regenerate takes functional specs, each as module:func-id, and "from scratch" with "whole chain" - not "${words}". Nothing was started.`, "warning");
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1179
1236
|
if (scratch && again.length > 0) {
|
|
1180
1237
|
say("Name functional specs or ask for it from scratch, not both: from scratch regenerates every one of them.", "warning");
|
|
1181
1238
|
return;
|
|
1182
1239
|
}
|
|
1183
1240
|
const loop = workLoopFor(jobs, cwd, ctx);
|
|
1184
1241
|
const model = jobModel(ctx, undefined, plainFile);
|
|
1185
|
-
const request = { ...(model !== undefined ? { model } : {})
|
|
1242
|
+
const request = { ...(model !== undefined ? { model } : {}) };
|
|
1186
1243
|
// Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
|
|
1187
1244
|
// began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
|
|
1188
1245
|
say(scratch
|
|
@@ -1403,7 +1460,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
|
|
|
1403
1460
|
const separately = asksOneByOne(words);
|
|
1404
1461
|
// From scratch - the tests written again, the code untouched - asked in the person's words; the whole chain's with it.
|
|
1405
1462
|
const scratch = asksFromScratch(words) ? (asksWholeChain(words) ? "chain" : "module") : undefined;
|
|
1406
|
-
// Nothing but the functional specs, from scratch and one by one:
|
|
1463
|
+
// Nothing but the functional specs, from scratch and one by one: other words are not dropped unsaid.
|
|
1407
1464
|
if (words !== "" && !separately && scratch === undefined) {
|
|
1408
1465
|
refuse(`/conform takes functional specs, each as module:func-id, "from scratch" with "whole chain" and "one by one" - not "${words}". Nothing was started.`);
|
|
1409
1466
|
return;
|
|
@@ -1796,6 +1853,10 @@ export function turnOnConformance(core, plainFile) {
|
|
|
1796
1853
|
}
|
|
1797
1854
|
/** The skills running in the background, by project and skill - one at a time each, whichever chat started it - with what stops them. */
|
|
1798
1855
|
const backgroundSkillRuns = new Map();
|
|
1856
|
+
/** The .plain file each run in `backgroundSkillRuns` is for. */
|
|
1857
|
+
const backgroundSkillFor = new Map();
|
|
1858
|
+
/** The runs for other modules waiting their turn, by project and skill: each started as the one before it ends, or dropped as turri quits. */
|
|
1859
|
+
const backgroundSkillQueue = new Map();
|
|
1799
1860
|
/**
|
|
1800
1861
|
* The model a pulse's agents run on: the one named on the call, checked now so a wrong name fails here and not minutes
|
|
1801
1862
|
* later in the background; else the coding model - `--coding-model`, or the module's config - else the conversation's.
|
|
@@ -1860,8 +1921,6 @@ function projectModel(ctx, plainFile) {
|
|
|
1860
1921
|
*/
|
|
1861
1922
|
/** The one work loop of a conversation's jobs: every tool that builds brings its modules up through it. */
|
|
1862
1923
|
const workLoops = new WeakMap();
|
|
1863
|
-
/** How the conversation wants the work planned, for the session - set with steer. */
|
|
1864
|
-
const steeringStore = createSteeringStore();
|
|
1865
1924
|
/** A session's launches, by its jobs: the launch track every chat's launch tool and every pulse's launch share. */
|
|
1866
1925
|
const sessionLaunches = new WeakMap();
|
|
1867
1926
|
function workLoopFor(jobs, cwd, ctx) {
|
|
@@ -1874,8 +1933,6 @@ function workLoopFor(jobs, cwd, ctx) {
|
|
|
1874
1933
|
modelFor: (plainFile) => projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx),
|
|
1875
1934
|
// The planner reasons about the whole of the work: it runs on the chat's model.
|
|
1876
1935
|
plannerModel: () => chatModelOf(from.ctx),
|
|
1877
|
-
// How the work is to be planned: the conversation's steering, and AGENTS.md's - read afresh each plan.
|
|
1878
|
-
steering: (plainFile) => steeringFor(plainFile, cwd, steeringStore),
|
|
1879
1936
|
// A pulse landed: its commit kept for the sentinel - and, under launch-after-pulse, launched in the background, the
|
|
1880
1937
|
// codebase's next pulse not waiting on it.
|
|
1881
1938
|
landed: (input) => sessionLaunches.get(jobs)?.landed(input),
|
|
@@ -1946,7 +2003,8 @@ const needsLooking = new WeakMap();
|
|
|
1946
2003
|
/** What heads a pulse told from the ledger: it is not this session's, and the facts are all there is of it. */
|
|
1947
2004
|
const pastPulseNote = "A pulse of an earlier session, as the ledger recorded it - facts, not its transcript. Its whole log is the file it names, " +
|
|
1948
2005
|
"for the read tool.";
|
|
1949
|
-
function registerJobTools(pi,
|
|
2006
|
+
function registerJobTools(pi, session) {
|
|
2007
|
+
const { jobs, cwd } = session;
|
|
1950
2008
|
pi.registerTool(doctorTool({ cwd }));
|
|
1951
2009
|
pi.registerTool({
|
|
1952
2010
|
name: "pulses",
|
|
@@ -1960,14 +2018,14 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1960
2018
|
"the last failing test run with its output, the last review that sent the work back, the tool calls that failed, and where " +
|
|
1961
2019
|
"the whole log is; of an earlier session, told from the ledger; planned (planned-<module>-N), its cases and - the next pulse " +
|
|
1962
2020
|
"of its codebase - the whole prompt its coding agent will get, from the plan regenerate runs. With plain_file, a look " +
|
|
1963
|
-
"ahead: that module's work planned as regenerate plans it,
|
|
1964
|
-
"for regenerate, which then runs this plan unless the ***plain
|
|
2021
|
+
"ahead: that module's work planned as regenerate plans it, and kept - nothing started, its pulses waiting " +
|
|
2022
|
+
"for regenerate, which then runs this plan unless the ***plain changed - and what is planned listed. " +
|
|
1965
2023
|
"What is left to regenerate, without a plan, is drift's. Every generation of a module's code and tests is a commit in its " +
|
|
1966
2024
|
"history, read with git: git --git-dir=plain_modules/<module>/.plaingit log, and show <commit>.",
|
|
1967
2025
|
promptSnippet: "pulses: every pulse or one - earlier, running or planned - why one did not land, and with plain_file what will run next and its prompt",
|
|
1968
2026
|
promptGuidelines: [
|
|
1969
2027
|
"When a pulse failed or did not land, call pulses with its id before you explain it or change the spec: go by what happened, not by the report alone.",
|
|
1970
|
-
"Call pulses with plain_file when the user wants to see or check what will run before it does, then with a planned row's id for its prompt. To change the plan,
|
|
2028
|
+
"Call pulses with plain_file when the user wants to see or check what will run before it does, then with a planned row's id for its prompt. To change the plan, change the ***plain, then look again.",
|
|
1971
2029
|
],
|
|
1972
2030
|
parameters: Type.Object({
|
|
1973
2031
|
job_id: Type.Optional(Type.String({
|
|
@@ -2027,8 +2085,6 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2027
2085
|
return { content: [{ type: "text", text }], details: { status: job.status } };
|
|
2028
2086
|
},
|
|
2029
2087
|
});
|
|
2030
|
-
// The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
|
|
2031
|
-
// list, finished jobs included, put in the transcript where it stays.
|
|
2032
2088
|
pi.registerCommand("halt", {
|
|
2033
2089
|
description: "Halt a queued or running pulse, a module's planned pulses, a launch, or what a launch started: /halt [pulse id | module | launched <name | module>]",
|
|
2034
2090
|
handler: async (args, ctx) => {
|
|
@@ -2106,8 +2162,14 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2106
2162
|
// While the panel has the keys, every key is its own.
|
|
2107
2163
|
// The side panel is the session's, one for every chat: it stays on the screen - beside the chat or over it - as
|
|
2108
2164
|
// another chat is shown, and what it says to a chat it says to the one shown.
|
|
2109
|
-
const sidePanel = sidePanelOf(
|
|
2165
|
+
const sidePanel = sidePanelOf(session);
|
|
2110
2166
|
const openPanel = sidePanel.open;
|
|
2167
|
+
if (session.terminal)
|
|
2168
|
+
pi.registerCommand("notifications", {
|
|
2169
|
+
description: "Open the side panel on finished pulses and sentinel notices",
|
|
2170
|
+
handler: async (_args, ctx) => { if (ctx.hasUI)
|
|
2171
|
+
openPanel(ctx, "notifications", "beside"); },
|
|
2172
|
+
});
|
|
2111
2173
|
pi.on("session_start", () => {
|
|
2112
2174
|
sidePanel.say = (text) => pi.sendUserMessage(text, { deliverAs: "followUp" });
|
|
2113
2175
|
});
|
|
@@ -2194,6 +2256,8 @@ export function pulseEndNote(job, options = {}) {
|
|
|
2194
2256
|
: job.status === "stopped"
|
|
2195
2257
|
? `Pulse ${job.id} (${job.kind}) was stopped after ${formatDuration(job)}. ${job.error ?? STOPPED_ON_REQUEST}${job.error === undefined || job.error === STOPPED_ON_REQUEST ? " The person stopped it; what it was building counts as not built." : ""}`
|
|
2196
2258
|
: `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
|
|
2259
|
+
if (options.quiet)
|
|
2260
|
+
return `${head}\n\nThis result is in notifications. It needs no announcement in the chat.`;
|
|
2197
2261
|
const landed = job.status === "succeeded" && job.details?.landed === true;
|
|
2198
2262
|
if (!landed || options.launching !== true)
|
|
2199
2263
|
return `${head}\n\n${JOB_FINISHED_REACTION}`;
|
|
@@ -2241,12 +2305,15 @@ export const JOB_FINISHED_REACTION = [
|
|
|
2241
2305
|
].join("\n");
|
|
2242
2306
|
const sidePanels = new WeakMap();
|
|
2243
2307
|
/** The side panel of the session these jobs are, made as a chat first asks for it. */
|
|
2244
|
-
function sidePanelOf(
|
|
2308
|
+
function sidePanelOf(session) {
|
|
2309
|
+
const { jobs, cwd } = session;
|
|
2245
2310
|
const known = sidePanels.get(jobs);
|
|
2246
2311
|
if (known !== undefined)
|
|
2247
2312
|
return known;
|
|
2248
2313
|
const self = {
|
|
2249
|
-
open: (ctx, view) => openPanel(ctx, view),
|
|
2314
|
+
open: (ctx, view, placement) => openPanel(ctx, view, placement),
|
|
2315
|
+
visible: () => panel !== undefined && panel.handle?.isHidden() !== true,
|
|
2316
|
+
close: () => panel?.close(),
|
|
2250
2317
|
shown: () => panel !== undefined && panel.keys,
|
|
2251
2318
|
};
|
|
2252
2319
|
sidePanels.set(jobs, self);
|
|
@@ -2284,9 +2351,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2284
2351
|
plan: () => workLoops.get(jobs)?.loop.mapPlan() ?? { files: [], codebases: [] },
|
|
2285
2352
|
});
|
|
2286
2353
|
/** Open the side panel - on the view named, or as it was left. */
|
|
2287
|
-
const openPanel = (ctx, view) => {
|
|
2288
|
-
// Found: ctrl+h under the job panel stops breathing.
|
|
2289
|
-
keyPressed("peek");
|
|
2354
|
+
const openPanel = (ctx, view, placement) => {
|
|
2290
2355
|
if (view !== undefined)
|
|
2291
2356
|
mapState.view = view;
|
|
2292
2357
|
// A pulse that failed or stopped since the panel was last opened: opened as it is, it is on that pulse - what went
|
|
@@ -2297,7 +2362,10 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2297
2362
|
mapState.view = "pulses";
|
|
2298
2363
|
}
|
|
2299
2364
|
needsLooking.delete(jobs);
|
|
2365
|
+
if (placement === "beside")
|
|
2366
|
+
panelDocked = true;
|
|
2300
2367
|
if (panel !== undefined) {
|
|
2368
|
+
panel.layOut();
|
|
2301
2369
|
panel.keepChatFocus();
|
|
2302
2370
|
panel.handle?.setHidden(false);
|
|
2303
2371
|
panel.keys = true;
|
|
@@ -2366,6 +2434,9 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2366
2434
|
// Opened, it reads the files again at once: they may have changed while it was closed.
|
|
2367
2435
|
specMap.refresh();
|
|
2368
2436
|
const view = createSidePanel({
|
|
2437
|
+
...(session.terminal ? { notifications: notificationView(session, { accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text) }, back) } : {}),
|
|
2438
|
+
pointer: terminalPointer(tui.terminal),
|
|
2439
|
+
tabLabel: (text, active, hovered, role) => buttonLabel(theme, text, active, hovered, role),
|
|
2369
2440
|
jobs: () => shownJobs(jobs),
|
|
2370
2441
|
earlier: earlierJobs,
|
|
2371
2442
|
tree: jobsTree,
|
|
@@ -2411,7 +2482,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2411
2482
|
return focused !== null && focused !== component;
|
|
2412
2483
|
},
|
|
2413
2484
|
});
|
|
2414
|
-
const entry = { view, close, keepChatFocus, keys: true };
|
|
2485
|
+
const entry = { view, close, keepChatFocus, layOut, keys: true };
|
|
2415
2486
|
panel = entry;
|
|
2416
2487
|
layOut();
|
|
2417
2488
|
// Every key goes to the panel while it shows, whatever has the focus: a question the chat model asks in the
|
|
@@ -2489,7 +2560,7 @@ function sidePanelOf(jobs, cwd) {
|
|
|
2489
2560
|
view.handleInput(data);
|
|
2490
2561
|
tui.requestRender();
|
|
2491
2562
|
},
|
|
2492
|
-
handleMouse: (event) => view.handleMouse(event),
|
|
2563
|
+
handleMouse: (event) => view.handleMouse(panelBeside() > 0 ? { ...event, x: event.x - 2, width: event.width - 2 } : event),
|
|
2493
2564
|
invalidate: () => view.invalidate(),
|
|
2494
2565
|
dispose: () => {
|
|
2495
2566
|
unlisten();
|
|
@@ -2574,7 +2645,7 @@ function describeLookAhead(loop, statuses) {
|
|
|
2574
2645
|
const listed = rows.length > 0 ? `\n\nThe planned pulses - pulses with a row's id tells its cases and, for the next pulse of a codebase, the whole prompt its coding agent will get:\n${rows.map((row) => `${row.id} ${row.summary}`).join("\n")}` : "";
|
|
2575
2646
|
return (`${describeModules(statuses)}${listed}\n\n` +
|
|
2576
2647
|
"Nothing was started. What is planned here waits for regenerate, conform or /regenerate, which runs this plan as it is - unless " +
|
|
2577
|
-
"the ***plain
|
|
2648
|
+
"the ***plain changes first, when it is planned again. To change the plan, change the ***plain, then " +
|
|
2578
2649
|
"look again. Tell the user what will run and in what order - the parts they are likely to care about.");
|
|
2579
2650
|
}
|
|
2580
2651
|
/** A planned row, for the chat: what it is, and its prompt when it is the next pulse of its codebase. */
|
|
@@ -2615,67 +2686,120 @@ function registerCheckPlain(pi, cwd, dialogs, afterAnswer) {
|
|
|
2615
2686
|
for (const tool of createWebTools())
|
|
2616
2687
|
pi.registerTool(tool);
|
|
2617
2688
|
}
|
|
2689
|
+
const SIDE_ENTRY = "turri_btw";
|
|
2690
|
+
/** A message the person sent while a skill ran in the chat, read by the skill's agent: drawn as the message it is. */
|
|
2691
|
+
const SKILL_MESSAGE_ENTRY = "turri_skill_message";
|
|
2692
|
+
/** The capture's lines above the input while it runs. */
|
|
2693
|
+
const CAPTURE_WIDGET = "turri-capture";
|
|
2618
2694
|
/**
|
|
2619
|
-
*
|
|
2620
|
-
*
|
|
2621
|
-
*
|
|
2695
|
+
* /capture [path]: the codebase at path - the chat's folder by default - captured into ***plain in <path>/plain, in the
|
|
2696
|
+
* background and offline (docs/capture.md). A command alone: capture turns conformance tests on in the project it writes,
|
|
2697
|
+
* which the person alone does. One at a time; its end comes back to this chat as a background skill's does, its report
|
|
2698
|
+
* for the chat's agent to pass on.
|
|
2622
2699
|
*/
|
|
2623
|
-
function
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
const
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2700
|
+
function registerCapture(pi, cwd, ends) {
|
|
2701
|
+
let running;
|
|
2702
|
+
pi.on("session_shutdown", (event) => {
|
|
2703
|
+
if (event.reason === "quit")
|
|
2704
|
+
running?.controller.abort();
|
|
2705
|
+
});
|
|
2706
|
+
// turri opened again here, in the project a capture wrote: its report told in the first chat, once.
|
|
2707
|
+
pi.on("session_start", () => {
|
|
2708
|
+
const told = readReopenedAfterCapture(process.env[REOPENED_AFTER_CAPTURE]);
|
|
2709
|
+
delete process.env[REOPENED_AFTER_CAPTURE];
|
|
2710
|
+
if (told !== undefined)
|
|
2711
|
+
ends.put(captureEnded(cwd, { plainDir: cwd, reportFile: captureReportFile(cwd), summary: told.summary }));
|
|
2712
|
+
});
|
|
2713
|
+
pi.registerCommand("capture", {
|
|
2714
|
+
description: "Capture an existing codebase into ***plain, in the background - nothing is asked, and its report comes back here; a stopped one goes on: /capture [path] (this folder by default - the ***plain goes into <path>/plain)",
|
|
2715
|
+
handler: async (args, ctx) => {
|
|
2716
|
+
const command = `/capture ${args.trim()}`.trim();
|
|
2717
|
+
await echoCommand(pi, command);
|
|
2718
|
+
const refuse = (text) => shownAfterCommand(pi, ctx, command, text, "error", true);
|
|
2719
|
+
if (running !== undefined)
|
|
2720
|
+
return refuse(`A capture of ${running.root} is running already: its report comes back here when it ends. Nothing new was started.`);
|
|
2721
|
+
const root = resolve(cwd, args.trim() || ".");
|
|
2722
|
+
const refusal = captureRefusal(root);
|
|
2723
|
+
if (refusal !== undefined)
|
|
2724
|
+
return refuse(refusal);
|
|
2725
|
+
const controller = new AbortController();
|
|
2726
|
+
running = { root, controller };
|
|
2727
|
+
const model = conversationModel(ctx);
|
|
2728
|
+
shownAfterCommand(pi, ctx, command, captureStartedText(root, captureGoesOn(root)), "info", true);
|
|
2729
|
+
// Above the input while it runs: where it is, each agent at work and what it did last - a capture at work
|
|
2730
|
+
// is told from one that hangs.
|
|
2731
|
+
let status;
|
|
2732
|
+
let redrawNow;
|
|
2733
|
+
if (ctx.hasUI) {
|
|
2734
|
+
ctx.ui.setWidget(CAPTURE_WIDGET, (tui, theme) => {
|
|
2735
|
+
// The spinner and the clocks move.
|
|
2736
|
+
const redraw = setInterval(() => tui.requestRender(), 1000);
|
|
2737
|
+
redraw.unref?.();
|
|
2738
|
+
redrawNow = () => tui.requestRender();
|
|
2739
|
+
const style = {
|
|
2740
|
+
heading: (text) => theme.bold(theme.fg("accent", text)),
|
|
2741
|
+
done: (text) => theme.fg("success", text),
|
|
2742
|
+
now: (text) => theme.bold(theme.fg("accent", text)),
|
|
2743
|
+
muted: (text) => theme.fg("muted", text),
|
|
2744
|
+
};
|
|
2745
|
+
return {
|
|
2746
|
+
render: (width) => (status === undefined ? [] : captureStatusLines(status, { frame: spinner(Date.now()), now: Date.now(), width }, style)),
|
|
2747
|
+
invalidate: () => { },
|
|
2748
|
+
dispose: () => {
|
|
2749
|
+
clearInterval(redraw);
|
|
2750
|
+
redrawNow = undefined;
|
|
2751
|
+
},
|
|
2752
|
+
};
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
const watch = (next) => {
|
|
2756
|
+
status = next;
|
|
2757
|
+
redrawNow?.();
|
|
2758
|
+
};
|
|
2759
|
+
// The captured project starts as the config in use here, with the chat's model and thinking of the moment, and the
|
|
2760
|
+
// coding model turri was started with, where it says otherwise.
|
|
2761
|
+
const codingModel = process.env[CODING_MODEL_ENV];
|
|
2762
|
+
const configured = {
|
|
2763
|
+
configFrom: cwd,
|
|
2764
|
+
...(model !== undefined ? { model, harnessModel: `${model}:${pi.getThinkingLevel()}` } : {}),
|
|
2765
|
+
...(codingModel !== undefined && codingModel !== "" ? { codingModel } : {}),
|
|
2672
2766
|
};
|
|
2767
|
+
void captureConsole(() => runCapture({ root, signal: controller.signal, watch, ...configured }))
|
|
2768
|
+
.then(async ({ result }) => {
|
|
2769
|
+
if (ctx.hasUI)
|
|
2770
|
+
ctx.ui.setWidget(CAPTURE_WIDGET, undefined);
|
|
2771
|
+
// A chat works on the project of its own folder, and the capture wrote one of its own: turri in a terminal
|
|
2772
|
+
// can open again there, on the chat's model, the report told there.
|
|
2773
|
+
if (ctx.hasUI && canReopen()) {
|
|
2774
|
+
const question = captureOpenQuestion(cwd, result);
|
|
2775
|
+
const chatModel = conversationModel(ctx);
|
|
2776
|
+
const codingModel = process.env[CODING_MODEL_ENV];
|
|
2777
|
+
const args = [
|
|
2778
|
+
...(chatModel !== undefined ? ["--model", chatModel] : []),
|
|
2779
|
+
"--thinking",
|
|
2780
|
+
pi.getThinkingLevel(),
|
|
2781
|
+
...(codingModel !== undefined && codingModel !== "" ? ["--coding-model", codingModel] : []),
|
|
2782
|
+
];
|
|
2783
|
+
if ((await ctx.ui.confirm(question.title, question.message)) && reopenIn(result.plainDir, { args, env: { [REOPENED_AFTER_CAPTURE]: reopenedAfterCapture(result.summary) } })) {
|
|
2784
|
+
ctx.shutdown();
|
|
2785
|
+
return;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
ends.put(captureEnded(cwd, result));
|
|
2789
|
+
})
|
|
2790
|
+
.catch((error) => {
|
|
2791
|
+
// Stopped as turri quits: nobody is left to tell.
|
|
2792
|
+
if (!controller.signal.aborted)
|
|
2793
|
+
ends.put(captureFailed(error));
|
|
2794
|
+
})
|
|
2795
|
+
.finally(() => {
|
|
2796
|
+
running = undefined;
|
|
2797
|
+
if (ctx.hasUI)
|
|
2798
|
+
ctx.ui.setWidget(CAPTURE_WIDGET, undefined);
|
|
2799
|
+
});
|
|
2673
2800
|
},
|
|
2674
2801
|
});
|
|
2675
2802
|
}
|
|
2676
|
-
const SIDE_ENTRY = "turri_btw";
|
|
2677
|
-
/** A message the person sent while a skill ran in the chat, read by the skill's agent: drawn as the message it is. */
|
|
2678
|
-
const SKILL_MESSAGE_ENTRY = "turri_skill_message";
|
|
2679
2803
|
/**
|
|
2680
2804
|
* /btw, a question on the side (btw.ts): answered at once, even while a skill runs - pi runs a command mid-turn - and
|
|
2681
2805
|
* shown in the transcript, never in a model's context.
|
|
@@ -2996,8 +3120,8 @@ function registerBranding(pi, skills) {
|
|
|
2996
3120
|
(data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
|
|
2997
3121
|
// A newer turri out, or one installed and hidden behind this one: said first, under the version it is about.
|
|
2998
3122
|
...(data.versions ?? []).map((line) => theme.fg("warning", line)),
|
|
2999
|
-
// A key renamed is information; the rest are the person's to take out.
|
|
3000
|
-
...(data.config ?? []).map((line) => theme.fg(line.kind === "renamed" ? "muted" : "warning", line.text)),
|
|
3123
|
+
// A key renamed is information; one that does not parse stops everything that reads it; the rest are the person's to take out.
|
|
3124
|
+
...(data.config ?? []).map((line) => theme.fg(line.kind === "renamed" ? "muted" : line.kind === "broken" ? "error" : "warning", line.text)),
|
|
3001
3125
|
`${theme.fg("text", "the first coding agent with the power of ")}${brandPink(theme)("regenerative software")}`,
|
|
3002
3126
|
// Where the settings are changed, without leaving the chat.
|
|
3003
3127
|
theme.fg("muted", "configure with /settings"),
|
|
@@ -3023,6 +3147,8 @@ function registerBranding(pi, skills) {
|
|
|
3023
3147
|
if (ctx.hasUI) {
|
|
3024
3148
|
padTheScreen(ctx);
|
|
3025
3149
|
animateJellyfish(ctx);
|
|
3150
|
+
// ***plain an agent shows in the chat, highlighted in the theme of the moment.
|
|
3151
|
+
highlightPlainCodeBlocks(() => ctx.ui.theme);
|
|
3026
3152
|
}
|
|
3027
3153
|
// Once a chat: it starts again each time it is shown.
|
|
3028
3154
|
if (bannered)
|