@turri-dev/cli 0.2.4-next.240620d → 0.2.4-next.359b847
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/dist/bedrock-region.js +3 -3
- 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 -10
- package/dist/chats.js +125 -41
- package/dist/cli.js +10 -26
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +32 -24
- package/dist/config.d.ts +101 -58
- package/dist/config.js +265 -118
- package/dist/conform-cli.js +14 -3
- package/dist/conformance-switch.d.ts +7 -6
- package/dist/conformance-switch.js +19 -16
- package/dist/extension.d.ts +29 -3
- package/dist/extension.js +375 -351
- package/dist/genome.js +5 -1
- package/dist/host-session.d.ts +8 -7
- package/dist/host-session.js +4 -4
- package/dist/host.d.ts +3 -1
- package/dist/host.js +3 -3
- package/dist/identity.js +2 -2
- package/dist/init-config.d.ts +1 -1
- package/dist/init-config.js +8 -8
- 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.js +4 -4
- package/dist/loop-tools.d.ts +45 -21
- package/dist/loop-tools.js +152 -82
- package/dist/notice.d.ts +7 -6
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +3 -0
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +6 -3
- package/dist/plain/check.d.ts +1 -1
- package/dist/plain/check.js +3 -1
- package/dist/plain-files.d.ts +2 -2
- package/dist/plain-files.js +7 -7
- 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/job-panel.js +3 -1
- package/dist/regenerate/jobs.d.ts +2 -2
- package/dist/regenerate/jobs.js +10 -10
- package/dist/regenerate/launch.d.ts +154 -0
- package/dist/regenerate/{release.js → launch.js} +195 -51
- package/dist/regenerate/ledger.d.ts +33 -2
- package/dist/regenerate/lineage.d.ts +2 -0
- package/dist/regenerate/lineage.js +8 -0
- package/dist/regenerate/loop.d.ts +30 -10
- package/dist/regenerate/loop.js +166 -59
- 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.js +4 -1
- 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/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 +6 -6
- package/dist/regenerate/testing-steps.js +8 -8
- package/dist/regenerate-cli.js +1 -1
- package/dist/self-invocation.d.ts +11 -0
- package/dist/self-invocation.js +36 -7
- 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 +72 -43
- 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/turri-versions.js +2 -1
- package/docs/README.md +4 -4
- package/docs/chats.md +5 -6
- package/docs/claude-subscription.md +2 -2
- package/docs/config.md +58 -46
- package/docs/development.md +2 -2
- package/docs/headless.md +4 -4
- package/docs/hosting.md +20 -19
- package/docs/launch.md +67 -0
- package/docs/parser.md +2 -2
- package/docs/regenerating.md +21 -15
- package/docs/sandbox.md +3 -3
- package/docs/sentinel.md +26 -14
- package/docs/skills-and-gates.md +4 -4
- package/docs/using.md +19 -28
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/turri-regeneration.md +5 -3
- 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/regenerate/engine.d.ts +0 -52
- package/dist/regenerate/release.d.ts +0 -121
- package/dist/release-agent.d.ts +0 -43
- package/dist/release-agent.js +0 -130
- package/dist/release-tools.d.ts +0 -44
- package/dist/release-tools.js +0 -170
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
- package/docs/deploy.md +0 -48
- /package/dist/{release-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/extension.js
CHANGED
|
@@ -9,7 +9,7 @@ import { allocateImageId, Box, getCapabilities, getPngDimensions, isKeyRelease,
|
|
|
9
9
|
import { defineTool, getMarkdownTheme, UserMessageComponent } from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { Type } from "typebox";
|
|
11
11
|
import { CODING_MODEL_ENV } from "./chat-models.js";
|
|
12
|
-
import { AGENT_ROLES,
|
|
12
|
+
import { AGENT_ROLES, CONFIG_FILE, configForSpec, readConfigFile, configModuleFor, hasProjectConfig, LEGACY_CONFIG_FILE, projectConfigFile, moduleConfigFile, moduleConfigFileIn, configModuleOf, moduleConfigsOf, withConfigModule, modelOnly, modelSpec, projectModels, readProjectConfig, roleModel, splitModelSpec, configLines } from "./config.js";
|
|
13
13
|
import { projectDirOf, skillRunDir } from "./regenerate/paths.js";
|
|
14
14
|
import { sweepOrphanedGroups } from "./regenerate/shell.js";
|
|
15
15
|
import { readScript, scriptAgainstMachine, stackOnMachine, toolchainsBlock } from "./stack.js";
|
|
@@ -21,25 +21,26 @@ 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
23
|
import { createAskUserTool } from "./tools.js";
|
|
24
|
-
import { asksFromScratch, asksWholeChain, driftTool, fromWorkingDir, haltTool, loopReply, MODEL_PARAM, regenerateTool,
|
|
24
|
+
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
25
|
import { createWebTools } from "./regenerate/web.js";
|
|
26
26
|
import { describeGates, interruptedRun, runSkill } from "./genome.js";
|
|
27
27
|
import { unqueue } from "./chat-waiting.js";
|
|
28
28
|
import { skillStatus } from "./skill.js";
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
29
|
+
import { runningLaunched, stopLaunched } from "./regenerate/launch.js";
|
|
30
|
+
import { launchTool } from "./launch-tools.js";
|
|
31
|
+
import { createSessionLaunches, launchedDir, launchedNote, replacedNote } from "./launch-session.js";
|
|
32
|
+
import { describeLaunchLine } from "./launch-track.js";
|
|
31
33
|
import { checkedSpecs } from "./sentinel-check.js";
|
|
32
|
-
import { runReleaseAgent } from "./release-agent.js";
|
|
33
34
|
import { createSteeringStore, EVERY_MODULE, moduleNameOf, queueSectionOf, steeringFor } from "./regenerate/steer.js";
|
|
34
35
|
import { askedForCommandLine, refusal, selfInvocation, TOOLS_NOT_CLI } from "./self-invocation.js";
|
|
35
36
|
import { NEW_PROJECT } from "./new-project.js";
|
|
36
|
-
import {
|
|
37
|
+
import { describeResolution, resolveModel } from "./regenerate/model-names.js";
|
|
37
38
|
import { checkPlainFile, formatCheckResults } from "./plain/check.js";
|
|
38
39
|
import { checkPlainTool } from "./parse-tool.js";
|
|
39
40
|
import { changedFiles, projectFiles } from "./plain-files.js";
|
|
40
41
|
import { whyFailed } from "./regenerate/diagnose-job.js";
|
|
41
42
|
import { didNotLand } from "./regenerate/failure-reports.js";
|
|
42
|
-
import { conformanceRefusal, createWorkLoop, describeModules, isUpToDate } from "./regenerate/loop.js";
|
|
43
|
+
import { conformanceRefusal, createWorkLoop, TestingStepsMissing, describeModules, isUpToDate } from "./regenerate/loop.js";
|
|
43
44
|
import { brandNeon, brandPink, plainPaint } from "./regenerate/plain-palette.js";
|
|
44
45
|
import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_REST, JELLYFISH_SEQUENCE, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
|
|
45
46
|
import { createJobPanel, didNotPass, keyPressed, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
|
|
@@ -52,7 +53,7 @@ import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
|
|
|
52
53
|
import { createSpecMapState } from "./regenerate/spec-map-view.js";
|
|
53
54
|
import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
|
|
54
55
|
import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
|
|
55
|
-
import { HISTORY_DIR, historyLog
|
|
56
|
+
import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
|
|
56
57
|
import { defaultBuildDir } from "./regenerate/paths.js";
|
|
57
58
|
import { describeTurnIncident, describeUsage, JobStoppedError, onModelEvent } from "./regenerate/activity.js";
|
|
58
59
|
import { ledgerWanted, startLedger } from "./regenerate/ledger.js";
|
|
@@ -61,15 +62,14 @@ import { doctorTool } from "./doctor-tool.js";
|
|
|
61
62
|
import { describeSpecConflict } from "./regenerate/stop-report.js";
|
|
62
63
|
import { inheritProviders, inheritThinkingLevel } from "./pi.js";
|
|
63
64
|
import { LOADING_PROVIDERS } from "./installed-providers.js";
|
|
64
|
-
import { machineChange, machineChangeReason, writesPlain } from "./regenerate/command-check.js";
|
|
65
|
+
import { machineChange, machineChangeReason, runsBuiltCode, writesPlain } from "./regenerate/command-check.js";
|
|
65
66
|
import { beginCapture, captureConsole, describeCaptured, dropNoise } from "./quiet.js";
|
|
66
67
|
import { loadRules, renderRulesBlock } from "./rules.js";
|
|
67
|
-
import {
|
|
68
|
+
import { registerSettings, ruleNames } from "./settings.js";
|
|
68
69
|
import { writeSetting } from "./config-edit.js";
|
|
69
70
|
import { describeStdlib } from "./stdlib.js";
|
|
70
71
|
import { DECLINED, peekKeyListener, runAsk } from "./ask.js";
|
|
71
72
|
import { QuestionDialog } from "./question-dialog.js";
|
|
72
|
-
import { registerStacks } from "./stacks.js";
|
|
73
73
|
import { catalogueLine, chosenCommand, createCommandGate, startPicked, discoverSkills, leftOutNote, startedByCommandOnly } from "./skills.js";
|
|
74
74
|
import { supersededByTurri } from "./chat-skills.js";
|
|
75
75
|
import { conversationIdentity } from "./identity.js";
|
|
@@ -100,6 +100,15 @@ const PACKAGE_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
|
100
100
|
* exchange is therefore reported back, so the interview is visible while it happens and
|
|
101
101
|
* survives in the tool's result afterwards.
|
|
102
102
|
*/
|
|
103
|
+
/**
|
|
104
|
+
* What a question gets with nobody to answer it - print, json and rpc modes. What is the agent's to decide it decides; the
|
|
105
|
+
* person's own files it leaves as they are, as it would have without their yes - a testing script it finds wrong is said,
|
|
106
|
+
* not rewritten.
|
|
107
|
+
*/
|
|
108
|
+
export const NO_USER_ANSWER = "No user is available to answer. Decide yourself what is yours to decide - the ***plain you were asked to write, a choice the " +
|
|
109
|
+
"***plain leaves open - and say in your report what you assumed. What you asked because it is the person's - their testing " +
|
|
110
|
+
"scripts, their config, any file of theirs you would replace or delete - leave as it is: say what you would change and why, " +
|
|
111
|
+
"and go on without it.";
|
|
103
112
|
export function askUserVia(ctx, onExchange,
|
|
104
113
|
/** Given, "/btw ..." typed as an answer is a side question: answered with this, and the question asked again. */
|
|
105
114
|
aside,
|
|
@@ -107,7 +116,7 @@ aside,
|
|
|
107
116
|
dialogs) {
|
|
108
117
|
return async (request) => {
|
|
109
118
|
if (dialogs === undefined && !ctx.hasUI) {
|
|
110
|
-
return
|
|
119
|
+
return NO_USER_ANSWER;
|
|
111
120
|
}
|
|
112
121
|
// Declined - ctrl+c at it, the host's decline, or the turn that asked it stopped: the dialog open is closed, no other is
|
|
113
122
|
// opened, and it comes back as DECLINED.
|
|
@@ -328,8 +337,27 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
328
337
|
core?.jobFinished(job);
|
|
329
338
|
},
|
|
330
339
|
});
|
|
340
|
+
// The session's launches (docs/launch.md): a codebase's one at a time, the newest commit winning, on the coding model
|
|
341
|
+
// of the codebase - and what the sentinel waits on of them.
|
|
342
|
+
const launches = createSessionLaunches({
|
|
343
|
+
cwd,
|
|
344
|
+
jobs,
|
|
345
|
+
model: (plainFile) => launchModel(workLoops.get(jobs)?.from.ctx, plainFile),
|
|
346
|
+
onChange: (launch) => {
|
|
347
|
+
core?.jobsChanged();
|
|
348
|
+
try {
|
|
349
|
+
host.onLaunch?.(launch);
|
|
350
|
+
}
|
|
351
|
+
catch {
|
|
352
|
+
/* a host that throws still has the launch in the track */
|
|
353
|
+
}
|
|
354
|
+
core?.launchChanged(launch);
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
sessionLaunches.set(jobs, launches);
|
|
331
358
|
core = createChats({
|
|
332
359
|
cwd,
|
|
360
|
+
launches,
|
|
333
361
|
host,
|
|
334
362
|
jobs,
|
|
335
363
|
extension: (pi, link) => turriExtension(pi, core, link),
|
|
@@ -346,8 +374,6 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
346
374
|
hosts.set(jobs, host);
|
|
347
375
|
// What the model is told of where the person watches the work, deep in the tools too: the host's surface, or the terminal.
|
|
348
376
|
setSurface(jobs, host.surface);
|
|
349
|
-
// What release has shipped, module by module: release does nothing for a module whose last commit it already shipped.
|
|
350
|
-
deployStates.set(jobs, createDeployState());
|
|
351
377
|
// What this session does, as facts, in the project's .turri/ledger - a pulse's own in its project. Said once, in the
|
|
352
378
|
// chat shown, when it cannot be written.
|
|
353
379
|
if (ledgerWanted()) {
|
|
@@ -400,7 +426,7 @@ export function sessionLoop(session) {
|
|
|
400
426
|
}
|
|
401
427
|
/**
|
|
402
428
|
* turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
|
|
403
|
-
* its
|
|
429
|
+
* its id on the pulses it asks for - on the session's job registry and work loop.
|
|
404
430
|
*/
|
|
405
431
|
function turriExtension(api, session, link) {
|
|
406
432
|
const pi = scopedToChat(api, link.scope);
|
|
@@ -436,75 +462,71 @@ function turriExtension(api, session, link) {
|
|
|
436
462
|
// gets the full report as a hidden message that starts a turn of its own - at once when it is
|
|
437
463
|
// idle, else as soon as the turn it is in ends (a follow-up, never cutting into a reply or an
|
|
438
464
|
// interview) - so it reacts to every job that ends without waiting for the person to speak:
|
|
439
|
-
// does what the project's guidance says to do then (
|
|
465
|
+
// does what the project's guidance says to do then (launch what was built, say), or says
|
|
440
466
|
// what finished. In the chat that asked for the pulse, shown or not.
|
|
441
467
|
const announce = (job) => {
|
|
442
468
|
announceJob(pi, job);
|
|
469
|
+
// 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
|
+
if (toldByWaitingCall(jobs, job) && job.specConflict === undefined)
|
|
471
|
+
return;
|
|
443
472
|
// A spec that contradicts itself is the person's to settle, now: the agent is started on it.
|
|
444
473
|
if (job.specConflict !== undefined) {
|
|
445
474
|
void pi.sendMessage({ customType: "turri_spec_conflict", content: specConflictTask(job.specConflict), display: false, details: { jobId: job.id } }, { triggerTurn: true });
|
|
446
475
|
return;
|
|
447
476
|
}
|
|
477
|
+
let launching = false;
|
|
478
|
+
try {
|
|
479
|
+
launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
|
|
480
|
+
}
|
|
481
|
+
catch {
|
|
482
|
+
/* a config that cannot be read launches nothing */
|
|
483
|
+
}
|
|
448
484
|
void pi.sendMessage({
|
|
449
485
|
customType: "turri_job",
|
|
450
|
-
content: (job
|
|
451
|
-
? `Pulse ${job.id} (${job.kind}) finished after ${formatDuration(job)}.\n\n${job.report ?? ""}`
|
|
452
|
-
: job.status === "stopped"
|
|
453
|
-
? `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." : ""}`
|
|
454
|
-
: `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`) +
|
|
455
|
-
`\n\n${JOB_FINISHED_REACTION}`,
|
|
486
|
+
content: pulseEndNote(job, { launching }),
|
|
456
487
|
display: false,
|
|
457
488
|
details: { jobId: job.id, status: job.status },
|
|
458
489
|
}, { triggerTurn: true, deliverAs: "followUp" });
|
|
459
490
|
};
|
|
460
491
|
// The sentinel's: what a pulse that ended is, told to its agent in a conversation of its own for the pulse. The hidden
|
|
461
492
|
// message is the conversation's first entry - a host splits the sentinel's work by pulse on it - so the pulse's end is
|
|
462
|
-
// not drawn above it here: the person's chat shows it.
|
|
493
|
+
// not drawn above it here: the person's chat shows it. Told once what runs holds its commit (chats.ts readyFor).
|
|
463
494
|
const brief = async (job, context) => {
|
|
464
|
-
const
|
|
495
|
+
const launch = sessionLaunches.get(jobs)?.forPulse(job) ?? { later: [], laterSpecs: [], running: [] };
|
|
465
496
|
const content = sentinelBrief(job, {
|
|
466
497
|
project: cwd,
|
|
467
498
|
...(context.asked !== undefined ? { asked: context.asked } : {}),
|
|
468
499
|
...(context.focused !== undefined ? { focused: context.focused } : {}),
|
|
469
|
-
|
|
470
|
-
releaseAfterPulse: config.releaseAfterPulse === true,
|
|
500
|
+
launch,
|
|
471
501
|
reaction: JOB_FINISHED_REACTION,
|
|
472
502
|
});
|
|
473
503
|
void pi.sendMessage({ customType: "turri_sentinel_pulse", content, display: false, details: { jobId: job.id, status: job.status } }, { triggerTurn: true });
|
|
474
504
|
};
|
|
475
|
-
// The sentinel's: functional specs a host asked it to check
|
|
476
|
-
//
|
|
477
|
-
// check, its hidden first message `turri_sentinel_check`. Why not, when the release failed: its agent is told nothing.
|
|
505
|
+
// The sentinel's: functional specs a host asked it to check, in what is launched of the module - told, in a
|
|
506
|
+
// conversation of its own for the check, its hidden first message `turri_sentinel_check`. It launches nothing.
|
|
478
507
|
const briefCheck = async (check, context) => {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
if (currentRelease(state, check.plainFile, check.module) === undefined) {
|
|
482
|
-
// Behind, never made, or what it started died: released afresh - the release tool would say it shipped that already.
|
|
483
|
-
state.released.delete(check.module);
|
|
484
|
-
let said;
|
|
485
|
-
try {
|
|
486
|
-
const ctx = contextNow();
|
|
487
|
-
const model = ctx !== undefined ? releaseModel(ctx, check.plainFile) : undefined;
|
|
488
|
-
said = await runReleaseAgent({ plainFile: check.plainFile, cwd, state, inModule: check.module, forCheck: { moduleName: check.module }, ...(model !== undefined ? { model } : {}) });
|
|
489
|
-
}
|
|
490
|
-
catch (error) {
|
|
491
|
-
return error instanceof Error ? error.message : String(error);
|
|
492
|
-
}
|
|
493
|
-
if (currentRelease(state, check.plainFile, check.module) === undefined)
|
|
494
|
-
return said.trim() || "its last commit was not released";
|
|
495
|
-
releasedNow = true;
|
|
496
|
-
}
|
|
497
|
-
const commit = state.released.get(check.module)?.commit;
|
|
508
|
+
const current = sessionLaunches.get(jobs)?.track.current(check.module);
|
|
509
|
+
const commit = current?.short;
|
|
498
510
|
const content = sentinelCheckBrief(check, {
|
|
499
511
|
specs: checkedSpecs(check),
|
|
500
|
-
|
|
501
|
-
releasedNow,
|
|
512
|
+
running: runningLaunched(check.module),
|
|
502
513
|
...(commit !== undefined ? { commit } : {}),
|
|
514
|
+
...(current?.status === "failed" ? { failed: { id: current.id, ...(current.summary !== undefined ? { summary: current.summary } : {}) } } : {}),
|
|
515
|
+
...(current !== undefined ? { dir: launchedDir(current) } : {}),
|
|
503
516
|
...(context.focused !== undefined ? { focused: context.focused } : {}),
|
|
504
517
|
});
|
|
505
518
|
void pi.sendMessage({ customType: "turri_sentinel_check", content, display: false, details: { checkId: check.id, module: check.module, funcIds: check.funcIds } }, { triggerTurn: true });
|
|
506
|
-
return undefined;
|
|
507
519
|
};
|
|
520
|
+
// The sentinel's: its check carried on in the conversation it was in, once its codebase was launched again.
|
|
521
|
+
const resume = async (work) => {
|
|
522
|
+
const launches = sessionLaunches.get(jobs);
|
|
523
|
+
if (launches === undefined)
|
|
524
|
+
return;
|
|
525
|
+
const content = launches.resumeText(work);
|
|
526
|
+
void pi.sendMessage({ customType: "turri_sentinel_resume", content, display: false }, { triggerTurn: true });
|
|
527
|
+
};
|
|
528
|
+
// A launch this chat is to hear of ended: its agent told how it went, to tell the person.
|
|
529
|
+
const launched = (launch) => tellLaunch(pi, jobs, launch);
|
|
508
530
|
// A pulse ended, with the sentinel on: said in the chat. One that landed is told to its agent too, to tell the person
|
|
509
531
|
// it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
|
|
510
532
|
// contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
|
|
@@ -512,11 +534,18 @@ function turriExtension(api, session, link) {
|
|
|
512
534
|
announceJob(pi, job);
|
|
513
535
|
if (job.specConflict !== undefined)
|
|
514
536
|
session.notice(specConflictNotice(job, specConflictTask(job.specConflict)));
|
|
515
|
-
if (options.tell !== true)
|
|
537
|
+
if (options.tell !== true || toldByWaitingCall(jobs, job))
|
|
516
538
|
return;
|
|
517
539
|
// A host that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
|
|
518
540
|
const shown = host.pulseEndsShown === true;
|
|
519
|
-
|
|
541
|
+
let launching = false;
|
|
542
|
+
try {
|
|
543
|
+
launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
/* a config that cannot be read launches nothing */
|
|
547
|
+
}
|
|
548
|
+
void pi.sendMessage({ customType: "turri_job_landed", content: landedNote(job, { shown, launching }), display: false, details: { jobId: job.id, status: job.status } }, shown ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
|
|
520
549
|
};
|
|
521
550
|
const notices = noticeDialogs(pi, session, link, contextNow);
|
|
522
551
|
link.live({
|
|
@@ -524,6 +553,8 @@ function turriExtension(api, session, link) {
|
|
|
524
553
|
landed,
|
|
525
554
|
brief,
|
|
526
555
|
briefCheck,
|
|
556
|
+
resume,
|
|
557
|
+
launched,
|
|
527
558
|
notice: notices.put,
|
|
528
559
|
noticeOver: notices.over,
|
|
529
560
|
concluded: notices.concluded,
|
|
@@ -545,7 +576,7 @@ function turriExtension(api, session, link) {
|
|
|
545
576
|
// With them, the instruction to do turri's work with its tools rather than its command
|
|
546
577
|
// line - enforced below, not only asked for.
|
|
547
578
|
const rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"), readProjectConfig(cwd).rulesOff ?? []);
|
|
548
|
-
// Laid out again once rules-off changes - /
|
|
579
|
+
// Laid out again once rules-off changes - /settings changes it as turri runs - and the same block in between.
|
|
549
580
|
let rulesKept = { off: (readProjectConfig(cwd).rulesOff ?? []).join(","), block: chatRulesBlock(rules) };
|
|
550
581
|
const rulesBlock = () => {
|
|
551
582
|
const off = readProjectConfig(cwd).rulesOff ?? [];
|
|
@@ -621,6 +652,14 @@ function turriExtension(api, session, link) {
|
|
|
621
652
|
const plain = isSentinel ? writesPlain(command) : undefined;
|
|
622
653
|
if (plain !== undefined)
|
|
623
654
|
return { block: true, reason: `${plain} is ***plain: the sentinel never changes it - put what it needs to the person with notify_person.` };
|
|
655
|
+
// Nor does a host's terminal start the code in plain_modules for it: what it tests is what is launched.
|
|
656
|
+
const built = isSentinel && event.toolName !== "bash" ? runsBuiltCode(command) : undefined;
|
|
657
|
+
if (built !== undefined) {
|
|
658
|
+
return {
|
|
659
|
+
block: true,
|
|
660
|
+
reason: `${built} is in plain_modules - the code a pulse may be writing, which nobody launched: the sentinel never runs it, nor starts a server of its own. Test what is launched, from where its brief says; a server that should run and does not is your finding.`,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
624
663
|
}
|
|
625
664
|
if (event.toolName === "bash" && typeof command === "string") {
|
|
626
665
|
const what = selfInvocation(command);
|
|
@@ -705,11 +744,9 @@ function turriExtension(api, session, link) {
|
|
|
705
744
|
registerRegenerate(pi, cwd, jobs);
|
|
706
745
|
registerDrift(pi, cwd, jobs);
|
|
707
746
|
registerBind(pi, cwd, jobs, (plainFile) => turnOnConformance(session, plainFile));
|
|
708
|
-
|
|
709
|
-
registerDeploy(pi, cwd, jobs, deployStates.get(jobs) ?? createDeployState());
|
|
747
|
+
registerLaunch(pi, cwd, jobs);
|
|
710
748
|
registerSteering(pi, cwd);
|
|
711
749
|
registerSideQuestions(pi, cwd, jobs);
|
|
712
|
-
registerStacks(pi, cwd);
|
|
713
750
|
// More chats beside this one, in the terminal: /chat, alt+n, alt+1…9 (chat-commands.ts).
|
|
714
751
|
if (session.terminal)
|
|
715
752
|
registerChats(pi, session);
|
|
@@ -741,17 +778,17 @@ function turriExtension(api, session, link) {
|
|
|
741
778
|
if (backgroundSkillRuns.has(key)) {
|
|
742
779
|
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 } };
|
|
743
780
|
}
|
|
744
|
-
const model = skill.model === "coding" ? jobModel(ctx,
|
|
745
|
-
const
|
|
781
|
+
const model = skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx);
|
|
782
|
+
const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
|
|
746
783
|
const kind = scriptKindOfSkill(skill.name);
|
|
747
784
|
const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
|
|
748
785
|
// While it writes a testing script, the modules that need it wait for it rather than fail for want of it.
|
|
749
|
-
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(
|
|
786
|
+
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
750
787
|
const controller = new AbortController();
|
|
751
788
|
backgroundSkillRuns.set(key, controller);
|
|
752
789
|
const context = [
|
|
753
790
|
conversationContext(ctx, params.context),
|
|
754
|
-
shown !== undefined ? `It is for ${shown}${
|
|
791
|
+
shown !== undefined ? `It is for ${shown}${configModule !== undefined ? `, built with ${moduleConfigFile(configModule)} over ${CONFIG_FILE}` : ""}.` : undefined,
|
|
755
792
|
BACKGROUND_NOTE,
|
|
756
793
|
]
|
|
757
794
|
.filter((part) => part !== undefined && part.trim() !== "")
|
|
@@ -763,7 +800,7 @@ function turriExtension(api, session, link) {
|
|
|
763
800
|
const end = (ended) => skillRunEnds.put(ended.ok
|
|
764
801
|
? { skill: skill.name, ok: true, line: doneLine(skill.name, ended.changed, kind), ...about }
|
|
765
802
|
: { skill: skill.name, ok: false, line: `${skill.name} ${ended.why}.`, task: failedTask(skill.name, ended.why, ended.output, kind), ...about });
|
|
766
|
-
void captureConsole(() =>
|
|
803
|
+
void captureConsole(() => withConfigModule(configModule, () => runSkill({
|
|
767
804
|
skillDir: skill.dir,
|
|
768
805
|
signal: controller.signal,
|
|
769
806
|
cwd,
|
|
@@ -835,7 +872,7 @@ function turriExtension(api, session, link) {
|
|
|
835
872
|
description: "Start a new run even though an interrupted one exists here, discarding it.",
|
|
836
873
|
})),
|
|
837
874
|
plainFile: Type.Optional(Type.String({
|
|
838
|
-
description: "The module the skill's work is for - its .plain file, e.g. backend.plain: a testing script is written for that module
|
|
875
|
+
description: "The module the skill's work is for - its .plain file, e.g. backend.plain: a testing script is written for that module, named in its config, " +
|
|
839
876
|
"on its coding model. Omitted: the project's.",
|
|
840
877
|
})),
|
|
841
878
|
}),
|
|
@@ -982,11 +1019,20 @@ function turriExtension(api, session, link) {
|
|
|
982
1019
|
},
|
|
983
1020
|
};
|
|
984
1021
|
// What the run changes in the project's ***plain - its specs, resources, scripts - is said with its result: a skill
|
|
985
|
-
// that writes nothing is not taken for one that did its work. Only those: a
|
|
1022
|
+
// that writes nothing is not taken for one that did its work. Only those: a launch or a running app changes other
|
|
986
1023
|
// files while it runs, and they are not its doing.
|
|
987
1024
|
const filesBefore = projectFiles(cwd);
|
|
988
1025
|
// A side question asked while it runs is told what it has done so far.
|
|
989
|
-
const
|
|
1026
|
+
const ran_ = skillRunStarted({ skill: skill.name, dir: skill.dir, step: () => live.step, trace: () => [...trace], runDir });
|
|
1027
|
+
// A testing script being written - here to its end, in print mode - holds the modules it is for, as in the background:
|
|
1028
|
+
// a pulse started meanwhile, by a regenerate called beside it, would run against the script as it was.
|
|
1029
|
+
const kind = scriptKindOfSkill(skill.name);
|
|
1030
|
+
const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
|
|
1031
|
+
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
1032
|
+
const ended = () => {
|
|
1033
|
+
written();
|
|
1034
|
+
ran_();
|
|
1035
|
+
};
|
|
990
1036
|
const ran = await captureConsole(() => runSkill({
|
|
991
1037
|
skillDir: skill.dir,
|
|
992
1038
|
// The chat's turn stopped - ctrl+c, esc - stops the run with it.
|
|
@@ -1005,20 +1051,20 @@ function turriExtension(api, session, link) {
|
|
|
1005
1051
|
push(` A: ${answer}`);
|
|
1006
1052
|
recordExchange(pi, { skill: skill.name, question, answer, ...(said !== undefined && said.trim() !== "" ? { said: said.trim() } : {}) });
|
|
1007
1053
|
}, (question) => askOnTheSide(pi, ctx, cwd, jobs, question), dialogs),
|
|
1008
|
-
model: skill.model === "coding" ? jobModel(ctx,
|
|
1054
|
+
model: skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx),
|
|
1009
1055
|
// Renders queued by a step land in the same registry as everything else, so
|
|
1010
1056
|
// pulses sees them without knowing a skill started them.
|
|
1011
1057
|
// Asked per job as it is queued, so a model chosen mid-interview applies from then on.
|
|
1012
1058
|
renderQueue: workLoopFor(jobs, cwd, ctx),
|
|
1013
1059
|
// The person answers the skill's agent while it runs, so it can take "render these with ..." too.
|
|
1014
1060
|
// parse too: a skill parses what it wrote with the same check the conversation has.
|
|
1015
|
-
sharedTools: [
|
|
1061
|
+
sharedTools: [checkPlainTool(cwd), ...createWebTools()],
|
|
1016
1062
|
// The conversation's own regenerate, drift, halt and conform, on its loop: a skill waits for nothing, and regenerates on the model chosen.
|
|
1017
1063
|
loopTools: [
|
|
1018
|
-
regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named
|
|
1064
|
+
regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, named, plainFile), wait: () => false }),
|
|
1019
1065
|
driftTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx) }),
|
|
1020
|
-
haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop }),
|
|
1021
|
-
conformTool({ cwd, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx,
|
|
1066
|
+
haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop, ...(sessionLaunches.get(jobs) !== undefined ? { launches: sessionLaunches.get(jobs).track } : {}) }),
|
|
1067
|
+
conformTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, named, plainFile), wait: () => false }),
|
|
1022
1068
|
],
|
|
1023
1069
|
// The escalation becomes a real dialog - the host's own, when it has them. Without one there is nobody to ask,
|
|
1024
1070
|
// so the gate stands.
|
|
@@ -1106,7 +1152,7 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1106
1152
|
cwd,
|
|
1107
1153
|
jobs,
|
|
1108
1154
|
loop: (ctx) => workLoopFor(jobs, cwd, ctx),
|
|
1109
|
-
model: (ctx, plainFile, named
|
|
1155
|
+
model: (ctx, plainFile, named) => jobModel(ctx, named, plainFile),
|
|
1110
1156
|
wait: (ctx, asked) => shouldWait(ctx.mode, asked),
|
|
1111
1157
|
}));
|
|
1112
1158
|
// /regenerate: the same as the tool, from the person - a module brought up to its spec as it is now, cut into pulses
|
|
@@ -1135,7 +1181,7 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1135
1181
|
return;
|
|
1136
1182
|
}
|
|
1137
1183
|
const loop = workLoopFor(jobs, cwd, ctx);
|
|
1138
|
-
const model = jobModel(ctx,
|
|
1184
|
+
const model = jobModel(ctx, undefined, plainFile);
|
|
1139
1185
|
const request = { ...(model !== undefined ? { model } : {}), ...(guidance !== "" ? { guidance } : {}) };
|
|
1140
1186
|
// Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
|
|
1141
1187
|
// began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
|
|
@@ -1150,8 +1196,8 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1150
1196
|
const target = plainFile;
|
|
1151
1197
|
void (async () => {
|
|
1152
1198
|
try {
|
|
1153
|
-
//
|
|
1154
|
-
const statuses = await
|
|
1199
|
+
// Refused when its config cannot be told, or would build it with no testing script.
|
|
1200
|
+
const statuses = await whenBuildable(target, () => scratch
|
|
1155
1201
|
? loop.fromScratch(target, { ...request, chain })
|
|
1156
1202
|
: again.length > 0
|
|
1157
1203
|
? loop.regenerateAgain(target, again, request)
|
|
@@ -1245,25 +1291,41 @@ echoed = false, react) {
|
|
|
1245
1291
|
else
|
|
1246
1292
|
void pi.sendMessage({ customType: COMMAND_OUTCOME, content, display: false }, { triggerTurn: true, deliverAs: "followUp" });
|
|
1247
1293
|
}
|
|
1294
|
+
/**
|
|
1295
|
+
* What a slash command found for the agent alone - guidance the person need not see: put in the conversation unseen,
|
|
1296
|
+
* and the agent started on it - at once when it is idle, else once its turn ends - told what to do with it.
|
|
1297
|
+
*/
|
|
1298
|
+
export function toldAfterCommand(pi, command, text, react) {
|
|
1299
|
+
const content = `The person ran ${command}. Not shown to them:\n${text}\n\n${react}`;
|
|
1300
|
+
void pi.sendMessage({ customType: COMMAND_OUTCOME, content, display: false }, { triggerTurn: true, deliverAs: "followUp" });
|
|
1301
|
+
}
|
|
1248
1302
|
/**
|
|
1249
1303
|
* What the agent does once /regenerate or /conform has started pulses: a command's output alone leaves the chat silent,
|
|
1250
1304
|
* and the person wondering whether to wait. It says what runs, and that they need not - and starts nothing itself.
|
|
1251
1305
|
*/
|
|
1252
1306
|
export const COMMAND_STARTED_REACTION = "My pulses are running from the person's command, in the background. Tell the person, in a line or two, what " +
|
|
1253
1307
|
"runs and what is planned - and that the two of us can go on with the ***plain, or anything else, meanwhile: they need " +
|
|
1254
|
-
"not wait for it. Start nothing for it: no regenerate, no check, no
|
|
1308
|
+
"not wait for it. Start nothing for it: no regenerate, no check, no launch - its end is told when it comes.";
|
|
1255
1309
|
/**
|
|
1256
|
-
* What the agent does when /conform
|
|
1257
|
-
*
|
|
1310
|
+
* What the agent does when /conform found a step of adding tests still to take: takes it at once, asking nothing - the
|
|
1311
|
+
* /conform was the person's yes - and says what it writes as the way there, never as a failure: the person saw none.
|
|
1258
1312
|
*/
|
|
1259
|
-
export const
|
|
1260
|
-
"
|
|
1261
|
-
"
|
|
1262
|
-
"
|
|
1263
|
-
"
|
|
1264
|
-
"
|
|
1265
|
-
"
|
|
1266
|
-
"
|
|
1313
|
+
export const CONFORM_STEPS_REACTION = "That is what conform needs before it can start - the steps of adding tests still to take - not an error: nothing " +
|
|
1314
|
+
"failed, and the person saw none of it. Their /conform is their yes to conformance tests here, so take the steps now, " +
|
|
1315
|
+
"in that order and only what is missing, asking nothing: the test reqs first; then the conformance testing script, " +
|
|
1316
|
+
"started with its skill before anything else - it runs in the background, so the scenarios are written while it does; " +
|
|
1317
|
+
"then the scenarios of the functional specs they named, or, naming none, of each functional spec that needs them by " +
|
|
1318
|
+
"the rules on test plain files. Then call regenerate for the module: the work loop writes and runs their tests once the " +
|
|
1319
|
+
"code is built. Tell the person in a line or two, as the way to their conformance tests and not as a refusal, what you " +
|
|
1320
|
+
"are writing, and for each functional spec why it needs scenarios - or, when none does, that and why.";
|
|
1321
|
+
/**
|
|
1322
|
+
* What the agent does when /conform started nothing for a reason that is not a step of adding tests - a functional spec
|
|
1323
|
+
* named that is not there, words it does not take: answers it at once - why, and what would let it start - rather than
|
|
1324
|
+
* leave the person with a refusal and a silent chat.
|
|
1325
|
+
*/
|
|
1326
|
+
export const CONFORM_REFUSED_REACTION = "Nothing was started from the person's /conform, for the reason shown. Tell them in a line or two why, and what would " +
|
|
1327
|
+
"let it start - a functional spec they named that is not there, ***plain that does not parse or would have to change its " +
|
|
1328
|
+
"meaning to be tested - and offer to do what is yours to do; start nothing.";
|
|
1267
1329
|
export const COMMAND_OUTCOME = "turri_command_outcome";
|
|
1268
1330
|
/** Longer than a frame of the TUI's (16ms): an entry appended before it is drawn by its end. */
|
|
1269
1331
|
const ONE_FRAME_MS = 20;
|
|
@@ -1313,8 +1375,9 @@ function registerDrift(pi, cwd, jobs) {
|
|
|
1313
1375
|
function registerBind(pi, cwd, jobs, turnOn) {
|
|
1314
1376
|
pi.registerTool(conformTool({
|
|
1315
1377
|
cwd,
|
|
1378
|
+
jobs,
|
|
1316
1379
|
loop: (ctx) => workLoopFor(jobs, cwd, ctx),
|
|
1317
|
-
model: (ctx, plainFile, named) => jobModel(ctx,
|
|
1380
|
+
model: (ctx, plainFile, named) => jobModel(ctx, named, plainFile),
|
|
1318
1381
|
wait: (ctx, asked) => shouldWait(ctx.mode, asked),
|
|
1319
1382
|
}));
|
|
1320
1383
|
// /conform: the same as the tool, from the person - a module's conformance tests written and run now, for the
|
|
@@ -1322,7 +1385,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
|
|
|
1322
1385
|
// them is asking for them on: off, they are turned on first. What would start nothing is found before anything is
|
|
1323
1386
|
// said, and the chat's agent answers it at once.
|
|
1324
1387
|
pi.registerCommand("conform", {
|
|
1325
|
-
description: "Write and run a module's conformance tests now - the functional specs named, or every one with scenarios - in one pulse, or one a functional spec when asked; turned on first when they are off: /conform [module | file.plain] [module:func-id ...] [one by one]",
|
|
1388
|
+
description: "Write and run a module's conformance tests now - the functional specs named, or every one with scenarios - in one pulse, or one a functional spec when asked; those written already written again, named, or from scratch - the tests folder at the tip of its chain taken out, started again from the module it requires, or from nothing with whole chain; turned on first when they are off: /conform [module | file.plain] [module:func-id ...] [from scratch [whole chain]] [one by one]",
|
|
1326
1389
|
handler: async (args, ctx) => {
|
|
1327
1390
|
const command = `/conform ${args.trim()}`.trim();
|
|
1328
1391
|
await echoCommand(pi, command);
|
|
@@ -1338,9 +1401,15 @@ function registerBind(pi, cwd, jobs, turnOn) {
|
|
|
1338
1401
|
const { funcIds, rest } = funcIdsNamedFirst(picked.rest);
|
|
1339
1402
|
const words = rest.join(" ").trim();
|
|
1340
1403
|
const separately = asksOneByOne(words);
|
|
1341
|
-
//
|
|
1342
|
-
|
|
1343
|
-
|
|
1404
|
+
// From scratch - the tests written again, the code untouched - asked in the person's words; the whole chain's with it.
|
|
1405
|
+
const scratch = asksFromScratch(words) ? (asksWholeChain(words) ? "chain" : "module") : undefined;
|
|
1406
|
+
// Nothing but the functional specs, from scratch and one by one: no planner reads guidance here, so other words are not dropped unsaid.
|
|
1407
|
+
if (words !== "" && !separately && scratch === undefined) {
|
|
1408
|
+
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
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (scratch !== undefined && funcIds.length > 0) {
|
|
1412
|
+
refuse("Name functional specs or ask for the conformance tests from scratch, not both: from scratch writes every one of them again. Nothing was started.");
|
|
1344
1413
|
return;
|
|
1345
1414
|
}
|
|
1346
1415
|
// Off: turned on - written where the module's value comes from, every chat's tools switched - and said with what follows.
|
|
@@ -1358,26 +1427,38 @@ function registerBind(pi, cwd, jobs, turnOn) {
|
|
|
1358
1427
|
// ***plain alone, before anything is said.
|
|
1359
1428
|
let refusal;
|
|
1360
1429
|
try {
|
|
1361
|
-
refusal =
|
|
1430
|
+
refusal = whenBuildable(plainFile, () => conformanceRefusal(plainFile, funcIds.length > 0 ? funcIds : undefined));
|
|
1362
1431
|
}
|
|
1363
1432
|
catch (error) {
|
|
1364
|
-
refusal = error instanceof Error ? error.message : String(error);
|
|
1433
|
+
refusal = { text: error instanceof Error ? error.message : String(error), stepsMissing: false };
|
|
1434
|
+
}
|
|
1435
|
+
// A step of adding tests still to take - the test reqs, the script, the scenarios: the chat's to take, so told to it
|
|
1436
|
+
// alone, as what conform needs first. The person sees it take them, and conformance turned on, if it was.
|
|
1437
|
+
if (refusal?.stepsMissing === true) {
|
|
1438
|
+
if (turnedOn !== undefined)
|
|
1439
|
+
shownAfterCommand(pi, ctx, command, turnedOn, "info", true);
|
|
1440
|
+
toldAfterCommand(pi, command, refusal.text, CONFORM_STEPS_REACTION);
|
|
1441
|
+
return;
|
|
1365
1442
|
}
|
|
1366
1443
|
if (refusal !== undefined) {
|
|
1367
|
-
refuse(withTurnedOn(refusal));
|
|
1444
|
+
refuse(withTurnedOn(refusal.text));
|
|
1368
1445
|
return;
|
|
1369
1446
|
}
|
|
1370
1447
|
const module = basename(plainFile).replace(/\.plain$/, "");
|
|
1371
|
-
const model = jobModel(ctx,
|
|
1372
|
-
|
|
1448
|
+
const model = jobModel(ctx, undefined, plainFile);
|
|
1449
|
+
const starting = scratch !== undefined
|
|
1450
|
+
? `Writing ${module}'s conformance tests${scratch === "chain" ? " and its whole chain's" : ""} again from scratch…`
|
|
1451
|
+
: `Starting ${funcIds.length > 0 ? `the conformance tests of ${funcIds.join(", ")}` : `${module}'s conformance tests`}…`;
|
|
1452
|
+
shownAfterCommand(pi, ctx, command, withTurnedOn(starting), "info", true);
|
|
1373
1453
|
await nextFrame();
|
|
1374
1454
|
// In the background, as /regenerate: a codebase built on the module may be stopped and deleted first.
|
|
1375
1455
|
void (async () => {
|
|
1376
1456
|
try {
|
|
1377
|
-
const statuses = await
|
|
1457
|
+
const statuses = await whenBuildable(plainFile, () => workLoopFor(jobs, cwd, ctx).conformance(plainFile, {
|
|
1378
1458
|
...(funcIds.length > 0 ? { funcIds } : {}),
|
|
1379
1459
|
...(model !== undefined ? { model } : {}),
|
|
1380
1460
|
...(separately ? { separately: true } : {}),
|
|
1461
|
+
...(scratch !== undefined ? { fromScratch: scratch } : {}),
|
|
1381
1462
|
}));
|
|
1382
1463
|
// Nothing to write: said in the loop's words - "up to date" alone speaks of the code, not its tests.
|
|
1383
1464
|
const upToDate = statuses.length > 0 && statuses.every(isUpToDate);
|
|
@@ -1386,7 +1467,10 @@ function registerBind(pi, cwd, jobs, turnOn) {
|
|
|
1386
1467
|
shownAfterCommand(pi, ctx, command, text, "info", true, upToDate ? undefined : COMMAND_STARTED_REACTION);
|
|
1387
1468
|
}
|
|
1388
1469
|
catch (error) {
|
|
1389
|
-
|
|
1470
|
+
if (error instanceof TestingStepsMissing)
|
|
1471
|
+
toldAfterCommand(pi, command, error.message, CONFORM_STEPS_REACTION);
|
|
1472
|
+
else
|
|
1473
|
+
refuse(error instanceof Error ? error.message : String(error));
|
|
1390
1474
|
}
|
|
1391
1475
|
})().catch(() => {
|
|
1392
1476
|
// The chat let go meanwhile: there is nobody to say it to.
|
|
@@ -1409,10 +1493,13 @@ function conformTool(options) {
|
|
|
1409
1493
|
"conformance and acceptance scenarios, at least one test each, by the spec's test reqs, runs them with the whole suite " +
|
|
1410
1494
|
"the module inherits, and, where one fails, fixes the test or the code, whichever is wrong. What they are written for is " +
|
|
1411
1495
|
"recorded apart from the code. The work loop starts these pulses by itself for every functional spec with scenarios whose " +
|
|
1412
|
-
"tests are behind, once the module's code is built; conform starts them now, or for the functional specs named - those alone: the module's others stay behind until conform names none, or the module is regenerated.
|
|
1496
|
+
"tests are behind, once the module's code is built; conform starts them now, or for the functional specs named - those alone: the module's others stay behind until conform names none, or the module is regenerated. " +
|
|
1497
|
+
"A functional spec named whose tests are written already has them written again - deleted and written anew from its " +
|
|
1498
|
+
"scenarios, its code untouched; with from_scratch, the module's whole tests folder is taken out and written again, at " +
|
|
1499
|
+
"the tip of each chain it is built in, as regenerate from scratch does its code. A " +
|
|
1413
1500
|
"functional spec with no scenarios - no test plain file - is refused: there is nothing to test until scenarios " +
|
|
1414
1501
|
"are written. So is one the spec does not have, and a module with scenarios that skipped a step of adding tests - " +
|
|
1415
|
-
"no test reqs, or no conformance testing script
|
|
1502
|
+
"no test reqs, or no conformance testing script: the refusal names the next step. While conformance tests " +
|
|
1416
1503
|
"are off it is refused too: they make each change take about twice as long, and turning them on is the person's - " +
|
|
1417
1504
|
"with /conform - never yours.",
|
|
1418
1505
|
promptSnippet: "conform: write and run the conformance tests of functional specs with scenarios",
|
|
@@ -1421,13 +1508,20 @@ function conformTool(options) {
|
|
|
1421
1508
|
"Call conform when the user asks for the conformance tests to be written or run now, for a module or some of its functional specs with scenarios.",
|
|
1422
1509
|
"What the user asks for comes first: for a module already regenerated, while a module built on it is being regenerated, conform stops that pulse, deletes the codebase built on it, writes the tests, and the module above is regenerated from it after - say so. For a module not regenerated yet, its tests are written once its code is built, before anything is built on it.",
|
|
1423
1510
|
"Conformance tests go in one pulse for all the functional specs tested. Set one_by_one only when the user asks for a pulse a functional spec - one at a time, separately, or the like.",
|
|
1511
|
+
"Name a functional spec whose tests are written only when the user asks for its tests to be written again: they are deleted and written anew. Set from_scratch only when the user asks for a module's conformance tests - or its whole chain's - to be written again from scratch, never to fix tests that did not pass. Name funcIds or set from_scratch, not both.",
|
|
1512
|
+
'from_scratch works where the module\'s code lives - the tip of each chain it is built in, never a module in the middle - and takes that codebase\'s whole tests folder out, committed first so its lineage keeps it. "module" starts it again from a copy of the tests of the module the tip requires, and writes the tip\'s own tests anew on them; "chain" starts it from nothing, every functional spec of the chain written anew. Neither touches the code, nor any other codebase.',
|
|
1424
1513
|
],
|
|
1425
1514
|
parameters: Type.Object({
|
|
1426
1515
|
plain_file: Type.String({ description: "A .plain file of the module" }),
|
|
1427
1516
|
working_dir: WORKING_DIR_PARAM,
|
|
1428
|
-
funcIds: Type.Optional(Type.Array(Type.String(), {
|
|
1517
|
+
funcIds: Type.Optional(Type.Array(Type.String(), {
|
|
1518
|
+
description: "The functional specs to test, each as module:func-id (todo:add-task) - each with scenarios; one whose tests are written has them written again. Omitted: every one with scenarios",
|
|
1519
|
+
})),
|
|
1520
|
+
from_scratch: Type.Optional(Type.Union([Type.Literal("module"), Type.Literal("chain")], {
|
|
1521
|
+
description: "Only when the user asks for it: the tests folder where the module's code lives - the tip of its chain - taken out, committed first so its lineage keeps it, and written again from a copy of the tests of the module the tip requires; the code untouched. " +
|
|
1522
|
+
'"chain": written again from nothing - every functional spec of the chain\'s tests',
|
|
1523
|
+
})),
|
|
1429
1524
|
one_by_one: Type.Optional(Type.Boolean({ description: "Only when the user asks for it: a pulse a functional spec. Omitted: every functional spec tested in one pulse, as far as the size guardrail lets" })),
|
|
1430
|
-
stack: STACK_PARAM,
|
|
1431
1525
|
model: MODEL_PARAM,
|
|
1432
1526
|
wait: WAIT_PARAM,
|
|
1433
1527
|
}),
|
|
@@ -1435,25 +1529,36 @@ function conformTool(options) {
|
|
|
1435
1529
|
const params = fromWorkingDir(cwd, given);
|
|
1436
1530
|
const plainFile = resolve(params.base, params.plain_file);
|
|
1437
1531
|
refuseTestPlainFile(plainFile);
|
|
1438
|
-
return
|
|
1532
|
+
return whenBuildable(plainFile, async () => {
|
|
1439
1533
|
// Off: the person's to turn on, never the chat's - it is told to say why it wants them, and they decide.
|
|
1440
1534
|
if (!conformanceTestsOn(plainFile))
|
|
1441
1535
|
return { content: [{ type: "text", text: CONFORMANCE_OFF_REFUSAL }], details: { refused: true } };
|
|
1442
1536
|
const model = options.model(ctx, plainFile, params.model);
|
|
1443
1537
|
const loop = options.loop(ctx);
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1538
|
+
const wait = options.wait(ctx, params.wait);
|
|
1539
|
+
const waiting = wait ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
|
|
1540
|
+
let statuses;
|
|
1541
|
+
try {
|
|
1542
|
+
statuses = await loop.conformance(plainFile, {
|
|
1543
|
+
...(params.funcIds !== undefined ? { funcIds: params.funcIds } : {}),
|
|
1544
|
+
...(model !== undefined ? { model } : {}),
|
|
1545
|
+
...(params.one_by_one === true ? { separately: true } : {}),
|
|
1546
|
+
...(params.from_scratch !== undefined ? { fromScratch: params.from_scratch } : {}),
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
catch (error) {
|
|
1550
|
+
if (waiting !== undefined)
|
|
1551
|
+
endWait(waiting.jobs, waiting.wait);
|
|
1552
|
+
throw error;
|
|
1553
|
+
}
|
|
1554
|
+
return loopReply(loop, statuses, wait, waiting);
|
|
1450
1555
|
});
|
|
1451
1556
|
},
|
|
1452
1557
|
});
|
|
1453
1558
|
}
|
|
1454
|
-
/** The config a spec is built with - its project's, with
|
|
1559
|
+
/** The config a spec is built with - its project's, with its module's own file over it - or, with no spec, the session folder's. */
|
|
1455
1560
|
function configOf(plainFile) {
|
|
1456
|
-
return plainFile !== undefined ? configForSpec(resolve(process.cwd(), plainFile)) : readProjectConfig(process.cwd(),
|
|
1561
|
+
return plainFile !== undefined ? configForSpec(resolve(process.cwd(), plainFile)) : readProjectConfig(process.cwd(), configModuleOf(process.cwd()));
|
|
1457
1562
|
}
|
|
1458
1563
|
/**
|
|
1459
1564
|
* How many jobs the chat runs at once: `parallel-jobs:` in the session folder's config.turri.yaml - the only place it
|
|
@@ -1563,74 +1668,77 @@ export function projectConfigBlock(root) {
|
|
|
1563
1668
|
if (projects.length === 0)
|
|
1564
1669
|
return "";
|
|
1565
1670
|
const describe = (dir) => {
|
|
1566
|
-
const
|
|
1567
|
-
const chosen = stackOf(dir);
|
|
1671
|
+
const modules = moduleConfigsOf(dir);
|
|
1568
1672
|
const where = dir === root ? "" : ` (paths relative to ${relative(root, dir)}/)`;
|
|
1569
1673
|
const at = (name) => (dir === root ? name : `${relative(root, dir)}/${name}`);
|
|
1570
1674
|
return [
|
|
1571
|
-
...settings(readProjectConfig(dir),
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
: []),
|
|
1575
|
-
// A stack: its file over the project's, for everything built while it is chosen.
|
|
1576
|
-
...stacks.flatMap((stack) => [
|
|
1675
|
+
...settings(readProjectConfig(dir), withConfigModule(undefined, () => findTestScripts(dir)), dir === root ? `${projectConfigFile(dir)}, for the specs here:` : `${relative(root, dir)}/${projectConfigFile(dir)}, for the specs in ${relative(root, dir)}/ - built in ${relative(root, dir)}/plain_modules:`, where, modules.length > 0 ? "project of module files" : "project"),
|
|
1676
|
+
// A module's own file: over the project's, for it and every module built on it that has no file of its own.
|
|
1677
|
+
...modules.flatMap((module) => [
|
|
1577
1678
|
"",
|
|
1578
|
-
...settings(readProjectConfig(dir,
|
|
1679
|
+
...settings(readProjectConfig(dir, module), withConfigModule(module, () => findTestScripts(dir)), `${at(moduleConfigFileIn(dir, module))}, over ${projectConfigFile(dir)}, for ${module}.plain and every module built on it that has no file of its own - what it sets itself, and the testing scripts it builds with; the rest is ${projectConfigFile(dir)}'s:`, where, "module", readConfigFile(join(dir, moduleConfigFileIn(dir, module)))),
|
|
1579
1680
|
]),
|
|
1580
1681
|
];
|
|
1581
1682
|
};
|
|
1582
1683
|
const settings = (config, scripts, heading, where,
|
|
1583
|
-
/** The project's file, and whether
|
|
1584
|
-
of
|
|
1585
|
-
|
|
1684
|
+
/** The project's file, and whether modules have files of their own - whose scripts are theirs - or a module's. */
|
|
1685
|
+
of,
|
|
1686
|
+
/** A module's file as written: only what it sets itself is said - an inherited setting said again reads as its own. */
|
|
1687
|
+
own) => {
|
|
1688
|
+
const perModule = of === "project of module files";
|
|
1689
|
+
const sets = (set) => own === undefined || set;
|
|
1586
1690
|
return [
|
|
1587
1691
|
heading,
|
|
1588
1692
|
...[
|
|
1589
|
-
config.module !== undefined && of !== "
|
|
1590
|
-
of !== "
|
|
1693
|
+
config.module !== undefined && of !== "module" ? `- module: ${config.module}${where} - the module to build when the user does not name one.` : undefined,
|
|
1694
|
+
of !== "module"
|
|
1591
1695
|
? "- conformance tests: written for every functional spec with scenarios - the conformance and acceptance scenarios of its test plain file - once the module's code is built, before anything is built on it. A functional spec with an empty test plain file is not tested. To have one tested, write its scenarios with the file tools, then call regenerate."
|
|
1592
1696
|
: undefined,
|
|
1593
|
-
|
|
1594
|
-
?
|
|
1595
|
-
:
|
|
1697
|
+
!sets(own?.review !== undefined)
|
|
1698
|
+
? undefined
|
|
1699
|
+
: config.review === true
|
|
1700
|
+
? "- review: true - the code and its tests are reviewed once they pass: two reviews at most, the arbiter weighing the second."
|
|
1701
|
+
: `- review: ${config.review === false ? "false" : "not set, so off"} - the code and its tests are not reviewed: a pulse lands once its tests pass.`,
|
|
1596
1702
|
...(() => {
|
|
1597
1703
|
// Each as it holds, with what it inherits: judge from coding, coding from harness.
|
|
1598
1704
|
const models = projectModels(config);
|
|
1599
1705
|
const shown = (choice) => modelSpec(choice) ?? "";
|
|
1600
1706
|
return [
|
|
1601
|
-
models.coding !== undefined ? `- coding-model: ${shown(models.coding)}${config.codingModel === undefined ? " (from harness-model)" : ""} - what
|
|
1602
|
-
models.judge !== undefined ? `- judge-model: ${shown(models.judge)}${config.judgeModel === undefined ? " (from coding-model)" : ""} - the judge and the test review in a conformance run.` : undefined,
|
|
1603
|
-
models.harness !== undefined && of !== "
|
|
1707
|
+
models.coding !== undefined && sets(own?.codingModel !== undefined || own?.models?.coding !== undefined || own?.models?.default !== undefined) ? `- coding-model: ${shown(models.coding)}${config.codingModel === undefined ? " (from harness-model)" : ""} - what pulses run on, unless a call names another model.` : undefined,
|
|
1708
|
+
models.judge !== undefined && sets(own?.judgeModel !== undefined || own?.models?.judge !== undefined) ? `- judge-model: ${shown(models.judge)}${config.judgeModel === undefined ? " (from coding-model)" : ""} - the judge and the test review in a conformance run.` : undefined,
|
|
1709
|
+
models.harness !== undefined && of !== "module" ? `- harness-model: ${shown(models.harness)} - the model you start with.` : undefined,
|
|
1604
1710
|
// The other roles' own, where models: names them.
|
|
1605
1711
|
...AGENT_ROLES.filter((role) => role !== "coding" && role !== "chat").flatMap((role) => {
|
|
1606
|
-
const
|
|
1607
|
-
return own !== undefined ? [`- models: ${role}: ${shown(
|
|
1712
|
+
const named = roleModel(config, role);
|
|
1713
|
+
return named !== undefined && sets(own?.models?.[role] !== undefined) ? [`- models: ${role}: ${shown(named)}`] : [];
|
|
1608
1714
|
}),
|
|
1609
1715
|
...(() => {
|
|
1610
1716
|
const limits = AGENT_ROLES.flatMap((role) => (config.models?.[role]?.turnLimit !== undefined ? [`${role} ${config.models[role].turnLimit}s`] : []));
|
|
1611
1717
|
const all = config.models?.default?.turnLimit ?? config.turnLimit;
|
|
1612
|
-
return all !== undefined || limits.length > 0 ? [`- turn limits: ${all !== undefined ? `${all}s each` : "two minutes each"}${limits.length > 0 ? `; ${limits.join(", ")}` : ""}.`] : [];
|
|
1718
|
+
return (all !== undefined || limits.length > 0) && sets(own?.turnLimit !== undefined || own?.models !== undefined) ? [`- turn limits: ${all !== undefined ? `${all}s each` : "two minutes each"}${limits.length > 0 ? `; ${limits.join(", ")}` : ""}.`] : [];
|
|
1613
1719
|
})(),
|
|
1614
1720
|
];
|
|
1615
1721
|
})(),
|
|
1616
|
-
`- unit testing script: ${scripts.unit !== undefined ? relative(root, scripts.unit) : perModule ? "none for the whole project - each
|
|
1617
|
-
`- conformance testing script: ${scripts.conformance !== undefined ? relative(root, scripts.conformance) : perModule ? "none for the whole project - see each
|
|
1722
|
+
`- unit testing script: ${scripts.unit !== undefined ? relative(root, scripts.unit) : perModule ? "none for the whole project - each module's file below names its own" : "none found - every build stops until there is one"}`,
|
|
1723
|
+
`- conformance testing script: ${scripts.conformance !== undefined ? relative(root, scripts.conformance) : perModule ? "none for the whole project - see each module's file" : "none found"}`,
|
|
1618
1724
|
scripts.prepare !== undefined ? `- prepare script: ${relative(root, scripts.prepare)} - run on the build before every conformance testing script run, which runs only once it passes` : undefined,
|
|
1619
|
-
|
|
1620
|
-
?
|
|
1621
|
-
:
|
|
1725
|
+
!sets(own?.testingScriptsRunOn !== undefined)
|
|
1726
|
+
? undefined
|
|
1727
|
+
: config.testingScriptsRunOn === "copy"
|
|
1728
|
+
? "- testing-scripts-run-on: copy - the testing scripts run on this machine, on a fresh copy of each module's code; `testing-scripts-run-on: in-place` (the default) runs them on the code in place."
|
|
1729
|
+
: "- testing-scripts-run-on: in-place - the testing scripts run on this machine on the code in place, from the project, against the host codebase; `testing-scripts-run-on: copy` runs them on a fresh copy of each module's code.",
|
|
1622
1730
|
].filter((line) => line !== undefined),
|
|
1623
1731
|
];
|
|
1624
1732
|
};
|
|
1625
1733
|
return [
|
|
1626
1734
|
`<project config>`,
|
|
1627
|
-
`A project's ${CONFIG_FILE} sets how its
|
|
1628
|
-
"
|
|
1629
|
-
"
|
|
1630
|
-
|
|
1631
|
-
`${
|
|
1632
|
-
"answer questions about the project's settings from
|
|
1633
|
-
"asked. Name a spec by its path from here - plain/hubspot.plain - and it is built in its own project.",
|
|
1735
|
+
`A project's ${CONFIG_FILE} sets how its modules are built - and a module's own config.turri.<module>.yaml, over it, how that`,
|
|
1736
|
+
"module is built, and every module built on it that has no file of its own: its testing scripts, toolchains, models and conformance -",
|
|
1737
|
+
"a backend and a frontend each with their own scripts. Nobody chooses it: each module is built with its own file, else the one of",
|
|
1738
|
+
"a module it requires, else the project's alone - two among the modules it requires is an error to fix. A project with no",
|
|
1739
|
+
`${CONFIG_FILE} yet is read from its ${LEGACY_CONFIG_FILE} (and config.<module>.yaml). Change a setting with the settings tool,`,
|
|
1740
|
+
"never by editing these files; answer questions about the project's settings from what follows, and say when a pulse will",
|
|
1741
|
+
"differ from it because the user asked. Name a spec by its path from here - plain/hubspot.plain - and it is built in its own project.",
|
|
1634
1742
|
...projects.flatMap((dir) => ["", ...describe(dir)]),
|
|
1635
1743
|
`</project config>`,
|
|
1636
1744
|
].join("\n");
|
|
@@ -1651,9 +1759,19 @@ function conversationModel(ctx, override) {
|
|
|
1651
1759
|
* The chat's model, read now - it can change while a skill runs - or, from a context that has
|
|
1652
1760
|
* gone stale since, the model it had when it was last readable.
|
|
1653
1761
|
*/
|
|
1654
|
-
/**
|
|
1655
|
-
|
|
1656
|
-
|
|
1762
|
+
/**
|
|
1763
|
+
* The model a launch runs on: the coding model of the codebase - a launch follows steps, and a small model thinking little
|
|
1764
|
+
* does that well. Without a chat's context yet, the config's as it names it.
|
|
1765
|
+
*/
|
|
1766
|
+
function launchModel(ctx, plainFile) {
|
|
1767
|
+
try {
|
|
1768
|
+
if (ctx !== undefined)
|
|
1769
|
+
return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
|
|
1770
|
+
}
|
|
1771
|
+
catch {
|
|
1772
|
+
/* a name the chat cannot resolve: the config's, as it is */
|
|
1773
|
+
}
|
|
1774
|
+
return modelSpec(projectModels(configForSpec(plainFile)).coding);
|
|
1657
1775
|
}
|
|
1658
1776
|
function chatModelOf(ctx) {
|
|
1659
1777
|
try {
|
|
@@ -1669,7 +1787,7 @@ let lastChatModel;
|
|
|
1669
1787
|
/**
|
|
1670
1788
|
* Conformance tests turned on, for the session: `conformance-tests: true` written where the module's value comes from
|
|
1671
1789
|
* (conformance-switch.ts) - what /conform does when they are off, and a host's turnOnConformance. Every chat is told at
|
|
1672
|
-
* its next turn. `plainFile`, absolute or from the project, picks the module whose
|
|
1790
|
+
* its next turn. `plainFile`, absolute or from the project, picks the module whose own file
|
|
1673
1791
|
* is written when that names the key. Returns the file written, from the project. Starts no conformance pulse.
|
|
1674
1792
|
*/
|
|
1675
1793
|
export function turnOnConformance(core, plainFile) {
|
|
@@ -1678,24 +1796,14 @@ export function turnOnConformance(core, plainFile) {
|
|
|
1678
1796
|
}
|
|
1679
1797
|
/** The skills running in the background, by project and skill - one at a time each, whichever chat started it - with what stops them. */
|
|
1680
1798
|
const backgroundSkillRuns = new Map();
|
|
1681
|
-
/** The models chosen in this session, by kind of work - for every chat. Saved in the chat they were chosen in, so reopening it keeps them. */
|
|
1682
|
-
const chosenModels = {};
|
|
1683
|
-
/** When they were last chosen: a chat reopened with older choices of its own leaves them be. */
|
|
1684
|
-
let chosenModelsAt = 0;
|
|
1685
|
-
const MODEL_CHOICE_ENTRY = "turri_render_models";
|
|
1686
1799
|
/**
|
|
1687
|
-
* The model a
|
|
1688
|
-
*
|
|
1689
|
-
* the conversation's.
|
|
1800
|
+
* 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
|
+
* later in the background; else the coding model - `--coding-model`, or the module's config - else the conversation's.
|
|
1690
1802
|
*/
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
* of work, or the project's - `model:` in config.turri.yaml - or the conversation's.
|
|
1694
|
-
*/
|
|
1695
|
-
function jobModel(ctx, work, named, plainFile) {
|
|
1696
|
-
const model = jobModelOf(ctx, work, named, plainFile);
|
|
1803
|
+
function jobModel(ctx, named, plainFile) {
|
|
1804
|
+
const model = jobModelOf(ctx, named, plainFile);
|
|
1697
1805
|
// The AWS region worked out again, with every model a job ran on this session: the config's may have changed since,
|
|
1698
|
-
// and one
|
|
1806
|
+
// and one named on a call counts as the config's do - two needing two regions are said, not flipped between.
|
|
1699
1807
|
if (model !== undefined)
|
|
1700
1808
|
jobModels.add(model);
|
|
1701
1809
|
applyBedrockRegion(plainFile !== undefined ? projectDirOf(plainFile) : process.cwd(), { also: [...jobModels] });
|
|
@@ -1703,14 +1811,14 @@ function jobModel(ctx, work, named, plainFile) {
|
|
|
1703
1811
|
}
|
|
1704
1812
|
/** Every model a job ran on in this session. */
|
|
1705
1813
|
const jobModels = new Set();
|
|
1706
|
-
function jobModelOf(ctx,
|
|
1814
|
+
function jobModelOf(ctx, named, plainFile) {
|
|
1707
1815
|
if (named !== undefined && named.trim() !== "") {
|
|
1708
1816
|
const resolved = resolveModel(named, ctx.modelRegistry);
|
|
1709
1817
|
if (!resolved.ok)
|
|
1710
1818
|
throw new Error(describeResolution(resolved));
|
|
1711
1819
|
return resolved.model;
|
|
1712
1820
|
}
|
|
1713
|
-
return
|
|
1821
|
+
return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
|
|
1714
1822
|
}
|
|
1715
1823
|
/**
|
|
1716
1824
|
* The coding model this session starts from, and where it was given: `turri
|
|
@@ -1743,107 +1851,6 @@ function projectModel(ctx, plainFile) {
|
|
|
1743
1851
|
}
|
|
1744
1852
|
return modelSpec({ model: resolved.model, thinking });
|
|
1745
1853
|
}
|
|
1746
|
-
/** The default coding model for showing, with where it came from - never an error. */
|
|
1747
|
-
function projectModelLabel(ctx) {
|
|
1748
|
-
const given = codingModelDefault();
|
|
1749
|
-
if (given === undefined)
|
|
1750
|
-
return undefined;
|
|
1751
|
-
try {
|
|
1752
|
-
return { model: projectModel(ctx), from: given.from };
|
|
1753
|
-
}
|
|
1754
|
-
catch {
|
|
1755
|
-
return { model: `${given.named} - which cannot be used here`, from: given.from };
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* engine, for the conversation's agent and for a skill's agent - whom the person talks
|
|
1760
|
-
* to while the skill runs - alike: both write the same choice. `conversation` is the context to
|
|
1761
|
-
* read models and the chat's model from; omitted, the one the tool is called with.
|
|
1762
|
-
*/
|
|
1763
|
-
function setRenderModelTool(pi, conversation) {
|
|
1764
|
-
return defineTool({
|
|
1765
|
-
name: "engine",
|
|
1766
|
-
label: "Engine",
|
|
1767
|
-
description: "The engine: which model the agents that regenerate the code run on. With no model, say which it is. With one, choose it " +
|
|
1768
|
-
"for the rest of this session: for spec changes (every pulse the work loop plans, conformance tests included), for " +
|
|
1769
|
-
"functionalities (regenerate with funcIds named), or for everything. By default " +
|
|
1770
|
-
"each runs on the model the project's config.turri.yaml names, or else the conversation's model. The model may be given as provider/model-id or by name as " +
|
|
1771
|
-
"the user said it; a name that fits more than one model, or none with credentials, comes back as a " +
|
|
1772
|
-
"list - ask the user which they meant, never pick one yourself. Pulses already queued keep their model.",
|
|
1773
|
-
promptSnippet: "the engine: show or choose the model that regenerates the code",
|
|
1774
|
-
promptGuidelines: [
|
|
1775
|
-
"When the user says which model should regenerate or build something, call engine with it - once; it holds for the rest of the session. To say which one it is, call engine with no model.",
|
|
1776
|
-
"If engine returns several candidates, ask the user which one with ask_user or in your reply, then call it again with the exact provider/model-id.",
|
|
1777
|
-
"Say which model a pulse will run on when you start one on something other than the conversation's model.",
|
|
1778
|
-
],
|
|
1779
|
-
parameters: Type.Object({
|
|
1780
|
-
work: Type.Optional(Type.Union([Type.Literal("spec_changes"), Type.Literal("functionalities"), Type.Literal("all")], {
|
|
1781
|
-
description: "spec_changes, functionalities, or all of it. Omitted: all",
|
|
1782
|
-
})),
|
|
1783
|
-
model: Type.Optional(Type.String({
|
|
1784
|
-
description: 'provider/model-id, or the model\'s name as the user said it. "chat" goes back to the conversation\'s model. Omitted: say which it is, changing nothing',
|
|
1785
|
-
})),
|
|
1786
|
-
}),
|
|
1787
|
-
async execute(_id, given, _signal, _onUpdate, called) {
|
|
1788
|
-
const ctx = conversation ?? called;
|
|
1789
|
-
if (given.model === undefined) {
|
|
1790
|
-
const text = `The engine:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}`;
|
|
1791
|
-
return { content: [{ type: "text", text }], details: { ...chosenModels } };
|
|
1792
|
-
}
|
|
1793
|
-
const params = { work: given.work ?? "all", model: given.model };
|
|
1794
|
-
const works = params.work === "all" ? ["all", "spec_changes", "functionalities"] : [params.work];
|
|
1795
|
-
if (/^(chat|default|conversation)$/i.test(params.model.trim())) {
|
|
1796
|
-
for (const work of works)
|
|
1797
|
-
delete chosenModels[work];
|
|
1798
|
-
}
|
|
1799
|
-
else {
|
|
1800
|
-
const resolved = resolveModel(params.model, ctx.modelRegistry);
|
|
1801
|
-
if (!resolved.ok)
|
|
1802
|
-
throw new Error(describeResolution(resolved));
|
|
1803
|
-
if (params.work === "all") {
|
|
1804
|
-
delete chosenModels.spec_changes;
|
|
1805
|
-
delete chosenModels.functionalities;
|
|
1806
|
-
}
|
|
1807
|
-
chosenModels[params.work] = resolved.model;
|
|
1808
|
-
}
|
|
1809
|
-
chosenModelsAt = Date.now();
|
|
1810
|
-
pi.appendEntry(MODEL_CHOICE_ENTRY, { ...chosenModels });
|
|
1811
|
-
const text = `The engine now:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}`;
|
|
1812
|
-
return { content: [{ type: "text", text }], details: { ...chosenModels } };
|
|
1813
|
-
},
|
|
1814
|
-
});
|
|
1815
|
-
}
|
|
1816
|
-
/** Choosing which model renders what, for the rest of the session. */
|
|
1817
|
-
function registerRenderModels(pi) {
|
|
1818
|
-
// The session's choices, every chat's: a chat reopened brings back what it chose, when that is newer than what the
|
|
1819
|
-
// session has - and a fresh chat starts with the session's.
|
|
1820
|
-
let started = false;
|
|
1821
|
-
pi.on("session_start", (_event, ctx) => {
|
|
1822
|
-
if (started)
|
|
1823
|
-
return;
|
|
1824
|
-
started = true;
|
|
1825
|
-
const saved = ctx.sessionManager
|
|
1826
|
-
.getBranch()
|
|
1827
|
-
.filter((entry) => entry.type === "custom" && entry.customType === MODEL_CHOICE_ENTRY)
|
|
1828
|
-
.at(-1);
|
|
1829
|
-
const at = Date.parse(saved?.timestamp ?? "") || 1;
|
|
1830
|
-
if (saved === undefined || at <= chosenModelsAt)
|
|
1831
|
-
return;
|
|
1832
|
-
chosenModelsAt = at;
|
|
1833
|
-
for (const key of Object.keys(chosenModels))
|
|
1834
|
-
delete chosenModels[key];
|
|
1835
|
-
Object.assign(chosenModels, saved.data ?? {});
|
|
1836
|
-
});
|
|
1837
|
-
pi.registerTool(setRenderModelTool(pi));
|
|
1838
|
-
pi.registerCommand("engine", {
|
|
1839
|
-
description: "Show the engine: which model regenerates spec changes and functionalities. To change it, say so in the conversation.",
|
|
1840
|
-
handler: async (_args, ctx) => {
|
|
1841
|
-
const text = `The engine:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}\n\nTo change it, say so - e.g. "regenerate spec changes with gpt 5.5".`;
|
|
1842
|
-
if (ctx.hasUI)
|
|
1843
|
-
ctx.ui.notify(text, "info");
|
|
1844
|
-
},
|
|
1845
|
-
});
|
|
1846
|
-
}
|
|
1847
1854
|
/**
|
|
1848
1855
|
* Run the work now, or start it as a background job and hand back an id.
|
|
1849
1856
|
*
|
|
@@ -1855,8 +1862,8 @@ function registerRenderModels(pi) {
|
|
|
1855
1862
|
const workLoops = new WeakMap();
|
|
1856
1863
|
/** How the conversation wants the work planned, for the session - set with steer. */
|
|
1857
1864
|
const steeringStore = createSteeringStore();
|
|
1858
|
-
/**
|
|
1859
|
-
const
|
|
1865
|
+
/** A session's launches, by its jobs: the launch track every chat's launch tool and every pulse's launch share. */
|
|
1866
|
+
const sessionLaunches = new WeakMap();
|
|
1860
1867
|
function workLoopFor(jobs, cwd, ctx) {
|
|
1861
1868
|
let shared = workLoops.get(jobs);
|
|
1862
1869
|
if (shared === undefined) {
|
|
@@ -1864,24 +1871,14 @@ function workLoopFor(jobs, cwd, ctx) {
|
|
|
1864
1871
|
const loop = createWorkLoop({
|
|
1865
1872
|
registry: jobs,
|
|
1866
1873
|
cwd,
|
|
1867
|
-
modelFor: (plainFile) =>
|
|
1874
|
+
modelFor: (plainFile) => projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx),
|
|
1868
1875
|
// The planner reasons about the whole of the work: it runs on the chat's model.
|
|
1869
1876
|
plannerModel: () => chatModelOf(from.ctx),
|
|
1870
1877
|
// How the work is to be planned: the conversation's steering, and AGENTS.md's - read afresh each plan.
|
|
1871
1878
|
steering: (plainFile) => steeringFor(plainFile, cwd, steeringStore),
|
|
1872
|
-
//
|
|
1873
|
-
//
|
|
1874
|
-
|
|
1875
|
-
const model = releaseModel(from.ctx, plainFile);
|
|
1876
|
-
return runReleaseAgent({
|
|
1877
|
-
plainFile,
|
|
1878
|
-
cwd,
|
|
1879
|
-
state: deployStates.get(jobs) ?? createDeployState(),
|
|
1880
|
-
afterPulse: { moduleName, subject: title },
|
|
1881
|
-
onDelta,
|
|
1882
|
-
...(model !== undefined ? { model } : {}),
|
|
1883
|
-
});
|
|
1884
|
-
},
|
|
1879
|
+
// A pulse landed: its commit kept for the sentinel - and, under launch-after-pulse, launched in the background, the
|
|
1880
|
+
// codebase's next pulse not waiting on it.
|
|
1881
|
+
landed: (input) => sessionLaunches.get(jobs)?.landed(input),
|
|
1885
1882
|
});
|
|
1886
1883
|
shared = { loop, from };
|
|
1887
1884
|
workLoops.set(jobs, shared);
|
|
@@ -1955,7 +1952,7 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1955
1952
|
name: "pulses",
|
|
1956
1953
|
label: "Pulses",
|
|
1957
1954
|
description: "Pulses in every tense - earlier sessions', this session's, running now and what runs next. With no parameter: every pulse of " +
|
|
1958
|
-
"this session - finished, running, and planned, those of a look ahead marked as waiting for regenerate - what
|
|
1955
|
+
"this session - finished, running, and planned, those of a look ahead marked as waiting for regenerate - the launches and what they started, " +
|
|
1959
1956
|
"and the last runs of earlier sessions, a line a pulse - how each ended, how long, what it cost. With job_id, one pulse: " +
|
|
1960
1957
|
"running, whether it still is and its latest output; finished, its report and what the ledger recorded of it - its rounds " +
|
|
1961
1958
|
"and test runs (how many failed the same way), the verdicts, the healers, the model provider's trouble, what turri refused, " +
|
|
@@ -1965,7 +1962,8 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1965
1962
|
"of its codebase - the whole prompt its coding agent will get, from the plan regenerate runs. With plain_file, a look " +
|
|
1966
1963
|
"ahead: that module's work planned as regenerate plans it, steering and all, and kept - nothing started, its pulses waiting " +
|
|
1967
1964
|
"for regenerate, which then runs this plan unless the ***plain or the steering changed - and what is planned listed. " +
|
|
1968
|
-
"What is left to regenerate, without a plan, is drift's."
|
|
1965
|
+
"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
|
+
"history, read with git: git --git-dir=plain_modules/<module>/.plaingit log, and show <commit>.",
|
|
1969
1967
|
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",
|
|
1970
1968
|
promptGuidelines: [
|
|
1971
1969
|
"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.",
|
|
@@ -1977,7 +1975,6 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1977
1975
|
})),
|
|
1978
1976
|
plain_file: Type.Optional(Type.String({ description: "A look ahead: the .plain file of the module to plan, starting nothing. Not with job_id. Omitted: no look ahead" })),
|
|
1979
1977
|
working_dir: WORKING_DIR_PARAM,
|
|
1980
|
-
stack: STACK_PARAM,
|
|
1981
1978
|
wait: Type.Optional(Type.Boolean({ description: "With a pulse started: block until it finishes instead of reporting its current state (default false)" })),
|
|
1982
1979
|
runs: Type.Optional(Type.Number({ description: `With no parameter: how many runs of earlier sessions to list (default ${EARLIER_RUNS})` })),
|
|
1983
1980
|
}),
|
|
@@ -1988,7 +1985,7 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1988
1985
|
const given = fromWorkingDir(cwd, params);
|
|
1989
1986
|
const plainFile = resolve(given.base, given.plain_file);
|
|
1990
1987
|
refuseTestPlainFile(plainFile);
|
|
1991
|
-
return
|
|
1988
|
+
return whenBuildable(plainFile, async () => {
|
|
1992
1989
|
const loop = workLoopFor(jobs, cwd, ctx);
|
|
1993
1990
|
const statuses = await loop.lookAhead(plainFile);
|
|
1994
1991
|
return { content: [{ type: "text", text: describeLookAhead(loop, statuses) }], details: { status: "looked ahead" } };
|
|
@@ -2033,33 +2030,43 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2033
2030
|
// The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
|
|
2034
2031
|
// list, finished jobs included, put in the transcript where it stays.
|
|
2035
2032
|
pi.registerCommand("halt", {
|
|
2036
|
-
description: "Halt a queued or running pulse, a module's planned pulses, or what
|
|
2033
|
+
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>]",
|
|
2037
2034
|
handler: async (args, ctx) => {
|
|
2038
2035
|
if (!ctx.hasUI)
|
|
2039
2036
|
return;
|
|
2040
2037
|
const live = jobs.list().filter((job) => job.status === "running" || job.status === "queued");
|
|
2041
|
-
const
|
|
2038
|
+
const servers = runningLaunched();
|
|
2039
|
+
const track = sessionLaunches.get(jobs)?.track;
|
|
2040
|
+
const underWay = (track?.list() ?? []).filter((launch) => launch.status === "running" || launch.status === "waiting");
|
|
2042
2041
|
const loop = workLoops.get(jobs)?.loop;
|
|
2043
2042
|
// A module's planned pulses, one line a module: halting one halts the module.
|
|
2044
2043
|
const plannedRows = loop?.planned() ?? [];
|
|
2045
2044
|
const planned = [...new Set(plannedRows.map((row) => row.module ?? ""))].filter((module) => module !== "");
|
|
2046
2045
|
let id = args.trim();
|
|
2047
2046
|
if (id === "") {
|
|
2048
|
-
if (live.length === 0 &&
|
|
2049
|
-
return ctx.ui.notify("Nothing is regenerating, queued or
|
|
2047
|
+
if (live.length === 0 && servers.length === 0 && underWay.length === 0 && planned.length === 0)
|
|
2048
|
+
return ctx.ui.notify("Nothing is regenerating, queued, planned or launched.", "info");
|
|
2050
2049
|
const label = (job) => `${job.id} ${job.status.padEnd(8)} ${pulseName(job)}`;
|
|
2051
2050
|
const plannedLabel = (module) => {
|
|
2052
2051
|
const rows = plannedRows.filter((row) => row.module === module);
|
|
2053
2052
|
const waiting = rows.find((row) => row.id.endsWith("-waiting"));
|
|
2054
2053
|
return `${module} ${waiting !== undefined ? waiting.summary : `${rows.length} planned`} - halts the module`;
|
|
2055
2054
|
};
|
|
2056
|
-
const labels = [
|
|
2055
|
+
const labels = [
|
|
2056
|
+
...live.map(label),
|
|
2057
|
+
...planned.map(plannedLabel),
|
|
2058
|
+
...underWay.map(describeLaunchLine),
|
|
2059
|
+
...servers.map((item) => launchedLabel(item.name, item.url ?? item.command)),
|
|
2060
|
+
];
|
|
2057
2061
|
const picked = await ctx.ui.select("Halt which?", labels);
|
|
2058
2062
|
const job = live.find((candidate) => picked !== undefined && label(candidate) === picked);
|
|
2059
2063
|
const module = planned.find((name) => picked !== undefined && plannedLabel(name) === picked);
|
|
2060
|
-
const
|
|
2064
|
+
const launch = underWay.find((candidate) => picked !== undefined && describeLaunchLine(candidate) === picked);
|
|
2065
|
+
const server = servers.find((item) => picked !== undefined && launchedLabel(item.name, item.url ?? item.command) === picked);
|
|
2061
2066
|
if (server !== undefined)
|
|
2062
|
-
id = `
|
|
2067
|
+
id = `launched ${server.name}`;
|
|
2068
|
+
else if (launch !== undefined)
|
|
2069
|
+
id = `launched ${launch.codebase}`;
|
|
2063
2070
|
else if (job !== undefined)
|
|
2064
2071
|
id = job.id;
|
|
2065
2072
|
else if (module !== undefined)
|
|
@@ -2067,11 +2074,9 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2067
2074
|
else
|
|
2068
2075
|
return;
|
|
2069
2076
|
}
|
|
2070
|
-
const name = /^
|
|
2071
|
-
if (name !== undefined)
|
|
2072
|
-
|
|
2073
|
-
return shownAfterCommand(pi, ctx, `/halt ${id}`, stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running as ${name}.`, "info");
|
|
2074
|
-
}
|
|
2077
|
+
const name = /^launched\s+(.+)$/.exec(id)?.[1]?.trim();
|
|
2078
|
+
if (name !== undefined)
|
|
2079
|
+
return shownAfterCommand(pi, ctx, `/halt ${id}`, await haltLaunched(name, track), "info");
|
|
2075
2080
|
ctx.ui.notify(stopJob(jobs, id, undefined, loop), "info");
|
|
2076
2081
|
},
|
|
2077
2082
|
});
|
|
@@ -2094,23 +2099,6 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2094
2099
|
pi.appendEntry(HISTORY_ENTRY, { module: name, text: historyLog(defaultBuildDir(name, cwd)) });
|
|
2095
2100
|
},
|
|
2096
2101
|
});
|
|
2097
|
-
pi.registerTool({
|
|
2098
|
-
name: "lineage",
|
|
2099
|
-
label: "Lineage",
|
|
2100
|
-
description: "Read a module's lineage: every generation of its code and tests - each regeneration, conformance run and spec change, " +
|
|
2101
|
-
"with what it was regenerated from - as git commits. Without a commit, the log; with one, that commit in full - its message and " +
|
|
2102
|
-
"the change it made.",
|
|
2103
|
-
promptSnippet: "a module's lineage: what was regenerated into it, and when",
|
|
2104
|
-
parameters: Type.Object({
|
|
2105
|
-
module: Type.String({ description: "The module's name" }),
|
|
2106
|
-
commit: Type.Optional(Type.String({ description: "A commit from the log, to see in full" })),
|
|
2107
|
-
}),
|
|
2108
|
-
async execute(_id, params) {
|
|
2109
|
-
const buildDir = defaultBuildDir(params.module, cwd);
|
|
2110
|
-
const text = params.commit ? historyShow(buildDir, params.commit) : historyLog(buildDir);
|
|
2111
|
-
return { content: [{ type: "text", text }], details: {} };
|
|
2112
|
-
},
|
|
2113
|
-
});
|
|
2114
2102
|
// The side panel: the regeneration - and the pulses behind p - over the whole screen, or beside the chat (s, from one to
|
|
2115
2103
|
// the other). Its key (PANEL_KEY) opens it; the key again closes it and goes back to the chat, as esc does over the
|
|
2116
2104
|
// screen - beside the chat, the key switches sides, giving the keys to the chat or the panel, as esc gives them to the
|
|
@@ -2152,9 +2140,9 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2152
2140
|
openPanel(ctx);
|
|
2153
2141
|
},
|
|
2154
2142
|
});
|
|
2155
|
-
// /
|
|
2143
|
+
// /settings: every setting of config.turri.yaml from the chat, each taking effect as it says - what turri fixed at its
|
|
2156
2144
|
// start changed here, as it runs.
|
|
2157
|
-
|
|
2145
|
+
registerSettings(pi, {
|
|
2158
2146
|
cwd,
|
|
2159
2147
|
rules: ruleNames,
|
|
2160
2148
|
chatSpec: () => modelSpec(projectModels(readProjectConfig(cwd)).harness),
|
|
@@ -2183,11 +2171,6 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2183
2171
|
dropped.push(`--coding-model ${process.env[CODING_MODEL_ENV]}`);
|
|
2184
2172
|
delete process.env[CODING_MODEL_ENV];
|
|
2185
2173
|
}
|
|
2186
|
-
chosenModelsAt = Date.now();
|
|
2187
|
-
for (const work of Object.keys(chosenModels)) {
|
|
2188
|
-
dropped.push(`the engine's ${work === "all" ? "" : `${work.replace(/_/g, " ")} `}model ${chosenModels[work]}`);
|
|
2189
|
-
delete chosenModels[work];
|
|
2190
|
-
}
|
|
2191
2174
|
return dropped.length === 0 ? undefined : `Chosen this session, and given way to the config: ${dropped.join("; ")}.`;
|
|
2192
2175
|
},
|
|
2193
2176
|
parallelJobs: (count) => {
|
|
@@ -2200,18 +2183,42 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2200
2183
|
}
|
|
2201
2184
|
export { fromWorkingDir };
|
|
2202
2185
|
const WATCH_REDRAW_MS = 500;
|
|
2186
|
+
/**
|
|
2187
|
+
* What a chat's agent is told of a pulse it asked for that ended, with the sentinel off. One that landed under
|
|
2188
|
+
* launch-after-pulse is being launched as it is told: it says so, and offers nothing else for it - it is told once the
|
|
2189
|
+
* launch ends.
|
|
2190
|
+
*/
|
|
2191
|
+
export function pulseEndNote(job, options = {}) {
|
|
2192
|
+
const head = job.status === "succeeded"
|
|
2193
|
+
? `Pulse ${job.id} (${job.kind}) finished after ${formatDuration(job)}.\n\n${job.report ?? ""}`
|
|
2194
|
+
: job.status === "stopped"
|
|
2195
|
+
? `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
|
+
: `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
|
|
2197
|
+
const landed = job.status === "succeeded" && job.details?.landed === true;
|
|
2198
|
+
if (!landed || options.launching !== true)
|
|
2199
|
+
return `${head}\n\n${JOB_FINISHED_REACTION}`;
|
|
2200
|
+
return [
|
|
2201
|
+
head,
|
|
2202
|
+
"",
|
|
2203
|
+
"It landed, and turri is launching the commit it landed now, in the background (launch-after-pulse): you are told once",
|
|
2204
|
+
"that launch ends - where it runs, or why it did not come up. React to this now - the person has not asked, and need",
|
|
2205
|
+
"not: say in a line or two what landed and that it is being launched. Offer nothing else for it - do not call launch,",
|
|
2206
|
+
"open it, run it or test it, and never say nothing runs - and start no other work, unless guidance for this project",
|
|
2207
|
+
"(its AGENTS.md, a skill, what the person said) says to do something besides launching it when a pulse finishes: do",
|
|
2208
|
+
"that. When you are told it is launched, do what you were told to do once something is launched.",
|
|
2209
|
+
].join("\n");
|
|
2210
|
+
}
|
|
2203
2211
|
/**
|
|
2204
2212
|
* What the agent is to do with a job that just ended, unasked: what the project's guidance says to do then, or else say
|
|
2205
2213
|
* in a line or two what ended - the person saw it end already, in the transcript.
|
|
2206
2214
|
*/
|
|
2207
2215
|
export const JOB_FINISHED_REACTION = [
|
|
2208
2216
|
"React to this now - the person has not asked, and need not. If guidance for this project - its AGENTS.md, a skill,",
|
|
2209
|
-
"what the person said earlier - says what to do when a pulse finishes (
|
|
2217
|
+
"what the person said earlier - says what to do when a pulse finishes (launch what was built, run something, tell",
|
|
2210
2218
|
"someone), do that, as it says. Otherwise say in a line or two what finished and what it means for the person - the",
|
|
2211
2219
|
"report is theirs to read in full; do not repeat it - and, when it failed, what they can do. Start no other work.",
|
|
2212
|
-
"
|
|
2213
|
-
"
|
|
2214
|
-
"told to do once something is released (opening it where the person can watch it, saying what to test), if anything.",
|
|
2220
|
+
"Under launch-after-pulse turri launches what a pulse lands itself, in the background: do not call launch for it - you",
|
|
2221
|
+
"are told once it is launched, and do then what you were told to do once something is launched.",
|
|
2215
2222
|
"A pulse that stopped on its environment - \"stopped: turri's sandbox kept its agents from…\" or \"stopped: the",
|
|
2216
2223
|
"environment lacks…\" - stops the same way again until that is fixed: never regenerate it before. Heal it, then regenerate the",
|
|
2217
2224
|
"module to resume:",
|
|
@@ -2526,9 +2533,9 @@ function modulesWithHistory(cwd) {
|
|
|
2526
2533
|
}
|
|
2527
2534
|
/** Stop a job by id or id prefix, and say what that means for the queue. */
|
|
2528
2535
|
/** Every job, in the order it was started, with what a queued one is waiting for. */
|
|
2529
|
-
/** What
|
|
2530
|
-
function
|
|
2531
|
-
return `
|
|
2536
|
+
/** What a launch started, as /halt offers it. */
|
|
2537
|
+
function launchedLabel(name, what) {
|
|
2538
|
+
return `launched ${name} running ${what}`;
|
|
2532
2539
|
}
|
|
2533
2540
|
/** The jobs as the person is shown them: those started, and those the work loop has planned after them. */
|
|
2534
2541
|
function shownJobs(jobs) {
|
|
@@ -2536,8 +2543,10 @@ function shownJobs(jobs) {
|
|
|
2536
2543
|
}
|
|
2537
2544
|
function listJobs(jobs, cwd, runs = EARLIER_RUNS) {
|
|
2538
2545
|
const all = [...shownJobs(jobs)].reverse().filter((job) => job.replacedBy === undefined);
|
|
2539
|
-
const
|
|
2540
|
-
const
|
|
2546
|
+
const servers = runningLaunched().map((item) => `launched ${item.name} running ${item.moduleName}: ${item.url ?? item.command} (pid ${item.pid}, output in ${relative(process.cwd(), item.log) || item.log})`);
|
|
2547
|
+
const launches = (sessionLaunches.get(jobs)?.track.list() ?? []).slice(-10).reverse().map(describeLaunchLine);
|
|
2548
|
+
const listed = (launches.length > 0 ? `\n\nLaunches, newest first - /halt launched <module> halts one under way:\n${launches.join("\n")}` : "") +
|
|
2549
|
+
(servers.length > 0 ? `\n\nWhat launches started - /halt launched <name> halts one:\n${servers.join("\n")}` : "");
|
|
2541
2550
|
const before = earlierRuns(jobs, cwd, runs);
|
|
2542
2551
|
if (all.length === 0)
|
|
2543
2552
|
return `No pulses have been started in this session.${listed}${before}`;
|
|
@@ -2664,11 +2673,6 @@ function registerSteering(pi, cwd) {
|
|
|
2664
2673
|
},
|
|
2665
2674
|
});
|
|
2666
2675
|
}
|
|
2667
|
-
/**
|
|
2668
|
-
* Deploy: the conversation puts what is built out in dist/<module> and starts it on this machine (see
|
|
2669
|
-
* regenerate/release.ts), installing what it needs in its own shell - nothing is put to the person. What it
|
|
2670
|
-
* started is stopped when the session ends.
|
|
2671
|
-
*/
|
|
2672
2676
|
const SIDE_ENTRY = "turri_btw";
|
|
2673
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. */
|
|
2674
2678
|
const SKILL_MESSAGE_ENTRY = "turri_skill_message";
|
|
@@ -2741,20 +2745,37 @@ async function askOnTheSide(pi, ctx, cwd, jobs, question) {
|
|
|
2741
2745
|
}
|
|
2742
2746
|
return answer;
|
|
2743
2747
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2748
|
+
/** A launch ended, told to a chat's agent - to tell the person where it runs, or why it did not come up. */
|
|
2749
|
+
function tellLaunch(pi, jobs, launch) {
|
|
2750
|
+
const job = "pulse" in launch.cause ? jobs.get(launch.cause.pulse) : undefined;
|
|
2751
|
+
void pi.sendMessage({ customType: "turri_launch", content: launchedNote(launch, job), display: false, details: { launch: launch.id, status: launch.status } }, { triggerTurn: true, deliverAs: "followUp" });
|
|
2752
|
+
}
|
|
2753
|
+
/** A newer launch took the place of one a chat asked for, told to its agent: it hears that one's end instead. */
|
|
2754
|
+
function tellReplaced(pi, jobs, launch, next) {
|
|
2755
|
+
const job = "pulse" in next.cause ? jobs.get(next.cause.pulse) : undefined;
|
|
2756
|
+
void pi.sendMessage({ customType: "turri_launch", content: replacedNote(launch, next, job), display: false, details: { launch: launch.id, status: launch.status, replacedBy: next.id } }, { triggerTurn: true, deliverAs: "followUp" });
|
|
2757
|
+
}
|
|
2758
|
+
function registerLaunch(pi, cwd, jobs) {
|
|
2759
|
+
const launches = sessionLaunches.get(jobs);
|
|
2760
|
+
if (launches !== undefined) {
|
|
2761
|
+
pi.registerTool(launchTool({
|
|
2762
|
+
cwd,
|
|
2763
|
+
track: launches.track,
|
|
2764
|
+
defaultPlainFile: () => readProjectConfig(cwd).module,
|
|
2765
|
+
chat: () => currentChat()?.id,
|
|
2766
|
+
// Told in the chat that asked, as a launch after a pulse is with the sentinel off.
|
|
2767
|
+
ended: (launch) => tellLaunch(pi, jobs, launch),
|
|
2768
|
+
replaced: (launch, next) => tellReplaced(pi, jobs, launch, next),
|
|
2769
|
+
wait: (ctx) => shouldWait(ctx.mode, undefined),
|
|
2770
|
+
}));
|
|
2771
|
+
}
|
|
2772
|
+
pi.registerTool(haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop, ...(launches !== undefined ? { launches: launches.track } : {}) }));
|
|
2773
|
+
// What launches started runs until turri ends - not when a chat is opened, closed, forked or reloaded.
|
|
2755
2774
|
pi.on("session_shutdown", async (event) => {
|
|
2756
|
-
if (event.reason
|
|
2757
|
-
|
|
2775
|
+
if (event.reason !== "quit")
|
|
2776
|
+
return;
|
|
2777
|
+
await launches?.track.stop();
|
|
2778
|
+
await stopLaunched();
|
|
2758
2779
|
});
|
|
2759
2780
|
}
|
|
2760
2781
|
const MILESTONE_ENTRY = "turri_milestone";
|
|
@@ -2975,9 +2996,11 @@ function registerBranding(pi, skills) {
|
|
|
2975
2996
|
(data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
|
|
2976
2997
|
// A newer turri out, or one installed and hidden behind this one: said first, under the version it is about.
|
|
2977
2998
|
...(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)),
|
|
2978
3001
|
`${theme.fg("text", "the first coding agent with the power of ")}${brandPink(theme)("regenerative software")}`,
|
|
2979
3002
|
// Where the settings are changed, without leaving the chat.
|
|
2980
|
-
theme.fg("muted", "configure with /
|
|
3003
|
+
theme.fg("muted", "configure with /settings"),
|
|
2981
3004
|
// Only what is wrong: skills that did not load, and agents' commands less fenced than they should be.
|
|
2982
3005
|
...(data.pending > 0 ? [theme.fg("warning", `${data.pending} skill${data.pending === 1 ? "" : "s"} failed to load`)] : []),
|
|
2983
3006
|
...(data.sandbox !== undefined && data.sandbox.level !== "ok" ? [theme.fg(data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)] : []),
|
|
@@ -3026,6 +3049,7 @@ function registerBranding(pi, skills) {
|
|
|
3026
3049
|
pending: skills.pending.length,
|
|
3027
3050
|
sandbox: sandboxSummary(),
|
|
3028
3051
|
versions: versions.lines,
|
|
3052
|
+
config: configLines(ctx.cwd),
|
|
3029
3053
|
});
|
|
3030
3054
|
}
|
|
3031
3055
|
catch {
|