@turri-dev/cli 0.2.3-next.fea0bd9 → 0.2.4-next.009bd0c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -62
- package/dist/bedrock-region.js +3 -3
- package/dist/chat-idle.d.ts +2 -2
- package/dist/chat-idle.js +2 -2
- package/dist/chat-models.d.ts +1 -1
- package/dist/chat-models.js +1 -1
- package/dist/chat-scope.d.ts +1 -3
- package/dist/chat-skills.d.ts +1 -1
- package/dist/chat-skills.js +1 -1
- package/dist/chats.d.ts +44 -20
- package/dist/chats.js +125 -64
- package/dist/cli.js +42 -31
- package/dist/config-edit.d.ts +20 -8
- package/dist/config-edit.js +32 -26
- package/dist/config.d.ts +106 -78
- package/dist/config.js +267 -133
- package/dist/conform-cli.js +14 -3
- package/dist/conformance-switch.d.ts +13 -22
- package/dist/conformance-switch.js +37 -59
- package/dist/drift-cli.js +1 -1
- package/dist/extension.d.ts +31 -12
- package/dist/extension.js +555 -556
- package/dist/genome.js +10 -49
- package/dist/graph.js +3 -5
- package/dist/host-session.d.ts +11 -21
- package/dist/host-session.js +6 -8
- package/dist/host.d.ts +4 -4
- package/dist/host.js +4 -7
- package/dist/identity.js +2 -3
- package/dist/init-config.d.ts +1 -2
- package/dist/init-config.js +10 -17
- package/dist/installed-providers.d.ts +1 -1
- package/dist/installed-providers.js +2 -2
- package/dist/launch-agent.d.ts +41 -0
- package/dist/launch-agent.js +219 -0
- package/dist/{release-cli.js → launch-cli.js} +41 -24
- package/dist/launch-session.d.ts +58 -0
- package/dist/launch-session.js +195 -0
- package/dist/launch-tools.d.ts +28 -0
- package/dist/launch-tools.js +69 -0
- package/dist/launch-track.d.ts +120 -0
- package/dist/launch-track.js +298 -0
- package/dist/loop-cli.d.ts +4 -3
- package/dist/loop-cli.js +17 -15
- package/dist/loop-tools.d.ts +45 -21
- package/dist/loop-tools.js +155 -90
- package/dist/new-project.js +2 -2
- package/dist/notice.d.ts +7 -6
- package/dist/parse-cli.js +2 -2
- package/dist/pi-launch.js +4 -1
- package/dist/pi-settings.d.ts +4 -0
- package/dist/pi-settings.js +39 -0
- package/dist/pi.js +12 -9
- package/dist/plain/check.d.ts +2 -9
- package/dist/plain/check.js +6 -39
- package/dist/plain-files.d.ts +2 -2
- package/dist/plain-files.js +7 -7
- package/dist/regenerate/activity.d.ts +0 -7
- package/dist/regenerate/activity.js +2 -20
- package/dist/regenerate/agent-env.d.ts +1 -1
- package/dist/regenerate/agent-env.js +3 -3
- package/dist/regenerate/agent-shell.js +5 -3
- package/dist/regenerate/audit.js +9 -0
- package/dist/regenerate/base-folder.d.ts +2 -2
- package/dist/regenerate/base-folder.js +1 -1
- package/dist/regenerate/cases.js +7 -0
- package/dist/regenerate/chunk-plan.d.ts +5 -0
- package/dist/regenerate/chunk-plan.js +16 -1
- package/dist/regenerate/command-check.d.ts +1 -1
- package/dist/regenerate/command-check.js +1 -1
- package/dist/regenerate/delivery.d.ts +1 -1
- package/dist/regenerate/delivery.js +3 -3
- package/dist/regenerate/drift.d.ts +4 -0
- package/dist/regenerate/drift.js +26 -6
- package/dist/regenerate/failure-reports.d.ts +28 -0
- package/dist/regenerate/failure-reports.js +79 -0
- package/dist/regenerate/job-panel.js +3 -1
- package/dist/regenerate/jobs-tree.js +1 -1
- package/dist/regenerate/jobs.d.ts +4 -2
- package/dist/regenerate/jobs.js +14 -10
- package/dist/regenerate/launch.d.ts +126 -0
- package/dist/regenerate/{release.js → launch.js} +60 -48
- package/dist/regenerate/ledger-view.d.ts +11 -24
- package/dist/regenerate/ledger-view.js +14 -60
- package/dist/regenerate/ledger.d.ts +26 -16
- package/dist/regenerate/ledger.js +1 -1
- package/dist/regenerate/lineage.d.ts +2 -0
- package/dist/regenerate/lineage.js +8 -0
- package/dist/regenerate/loop.d.ts +57 -65
- package/dist/regenerate/loop.js +354 -171
- package/dist/regenerate/model-names.d.ts +33 -0
- package/dist/regenerate/{engine.js → model-names.js} +2 -28
- package/dist/regenerate/paths.d.ts +3 -3
- package/dist/regenerate/paths.js +4 -4
- package/dist/regenerate/records.d.ts +11 -0
- package/dist/regenerate/records.js +15 -0
- package/dist/regenerate/regenerate.d.ts +0 -2
- package/dist/regenerate/regenerate.js +4 -15
- package/dist/regenerate/renames.js +4 -4
- package/dist/regenerate/requires.d.ts +7 -0
- package/dist/regenerate/requires.js +24 -18
- package/dist/regenerate/scripts-being-written.d.ts +4 -4
- package/dist/regenerate/scripts-being-written.js +3 -3
- package/dist/regenerate/spec-map.js +3 -3
- package/dist/regenerate/standing.js +1 -1
- package/dist/regenerate/submit-work.d.ts +2 -0
- package/dist/regenerate/submit-work.js +8 -3
- package/dist/regenerate/test-scripts.d.ts +2 -1
- package/dist/regenerate/test-scripts.js +33 -23
- package/dist/regenerate/testing-steps.d.ts +16 -5
- package/dist/regenerate/testing-steps.js +28 -9
- package/dist/regenerate-cli.js +18 -9
- package/dist/self-invocation.d.ts +11 -0
- package/dist/self-invocation.js +37 -11
- package/dist/sentinel-check.d.ts +3 -3
- package/dist/sentinel-check.js +3 -3
- package/dist/sentinel.d.ts +17 -12
- package/dist/sentinel.js +75 -46
- package/dist/{config-command.d.ts → settings.d.ts} +13 -8
- package/dist/{config-command.js → settings.js} +155 -24
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +7 -7
- package/dist/skill.d.ts +0 -11
- package/dist/skill.js +0 -9
- package/dist/tools.js +2 -3
- package/dist/turri-versions.js +2 -1
- package/docs/README.md +4 -6
- package/docs/authoring-plain.md +3 -3
- package/docs/chats.md +6 -9
- package/docs/claude-subscription.md +8 -8
- package/docs/config.md +62 -52
- package/docs/development.md +4 -5
- package/docs/headless.md +7 -6
- package/docs/hosting.md +25 -24
- package/docs/installation.md +4 -0
- package/docs/launch.md +63 -0
- package/docs/parser.md +3 -3
- package/docs/regenerating.md +30 -22
- package/docs/sandbox.md +3 -3
- package/docs/sentinel.md +27 -16
- package/docs/skills-and-gates.md +6 -11
- package/docs/using.md +26 -42
- package/genome/rules/project-model.md +2 -1
- package/genome/rules/test-plain-files.md +15 -7
- package/genome/rules/turri-regeneration.md +7 -10
- package/genome/skills/convert-old-syntax/SKILL.md +5 -5
- package/genome/skills/implement-conformance-testing-script/SKILL.md +2 -2
- package/genome/skills/implement-unit-testing-script/SKILL.md +3 -3
- package/package.json +1 -1
- package/dist/advisor-chat.d.ts +0 -63
- package/dist/advisor-chat.js +0 -290
- package/dist/change-plain-cli.js +0 -55
- package/dist/ledger-cli.d.ts +0 -1
- package/dist/ledger-cli.js +0 -50
- package/dist/ledger-tools.d.ts +0 -10
- package/dist/ledger-tools.js +0 -64
- package/dist/regenerate/advisor-records.d.ts +0 -93
- package/dist/regenerate/advisor-records.js +0 -110
- package/dist/regenerate/advisor-runs.d.ts +0 -87
- package/dist/regenerate/advisor-runs.js +0 -327
- package/dist/regenerate/engine.d.ts +0 -52
- package/dist/regenerate/release.d.ts +0 -121
- package/dist/regenerate/test-advisor.d.ts +0 -101
- package/dist/regenerate/test-advisor.js +0 -379
- package/dist/release-agent.d.ts +0 -43
- package/dist/release-agent.js +0 -130
- package/dist/release-cli.d.ts +0 -1
- package/dist/release-tools.d.ts +0 -44
- package/dist/release-tools.js +0 -170
- package/dist/spec-tools.d.ts +0 -36
- package/dist/spec-tools.js +0 -128
- package/dist/stacks.d.ts +0 -13
- package/dist/stacks.js +0 -96
- package/docs/deploy.md +0 -48
- package/docs/test-advisor.md +0 -110
- /package/dist/{change-plain-cli.d.ts → launch-cli.d.ts} +0 -0
package/dist/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";
|
|
@@ -18,30 +18,29 @@ import { findTestScripts, scriptKindOfSkill } from "./regenerate/test-scripts.js
|
|
|
18
18
|
import { writingScript } from "./regenerate/scripts-being-written.js";
|
|
19
19
|
import { applyBedrockRegion } from "./bedrock-region.js";
|
|
20
20
|
import { bannerWarnings } from "./turri-versions.js";
|
|
21
|
-
import {
|
|
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, 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
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import { advisorDir } from "./regenerate/advisor-records.js";
|
|
44
|
-
import { bindAdvisor, evaluateTestsTool, TEST_ADVISOR_BLOCK, verdictDelivery } from "./advisor-chat.js";
|
|
42
|
+
import { didNotLand } from "./regenerate/failure-reports.js";
|
|
43
|
+
import { conformanceRefusal, createWorkLoop, describeModules, isUpToDate } from "./regenerate/loop.js";
|
|
45
44
|
import { brandNeon, brandPink, plainPaint } from "./regenerate/plain-palette.js";
|
|
46
45
|
import { halfBlocks, JELLYFISH_FRAME_MS, JELLYFISH_REST, JELLYFISH_SEQUENCE, JELLYFISH_TEXT_FRAMES } from "./jellyfish.js";
|
|
47
46
|
import { createJobPanel, didNotPass, keyPressed, PANEL_KEY, spinner } from "./regenerate/job-panel.js";
|
|
@@ -54,25 +53,23 @@ import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
|
|
|
54
53
|
import { createSpecMapState } from "./regenerate/spec-map-view.js";
|
|
55
54
|
import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
|
|
56
55
|
import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
|
|
57
|
-
import { HISTORY_DIR, historyLog
|
|
56
|
+
import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
|
|
58
57
|
import { defaultBuildDir } from "./regenerate/paths.js";
|
|
59
58
|
import { describeTurnIncident, describeUsage, JobStoppedError, onModelEvent } from "./regenerate/activity.js";
|
|
60
59
|
import { ledgerWanted, startLedger } from "./regenerate/ledger.js";
|
|
61
60
|
import { describePastPulse, describeRuns, earlierPulses, ledgerProjects } from "./regenerate/ledger-view.js";
|
|
62
61
|
import { doctorTool } from "./doctor-tool.js";
|
|
63
|
-
import { ledgerTool } from "./ledger-tools.js";
|
|
64
62
|
import { describeSpecConflict } from "./regenerate/stop-report.js";
|
|
65
63
|
import { inheritProviders, inheritThinkingLevel } from "./pi.js";
|
|
66
64
|
import { LOADING_PROVIDERS } from "./installed-providers.js";
|
|
67
65
|
import { machineChange, machineChangeReason, writesPlain } from "./regenerate/command-check.js";
|
|
68
66
|
import { beginCapture, captureConsole, describeCaptured, dropNoise } from "./quiet.js";
|
|
69
67
|
import { loadRules, renderRulesBlock } from "./rules.js";
|
|
70
|
-
import {
|
|
68
|
+
import { registerSettings, ruleNames } from "./settings.js";
|
|
71
69
|
import { writeSetting } from "./config-edit.js";
|
|
72
70
|
import { describeStdlib } from "./stdlib.js";
|
|
73
71
|
import { DECLINED, peekKeyListener, runAsk } from "./ask.js";
|
|
74
72
|
import { QuestionDialog } from "./question-dialog.js";
|
|
75
|
-
import { registerStacks } from "./stacks.js";
|
|
76
73
|
import { catalogueLine, chosenCommand, createCommandGate, startPicked, discoverSkills, leftOutNote, startedByCommandOnly } from "./skills.js";
|
|
77
74
|
import { supersededByTurri } from "./chat-skills.js";
|
|
78
75
|
import { conversationIdentity } from "./identity.js";
|
|
@@ -84,7 +81,7 @@ import { currentChat } from "./chat-scope.js";
|
|
|
84
81
|
import { registerChats } from "./chat-commands.js";
|
|
85
82
|
import { turriIdentity } from "./environment.js";
|
|
86
83
|
import { answerSideQuestion, askWithAsides, BTW_HOW, runningSkill, skillRunStarted, skillSessionText, transcriptOf } from "./btw.js";
|
|
87
|
-
import { createJobRegistry, defaultParallelJobs, describeJob,
|
|
84
|
+
import { createJobRegistry, defaultParallelJobs, describeJob, formatDuration, pulseName, shouldWait, STOPPED_ON_REQUEST, } from "./regenerate/jobs.js";
|
|
88
85
|
/**
|
|
89
86
|
* Makes gated skills reachable from a conversation.
|
|
90
87
|
*
|
|
@@ -103,6 +100,15 @@ const PACKAGE_ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
|
103
100
|
* exchange is therefore reported back, so the interview is visible while it happens and
|
|
104
101
|
* survives in the tool's result afterwards.
|
|
105
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.";
|
|
106
112
|
export function askUserVia(ctx, onExchange,
|
|
107
113
|
/** Given, "/btw ..." typed as an answer is a side question: answered with this, and the question asked again. */
|
|
108
114
|
aside,
|
|
@@ -110,7 +116,7 @@ aside,
|
|
|
110
116
|
dialogs) {
|
|
111
117
|
return async (request) => {
|
|
112
118
|
if (dialogs === undefined && !ctx.hasUI) {
|
|
113
|
-
return
|
|
119
|
+
return NO_USER_ANSWER;
|
|
114
120
|
}
|
|
115
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
|
|
116
122
|
// opened, and it comes back as DECLINED.
|
|
@@ -331,8 +337,27 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
331
337
|
core?.jobFinished(job);
|
|
332
338
|
},
|
|
333
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);
|
|
334
358
|
core = createChats({
|
|
335
359
|
cwd,
|
|
360
|
+
launches,
|
|
336
361
|
host,
|
|
337
362
|
jobs,
|
|
338
363
|
extension: (pi, link) => turriExtension(pi, core, link),
|
|
@@ -349,32 +374,6 @@ export function createTurriCore(host = {}, options = {}) {
|
|
|
349
374
|
hosts.set(jobs, host);
|
|
350
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.
|
|
351
376
|
setSurface(jobs, host.surface);
|
|
352
|
-
// What release has shipped, module by module: release does nothing for a module whose last commit it already shipped.
|
|
353
|
-
deployStates.set(jobs, createDeployState());
|
|
354
|
-
// The test advisor watches what the work loop looks at, and picks up what it left pending when turri last quit.
|
|
355
|
-
if (options.advisor === true) {
|
|
356
|
-
// The conversation's own words on how the work is to be planned - AGENTS.md the advisor reads itself.
|
|
357
|
-
const context = (plainFile) => [...steeringStore.get(EVERY_MODULE), ...steeringStore.get(moduleNameOf(plainFile))];
|
|
358
|
-
const advisor = createTestAdvisor({
|
|
359
|
-
context,
|
|
360
|
-
// A verdict goes to the chat the person looks at - a host's too - which writes the scenarios on a yes.
|
|
361
|
-
onVerdict: (verdict) => void session.advised(verdict),
|
|
362
|
-
});
|
|
363
|
-
advisors.set(jobs, advisor);
|
|
364
|
-
// Where it may have left work pending: the folder turri runs in, and a project in a folder of it - ***plain kept in plain/.
|
|
365
|
-
const projects = () => {
|
|
366
|
-
try {
|
|
367
|
-
return [cwd, ...readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && existsSync(advisorDir(join(cwd, entry.name)))).map((entry) => join(cwd, entry.name))];
|
|
368
|
-
}
|
|
369
|
-
catch {
|
|
370
|
-
return [cwd];
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
setTimeout(() => {
|
|
374
|
-
for (const project of projects())
|
|
375
|
-
advisor.resume(project);
|
|
376
|
-
}, 0).unref?.();
|
|
377
|
-
}
|
|
378
377
|
// What this session does, as facts, in the project's .turri/ledger - a pulse's own in its project. Said once, in the
|
|
379
378
|
// chat shown, when it cannot be written.
|
|
380
379
|
if (ledgerWanted()) {
|
|
@@ -427,7 +426,7 @@ export function sessionLoop(session) {
|
|
|
427
426
|
}
|
|
428
427
|
/**
|
|
429
428
|
* turri's extension, built into one chat of the session: its tools, commands and handlers run in the chat's scope -
|
|
430
|
-
* its
|
|
429
|
+
* its id on the pulses it asks for - on the session's job registry and work loop.
|
|
431
430
|
*/
|
|
432
431
|
function turriExtension(api, session, link) {
|
|
433
432
|
const pi = scopedToChat(api, link.scope);
|
|
@@ -463,75 +462,70 @@ function turriExtension(api, session, link) {
|
|
|
463
462
|
// gets the full report as a hidden message that starts a turn of its own - at once when it is
|
|
464
463
|
// idle, else as soon as the turn it is in ends (a follow-up, never cutting into a reply or an
|
|
465
464
|
// interview) - so it reacts to every job that ends without waiting for the person to speak:
|
|
466
|
-
// 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
|
|
467
466
|
// what finished. In the chat that asked for the pulse, shown or not.
|
|
468
467
|
const announce = (job) => {
|
|
469
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;
|
|
470
472
|
// A spec that contradicts itself is the person's to settle, now: the agent is started on it.
|
|
471
473
|
if (job.specConflict !== undefined) {
|
|
472
474
|
void pi.sendMessage({ customType: "turri_spec_conflict", content: specConflictTask(job.specConflict), display: false, details: { jobId: job.id } }, { triggerTurn: true });
|
|
473
475
|
return;
|
|
474
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
|
+
}
|
|
475
484
|
void pi.sendMessage({
|
|
476
485
|
customType: "turri_job",
|
|
477
|
-
content: (job
|
|
478
|
-
? `Pulse ${job.id} (${job.kind}) finished after ${formatDuration(job)}.\n\n${job.report ?? ""}`
|
|
479
|
-
: job.status === "stopped"
|
|
480
|
-
? `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." : ""}`
|
|
481
|
-
: `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`) +
|
|
482
|
-
`\n\n${JOB_FINISHED_REACTION}`,
|
|
486
|
+
content: pulseEndNote(job, { launching }),
|
|
483
487
|
display: false,
|
|
484
488
|
details: { jobId: job.id, status: job.status },
|
|
485
489
|
}, { triggerTurn: true, deliverAs: "followUp" });
|
|
486
490
|
};
|
|
487
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
|
|
488
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
|
|
489
|
-
// 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).
|
|
490
494
|
const brief = async (job, context) => {
|
|
491
|
-
const
|
|
495
|
+
const launch = sessionLaunches.get(jobs)?.forPulse(job) ?? { later: [], laterSpecs: [], running: [] };
|
|
492
496
|
const content = sentinelBrief(job, {
|
|
493
497
|
project: cwd,
|
|
494
498
|
...(context.asked !== undefined ? { asked: context.asked } : {}),
|
|
495
499
|
...(context.focused !== undefined ? { focused: context.focused } : {}),
|
|
496
|
-
|
|
497
|
-
releaseAfterPulse: config.releaseAfterPulse === true,
|
|
500
|
+
launch,
|
|
498
501
|
reaction: JOB_FINISHED_REACTION,
|
|
499
502
|
});
|
|
500
503
|
void pi.sendMessage({ customType: "turri_sentinel_pulse", content, display: false, details: { jobId: job.id, status: job.status } }, { triggerTurn: true });
|
|
501
504
|
};
|
|
502
|
-
// The sentinel's: functional specs a host asked it to check
|
|
503
|
-
//
|
|
504
|
-
// 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.
|
|
505
507
|
const briefCheck = async (check, context) => {
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
if (currentRelease(state, check.plainFile, check.module) === undefined) {
|
|
509
|
-
// Behind, never made, or what it started died: released afresh - the release tool would say it shipped that already.
|
|
510
|
-
state.released.delete(check.module);
|
|
511
|
-
let said;
|
|
512
|
-
try {
|
|
513
|
-
const ctx = contextNow();
|
|
514
|
-
const model = ctx !== undefined ? releaseModel(ctx, check.plainFile) : undefined;
|
|
515
|
-
said = await runReleaseAgent({ plainFile: check.plainFile, cwd, state, inModule: check.module, forCheck: { moduleName: check.module }, ...(model !== undefined ? { model } : {}) });
|
|
516
|
-
}
|
|
517
|
-
catch (error) {
|
|
518
|
-
return error instanceof Error ? error.message : String(error);
|
|
519
|
-
}
|
|
520
|
-
if (currentRelease(state, check.plainFile, check.module) === undefined)
|
|
521
|
-
return said.trim() || "its last commit was not released";
|
|
522
|
-
releasedNow = true;
|
|
523
|
-
}
|
|
524
|
-
const commit = state.released.get(check.module)?.commit;
|
|
508
|
+
const current = sessionLaunches.get(jobs)?.track.current(check.module);
|
|
509
|
+
const commit = current?.short;
|
|
525
510
|
const content = sentinelCheckBrief(check, {
|
|
526
511
|
specs: checkedSpecs(check),
|
|
527
|
-
|
|
528
|
-
releasedNow,
|
|
512
|
+
running: runningLaunched(check.module),
|
|
529
513
|
...(commit !== undefined ? { commit } : {}),
|
|
514
|
+
...(current?.status === "failed" ? { failed: { id: current.id, ...(current.summary !== undefined ? { summary: current.summary } : {}) } } : {}),
|
|
530
515
|
...(context.focused !== undefined ? { focused: context.focused } : {}),
|
|
531
516
|
});
|
|
532
517
|
void pi.sendMessage({ customType: "turri_sentinel_check", content, display: false, details: { checkId: check.id, module: check.module, funcIds: check.funcIds } }, { triggerTurn: true });
|
|
533
|
-
return undefined;
|
|
534
518
|
};
|
|
519
|
+
// The sentinel's: its check carried on in the conversation it was in, once its codebase was launched again.
|
|
520
|
+
const resume = async (work) => {
|
|
521
|
+
const launches = sessionLaunches.get(jobs);
|
|
522
|
+
if (launches === undefined)
|
|
523
|
+
return;
|
|
524
|
+
const content = launches.resumeText(work);
|
|
525
|
+
void pi.sendMessage({ customType: "turri_sentinel_resume", content, display: false }, { triggerTurn: true });
|
|
526
|
+
};
|
|
527
|
+
// A launch this chat is to hear of ended: its agent told how it went, to tell the person.
|
|
528
|
+
const launched = (launch) => tellLaunch(pi, jobs, launch);
|
|
535
529
|
// A pulse ended, with the sentinel on: said in the chat. One that landed is told to its agent too, to tell the person
|
|
536
530
|
// it landed and what the sentinel does with it - and nothing more: the pulse is the sentinel's. ***plain that
|
|
537
531
|
// contradicts itself is put to the person at once, by turri itself, as the chat would have been started on it.
|
|
@@ -539,31 +533,36 @@ function turriExtension(api, session, link) {
|
|
|
539
533
|
announceJob(pi, job);
|
|
540
534
|
if (job.specConflict !== undefined)
|
|
541
535
|
session.notice(specConflictNotice(job, specConflictTask(job.specConflict)));
|
|
542
|
-
if (options.tell !== true)
|
|
536
|
+
if (options.tell !== true || toldByWaitingCall(jobs, job))
|
|
543
537
|
return;
|
|
544
538
|
// A host that shows the person the pulse's end itself: the chat knows of it - in order, with no turn of its own.
|
|
545
539
|
const shown = host.pulseEndsShown === true;
|
|
546
|
-
|
|
540
|
+
let launching = false;
|
|
541
|
+
try {
|
|
542
|
+
launching = readProjectConfig(cwd, job.configModule).launchAfterPulse === true;
|
|
543
|
+
}
|
|
544
|
+
catch {
|
|
545
|
+
/* a config that cannot be read launches nothing */
|
|
546
|
+
}
|
|
547
|
+
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" });
|
|
547
548
|
};
|
|
548
549
|
const notices = noticeDialogs(pi, session, link, contextNow);
|
|
549
|
-
// The test advisor's verdicts, once the chat is idle: a yes starts a turn that writes its scenarios, a no is a line.
|
|
550
|
-
const verdicts = verdictDelivery(pi, link, contextNow);
|
|
551
550
|
link.live({
|
|
552
551
|
announce,
|
|
553
552
|
landed,
|
|
554
553
|
brief,
|
|
555
554
|
briefCheck,
|
|
555
|
+
resume,
|
|
556
|
+
launched,
|
|
556
557
|
notice: notices.put,
|
|
557
558
|
noticeOver: notices.over,
|
|
558
559
|
concluded: notices.concluded,
|
|
559
|
-
advised: verdicts.put,
|
|
560
560
|
act: (task) => {
|
|
561
561
|
void pi.sendMessage({ customType: "turri_notice_answer", content: task, display: false }, { triggerTurn: true, deliverAs: "followUp" });
|
|
562
562
|
},
|
|
563
563
|
jobsChanged: () => panel.refresh(),
|
|
564
564
|
thinkingLevel: () => pi.getThinkingLevel(),
|
|
565
565
|
context: contextNow,
|
|
566
|
-
conformanceSwitched: () => conformanceTools(),
|
|
567
566
|
});
|
|
568
567
|
pi.on("session_start", (_event, ctx) => {
|
|
569
568
|
lastContext = ctx;
|
|
@@ -576,7 +575,7 @@ function turriExtension(api, session, link) {
|
|
|
576
575
|
// With them, the instruction to do turri's work with its tools rather than its command
|
|
577
576
|
// line - enforced below, not only asked for.
|
|
578
577
|
const rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"), readProjectConfig(cwd).rulesOff ?? []);
|
|
579
|
-
// Laid out again once rules-off changes - /
|
|
578
|
+
// Laid out again once rules-off changes - /settings changes it as turri runs - and the same block in between.
|
|
580
579
|
let rulesKept = { off: (readProjectConfig(cwd).rulesOff ?? []).join(","), block: chatRulesBlock(rules) };
|
|
581
580
|
const rulesBlock = () => {
|
|
582
581
|
const off = readProjectConfig(cwd).rulesOff ?? [];
|
|
@@ -616,8 +615,6 @@ function turriExtension(api, session, link) {
|
|
|
616
615
|
pulseEndsBlock(session.sentinelOn()),
|
|
617
616
|
// Conformance tests - what they are, whether they are on here, and how they are turned on: every turn, read afresh.
|
|
618
617
|
conformanceBlock(conformanceTestsOnIn(cwd)),
|
|
619
|
-
// The test advisor, and that the chat alone writes scenarios - while the session has one the project wants.
|
|
620
|
-
...(sessionAdvisor(session) !== undefined && conformanceTestsOnIn(cwd) && readProjectConfig(cwd).testAdvisor !== false ? [TEST_ADVISOR_BLOCK] : []),
|
|
621
618
|
projectConfigBlock(cwd),
|
|
622
619
|
machineBlock(cwd, machine.now()),
|
|
623
620
|
rulesBlock(),
|
|
@@ -737,40 +734,10 @@ function turriExtension(api, session, link) {
|
|
|
737
734
|
});
|
|
738
735
|
registerRegenerate(pi, cwd, jobs);
|
|
739
736
|
registerDrift(pi, cwd, jobs);
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
registerRenderModels(pi);
|
|
743
|
-
registerDeploy(pi, cwd, jobs, deployStates.get(jobs) ?? createDeployState());
|
|
737
|
+
registerBind(pi, cwd, jobs, (plainFile) => turnOnConformance(session, plainFile));
|
|
738
|
+
registerLaunch(pi, cwd, jobs);
|
|
744
739
|
registerSteering(pi, cwd);
|
|
745
740
|
registerSideQuestions(pi, cwd, jobs);
|
|
746
|
-
registerStacks(pi, cwd);
|
|
747
|
-
// The chat's own way to the test advisor, while the session has one - whatever test-advisor says.
|
|
748
|
-
if (sessionAdvisor(session) !== undefined)
|
|
749
|
-
pi.registerTool(evaluateTestsTool({ cwd, advisor: () => sessionAdvisor(session) }));
|
|
750
|
-
// Conformance tests on or off: conform and evaluate_tests are the chat's while they are on, the tool that turns them on
|
|
751
|
-
// while they are off - set as each turn starts, and at once when the chat turns them on. Not the sentinel's: it has its own.
|
|
752
|
-
const conformanceTools = () => {
|
|
753
|
-
if (isSentinel)
|
|
754
|
-
return;
|
|
755
|
-
try {
|
|
756
|
-
const on = conformanceTestsOnIn(cwd);
|
|
757
|
-
const registered = new Set(pi.getAllTools().map((tool) => tool.name));
|
|
758
|
-
const active = pi.getActiveTools();
|
|
759
|
-
const wanted = [
|
|
760
|
-
...active.filter((name) => !CONFORMANCE_TOOLS.includes(name) && name !== TURN_ON_TOOL),
|
|
761
|
-
...(on ? CONFORMANCE_TOOLS : [TURN_ON_TOOL]).filter((name) => registered.has(name)),
|
|
762
|
-
];
|
|
763
|
-
if (wanted.length !== active.length || wanted.some((name) => !active.includes(name)))
|
|
764
|
-
pi.setActiveTools(wanted);
|
|
765
|
-
}
|
|
766
|
-
catch {
|
|
767
|
-
/* not bound to a session yet: the next turn sets them */
|
|
768
|
-
}
|
|
769
|
-
};
|
|
770
|
-
if (!isSentinel)
|
|
771
|
-
pi.registerTool(turnOnConformanceTestsTool({ turnOn: (plainFile) => turnOnConformance(session, plainFile) }));
|
|
772
|
-
pi.on("session_start", () => conformanceTools());
|
|
773
|
-
pi.on("before_agent_start", () => conformanceTools());
|
|
774
741
|
// More chats beside this one, in the terminal: /chat, alt+n, alt+1…9 (chat-commands.ts).
|
|
775
742
|
if (session.terminal)
|
|
776
743
|
registerChats(pi, session);
|
|
@@ -802,29 +769,29 @@ function turriExtension(api, session, link) {
|
|
|
802
769
|
if (backgroundSkillRuns.has(key)) {
|
|
803
770
|
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 } };
|
|
804
771
|
}
|
|
805
|
-
const model = skill.model === "coding" ? jobModel(ctx,
|
|
806
|
-
const
|
|
772
|
+
const model = skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx);
|
|
773
|
+
const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
|
|
807
774
|
const kind = scriptKindOfSkill(skill.name);
|
|
808
775
|
const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
|
|
809
776
|
// While it writes a testing script, the modules that need it wait for it rather than fail for want of it.
|
|
810
|
-
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(
|
|
777
|
+
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
811
778
|
const controller = new AbortController();
|
|
812
779
|
backgroundSkillRuns.set(key, controller);
|
|
813
780
|
const context = [
|
|
814
781
|
conversationContext(ctx, params.context),
|
|
815
|
-
shown !== undefined ? `It is for ${shown}${
|
|
782
|
+
shown !== undefined ? `It is for ${shown}${configModule !== undefined ? `, built with ${moduleConfigFile(configModule)} over ${CONFIG_FILE}` : ""}.` : undefined,
|
|
816
783
|
BACKGROUND_NOTE,
|
|
817
784
|
]
|
|
818
785
|
.filter((part) => part !== undefined && part.trim() !== "")
|
|
819
786
|
.join("\n\n");
|
|
820
787
|
const filesBefore = projectFiles(cwd);
|
|
821
|
-
const writes = ["write", "edit", "bash"
|
|
788
|
+
const writes = ["write", "edit", "bash"].some((tool) => skill.allowedTools.includes(tool));
|
|
822
789
|
const quiet = { step: () => { }, artifact: () => { }, gate: () => { }, judge: () => { }, outcome: () => { } };
|
|
823
790
|
const about = runDetails(kind, shown);
|
|
824
791
|
const end = (ended) => skillRunEnds.put(ended.ok
|
|
825
792
|
? { skill: skill.name, ok: true, line: doneLine(skill.name, ended.changed, kind), ...about }
|
|
826
793
|
: { skill: skill.name, ok: false, line: `${skill.name} ${ended.why}.`, task: failedTask(skill.name, ended.why, ended.output, kind), ...about });
|
|
827
|
-
void captureConsole(() =>
|
|
794
|
+
void captureConsole(() => withConfigModule(configModule, () => runSkill({
|
|
828
795
|
skillDir: skill.dir,
|
|
829
796
|
signal: controller.signal,
|
|
830
797
|
cwd,
|
|
@@ -896,7 +863,7 @@ function turriExtension(api, session, link) {
|
|
|
896
863
|
description: "Start a new run even though an interrupted one exists here, discarding it.",
|
|
897
864
|
})),
|
|
898
865
|
plainFile: Type.Optional(Type.String({
|
|
899
|
-
description: "The module the skill's work is for - its .plain file, e.g. backend.plain: a testing script is written for that module
|
|
866
|
+
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, " +
|
|
900
867
|
"on its coding model. Omitted: the project's.",
|
|
901
868
|
})),
|
|
902
869
|
}),
|
|
@@ -913,7 +880,7 @@ function turriExtension(api, session, link) {
|
|
|
913
880
|
// The conformance testing script is for conformance tests: none is written while they are off.
|
|
914
881
|
if (scriptKindOfSkill(skill.name) === "conformance" && !conformanceTestsOnIn(cwd)) {
|
|
915
882
|
return {
|
|
916
|
-
content: [{ type: "text", text: `${skill.name} writes the conformance testing script,
|
|
883
|
+
content: [{ type: "text", text: `${skill.name} writes the conformance testing script, for conformance tests. ${CONFORMANCE_OFF_REFUSAL}` }],
|
|
917
884
|
details: { notStarted: true },
|
|
918
885
|
};
|
|
919
886
|
}
|
|
@@ -1043,13 +1010,20 @@ function turriExtension(api, session, link) {
|
|
|
1043
1010
|
},
|
|
1044
1011
|
};
|
|
1045
1012
|
// What the run changes in the project's ***plain - its specs, resources, scripts - is said with its result: a skill
|
|
1046
|
-
// that writes nothing is not taken for one that did its work. Only those: a
|
|
1013
|
+
// that writes nothing is not taken for one that did its work. Only those: a launch or a running app changes other
|
|
1047
1014
|
// files while it runs, and they are not its doing.
|
|
1048
1015
|
const filesBefore = projectFiles(cwd);
|
|
1049
1016
|
// A side question asked while it runs is told what it has done so far.
|
|
1050
|
-
const
|
|
1051
|
-
//
|
|
1052
|
-
|
|
1017
|
+
const ran_ = skillRunStarted({ skill: skill.name, dir: skill.dir, step: () => live.step, trace: () => [...trace], runDir });
|
|
1018
|
+
// A testing script being written - here to its end, in print mode - holds the modules it is for, as in the background:
|
|
1019
|
+
// a pulse started meanwhile, by a regenerate called beside it, would run against the script as it was.
|
|
1020
|
+
const kind = scriptKindOfSkill(skill.name);
|
|
1021
|
+
const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
|
|
1022
|
+
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
1023
|
+
const ended = () => {
|
|
1024
|
+
written();
|
|
1025
|
+
ran_();
|
|
1026
|
+
};
|
|
1053
1027
|
const ran = await captureConsole(() => runSkill({
|
|
1054
1028
|
skillDir: skill.dir,
|
|
1055
1029
|
// The chat's turn stopped - ctrl+c, esc - stops the run with it.
|
|
@@ -1068,20 +1042,20 @@ function turriExtension(api, session, link) {
|
|
|
1068
1042
|
push(` A: ${answer}`);
|
|
1069
1043
|
recordExchange(pi, { skill: skill.name, question, answer, ...(said !== undefined && said.trim() !== "" ? { said: said.trim() } : {}) });
|
|
1070
1044
|
}, (question) => askOnTheSide(pi, ctx, cwd, jobs, question), dialogs),
|
|
1071
|
-
model: skill.model === "coding" ? jobModel(ctx,
|
|
1045
|
+
model: skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx),
|
|
1072
1046
|
// Renders queued by a step land in the same registry as everything else, so
|
|
1073
1047
|
// pulses sees them without knowing a skill started them.
|
|
1074
1048
|
// Asked per job as it is queued, so a model chosen mid-interview applies from then on.
|
|
1075
1049
|
renderQueue: workLoopFor(jobs, cwd, ctx),
|
|
1076
1050
|
// The person answers the skill's agent while it runs, so it can take "render these with ..." too.
|
|
1077
1051
|
// parse too: a skill parses what it wrote with the same check the conversation has.
|
|
1078
|
-
sharedTools: [
|
|
1052
|
+
sharedTools: [checkPlainTool(cwd), ...createWebTools()],
|
|
1079
1053
|
// The conversation's own regenerate, drift, halt and conform, on its loop: a skill waits for nothing, and regenerates on the model chosen.
|
|
1080
1054
|
loopTools: [
|
|
1081
|
-
regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named
|
|
1055
|
+
regenerateTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, named, plainFile), wait: () => false }),
|
|
1082
1056
|
driftTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx) }),
|
|
1083
|
-
haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop }),
|
|
1084
|
-
conformTool({ cwd, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx,
|
|
1057
|
+
haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop, ...(sessionLaunches.get(jobs) !== undefined ? { launches: sessionLaunches.get(jobs).track } : {}) }),
|
|
1058
|
+
conformTool({ cwd, jobs, loop: () => workLoopFor(jobs, cwd, ctx), model: (_skill, plainFile, named) => jobModel(ctx, named, plainFile), wait: () => false }),
|
|
1085
1059
|
],
|
|
1086
1060
|
// The escalation becomes a real dialog - the host's own, when it has them. Without one there is nobody to ask,
|
|
1087
1061
|
// so the gate stands.
|
|
@@ -1126,7 +1100,7 @@ function turriExtension(api, session, link) {
|
|
|
1126
1100
|
push(noise);
|
|
1127
1101
|
const changes = changedFiles(filesBefore, projectFiles(cwd, filesBefore.keys()));
|
|
1128
1102
|
// A skill that only reads and reports - an analysis - changes nothing, and its result is its verdict.
|
|
1129
|
-
const writes = ["write", "edit", "bash"
|
|
1103
|
+
const writes = ["write", "edit", "bash"].some((tool) => skill.allowedTools.includes(tool));
|
|
1130
1104
|
const changed = changes.length > 0
|
|
1131
1105
|
? `It changed ${changes.length} file${changes.length === 1 ? "" : "s"} in the project: ${changes.join(", ")}.`
|
|
1132
1106
|
: writes
|
|
@@ -1139,22 +1113,16 @@ function turriExtension(api, session, link) {
|
|
|
1139
1113
|
const owner = moduleOfTestPlainFile(resolve(cwd, path));
|
|
1140
1114
|
return owner === undefined ? path : `${path} (a test plain file of ${owner.plainFile !== undefined ? relative(cwd, owner.plainFile) : owner.module})`;
|
|
1141
1115
|
});
|
|
1142
|
-
const unrendered = specsChanged.length > 0
|
|
1116
|
+
const unrendered = specsChanged.length > 0
|
|
1143
1117
|
? `${named.join(", ")} changed, and nothing is regenerated from that yet: call regenerate for ${named.length === 1 ? "its module" : "their modules"}, and the code and its conformance tests are brought up to the spec.`
|
|
1144
1118
|
: "";
|
|
1145
1119
|
const gated = skill.steps.some((step) => step.gate !== undefined);
|
|
1146
|
-
const first = skill.allowedTools.includes("change_plain") ? firstRegeneration(jobs.list(), began) : {};
|
|
1147
|
-
const ttfr = first.started === undefined
|
|
1148
|
-
? ""
|
|
1149
|
-
: `Time to first regeneration: ${formatElapsed(first.started)} - its first pulse started that long after ${skill.name} began` +
|
|
1150
|
-
(first.landed !== undefined ? `, and landed after ${formatElapsed(first.landed)}.` : ".");
|
|
1151
1120
|
const said = heard.length > 0 ? ["", `While it ran, the person said to it - its agent read and acted on each:`, ...heard.map((text) => `- ${text.replace(/\s+/g, " ").trim()}`)] : [];
|
|
1152
1121
|
const text = result.ok
|
|
1153
1122
|
? [
|
|
1154
1123
|
gated ? `${skill.name}: passed all gates.` : `${skill.name}: finished. It has no review gates, so nothing checked its work: read what it changed before you report it.`,
|
|
1155
1124
|
changed,
|
|
1156
1125
|
...(unrendered !== "" ? [unrendered] : []),
|
|
1157
|
-
...(ttfr !== "" ? [ttfr] : []),
|
|
1158
1126
|
...said,
|
|
1159
1127
|
"",
|
|
1160
1128
|
"<artifact>",
|
|
@@ -1175,7 +1143,7 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1175
1143
|
cwd,
|
|
1176
1144
|
jobs,
|
|
1177
1145
|
loop: (ctx) => workLoopFor(jobs, cwd, ctx),
|
|
1178
|
-
model: (ctx, plainFile, named
|
|
1146
|
+
model: (ctx, plainFile, named) => jobModel(ctx, named, plainFile),
|
|
1179
1147
|
wait: (ctx, asked) => shouldWait(ctx.mode, asked),
|
|
1180
1148
|
}));
|
|
1181
1149
|
// /regenerate: the same as the tool, from the person - a module brought up to its spec as it is now, cut into pulses
|
|
@@ -1187,41 +1155,13 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1187
1155
|
const command = `/regenerate ${args.trim()}`.trim();
|
|
1188
1156
|
await echoCommand(pi, command);
|
|
1189
1157
|
const say = (text, level) => shownAfterCommand(pi, ctx, command, text, level, true);
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1192
|
-
const { named, rest } = moduleNamedFirst(cwd, all);
|
|
1193
|
-
if (named === undefined && first.endsWith(".plain")) {
|
|
1194
|
-
say(`There is no ${first} here.`, "error");
|
|
1158
|
+
const picked = await commandModule(cwd, ctx, args, say, { verb: "regenerate", outcome: "regenerated" });
|
|
1159
|
+
if (picked === undefined)
|
|
1195
1160
|
return;
|
|
1196
|
-
}
|
|
1161
|
+
const { plainFile } = picked;
|
|
1197
1162
|
// Functional specs named first, each as module:func-id, as on the command line; what follows them is guidance.
|
|
1198
|
-
const words = rest;
|
|
1199
|
-
const again = [];
|
|
1200
|
-
while (words.length > 0 && /^[^\s:]+:[a-z0-9-]+,?$/.test(words[0]))
|
|
1201
|
-
again.push(words.shift().replace(/,$/, ""));
|
|
1163
|
+
const { funcIds: again, rest: words } = funcIdsNamedFirst(picked.rest);
|
|
1202
1164
|
const guidance = words.join(" ").trim();
|
|
1203
|
-
let plainFile = named;
|
|
1204
|
-
if (plainFile === undefined) {
|
|
1205
|
-
const modules = defaultMapFiles(cwd);
|
|
1206
|
-
if (modules.length === 0) {
|
|
1207
|
-
say("No .plain file to regenerate: name one - /regenerate app.plain - or set module: in config.turri.yaml.", "warning");
|
|
1208
|
-
return;
|
|
1209
|
-
}
|
|
1210
|
-
if (modules.length === 1 || !ctx.hasUI)
|
|
1211
|
-
plainFile = modules[0];
|
|
1212
|
-
else {
|
|
1213
|
-
const label = (file) => relative(cwd, file) || basename(file);
|
|
1214
|
-
const picked = await ctx.ui.select("Regenerate which module?", modules.map(label));
|
|
1215
|
-
plainFile = modules.find((file) => label(file) === picked);
|
|
1216
|
-
if (plainFile === undefined)
|
|
1217
|
-
return;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
const check = checkPlainFile(plainFile);
|
|
1221
|
-
if (!check.ok) {
|
|
1222
|
-
say(`${relative(cwd, plainFile) || plainFile} does not parse, so nothing can be regenerated from it yet:\n${formatCheckResults([check])}`, "error");
|
|
1223
|
-
return;
|
|
1224
|
-
}
|
|
1225
1165
|
// From scratch - started over, its code deleted - asked in the person's words: started at once, as asked.
|
|
1226
1166
|
const scratch = asksFromScratch(guidance);
|
|
1227
1167
|
// The whole chain with it - "from scratch, the whole chain" - every module it requires built again from the bottom.
|
|
@@ -1232,7 +1172,7 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1232
1172
|
return;
|
|
1233
1173
|
}
|
|
1234
1174
|
const loop = workLoopFor(jobs, cwd, ctx);
|
|
1235
|
-
const model = jobModel(ctx,
|
|
1175
|
+
const model = jobModel(ctx, undefined, plainFile);
|
|
1236
1176
|
const request = { ...(model !== undefined ? { model } : {}), ...(guidance !== "" ? { guidance } : {}) };
|
|
1237
1177
|
// Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
|
|
1238
1178
|
// began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
|
|
@@ -1247,8 +1187,8 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1247
1187
|
const target = plainFile;
|
|
1248
1188
|
void (async () => {
|
|
1249
1189
|
try {
|
|
1250
|
-
//
|
|
1251
|
-
const statuses = await
|
|
1190
|
+
// Refused when its config cannot be told, or would build it with no testing script.
|
|
1191
|
+
const statuses = await whenBuildable(target, () => scratch
|
|
1252
1192
|
? loop.fromScratch(target, { ...request, chain })
|
|
1253
1193
|
: again.length > 0
|
|
1254
1194
|
? loop.regenerateAgain(target, again, request)
|
|
@@ -1270,6 +1210,55 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1270
1210
|
},
|
|
1271
1211
|
});
|
|
1272
1212
|
}
|
|
1213
|
+
/**
|
|
1214
|
+
* The module a /regenerate or /conform is for, and the words after it: the one its first words name, else the one
|
|
1215
|
+
* `module:` names, else the folder's top modules to pick from - checked to parse. Undefined, said why, when there is
|
|
1216
|
+
* none to take, or the person picked none.
|
|
1217
|
+
*/
|
|
1218
|
+
async function commandModule(cwd, ctx, args, say, words) {
|
|
1219
|
+
const all = args.trim().split(/\s+/).filter((word) => word !== "");
|
|
1220
|
+
const [first = ""] = all;
|
|
1221
|
+
const { named, rest } = moduleNamedFirst(cwd, all);
|
|
1222
|
+
if (named === undefined && first.endsWith(".plain")) {
|
|
1223
|
+
say(`There is no ${first} here.`, "error");
|
|
1224
|
+
return undefined;
|
|
1225
|
+
}
|
|
1226
|
+
let plainFile = named;
|
|
1227
|
+
if (plainFile === undefined) {
|
|
1228
|
+
const modules = defaultMapFiles(cwd);
|
|
1229
|
+
if (modules.length === 0) {
|
|
1230
|
+
say(`No .plain file to ${words.verb}: name one - /${words.verb} app.plain - or set module: in config.turri.yaml.`, "warning");
|
|
1231
|
+
return undefined;
|
|
1232
|
+
}
|
|
1233
|
+
if (modules.length === 1 || !ctx.hasUI)
|
|
1234
|
+
plainFile = modules[0];
|
|
1235
|
+
else {
|
|
1236
|
+
const label = (file) => relative(cwd, file) || basename(file);
|
|
1237
|
+
const picked = await ctx.ui.select(`${words.verb === "regenerate" ? "Regenerate" : "Conform"} which module?`, modules.map(label));
|
|
1238
|
+
plainFile = modules.find((file) => label(file) === picked);
|
|
1239
|
+
if (plainFile === undefined)
|
|
1240
|
+
return undefined;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
const check = checkPlainFile(plainFile);
|
|
1244
|
+
if (!check.ok) {
|
|
1245
|
+
say(`${relative(cwd, plainFile) || plainFile} does not parse, so nothing can be ${words.outcome} from it yet:\n${formatCheckResults([check])}`, "error");
|
|
1246
|
+
return undefined;
|
|
1247
|
+
}
|
|
1248
|
+
return { plainFile, rest };
|
|
1249
|
+
}
|
|
1250
|
+
/** The functional specs a command's words name first, each as module:func-id - a comma after one allowed - and the words after them. */
|
|
1251
|
+
export function funcIdsNamedFirst(words) {
|
|
1252
|
+
const rest = [...words];
|
|
1253
|
+
const funcIds = [];
|
|
1254
|
+
while (rest.length > 0 && /^[^\s:]+:[a-z0-9-]+,?$/.test(rest[0]))
|
|
1255
|
+
funcIds.push(rest.shift().replace(/,$/, ""));
|
|
1256
|
+
return { funcIds, rest };
|
|
1257
|
+
}
|
|
1258
|
+
/** Whether a /conform's words after its functional specs ask for a pulse a functional spec - "one by one", "separately". */
|
|
1259
|
+
export function asksOneByOne(words) {
|
|
1260
|
+
return /\b(one[\s-]+(by|at)[\s-]+(one|a[\s-]+time)|separately|each[\s-]+(on[\s-]+its[\s-]+own|alone))\b/i.test(words);
|
|
1261
|
+
}
|
|
1273
1262
|
/**
|
|
1274
1263
|
* What a slash command showed the person: kept in the chat, where they read it, and put in the conversation as well -
|
|
1275
1264
|
* unseen there - so that when they speak of it next ("fix it"), the agent knows what they saw. A command runs outside
|
|
@@ -1294,12 +1283,26 @@ echoed = false, react) {
|
|
|
1294
1283
|
void pi.sendMessage({ customType: COMMAND_OUTCOME, content, display: false }, { triggerTurn: true, deliverAs: "followUp" });
|
|
1295
1284
|
}
|
|
1296
1285
|
/**
|
|
1297
|
-
* What the agent does once /regenerate has started pulses: a command's output alone leaves the chat silent,
|
|
1298
|
-
* person wondering whether to wait. It says what runs, and that they need not - and starts nothing itself.
|
|
1286
|
+
* What the agent does once /regenerate or /conform has started pulses: a command's output alone leaves the chat silent,
|
|
1287
|
+
* and the person wondering whether to wait. It says what runs, and that they need not - and starts nothing itself.
|
|
1299
1288
|
*/
|
|
1300
|
-
export const COMMAND_STARTED_REACTION = "My pulses are
|
|
1289
|
+
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 " +
|
|
1301
1290
|
"runs and what is planned - and that the two of us can go on with the ***plain, or anything else, meanwhile: they need " +
|
|
1302
|
-
"not wait for it. Start nothing for it: no regenerate, no check, no
|
|
1291
|
+
"not wait for it. Start nothing for it: no regenerate, no check, no launch - its end is told when it comes.";
|
|
1292
|
+
/**
|
|
1293
|
+
* What the agent does when /conform started nothing: answers it at once - why, and what would let it start - and offers
|
|
1294
|
+
* to do that, rather than leave the person with a refusal and a silent chat.
|
|
1295
|
+
*/
|
|
1296
|
+
export const CONFORM_REFUSED_REACTION = "Nothing was started from the person's /conform, for the reason shown - and their /conform is their yes to conformance " +
|
|
1297
|
+
"tests here. Where what is missing is yours to write - the test reqs, the conformance testing script, the scenarios - " +
|
|
1298
|
+
"write it now, in that order and only what is missing, asking nothing: the test reqs first; then the conformance testing " +
|
|
1299
|
+
"script, started with its skill before anything else - it runs in the background, so the scenarios are written while it " +
|
|
1300
|
+
"does; then the scenarios of the functional specs they named, " +
|
|
1301
|
+
"or, naming none, of each functional spec that needs them by the rules on test plain files. Then call regenerate for the " +
|
|
1302
|
+
"module: the work loop writes and runs their tests once the code is built. Say in a line or two what you wrote, and for " +
|
|
1303
|
+
"each functional spec why it needs scenarios - or, when none does, that and why. Where it is not yours to settle - a " +
|
|
1304
|
+
"functional spec they named that is not there, ***plain that would have to change its meaning to be tested - tell them " +
|
|
1305
|
+
"why nothing started and what would let it, and start nothing.";
|
|
1303
1306
|
export const COMMAND_OUTCOME = "turri_command_outcome";
|
|
1304
1307
|
/** Longer than a frame of the TUI's (16ms): an entry appended before it is drawn by its end. */
|
|
1305
1308
|
const ONE_FRAME_MS = 20;
|
|
@@ -1346,13 +1349,100 @@ function plainFileNamed(cwd, word) {
|
|
|
1346
1349
|
function registerDrift(pi, cwd, jobs) {
|
|
1347
1350
|
pi.registerTool(driftTool({ cwd, jobs, loop: (ctx) => workLoopFor(jobs, cwd, ctx) }));
|
|
1348
1351
|
}
|
|
1349
|
-
function registerBind(pi, cwd, jobs) {
|
|
1352
|
+
function registerBind(pi, cwd, jobs, turnOn) {
|
|
1350
1353
|
pi.registerTool(conformTool({
|
|
1351
1354
|
cwd,
|
|
1355
|
+
jobs,
|
|
1352
1356
|
loop: (ctx) => workLoopFor(jobs, cwd, ctx),
|
|
1353
|
-
model: (ctx, plainFile, named) => jobModel(ctx,
|
|
1357
|
+
model: (ctx, plainFile, named) => jobModel(ctx, named, plainFile),
|
|
1354
1358
|
wait: (ctx, asked) => shouldWait(ctx.mode, asked),
|
|
1355
1359
|
}));
|
|
1360
|
+
// /conform: the same as the tool, from the person - a module's conformance tests written and run now, for the
|
|
1361
|
+
// functional specs named or every one with scenarios, in one pulse unless asked for one a functional spec. Asking for
|
|
1362
|
+
// them is asking for them on: off, they are turned on first. What would start nothing is found before anything is
|
|
1363
|
+
// said, and the chat's agent answers it at once.
|
|
1364
|
+
pi.registerCommand("conform", {
|
|
1365
|
+
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]",
|
|
1366
|
+
handler: async (args, ctx) => {
|
|
1367
|
+
const command = `/conform ${args.trim()}`.trim();
|
|
1368
|
+
await echoCommand(pi, command);
|
|
1369
|
+
/** Nothing started: shown, and the agent told to answer it now. */
|
|
1370
|
+
const refuse = (text) => shownAfterCommand(pi, ctx, command, text, "error", true, CONFORM_REFUSED_REACTION);
|
|
1371
|
+
const picked = await commandModule(cwd, ctx, args, (text, level) => (level === "info" ? shownAfterCommand(pi, ctx, command, text, level, true) : refuse(text)), {
|
|
1372
|
+
verb: "conform",
|
|
1373
|
+
outcome: "conformance tested",
|
|
1374
|
+
});
|
|
1375
|
+
if (picked === undefined)
|
|
1376
|
+
return;
|
|
1377
|
+
const { plainFile } = picked;
|
|
1378
|
+
const { funcIds, rest } = funcIdsNamedFirst(picked.rest);
|
|
1379
|
+
const words = rest.join(" ").trim();
|
|
1380
|
+
const separately = asksOneByOne(words);
|
|
1381
|
+
// From scratch - the tests written again, the code untouched - asked in the person's words; the whole chain's with it.
|
|
1382
|
+
const scratch = asksFromScratch(words) ? (asksWholeChain(words) ? "chain" : "module") : undefined;
|
|
1383
|
+
// Nothing but the functional specs, from scratch and one by one: no planner reads guidance here, so other words are not dropped unsaid.
|
|
1384
|
+
if (words !== "" && !separately && scratch === undefined) {
|
|
1385
|
+
refuse(`/conform takes functional specs, each as module:func-id, "from scratch" with "whole chain" and "one by one" - not "${words}". Nothing was started.`);
|
|
1386
|
+
return;
|
|
1387
|
+
}
|
|
1388
|
+
if (scratch !== undefined && funcIds.length > 0) {
|
|
1389
|
+
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.");
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
// Off: turned on - written where the module's value comes from, every chat's tools switched - and said with what follows.
|
|
1393
|
+
let turnedOn;
|
|
1394
|
+
try {
|
|
1395
|
+
if (!conformanceTestsOn(plainFile))
|
|
1396
|
+
turnedOn = `Conformance tests are on now - conformance-tests: true, written in ${turnOn(plainFile)}.`;
|
|
1397
|
+
}
|
|
1398
|
+
catch (error) {
|
|
1399
|
+
refuse(`Conformance tests could not be turned on: ${error instanceof Error ? error.message : String(error)}. Nothing was started.`);
|
|
1400
|
+
return;
|
|
1401
|
+
}
|
|
1402
|
+
const withTurnedOn = (text) => (turnedOn !== undefined ? `${turnedOn}\n${text}` : text);
|
|
1403
|
+
// What would start nothing - no scenarios, a functional spec not there, a step of adding tests skipped - read from the
|
|
1404
|
+
// ***plain alone, before anything is said.
|
|
1405
|
+
let refusal;
|
|
1406
|
+
try {
|
|
1407
|
+
refusal = whenBuildable(plainFile, () => conformanceRefusal(plainFile, funcIds.length > 0 ? funcIds : undefined));
|
|
1408
|
+
}
|
|
1409
|
+
catch (error) {
|
|
1410
|
+
refusal = error instanceof Error ? error.message : String(error);
|
|
1411
|
+
}
|
|
1412
|
+
if (refusal !== undefined) {
|
|
1413
|
+
refuse(withTurnedOn(refusal));
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
const module = basename(plainFile).replace(/\.plain$/, "");
|
|
1417
|
+
const model = jobModel(ctx, undefined, plainFile);
|
|
1418
|
+
const starting = scratch !== undefined
|
|
1419
|
+
? `Writing ${module}'s conformance tests${scratch === "chain" ? " and its whole chain's" : ""} again from scratch…`
|
|
1420
|
+
: `Starting ${funcIds.length > 0 ? `the conformance tests of ${funcIds.join(", ")}` : `${module}'s conformance tests`}…`;
|
|
1421
|
+
shownAfterCommand(pi, ctx, command, withTurnedOn(starting), "info", true);
|
|
1422
|
+
await nextFrame();
|
|
1423
|
+
// In the background, as /regenerate: a codebase built on the module may be stopped and deleted first.
|
|
1424
|
+
void (async () => {
|
|
1425
|
+
try {
|
|
1426
|
+
const statuses = await whenBuildable(plainFile, () => workLoopFor(jobs, cwd, ctx).conformance(plainFile, {
|
|
1427
|
+
...(funcIds.length > 0 ? { funcIds } : {}),
|
|
1428
|
+
...(model !== undefined ? { model } : {}),
|
|
1429
|
+
...(separately ? { separately: true } : {}),
|
|
1430
|
+
...(scratch !== undefined ? { fromScratch: scratch } : {}),
|
|
1431
|
+
}));
|
|
1432
|
+
// Nothing to write: said in the loop's words - "up to date" alone speaks of the code, not its tests.
|
|
1433
|
+
const upToDate = statuses.length > 0 && statuses.every(isUpToDate);
|
|
1434
|
+
const note = statuses.find((status) => status.conformanceNote !== undefined)?.conformanceNote;
|
|
1435
|
+
const text = upToDate ? `${(note ?? `the conformance tests of ${module} are written for it as built: there is nothing to write`).replace(/^./, (c) => c.toUpperCase())}.` : describeModules(statuses);
|
|
1436
|
+
shownAfterCommand(pi, ctx, command, text, "info", true, upToDate ? undefined : COMMAND_STARTED_REACTION);
|
|
1437
|
+
}
|
|
1438
|
+
catch (error) {
|
|
1439
|
+
refuse(error instanceof Error ? error.message : String(error));
|
|
1440
|
+
}
|
|
1441
|
+
})().catch(() => {
|
|
1442
|
+
// The chat let go meanwhile: there is nobody to say it to.
|
|
1443
|
+
});
|
|
1444
|
+
},
|
|
1445
|
+
});
|
|
1356
1446
|
}
|
|
1357
1447
|
/**
|
|
1358
1448
|
* conform, for the conversation and for a skill that names it in its allowed-tools - the skill's on the conversation's
|
|
@@ -1369,23 +1459,35 @@ function conformTool(options) {
|
|
|
1369
1459
|
"conformance and acceptance scenarios, at least one test each, by the spec's test reqs, runs them with the whole suite " +
|
|
1370
1460
|
"the module inherits, and, where one fails, fixes the test or the code, whichever is wrong. What they are written for is " +
|
|
1371
1461
|
"recorded apart from the code. The work loop starts these pulses by itself for every functional spec with scenarios whose " +
|
|
1372
|
-
"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.
|
|
1462
|
+
"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. " +
|
|
1463
|
+
"A functional spec named whose tests are written already has them written again - deleted and written anew from its " +
|
|
1464
|
+
"scenarios, its code untouched; with from_scratch, the module's whole tests folder is taken out and written again, at " +
|
|
1465
|
+
"the tip of each chain it is built in, as regenerate from scratch does its code. A " +
|
|
1373
1466
|
"functional spec with no scenarios - no test plain file - is refused: there is nothing to test until scenarios " +
|
|
1374
1467
|
"are written. So is one the spec does not have, and a module with scenarios that skipped a step of adding tests - " +
|
|
1375
|
-
"no test reqs, or no conformance testing script
|
|
1468
|
+
"no test reqs, or no conformance testing script: the refusal names the next step. While conformance tests " +
|
|
1469
|
+
"are off it is refused too: they make each change take about twice as long, and turning them on is the person's - " +
|
|
1470
|
+
"with /conform - never yours.",
|
|
1376
1471
|
promptSnippet: "conform: write and run the conformance tests of functional specs with scenarios",
|
|
1377
1472
|
promptGuidelines: [
|
|
1378
|
-
"What is tested is the scenarios: a functional spec's conformance and acceptance scenarios, in its test plain file, tests/<module>/<func-id>.plain. When the user asks for conformance tests, decide in a sentence or two which scenarios to write,
|
|
1473
|
+
"What is tested is the scenarios: a functional spec's conformance and acceptance scenarios, in its test plain file, tests/<module>/<func-id>.plain. When the user asks for conformance tests, decide in a sentence or two which scenarios to write, write them with the file tools - a test plain file's ***conformance tests*** and ***acceptance tests***, each scenario a # <scenario-id> heading and its text - then call regenerate for the module. Every scenario written is tested once the code is built: the loop starts the conformance pulse by itself. Never edit config.turri.yaml for it, and never name a functionality in funcIds to get them.",
|
|
1379
1474
|
"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.",
|
|
1380
1475
|
"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.",
|
|
1381
1476
|
"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.",
|
|
1477
|
+
"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.",
|
|
1478
|
+
'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.',
|
|
1382
1479
|
],
|
|
1383
1480
|
parameters: Type.Object({
|
|
1384
1481
|
plain_file: Type.String({ description: "A .plain file of the module" }),
|
|
1385
1482
|
working_dir: WORKING_DIR_PARAM,
|
|
1386
|
-
funcIds: Type.Optional(Type.Array(Type.String(), {
|
|
1483
|
+
funcIds: Type.Optional(Type.Array(Type.String(), {
|
|
1484
|
+
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",
|
|
1485
|
+
})),
|
|
1486
|
+
from_scratch: Type.Optional(Type.Union([Type.Literal("module"), Type.Literal("chain")], {
|
|
1487
|
+
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. " +
|
|
1488
|
+
'"chain": written again from nothing - every functional spec of the chain\'s tests',
|
|
1489
|
+
})),
|
|
1387
1490
|
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" })),
|
|
1388
|
-
stack: STACK_PARAM,
|
|
1389
1491
|
model: MODEL_PARAM,
|
|
1390
1492
|
wait: WAIT_PARAM,
|
|
1391
1493
|
}),
|
|
@@ -1393,71 +1495,36 @@ function conformTool(options) {
|
|
|
1393
1495
|
const params = fromWorkingDir(cwd, given);
|
|
1394
1496
|
const plainFile = resolve(params.base, params.plain_file);
|
|
1395
1497
|
refuseTestPlainFile(plainFile);
|
|
1396
|
-
return
|
|
1498
|
+
return whenBuildable(plainFile, async () => {
|
|
1499
|
+
// Off: the person's to turn on, never the chat's - it is told to say why it wants them, and they decide.
|
|
1500
|
+
if (!conformanceTestsOn(plainFile))
|
|
1501
|
+
return { content: [{ type: "text", text: CONFORMANCE_OFF_REFUSAL }], details: { refused: true } };
|
|
1397
1502
|
const model = options.model(ctx, plainFile, params.model);
|
|
1398
1503
|
const loop = options.loop(ctx);
|
|
1399
|
-
const
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
promptSnippet: "glimpse: the next pulse of a module and its coding agent's whole prompt, starting nothing",
|
|
1417
|
-
promptGuidelines: [
|
|
1418
|
-
"Use glimpse when the user wants to see what a pulse will be told before it runs, or to check a plan before steering it with steer.",
|
|
1419
|
-
],
|
|
1420
|
-
parameters: Type.Object({
|
|
1421
|
-
plain_file: Type.String({ description: "Path to the .plain file" }),
|
|
1422
|
-
working_dir: WORKING_DIR_PARAM,
|
|
1423
|
-
stack: STACK_PARAM,
|
|
1424
|
-
}),
|
|
1425
|
-
async execute(_id, given, _signal, _onUpdate, ctx) {
|
|
1426
|
-
const params = fromWorkingDir(cwd, given);
|
|
1427
|
-
const plainFile = resolve(params.base, params.plain_file);
|
|
1428
|
-
refuseTestPlainFile(plainFile);
|
|
1429
|
-
return withCallStack(plainFile, params.stack, async () => {
|
|
1430
|
-
const running = new Set(workLoopFor(jobs, cwd, ctx).status().filter((status) => status.running !== undefined).map((status) => status.module));
|
|
1431
|
-
const planner = chatModelOf(ctx);
|
|
1432
|
-
const model = modelFor(chosenModels, "spec_changes", projectModel(ctx, plainFile) ?? planner);
|
|
1433
|
-
const { statuses, previews, busy } = await previewJobs({
|
|
1434
|
-
plainFile,
|
|
1435
|
-
cwd,
|
|
1436
|
-
...(model !== undefined ? { model } : {}),
|
|
1437
|
-
...(planner !== undefined ? { plannerModel: planner } : {}),
|
|
1438
|
-
steering: (file) => steeringFor(file, cwd, steeringStore),
|
|
1439
|
-
busy: (module) => running.has(module),
|
|
1440
|
-
});
|
|
1441
|
-
const text = [
|
|
1442
|
-
describeModules(statuses),
|
|
1443
|
-
...busy.map((module) => `\n${module} has a pulse running: its next pulse is planned from what that one lands - preview it once it has.`),
|
|
1444
|
-
...previews.map((preview) => [
|
|
1445
|
-
"",
|
|
1446
|
-
`<next pulse module="${preview.module}" track="${preview.track}" title="${preview.title}">`,
|
|
1447
|
-
preview.task ?? "A conformance pulse's prompt is built from what the code it tests holds once it is built: it is not shown before.",
|
|
1448
|
-
"</next pulse>",
|
|
1449
|
-
].join("\n")),
|
|
1450
|
-
"",
|
|
1451
|
-
"Nothing was started. Tell the user what the next pulse is and what it will be told - the parts they are likely to care about, not the whole prompt unless they ask.",
|
|
1452
|
-
].join("\n");
|
|
1453
|
-
return { content: [{ type: "text", text }], details: {} };
|
|
1504
|
+
const wait = options.wait(ctx, params.wait);
|
|
1505
|
+
const waiting = wait ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
|
|
1506
|
+
let statuses;
|
|
1507
|
+
try {
|
|
1508
|
+
statuses = await loop.conformance(plainFile, {
|
|
1509
|
+
...(params.funcIds !== undefined ? { funcIds: params.funcIds } : {}),
|
|
1510
|
+
...(model !== undefined ? { model } : {}),
|
|
1511
|
+
...(params.one_by_one === true ? { separately: true } : {}),
|
|
1512
|
+
...(params.from_scratch !== undefined ? { fromScratch: params.from_scratch } : {}),
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
catch (error) {
|
|
1516
|
+
if (waiting !== undefined)
|
|
1517
|
+
endWait(waiting.jobs, waiting.wait);
|
|
1518
|
+
throw error;
|
|
1519
|
+
}
|
|
1520
|
+
return loopReply(loop, statuses, wait, waiting);
|
|
1454
1521
|
});
|
|
1455
1522
|
},
|
|
1456
1523
|
});
|
|
1457
1524
|
}
|
|
1458
|
-
/** The config a spec is built with - its project's, with
|
|
1525
|
+
/** 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. */
|
|
1459
1526
|
function configOf(plainFile) {
|
|
1460
|
-
return plainFile !== undefined ? configForSpec(resolve(process.cwd(), plainFile)) : readProjectConfig(process.cwd(),
|
|
1527
|
+
return plainFile !== undefined ? configForSpec(resolve(process.cwd(), plainFile)) : readProjectConfig(process.cwd(), configModuleOf(process.cwd()));
|
|
1461
1528
|
}
|
|
1462
1529
|
/**
|
|
1463
1530
|
* How many jobs the chat runs at once: `parallel-jobs:` in the session folder's config.turri.yaml - the only place it
|
|
@@ -1567,74 +1634,77 @@ export function projectConfigBlock(root) {
|
|
|
1567
1634
|
if (projects.length === 0)
|
|
1568
1635
|
return "";
|
|
1569
1636
|
const describe = (dir) => {
|
|
1570
|
-
const
|
|
1571
|
-
const chosen = stackOf(dir);
|
|
1637
|
+
const modules = moduleConfigsOf(dir);
|
|
1572
1638
|
const where = dir === root ? "" : ` (paths relative to ${relative(root, dir)}/)`;
|
|
1573
1639
|
const at = (name) => (dir === root ? name : `${relative(root, dir)}/${name}`);
|
|
1574
1640
|
return [
|
|
1575
|
-
...settings(readProjectConfig(dir),
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
: []),
|
|
1579
|
-
// A stack: its file over the project's, for everything built while it is chosen.
|
|
1580
|
-
...stacks.flatMap((stack) => [
|
|
1641
|
+
...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"),
|
|
1642
|
+
// A module's own file: over the project's, for it and every module built on it that has no file of its own.
|
|
1643
|
+
...modules.flatMap((module) => [
|
|
1581
1644
|
"",
|
|
1582
|
-
...settings(readProjectConfig(dir,
|
|
1645
|
+
...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)))),
|
|
1583
1646
|
]),
|
|
1584
1647
|
];
|
|
1585
1648
|
};
|
|
1586
1649
|
const settings = (config, scripts, heading, where,
|
|
1587
|
-
/** The project's file, and whether
|
|
1588
|
-
of
|
|
1589
|
-
|
|
1650
|
+
/** The project's file, and whether modules have files of their own - whose scripts are theirs - or a module's. */
|
|
1651
|
+
of,
|
|
1652
|
+
/** A module's file as written: only what it sets itself is said - an inherited setting said again reads as its own. */
|
|
1653
|
+
own) => {
|
|
1654
|
+
const perModule = of === "project of module files";
|
|
1655
|
+
const sets = (set) => own === undefined || set;
|
|
1590
1656
|
return [
|
|
1591
1657
|
heading,
|
|
1592
1658
|
...[
|
|
1593
|
-
config.module !== undefined && of !== "
|
|
1594
|
-
of !== "
|
|
1595
|
-
? "- 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
|
|
1659
|
+
config.module !== undefined && of !== "module" ? `- module: ${config.module}${where} - the module to build when the user does not name one.` : undefined,
|
|
1660
|
+
of !== "module"
|
|
1661
|
+
? "- 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."
|
|
1596
1662
|
: undefined,
|
|
1597
|
-
|
|
1598
|
-
?
|
|
1599
|
-
:
|
|
1663
|
+
!sets(own?.review !== undefined)
|
|
1664
|
+
? undefined
|
|
1665
|
+
: config.review === true
|
|
1666
|
+
? "- review: true - the code and its tests are reviewed once they pass: two reviews at most, the arbiter weighing the second."
|
|
1667
|
+
: `- review: ${config.review === false ? "false" : "not set, so off"} - the code and its tests are not reviewed: a pulse lands once its tests pass.`,
|
|
1600
1668
|
...(() => {
|
|
1601
1669
|
// Each as it holds, with what it inherits: judge from coding, coding from harness.
|
|
1602
1670
|
const models = projectModels(config);
|
|
1603
1671
|
const shown = (choice) => modelSpec(choice) ?? "";
|
|
1604
1672
|
return [
|
|
1605
|
-
models.coding !== undefined ? `- coding-model: ${shown(models.coding)}${config.codingModel === undefined ? " (from harness-model)" : ""} - what
|
|
1606
|
-
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,
|
|
1607
|
-
models.harness !== undefined && of !== "
|
|
1673
|
+
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,
|
|
1674
|
+
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,
|
|
1675
|
+
models.harness !== undefined && of !== "module" ? `- harness-model: ${shown(models.harness)} - the model you start with.` : undefined,
|
|
1608
1676
|
// The other roles' own, where models: names them.
|
|
1609
1677
|
...AGENT_ROLES.filter((role) => role !== "coding" && role !== "chat").flatMap((role) => {
|
|
1610
|
-
const
|
|
1611
|
-
return own !== undefined ? [`- models: ${role}: ${shown(
|
|
1678
|
+
const named = roleModel(config, role);
|
|
1679
|
+
return named !== undefined && sets(own?.models?.[role] !== undefined) ? [`- models: ${role}: ${shown(named)}`] : [];
|
|
1612
1680
|
}),
|
|
1613
1681
|
...(() => {
|
|
1614
1682
|
const limits = AGENT_ROLES.flatMap((role) => (config.models?.[role]?.turnLimit !== undefined ? [`${role} ${config.models[role].turnLimit}s`] : []));
|
|
1615
1683
|
const all = config.models?.default?.turnLimit ?? config.turnLimit;
|
|
1616
|
-
return all !== undefined || limits.length > 0 ? [`- turn limits: ${all !== undefined ? `${all}s each` : "two minutes each"}${limits.length > 0 ? `; ${limits.join(", ")}` : ""}.`] : [];
|
|
1684
|
+
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(", ")}` : ""}.`] : [];
|
|
1617
1685
|
})(),
|
|
1618
1686
|
];
|
|
1619
1687
|
})(),
|
|
1620
|
-
`- unit testing script: ${scripts.unit !== undefined ? relative(root, scripts.unit) : perModule ? "none for the whole project - each
|
|
1621
|
-
`- conformance testing script: ${scripts.conformance !== undefined ? relative(root, scripts.conformance) : perModule ? "none for the whole project - see each
|
|
1688
|
+
`- 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"}`,
|
|
1689
|
+
`- conformance testing script: ${scripts.conformance !== undefined ? relative(root, scripts.conformance) : perModule ? "none for the whole project - see each module's file" : "none found"}`,
|
|
1622
1690
|
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,
|
|
1623
|
-
|
|
1624
|
-
?
|
|
1625
|
-
:
|
|
1691
|
+
!sets(own?.testingScriptsRunOn !== undefined)
|
|
1692
|
+
? undefined
|
|
1693
|
+
: config.testingScriptsRunOn === "copy"
|
|
1694
|
+
? "- 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."
|
|
1695
|
+
: "- 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.",
|
|
1626
1696
|
].filter((line) => line !== undefined),
|
|
1627
1697
|
];
|
|
1628
1698
|
};
|
|
1629
1699
|
return [
|
|
1630
1700
|
`<project config>`,
|
|
1631
|
-
`A project's ${CONFIG_FILE} sets how its
|
|
1632
|
-
"
|
|
1633
|
-
"
|
|
1634
|
-
|
|
1635
|
-
`${
|
|
1636
|
-
"answer questions about the project's settings from
|
|
1637
|
-
"asked. Name a spec by its path from here - plain/hubspot.plain - and it is built in its own project.",
|
|
1701
|
+
`A project's ${CONFIG_FILE} sets how its modules are built - and a module's own config.turri.<module>.yaml, over it, how that`,
|
|
1702
|
+
"module is built, and every module built on it that has no file of its own: its testing scripts, toolchains, models and conformance -",
|
|
1703
|
+
"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",
|
|
1704
|
+
"a module it requires, else the project's alone - two among the modules it requires is an error to fix. A project with no",
|
|
1705
|
+
`${CONFIG_FILE} yet is read from its ${LEGACY_CONFIG_FILE} (and config.<module>.yaml). Change a setting with the settings tool,`,
|
|
1706
|
+
"never by editing these files; answer questions about the project's settings from what follows, and say when a pulse will",
|
|
1707
|
+
"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.",
|
|
1638
1708
|
...projects.flatMap((dir) => ["", ...describe(dir)]),
|
|
1639
1709
|
`</project config>`,
|
|
1640
1710
|
].join("\n");
|
|
@@ -1655,9 +1725,19 @@ function conversationModel(ctx, override) {
|
|
|
1655
1725
|
* The chat's model, read now - it can change while a skill runs - or, from a context that has
|
|
1656
1726
|
* gone stale since, the model it had when it was last readable.
|
|
1657
1727
|
*/
|
|
1658
|
-
/**
|
|
1659
|
-
|
|
1660
|
-
|
|
1728
|
+
/**
|
|
1729
|
+
* The model a launch runs on: the coding model of the codebase - a launch follows steps, and a small model thinking little
|
|
1730
|
+
* does that well. Without a chat's context yet, the config's as it names it.
|
|
1731
|
+
*/
|
|
1732
|
+
function launchModel(ctx, plainFile) {
|
|
1733
|
+
try {
|
|
1734
|
+
if (ctx !== undefined)
|
|
1735
|
+
return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
|
|
1736
|
+
}
|
|
1737
|
+
catch {
|
|
1738
|
+
/* a name the chat cannot resolve: the config's, as it is */
|
|
1739
|
+
}
|
|
1740
|
+
return modelSpec(projectModels(configForSpec(plainFile)).coding);
|
|
1661
1741
|
}
|
|
1662
1742
|
function chatModelOf(ctx) {
|
|
1663
1743
|
try {
|
|
@@ -1672,43 +1752,24 @@ function chatModelOf(ctx) {
|
|
|
1672
1752
|
let lastChatModel;
|
|
1673
1753
|
/**
|
|
1674
1754
|
* Conformance tests turned on, for the session: `conformance-tests: true` written where the module's value comes from
|
|
1675
|
-
* (conformance-switch.ts)
|
|
1676
|
-
*
|
|
1755
|
+
* (conformance-switch.ts) - what /conform does when they are off, and a host's turnOnConformance. Every chat is told at
|
|
1756
|
+
* its next turn. `plainFile`, absolute or from the project, picks the module whose own file
|
|
1677
1757
|
* is written when that names the key. Returns the file written, from the project. Starts no conformance pulse.
|
|
1678
1758
|
*/
|
|
1679
1759
|
export function turnOnConformance(core, plainFile) {
|
|
1680
1760
|
const file = turnOnConformanceTests(core.cwd, plainFile !== undefined && plainFile.trim() !== "" ? resolve(core.cwd, plainFile) : undefined);
|
|
1681
|
-
for (const chat of core.chats()) {
|
|
1682
|
-
const live = core.session(chat.id);
|
|
1683
|
-
try {
|
|
1684
|
-
(live !== undefined ? core.chatOfSession(live) : undefined)?.instance?.conformanceSwitched?.();
|
|
1685
|
-
}
|
|
1686
|
-
catch {
|
|
1687
|
-
/* a chat let go: its next turn sets its tools */
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
1761
|
return file;
|
|
1691
1762
|
}
|
|
1692
1763
|
/** The skills running in the background, by project and skill - one at a time each, whichever chat started it - with what stops them. */
|
|
1693
1764
|
const backgroundSkillRuns = new Map();
|
|
1694
|
-
/** 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. */
|
|
1695
|
-
const chosenModels = {};
|
|
1696
|
-
/** When they were last chosen: a chat reopened with older choices of its own leaves them be. */
|
|
1697
|
-
let chosenModelsAt = 0;
|
|
1698
|
-
const MODEL_CHOICE_ENTRY = "turri_render_models";
|
|
1699
1765
|
/**
|
|
1700
|
-
* The model a
|
|
1701
|
-
*
|
|
1702
|
-
* the conversation's.
|
|
1766
|
+
* 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
|
|
1767
|
+
* later in the background; else the coding model - `--coding-model`, or the module's config - else the conversation's.
|
|
1703
1768
|
*/
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
* of work, or the project's - `model:` in config.turri.yaml - or the conversation's.
|
|
1707
|
-
*/
|
|
1708
|
-
function jobModel(ctx, work, named, plainFile) {
|
|
1709
|
-
const model = jobModelOf(ctx, work, named, plainFile);
|
|
1769
|
+
function jobModel(ctx, named, plainFile) {
|
|
1770
|
+
const model = jobModelOf(ctx, named, plainFile);
|
|
1710
1771
|
// The AWS region worked out again, with every model a job ran on this session: the config's may have changed since,
|
|
1711
|
-
// and one
|
|
1772
|
+
// and one named on a call counts as the config's do - two needing two regions are said, not flipped between.
|
|
1712
1773
|
if (model !== undefined)
|
|
1713
1774
|
jobModels.add(model);
|
|
1714
1775
|
applyBedrockRegion(plainFile !== undefined ? projectDirOf(plainFile) : process.cwd(), { also: [...jobModels] });
|
|
@@ -1716,14 +1777,14 @@ function jobModel(ctx, work, named, plainFile) {
|
|
|
1716
1777
|
}
|
|
1717
1778
|
/** Every model a job ran on in this session. */
|
|
1718
1779
|
const jobModels = new Set();
|
|
1719
|
-
function jobModelOf(ctx,
|
|
1780
|
+
function jobModelOf(ctx, named, plainFile) {
|
|
1720
1781
|
if (named !== undefined && named.trim() !== "") {
|
|
1721
1782
|
const resolved = resolveModel(named, ctx.modelRegistry);
|
|
1722
1783
|
if (!resolved.ok)
|
|
1723
1784
|
throw new Error(describeResolution(resolved));
|
|
1724
1785
|
return resolved.model;
|
|
1725
1786
|
}
|
|
1726
|
-
return
|
|
1787
|
+
return projectModel(ctx, plainFile) ?? chatModelOf(ctx);
|
|
1727
1788
|
}
|
|
1728
1789
|
/**
|
|
1729
1790
|
* The coding model this session starts from, and where it was given: `turri
|
|
@@ -1756,108 +1817,6 @@ function projectModel(ctx, plainFile) {
|
|
|
1756
1817
|
}
|
|
1757
1818
|
return modelSpec({ model: resolved.model, thinking });
|
|
1758
1819
|
}
|
|
1759
|
-
/** The default coding model for showing, with where it came from - never an error. */
|
|
1760
|
-
function projectModelLabel(ctx) {
|
|
1761
|
-
const given = codingModelDefault();
|
|
1762
|
-
if (given === undefined)
|
|
1763
|
-
return undefined;
|
|
1764
|
-
try {
|
|
1765
|
-
return { model: projectModel(ctx), from: given.from };
|
|
1766
|
-
}
|
|
1767
|
-
catch {
|
|
1768
|
-
return { model: `${given.named} - which cannot be used here`, from: given.from };
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
/**
|
|
1772
|
-
* engine, for the conversation's agent and for a skill's agent - whom the person talks
|
|
1773
|
-
* to while the skill runs - alike: both write the same choice. `conversation` is the context to
|
|
1774
|
-
* read models and the chat's model from; omitted, the one the tool is called with.
|
|
1775
|
-
*/
|
|
1776
|
-
function setRenderModelTool(pi, conversation) {
|
|
1777
|
-
return defineTool({
|
|
1778
|
-
name: "engine",
|
|
1779
|
-
label: "Engine",
|
|
1780
|
-
description: "The engine: which model the agents that regenerate the code run on. With no model, say which it is. With one, choose it " +
|
|
1781
|
-
"for the rest of this session: for spec changes " +
|
|
1782
|
-
"(render spec diff pulses, and the ones change_plain queues), for functionalities (render, module, " +
|
|
1783
|
-
"regenerate with functionalities named, conformance), or for everything. By default " +
|
|
1784
|
-
"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 " +
|
|
1785
|
-
"the user said it; a name that fits more than one model, or none with credentials, comes back as a " +
|
|
1786
|
-
"list - ask the user which they meant, never pick one yourself. Pulses already queued keep their model.",
|
|
1787
|
-
promptSnippet: "the engine: show or choose the model that regenerates the code",
|
|
1788
|
-
promptGuidelines: [
|
|
1789
|
-
"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.",
|
|
1790
|
-
"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.",
|
|
1791
|
-
"Say which model a render will run on when you start one on something other than the conversation's model.",
|
|
1792
|
-
],
|
|
1793
|
-
parameters: Type.Object({
|
|
1794
|
-
work: Type.Optional(Type.Union([Type.Literal("spec_changes"), Type.Literal("functionalities"), Type.Literal("all")], {
|
|
1795
|
-
description: "spec_changes, functionalities, or all of it. Omitted: all",
|
|
1796
|
-
})),
|
|
1797
|
-
model: Type.Optional(Type.String({
|
|
1798
|
-
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',
|
|
1799
|
-
})),
|
|
1800
|
-
}),
|
|
1801
|
-
async execute(_id, given, _signal, _onUpdate, called) {
|
|
1802
|
-
const ctx = conversation ?? called;
|
|
1803
|
-
if (given.model === undefined) {
|
|
1804
|
-
const text = `The engine:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}`;
|
|
1805
|
-
return { content: [{ type: "text", text }], details: { ...chosenModels } };
|
|
1806
|
-
}
|
|
1807
|
-
const params = { work: given.work ?? "all", model: given.model };
|
|
1808
|
-
const works = params.work === "all" ? ["all", "spec_changes", "functionalities"] : [params.work];
|
|
1809
|
-
if (/^(chat|default|conversation)$/i.test(params.model.trim())) {
|
|
1810
|
-
for (const work of works)
|
|
1811
|
-
delete chosenModels[work];
|
|
1812
|
-
}
|
|
1813
|
-
else {
|
|
1814
|
-
const resolved = resolveModel(params.model, ctx.modelRegistry);
|
|
1815
|
-
if (!resolved.ok)
|
|
1816
|
-
throw new Error(describeResolution(resolved));
|
|
1817
|
-
if (params.work === "all") {
|
|
1818
|
-
delete chosenModels.spec_changes;
|
|
1819
|
-
delete chosenModels.functionalities;
|
|
1820
|
-
}
|
|
1821
|
-
chosenModels[params.work] = resolved.model;
|
|
1822
|
-
}
|
|
1823
|
-
chosenModelsAt = Date.now();
|
|
1824
|
-
pi.appendEntry(MODEL_CHOICE_ENTRY, { ...chosenModels });
|
|
1825
|
-
const text = `The engine now:\n${describeChoices(chosenModels, chatModelOf(ctx), projectModelLabel(ctx))}`;
|
|
1826
|
-
return { content: [{ type: "text", text }], details: { ...chosenModels } };
|
|
1827
|
-
},
|
|
1828
|
-
});
|
|
1829
|
-
}
|
|
1830
|
-
/** Choosing which model renders what, for the rest of the session. */
|
|
1831
|
-
function registerRenderModels(pi) {
|
|
1832
|
-
// The session's choices, every chat's: a chat reopened brings back what it chose, when that is newer than what the
|
|
1833
|
-
// session has - and a fresh chat starts with the session's.
|
|
1834
|
-
let started = false;
|
|
1835
|
-
pi.on("session_start", (_event, ctx) => {
|
|
1836
|
-
if (started)
|
|
1837
|
-
return;
|
|
1838
|
-
started = true;
|
|
1839
|
-
const saved = ctx.sessionManager
|
|
1840
|
-
.getBranch()
|
|
1841
|
-
.filter((entry) => entry.type === "custom" && entry.customType === MODEL_CHOICE_ENTRY)
|
|
1842
|
-
.at(-1);
|
|
1843
|
-
const at = Date.parse(saved?.timestamp ?? "") || 1;
|
|
1844
|
-
if (saved === undefined || at <= chosenModelsAt)
|
|
1845
|
-
return;
|
|
1846
|
-
chosenModelsAt = at;
|
|
1847
|
-
for (const key of Object.keys(chosenModels))
|
|
1848
|
-
delete chosenModels[key];
|
|
1849
|
-
Object.assign(chosenModels, saved.data ?? {});
|
|
1850
|
-
});
|
|
1851
|
-
pi.registerTool(setRenderModelTool(pi));
|
|
1852
|
-
pi.registerCommand("engine", {
|
|
1853
|
-
description: "Show the engine: which model regenerates spec changes and functionalities. To change it, say so in the conversation.",
|
|
1854
|
-
handler: async (_args, ctx) => {
|
|
1855
|
-
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".`;
|
|
1856
|
-
if (ctx.hasUI)
|
|
1857
|
-
ctx.ui.notify(text, "info");
|
|
1858
|
-
},
|
|
1859
|
-
});
|
|
1860
|
-
}
|
|
1861
1820
|
/**
|
|
1862
1821
|
* Run the work now, or start it as a background job and hand back an id.
|
|
1863
1822
|
*
|
|
@@ -1869,14 +1828,8 @@ function registerRenderModels(pi) {
|
|
|
1869
1828
|
const workLoops = new WeakMap();
|
|
1870
1829
|
/** How the conversation wants the work planned, for the session - set with steer. */
|
|
1871
1830
|
const steeringStore = createSteeringStore();
|
|
1872
|
-
/**
|
|
1873
|
-
const
|
|
1874
|
-
/** A session's test advisor, by its jobs - only a chat's or a host's has one. */
|
|
1875
|
-
const advisors = new WeakMap();
|
|
1876
|
-
/** The session's test advisor, when it has one: the chat's and a host's - never pi's print, json and rpc modes'. */
|
|
1877
|
-
export function sessionAdvisor(session) {
|
|
1878
|
-
return advisors.get(session.jobs);
|
|
1879
|
-
}
|
|
1831
|
+
/** A session's launches, by its jobs: the launch track every chat's launch tool and every pulse's launch share. */
|
|
1832
|
+
const sessionLaunches = new WeakMap();
|
|
1880
1833
|
function workLoopFor(jobs, cwd, ctx) {
|
|
1881
1834
|
let shared = workLoops.get(jobs);
|
|
1882
1835
|
if (shared === undefined) {
|
|
@@ -1884,28 +1837,15 @@ function workLoopFor(jobs, cwd, ctx) {
|
|
|
1884
1837
|
const loop = createWorkLoop({
|
|
1885
1838
|
registry: jobs,
|
|
1886
1839
|
cwd,
|
|
1887
|
-
modelFor: (plainFile) =>
|
|
1840
|
+
modelFor: (plainFile) => projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx),
|
|
1888
1841
|
// The planner reasons about the whole of the work: it runs on the chat's model.
|
|
1889
1842
|
plannerModel: () => chatModelOf(from.ctx),
|
|
1890
1843
|
// How the work is to be planned: the conversation's steering, and AGENTS.md's - read afresh each plan.
|
|
1891
1844
|
steering: (plainFile) => steeringFor(plainFile, cwd, steeringStore),
|
|
1892
|
-
//
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
// regenerated it: a release follows steps, and a small model thinking little does that well.
|
|
1896
|
-
release: ({ plainFile, moduleName, title, onDelta }) => {
|
|
1897
|
-
const model = releaseModel(from.ctx, plainFile);
|
|
1898
|
-
return runReleaseAgent({
|
|
1899
|
-
plainFile,
|
|
1900
|
-
cwd,
|
|
1901
|
-
state: deployStates.get(jobs) ?? createDeployState(),
|
|
1902
|
-
afterPulse: { moduleName, subject: title },
|
|
1903
|
-
onDelta,
|
|
1904
|
-
...(model !== undefined ? { model } : {}),
|
|
1905
|
-
});
|
|
1906
|
-
},
|
|
1845
|
+
// A pulse landed: its commit kept for the sentinel - and, under launch-after-pulse, launched in the background, the
|
|
1846
|
+
// codebase's next pulse not waiting on it.
|
|
1847
|
+
landed: (input) => sessionLaunches.get(jobs)?.landed(input),
|
|
1907
1848
|
});
|
|
1908
|
-
bindAdvisor(loop, () => advisors.get(jobs));
|
|
1909
1849
|
shared = { loop, from };
|
|
1910
1850
|
workLoops.set(jobs, shared);
|
|
1911
1851
|
}
|
|
@@ -1973,53 +1913,59 @@ const needsLooking = new WeakMap();
|
|
|
1973
1913
|
const pastPulseNote = "A pulse of an earlier session, as the ledger recorded it - facts, not its transcript. Its whole log is the file it names, " +
|
|
1974
1914
|
"for the read tool.";
|
|
1975
1915
|
function registerJobTools(pi, jobs, cwd) {
|
|
1976
|
-
pi.registerTool({
|
|
1977
|
-
name: "diagnose",
|
|
1978
|
-
label: "Diagnose a pulse",
|
|
1979
|
-
description: "Why a pulse did not land, from its whole transcript: how it ended and its diagnosis, the stages that went wrong, the " +
|
|
1980
|
-
"last failing test run with its output, the last review that sent the work back, and the tool calls that failed - " +
|
|
1981
|
-
"and where the whole log is. A pulse of an earlier session is told from the ledger - what it recorded of it, as facts.",
|
|
1982
|
-
promptSnippet: "diagnose: why a pulse did not land, from its transcript",
|
|
1983
|
-
promptGuidelines: ["When a pulse failed or did not land, call diagnose before you explain it or change the spec: go by what happened, not by the report alone."],
|
|
1984
|
-
parameters: Type.Object({ job_id: Type.String({ description: "The pulse's id" }) }),
|
|
1985
|
-
async execute(_id, params) {
|
|
1986
|
-
const job = jobs.get(params.job_id);
|
|
1987
|
-
if (job === undefined) {
|
|
1988
|
-
const past = describePastPulse(ledgerProjects(cwd), params.job_id);
|
|
1989
|
-
if (past !== undefined)
|
|
1990
|
-
return { content: [{ type: "text", text: `${pastPulseNote}\n\n${past}` }], details: { status: "earlier" } };
|
|
1991
|
-
return { content: [{ type: "text", text: `No pulse ${params.job_id} has run in this session, and the ledger has none by that id.` }], details: { status: "unknown" } };
|
|
1992
|
-
}
|
|
1993
|
-
// What the ledger recorded of it besides: its rounds, test runs, healers and commits, as facts.
|
|
1994
|
-
const facts = describePastPulse(ledgerProjects(cwd), job.id);
|
|
1995
|
-
const text = facts !== undefined ? `${whyFailed(job)}\n\nWhat the ledger recorded of it:\n${facts}` : whyFailed(job);
|
|
1996
|
-
return { content: [{ type: "text", text }], details: { status: job.status } };
|
|
1997
|
-
},
|
|
1998
|
-
});
|
|
1999
|
-
pi.registerTool(ledgerTool({ cwd }));
|
|
2000
1916
|
pi.registerTool(doctorTool({ cwd }));
|
|
2001
1917
|
pi.registerTool({
|
|
2002
1918
|
name: "pulses",
|
|
2003
1919
|
label: "Pulses",
|
|
2004
|
-
description: "
|
|
2005
|
-
"
|
|
2006
|
-
"
|
|
2007
|
-
|
|
1920
|
+
description: "Pulses in every tense - earlier sessions', this session's, running now and what runs next. With no parameter: every pulse of " +
|
|
1921
|
+
"this session - finished, running, and planned, those of a look ahead marked as waiting for regenerate - the launches and what they started, " +
|
|
1922
|
+
"and the last runs of earlier sessions, a line a pulse - how each ended, how long, what it cost. With job_id, one pulse: " +
|
|
1923
|
+
"running, whether it still is and its latest output; finished, its report and what the ledger recorded of it - its rounds " +
|
|
1924
|
+
"and test runs (how many failed the same way), the verdicts, the healers, the model provider's trouble, what turri refused, " +
|
|
1925
|
+
"what it committed - and, one that did not land, why, from its whole transcript: its diagnosis, the stages that went wrong, " +
|
|
1926
|
+
"the last failing test run with its output, the last review that sent the work back, the tool calls that failed, and where " +
|
|
1927
|
+
"the whole log is; of an earlier session, told from the ledger; planned (planned-<module>-N), its cases and - the next pulse " +
|
|
1928
|
+
"of its codebase - the whole prompt its coding agent will get, from the plan regenerate runs. With plain_file, a look " +
|
|
1929
|
+
"ahead: that module's work planned as regenerate plans it, steering and all, and kept - nothing started, its pulses waiting " +
|
|
1930
|
+
"for regenerate, which then runs this plan unless the ***plain or the steering changed - and what is planned listed. " +
|
|
1931
|
+
"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 " +
|
|
1932
|
+
"history, read with git: git --git-dir=plain_modules/<module>/.plaingit log, and show <commit>.",
|
|
1933
|
+
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",
|
|
1934
|
+
promptGuidelines: [
|
|
1935
|
+
"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.",
|
|
1936
|
+
"Call pulses with plain_file when the user wants to see or check what will run before it does, then with a planned row's id for its prompt. To change the plan, use steer or change the ***plain, then look again.",
|
|
1937
|
+
],
|
|
2008
1938
|
parameters: Type.Object({
|
|
2009
|
-
job_id: Type.Optional(Type.String({
|
|
2010
|
-
|
|
1939
|
+
job_id: Type.Optional(Type.String({
|
|
1940
|
+
description: "One pulse: the id returned when it started, an earlier session's, or a planned row's (planned-<module>-N). Omitted: every pulse",
|
|
1941
|
+
})),
|
|
1942
|
+
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" })),
|
|
1943
|
+
working_dir: WORKING_DIR_PARAM,
|
|
1944
|
+
wait: Type.Optional(Type.Boolean({ description: "With a pulse started: block until it finishes instead of reporting its current state (default false)" })),
|
|
1945
|
+
runs: Type.Optional(Type.Number({ description: `With no parameter: how many runs of earlier sessions to list (default ${EARLIER_RUNS})` })),
|
|
2011
1946
|
}),
|
|
2012
|
-
async execute(_id, params) {
|
|
1947
|
+
async execute(_id, params, _signal, _onUpdate, ctx) {
|
|
1948
|
+
if (params.plain_file !== undefined) {
|
|
1949
|
+
if (params.job_id !== undefined)
|
|
1950
|
+
return { content: [{ type: "text", text: "Pass job_id or plain_file, not both: plain_file looks ahead at a module, job_id tells one pulse." }], details: { status: "refused" } };
|
|
1951
|
+
const given = fromWorkingDir(cwd, params);
|
|
1952
|
+
const plainFile = resolve(given.base, given.plain_file);
|
|
1953
|
+
refuseTestPlainFile(plainFile);
|
|
1954
|
+
return whenBuildable(plainFile, async () => {
|
|
1955
|
+
const loop = workLoopFor(jobs, cwd, ctx);
|
|
1956
|
+
const statuses = await loop.lookAhead(plainFile);
|
|
1957
|
+
return { content: [{ type: "text", text: describeLookAhead(loop, statuses) }], details: { status: "looked ahead" } };
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
2013
1960
|
if (params.job_id === undefined) {
|
|
2014
|
-
|
|
1961
|
+
const runs = params.runs !== undefined && Number.isFinite(params.runs) ? Math.max(1, Math.floor(params.runs)) : EARLIER_RUNS;
|
|
1962
|
+
return { content: [{ type: "text", text: listJobs(jobs, cwd, runs) }], details: { status: "all" } };
|
|
2015
1963
|
}
|
|
2016
1964
|
const existing = jobs.get(params.job_id);
|
|
2017
1965
|
const planned = shownJobs(jobs).find((job) => job.id === params.job_id && jobs.get(job.id) === undefined);
|
|
2018
1966
|
if (planned !== undefined) {
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
details: { status: "planned" },
|
|
2022
|
-
};
|
|
1967
|
+
const pulse = await workLoops.get(jobs)?.loop.plannedPulse(planned.id);
|
|
1968
|
+
return { content: [{ type: "text", text: describePlannedRow(planned, pulse) }], details: { status: "planned" } };
|
|
2023
1969
|
}
|
|
2024
1970
|
if (existing === undefined) {
|
|
2025
1971
|
const past = describePastPulse(ledgerProjects(cwd), params.job_id);
|
|
@@ -2037,42 +1983,56 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2037
1983
|
};
|
|
2038
1984
|
}
|
|
2039
1985
|
const job = params.wait === true ? await jobs.wait(params.job_id) : existing;
|
|
2040
|
-
|
|
2041
|
-
content: [{ type: "text", text: describeJob(job) }],
|
|
2042
|
-
|
|
2043
|
-
|
|
1986
|
+
if (job.status === "running" || job.status === "queued")
|
|
1987
|
+
return { content: [{ type: "text", text: describeJob(job) }], details: { status: job.status } };
|
|
1988
|
+
// Ended: how it went - why, for one that did not land - and what the ledger recorded of it besides: its rounds, test
|
|
1989
|
+
// runs, verdicts, healers and commits, as facts. A pulse that landed after a struggle shows it there.
|
|
1990
|
+
const told = didNotLand(job) ? whyFailed(job) : describeJob(job);
|
|
1991
|
+
const facts = describePastPulse(ledgerProjects(cwd), job.id, { report: false });
|
|
1992
|
+
const text = facts !== undefined ? `${told}\n\nWhat the ledger recorded of it:\n${facts}` : told;
|
|
1993
|
+
return { content: [{ type: "text", text }], details: { status: job.status } };
|
|
2044
1994
|
},
|
|
2045
1995
|
});
|
|
2046
1996
|
// The panel is compact and ctrl+o only lasts as long as the work does. This is the whole
|
|
2047
1997
|
// list, finished jobs included, put in the transcript where it stays.
|
|
2048
1998
|
pi.registerCommand("halt", {
|
|
2049
|
-
description: "Halt a queued or running pulse, a module's planned pulses, or what
|
|
1999
|
+
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>]",
|
|
2050
2000
|
handler: async (args, ctx) => {
|
|
2051
2001
|
if (!ctx.hasUI)
|
|
2052
2002
|
return;
|
|
2053
2003
|
const live = jobs.list().filter((job) => job.status === "running" || job.status === "queued");
|
|
2054
|
-
const
|
|
2004
|
+
const servers = runningLaunched();
|
|
2005
|
+
const track = sessionLaunches.get(jobs)?.track;
|
|
2006
|
+
const underWay = (track?.list() ?? []).filter((launch) => launch.status === "running" || launch.status === "waiting");
|
|
2055
2007
|
const loop = workLoops.get(jobs)?.loop;
|
|
2056
2008
|
// A module's planned pulses, one line a module: halting one halts the module.
|
|
2057
2009
|
const plannedRows = loop?.planned() ?? [];
|
|
2058
2010
|
const planned = [...new Set(plannedRows.map((row) => row.module ?? ""))].filter((module) => module !== "");
|
|
2059
2011
|
let id = args.trim();
|
|
2060
2012
|
if (id === "") {
|
|
2061
|
-
if (live.length === 0 &&
|
|
2062
|
-
return ctx.ui.notify("Nothing is regenerating, queued or
|
|
2013
|
+
if (live.length === 0 && servers.length === 0 && underWay.length === 0 && planned.length === 0)
|
|
2014
|
+
return ctx.ui.notify("Nothing is regenerating, queued, planned or launched.", "info");
|
|
2063
2015
|
const label = (job) => `${job.id} ${job.status.padEnd(8)} ${pulseName(job)}`;
|
|
2064
2016
|
const plannedLabel = (module) => {
|
|
2065
2017
|
const rows = plannedRows.filter((row) => row.module === module);
|
|
2066
2018
|
const waiting = rows.find((row) => row.id.endsWith("-waiting"));
|
|
2067
2019
|
return `${module} ${waiting !== undefined ? waiting.summary : `${rows.length} planned`} - halts the module`;
|
|
2068
2020
|
};
|
|
2069
|
-
const labels = [
|
|
2021
|
+
const labels = [
|
|
2022
|
+
...live.map(label),
|
|
2023
|
+
...planned.map(plannedLabel),
|
|
2024
|
+
...underWay.map(describeLaunchLine),
|
|
2025
|
+
...servers.map((item) => launchedLabel(item.name, item.url ?? item.command)),
|
|
2026
|
+
];
|
|
2070
2027
|
const picked = await ctx.ui.select("Halt which?", labels);
|
|
2071
2028
|
const job = live.find((candidate) => picked !== undefined && label(candidate) === picked);
|
|
2072
2029
|
const module = planned.find((name) => picked !== undefined && plannedLabel(name) === picked);
|
|
2073
|
-
const
|
|
2030
|
+
const launch = underWay.find((candidate) => picked !== undefined && describeLaunchLine(candidate) === picked);
|
|
2031
|
+
const server = servers.find((item) => picked !== undefined && launchedLabel(item.name, item.url ?? item.command) === picked);
|
|
2074
2032
|
if (server !== undefined)
|
|
2075
|
-
id = `
|
|
2033
|
+
id = `launched ${server.name}`;
|
|
2034
|
+
else if (launch !== undefined)
|
|
2035
|
+
id = `launched ${launch.codebase}`;
|
|
2076
2036
|
else if (job !== undefined)
|
|
2077
2037
|
id = job.id;
|
|
2078
2038
|
else if (module !== undefined)
|
|
@@ -2080,11 +2040,9 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2080
2040
|
else
|
|
2081
2041
|
return;
|
|
2082
2042
|
}
|
|
2083
|
-
const name = /^
|
|
2084
|
-
if (name !== undefined)
|
|
2085
|
-
|
|
2086
|
-
return shownAfterCommand(pi, ctx, `/halt ${id}`, stopped.length > 0 ? `Halted ${stopped.join(", ")}.` : `Nothing activate started is running as ${name}.`, "info");
|
|
2087
|
-
}
|
|
2043
|
+
const name = /^launched\s+(.+)$/.exec(id)?.[1]?.trim();
|
|
2044
|
+
if (name !== undefined)
|
|
2045
|
+
return shownAfterCommand(pi, ctx, `/halt ${id}`, await haltLaunched(name, track), "info");
|
|
2088
2046
|
ctx.ui.notify(stopJob(jobs, id, undefined, loop), "info");
|
|
2089
2047
|
},
|
|
2090
2048
|
});
|
|
@@ -2107,23 +2065,6 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2107
2065
|
pi.appendEntry(HISTORY_ENTRY, { module: name, text: historyLog(defaultBuildDir(name, cwd)) });
|
|
2108
2066
|
},
|
|
2109
2067
|
});
|
|
2110
|
-
pi.registerTool({
|
|
2111
|
-
name: "lineage",
|
|
2112
|
-
label: "Lineage",
|
|
2113
|
-
description: "Read a module's lineage: every generation of its code and tests - each regeneration, conformance run and spec change, " +
|
|
2114
|
-
"with what it was regenerated from - as git commits. Without a commit, the log; with one, that commit in full - its message and " +
|
|
2115
|
-
"the change it made.",
|
|
2116
|
-
promptSnippet: "a module's lineage: what was regenerated into it, and when",
|
|
2117
|
-
parameters: Type.Object({
|
|
2118
|
-
module: Type.String({ description: "The module's name" }),
|
|
2119
|
-
commit: Type.Optional(Type.String({ description: "A commit from the log, to see in full" })),
|
|
2120
|
-
}),
|
|
2121
|
-
async execute(_id, params) {
|
|
2122
|
-
const buildDir = defaultBuildDir(params.module, cwd);
|
|
2123
|
-
const text = params.commit ? historyShow(buildDir, params.commit) : historyLog(buildDir);
|
|
2124
|
-
return { content: [{ type: "text", text }], details: {} };
|
|
2125
|
-
},
|
|
2126
|
-
});
|
|
2127
2068
|
// The side panel: the regeneration - and the pulses behind p - over the whole screen, or beside the chat (s, from one to
|
|
2128
2069
|
// the other). Its key (PANEL_KEY) opens it; the key again closes it and goes back to the chat, as esc does over the
|
|
2129
2070
|
// screen - beside the chat, the key switches sides, giving the keys to the chat or the panel, as esc gives them to the
|
|
@@ -2165,9 +2106,9 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2165
2106
|
openPanel(ctx);
|
|
2166
2107
|
},
|
|
2167
2108
|
});
|
|
2168
|
-
// /
|
|
2109
|
+
// /settings: every setting of config.turri.yaml from the chat, each taking effect as it says - what turri fixed at its
|
|
2169
2110
|
// start changed here, as it runs.
|
|
2170
|
-
|
|
2111
|
+
registerSettings(pi, {
|
|
2171
2112
|
cwd,
|
|
2172
2113
|
rules: ruleNames,
|
|
2173
2114
|
chatSpec: () => modelSpec(projectModels(readProjectConfig(cwd)).harness),
|
|
@@ -2196,11 +2137,6 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2196
2137
|
dropped.push(`--coding-model ${process.env[CODING_MODEL_ENV]}`);
|
|
2197
2138
|
delete process.env[CODING_MODEL_ENV];
|
|
2198
2139
|
}
|
|
2199
|
-
chosenModelsAt = Date.now();
|
|
2200
|
-
for (const work of Object.keys(chosenModels)) {
|
|
2201
|
-
dropped.push(`the engine's ${work === "all" ? "" : `${work.replace(/_/g, " ")} `}model ${chosenModels[work]}`);
|
|
2202
|
-
delete chosenModels[work];
|
|
2203
|
-
}
|
|
2204
2140
|
return dropped.length === 0 ? undefined : `Chosen this session, and given way to the config: ${dropped.join("; ")}.`;
|
|
2205
2141
|
},
|
|
2206
2142
|
parallelJobs: (count) => {
|
|
@@ -2213,18 +2149,42 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
2213
2149
|
}
|
|
2214
2150
|
export { fromWorkingDir };
|
|
2215
2151
|
const WATCH_REDRAW_MS = 500;
|
|
2152
|
+
/**
|
|
2153
|
+
* What a chat's agent is told of a pulse it asked for that ended, with the sentinel off. One that landed under
|
|
2154
|
+
* launch-after-pulse is being launched as it is told: it says so, and offers nothing else for it - it is told once the
|
|
2155
|
+
* launch ends.
|
|
2156
|
+
*/
|
|
2157
|
+
export function pulseEndNote(job, options = {}) {
|
|
2158
|
+
const head = job.status === "succeeded"
|
|
2159
|
+
? `Pulse ${job.id} (${job.kind}) finished after ${formatDuration(job)}.\n\n${job.report ?? ""}`
|
|
2160
|
+
: job.status === "stopped"
|
|
2161
|
+
? `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." : ""}`
|
|
2162
|
+
: `Pulse ${job.id} (${job.kind}) failed after ${formatDuration(job)}.\n\n${job.error ?? ""}`;
|
|
2163
|
+
const landed = job.status === "succeeded" && job.details?.landed === true;
|
|
2164
|
+
if (!landed || options.launching !== true)
|
|
2165
|
+
return `${head}\n\n${JOB_FINISHED_REACTION}`;
|
|
2166
|
+
return [
|
|
2167
|
+
head,
|
|
2168
|
+
"",
|
|
2169
|
+
"It landed, and turri is launching the commit it landed now, in the background (launch-after-pulse): you are told once",
|
|
2170
|
+
"that launch ends - where it runs, or why it did not come up. React to this now - the person has not asked, and need",
|
|
2171
|
+
"not: say in a line or two what landed and that it is being launched. Offer nothing else for it - do not call launch,",
|
|
2172
|
+
"open it, run it or test it, and never say nothing runs - and start no other work, unless guidance for this project",
|
|
2173
|
+
"(its AGENTS.md, a skill, what the person said) says to do something besides launching it when a pulse finishes: do",
|
|
2174
|
+
"that. When you are told it is launched, do what you were told to do once something is launched.",
|
|
2175
|
+
].join("\n");
|
|
2176
|
+
}
|
|
2216
2177
|
/**
|
|
2217
2178
|
* 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
|
|
2218
2179
|
* in a line or two what ended - the person saw it end already, in the transcript.
|
|
2219
2180
|
*/
|
|
2220
2181
|
export const JOB_FINISHED_REACTION = [
|
|
2221
2182
|
"React to this now - the person has not asked, and need not. If guidance for this project - its AGENTS.md, a skill,",
|
|
2222
|
-
"what the person said earlier - says what to do when a pulse finishes (
|
|
2183
|
+
"what the person said earlier - says what to do when a pulse finishes (launch what was built, run something, tell",
|
|
2223
2184
|
"someone), do that, as it says. Otherwise say in a line or two what finished and what it means for the person - the",
|
|
2224
2185
|
"report is theirs to read in full; do not repeat it - and, when it failed, what they can do. Start no other work.",
|
|
2225
|
-
"
|
|
2226
|
-
"
|
|
2227
|
-
"told to do once something is released (opening it where the person can watch it, saying what to test), if anything.",
|
|
2186
|
+
"Under launch-after-pulse turri launches what a pulse lands itself, in the background: do not call launch for it - you",
|
|
2187
|
+
"are told once it is launched, and do then what you were told to do once something is launched.",
|
|
2228
2188
|
"A pulse that stopped on its environment - \"stopped: turri's sandbox kept its agents from…\" or \"stopped: the",
|
|
2229
2189
|
"environment lacks…\" - stops the same way again until that is fixed: never regenerate it before. Heal it, then regenerate the",
|
|
2230
2190
|
"module to resume:",
|
|
@@ -2539,36 +2499,59 @@ function modulesWithHistory(cwd) {
|
|
|
2539
2499
|
}
|
|
2540
2500
|
/** Stop a job by id or id prefix, and say what that means for the queue. */
|
|
2541
2501
|
/** Every job, in the order it was started, with what a queued one is waiting for. */
|
|
2542
|
-
/** What
|
|
2543
|
-
function
|
|
2544
|
-
return `
|
|
2502
|
+
/** What a launch started, as /halt offers it. */
|
|
2503
|
+
function launchedLabel(name, what) {
|
|
2504
|
+
return `launched ${name} running ${what}`;
|
|
2545
2505
|
}
|
|
2546
2506
|
/** The jobs as the person is shown them: those started, and those the work loop has planned after them. */
|
|
2547
2507
|
function shownJobs(jobs) {
|
|
2548
2508
|
return [...(workLoops.get(jobs)?.loop.planned() ?? []), ...jobs.list()];
|
|
2549
2509
|
}
|
|
2550
|
-
function listJobs(jobs, cwd) {
|
|
2510
|
+
function listJobs(jobs, cwd, runs = EARLIER_RUNS) {
|
|
2551
2511
|
const all = [...shownJobs(jobs)].reverse().filter((job) => job.replacedBy === undefined);
|
|
2552
|
-
const
|
|
2553
|
-
const
|
|
2554
|
-
const
|
|
2512
|
+
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})`);
|
|
2513
|
+
const launches = (sessionLaunches.get(jobs)?.track.list() ?? []).slice(-10).reverse().map(describeLaunchLine);
|
|
2514
|
+
const listed = (launches.length > 0 ? `\n\nLaunches, newest first - /halt launched <module> halts one under way:\n${launches.join("\n")}` : "") +
|
|
2515
|
+
(servers.length > 0 ? `\n\nWhat launches started - /halt launched <name> halts one:\n${servers.join("\n")}` : "");
|
|
2516
|
+
const before = earlierRuns(jobs, cwd, runs);
|
|
2555
2517
|
if (all.length === 0)
|
|
2556
2518
|
return `No pulses have been started in this session.${listed}${before}`;
|
|
2557
2519
|
return `${jobLines(all)}${listed}${before}`;
|
|
2558
2520
|
}
|
|
2521
|
+
/** How many runs of earlier sessions `pulses` lists when it is asked for none. */
|
|
2522
|
+
const EARLIER_RUNS = 3;
|
|
2559
2523
|
/** Earlier sessions' last runs and their pulses, from the ledger - nothing when it has none. */
|
|
2560
|
-
function earlierRuns(jobs, cwd) {
|
|
2524
|
+
function earlierRuns(jobs, cwd, runs) {
|
|
2561
2525
|
try {
|
|
2562
|
-
const found = earlierPulses(ledgerProjects(cwd), new Set(jobs.list().map((job) => job.id)));
|
|
2526
|
+
const found = earlierPulses(ledgerProjects(cwd), new Set(jobs.list().map((job) => job.id)), runs);
|
|
2563
2527
|
if (found.runs.length === 0)
|
|
2564
2528
|
return "";
|
|
2565
|
-
const more = found.more > 0 ? `\n\n${found.more} earlier run${found.more === 1 ? "" : "s"} beyond these
|
|
2566
|
-
return `\n\nEarlier sessions, from the ledger - pulses
|
|
2529
|
+
const more = found.more > 0 ? `\n\n${found.more} earlier run${found.more === 1 ? "" : "s"} beyond these: ask with runs for more.` : "";
|
|
2530
|
+
return `\n\nEarlier sessions, from the ledger - pulses with a pulse's id tells one:\n${describeRuns(found.runs)}${more}`;
|
|
2567
2531
|
}
|
|
2568
2532
|
catch {
|
|
2569
2533
|
return "";
|
|
2570
2534
|
}
|
|
2571
2535
|
}
|
|
2536
|
+
/** A look ahead, for the chat: what is planned in each codebase, each row by its id, and what happens next. */
|
|
2537
|
+
function describeLookAhead(loop, statuses) {
|
|
2538
|
+
const modules = new Set(statuses.map((status) => status.module));
|
|
2539
|
+
const rows = loop.planned().filter((row) => row.module !== undefined && modules.has(row.module));
|
|
2540
|
+
const listed = rows.length > 0 ? `\n\nThe planned pulses - pulses with a row's id tells its cases and, for the next pulse of a codebase, the whole prompt its coding agent will get:\n${rows.map((row) => `${row.id} ${row.summary}`).join("\n")}` : "";
|
|
2541
|
+
return (`${describeModules(statuses)}${listed}\n\n` +
|
|
2542
|
+
"Nothing was started. What is planned here waits for regenerate, conform or /regenerate, which runs this plan as it is - unless " +
|
|
2543
|
+
"the ***plain or the steering changes first, when it is planned again. To change the plan, use steer or change the ***plain, then " +
|
|
2544
|
+
"look again. Tell the user what will run and in what order - the parts they are likely to care about.");
|
|
2545
|
+
}
|
|
2546
|
+
/** A planned row, for the chat: what it is, and its prompt when it is the next pulse of its codebase. */
|
|
2547
|
+
function describePlannedRow(row, pulse) {
|
|
2548
|
+
const head = `${row.id} · ${pulseName(row)}: ${row.note ?? "planned, not started"}${row.waitingOn.length > 0 ? ` It runs after ${row.waitingOn.join(", ")}.` : ""}`;
|
|
2549
|
+
if (pulse?.task !== undefined) {
|
|
2550
|
+
return (`${head}\n\nThe whole prompt its coding agent will get - built from the plan kept, the one regenerate runs:\n<prompt>\n${pulse.task}\n</prompt>\n\n` +
|
|
2551
|
+
"Tell the user what the pulse is and what it will be told - the parts they are likely to care about, not the whole prompt unless they ask.");
|
|
2552
|
+
}
|
|
2553
|
+
return pulse?.why !== undefined ? `${head}\n\nNo prompt shown: ${pulse.why}` : head;
|
|
2554
|
+
}
|
|
2572
2555
|
function jobLines(all) {
|
|
2573
2556
|
return all
|
|
2574
2557
|
.map((job) => {
|
|
@@ -2578,7 +2561,8 @@ function jobLines(all) {
|
|
|
2578
2561
|
const after = job.status === "queued" && job.waitingOn.length > 0 ? ` (after ${job.waitingOn.join(", ")})` : "";
|
|
2579
2562
|
const spent = describeUsage(job.usage);
|
|
2580
2563
|
const model = job.model ? ` · ${job.model}` : "";
|
|
2581
|
-
|
|
2564
|
+
const held = job.lookedAhead === true ? " · looked ahead: waits for regenerate" : "";
|
|
2565
|
+
return `${job.id} ${(planned ? "planned" : job.status).padEnd(9)} ${time.padStart(7)} ${pulseName(job)}${model}${after}${held}${spent ? ` · ${spent}` : ""}`;
|
|
2582
2566
|
})
|
|
2583
2567
|
.join("\n");
|
|
2584
2568
|
}
|
|
@@ -2655,11 +2639,6 @@ function registerSteering(pi, cwd) {
|
|
|
2655
2639
|
},
|
|
2656
2640
|
});
|
|
2657
2641
|
}
|
|
2658
|
-
/**
|
|
2659
|
-
* Deploy: the conversation puts what is built out in dist/<module> and starts it on this machine (see
|
|
2660
|
-
* regenerate/release.ts), installing what it needs in its own shell - nothing is put to the person. What it
|
|
2661
|
-
* started is stopped when the session ends.
|
|
2662
|
-
*/
|
|
2663
2642
|
const SIDE_ENTRY = "turri_btw";
|
|
2664
2643
|
/** A message the person sent while a skill ran in the chat, read by the skill's agent: drawn as the message it is. */
|
|
2665
2644
|
const SKILL_MESSAGE_ENTRY = "turri_skill_message";
|
|
@@ -2732,20 +2711,37 @@ async function askOnTheSide(pi, ctx, cwd, jobs, question) {
|
|
|
2732
2711
|
}
|
|
2733
2712
|
return answer;
|
|
2734
2713
|
}
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2714
|
+
/** A launch ended, told to a chat's agent - to tell the person where it runs, or why it did not come up. */
|
|
2715
|
+
function tellLaunch(pi, jobs, launch) {
|
|
2716
|
+
const job = "pulse" in launch.cause ? jobs.get(launch.cause.pulse) : undefined;
|
|
2717
|
+
void pi.sendMessage({ customType: "turri_launch", content: launchedNote(launch, job), display: false, details: { launch: launch.id, status: launch.status } }, { triggerTurn: true, deliverAs: "followUp" });
|
|
2718
|
+
}
|
|
2719
|
+
/** A newer launch took the place of one a chat asked for, told to its agent: it hears that one's end instead. */
|
|
2720
|
+
function tellReplaced(pi, jobs, launch, next) {
|
|
2721
|
+
const job = "pulse" in next.cause ? jobs.get(next.cause.pulse) : undefined;
|
|
2722
|
+
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" });
|
|
2723
|
+
}
|
|
2724
|
+
function registerLaunch(pi, cwd, jobs) {
|
|
2725
|
+
const launches = sessionLaunches.get(jobs);
|
|
2726
|
+
if (launches !== undefined) {
|
|
2727
|
+
pi.registerTool(launchTool({
|
|
2728
|
+
cwd,
|
|
2729
|
+
track: launches.track,
|
|
2730
|
+
defaultPlainFile: () => readProjectConfig(cwd).module,
|
|
2731
|
+
chat: () => currentChat()?.id,
|
|
2732
|
+
// Told in the chat that asked, as a launch after a pulse is with the sentinel off.
|
|
2733
|
+
ended: (launch) => tellLaunch(pi, jobs, launch),
|
|
2734
|
+
replaced: (launch, next) => tellReplaced(pi, jobs, launch, next),
|
|
2735
|
+
wait: (ctx) => shouldWait(ctx.mode, undefined),
|
|
2736
|
+
}));
|
|
2737
|
+
}
|
|
2738
|
+
pi.registerTool(haltTool({ jobs, workLoop: () => workLoops.get(jobs)?.loop, ...(launches !== undefined ? { launches: launches.track } : {}) }));
|
|
2739
|
+
// What launches started runs until turri ends - not when a chat is opened, closed, forked or reloaded.
|
|
2746
2740
|
pi.on("session_shutdown", async (event) => {
|
|
2747
|
-
if (event.reason
|
|
2748
|
-
|
|
2741
|
+
if (event.reason !== "quit")
|
|
2742
|
+
return;
|
|
2743
|
+
await launches?.track.stop();
|
|
2744
|
+
await stopLaunched();
|
|
2749
2745
|
});
|
|
2750
2746
|
}
|
|
2751
2747
|
const MILESTONE_ENTRY = "turri_milestone";
|
|
@@ -2966,9 +2962,11 @@ function registerBranding(pi, skills) {
|
|
|
2966
2962
|
(data.commit !== undefined ? theme.fg("dim", ` from a clone, ${data.commit}${data.changed ? " with changes" : ""}`) : ""),
|
|
2967
2963
|
// A newer turri out, or one installed and hidden behind this one: said first, under the version it is about.
|
|
2968
2964
|
...(data.versions ?? []).map((line) => theme.fg("warning", line)),
|
|
2965
|
+
// A key renamed is information; the rest are the person's to take out.
|
|
2966
|
+
...(data.config ?? []).map((line) => theme.fg(line.kind === "renamed" ? "muted" : "warning", line.text)),
|
|
2969
2967
|
`${theme.fg("text", "the first coding agent with the power of ")}${brandPink(theme)("regenerative software")}`,
|
|
2970
2968
|
// Where the settings are changed, without leaving the chat.
|
|
2971
|
-
theme.fg("muted", "configure with /
|
|
2969
|
+
theme.fg("muted", "configure with /settings"),
|
|
2972
2970
|
// Only what is wrong: skills that did not load, and agents' commands less fenced than they should be.
|
|
2973
2971
|
...(data.pending > 0 ? [theme.fg("warning", `${data.pending} skill${data.pending === 1 ? "" : "s"} failed to load`)] : []),
|
|
2974
2972
|
...(data.sandbox !== undefined && data.sandbox.level !== "ok" ? [theme.fg(data.sandbox.level === "limited" ? "warning" : "error", data.sandbox.text)] : []),
|
|
@@ -3017,6 +3015,7 @@ function registerBranding(pi, skills) {
|
|
|
3017
3015
|
pending: skills.pending.length,
|
|
3018
3016
|
sandbox: sandboxSummary(),
|
|
3019
3017
|
versions: versions.lines,
|
|
3018
|
+
config: configLines(ctx.cwd),
|
|
3020
3019
|
});
|
|
3021
3020
|
}
|
|
3022
3021
|
catch {
|