@turri-dev/cli 0.4.2-next.a6867e8 → 0.4.3-next.aea3ca1
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/dist/chat-terminal.js +7 -7
- package/dist/chat-waiting.d.ts +4 -1
- package/dist/chat-waiting.js +7 -4
- package/dist/chats.d.ts +1 -1
- package/dist/chats.js +1 -1
- package/dist/extension.js +66 -84
- package/dist/identity.js +1 -1
- package/dist/loop-tools.d.ts +2 -3
- package/dist/loop-tools.js +7 -12
- package/dist/regenerate/chunk-plan.d.ts +2 -11
- package/dist/regenerate/chunk-plan.js +9 -20
- package/dist/regenerate/command-check.d.ts +9 -0
- package/dist/regenerate/command-check.js +83 -3
- package/dist/regenerate/loop.d.ts +6 -14
- package/dist/regenerate/loop.js +42 -34
- package/dist/regenerate/test-scripts.d.ts +3 -0
- package/dist/regenerate/test-scripts.js +16 -5
- package/dist/resume-line.d.ts +4 -1
- package/dist/resume-line.js +5 -2
- package/dist/sentinel.js +1 -1
- package/docs/chats.md +0 -1
- package/docs/config.md +2 -0
- package/docs/regenerating.md +8 -7
- package/docs/sandbox.md +2 -0
- package/docs/skills-and-gates.md +1 -1
- package/docs/using.md +2 -3
- package/genome/rules/turri-regeneration.md +1 -1
- package/package.json +3 -3
- package/dist/regenerate/steer.d.ts +0 -34
- package/dist/regenerate/steer.js +0 -91
package/dist/chat-terminal.js
CHANGED
|
@@ -135,17 +135,17 @@ export function driveTerminal(core, options = {}) {
|
|
|
135
135
|
return;
|
|
136
136
|
from?.ui?.hide();
|
|
137
137
|
// pi takes the shown chat's widgets and dialogs off the screen, as it does before replacing a session - but not the
|
|
138
|
-
//
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
// overlays on it: the side panel, the session's and not the chat's, stays where it is, beside the chat or over it.
|
|
139
|
+
// pi takes off every overlay it holds, so for that moment it holds none.
|
|
140
|
+
const overlays = screen?.extensionOverlays;
|
|
141
|
+
const kept = [...(overlays ?? [])];
|
|
142
|
+
overlays?.clear();
|
|
143
143
|
try {
|
|
144
144
|
runtime.beforeSessionInvalidate?.();
|
|
145
145
|
}
|
|
146
146
|
finally {
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
for (const [handle, remove] of kept)
|
|
148
|
+
overlays?.set(handle, remove);
|
|
149
149
|
}
|
|
150
150
|
runtime._session = chat.session;
|
|
151
151
|
runtime._services = chat.services;
|
package/dist/chat-waiting.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ import { type Component } from "@earendil-works/pi-tui";
|
|
|
14
14
|
export interface WaitingScreen {
|
|
15
15
|
chatContainer: Container;
|
|
16
16
|
pendingMessagesContainer: Container;
|
|
17
|
+
/** The output of commands the person ran (`!`) while the agent works: pi keeps it there until it goes in the chat. */
|
|
18
|
+
pendingBashComponents?: Component[];
|
|
17
19
|
getAllQueuedMessages(): {
|
|
18
20
|
steering: string[];
|
|
19
21
|
followUp: string[];
|
|
@@ -36,7 +38,8 @@ export declare class Shade implements Component {
|
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Under the chat, each message the agent has not read yet, drawn as pi draws a message in the chat - shaded, and
|
|
39
|
-
* marked not read yet - in the order they were sent
|
|
41
|
+
* marked not read yet - in the order they were sent; under the output of any command the person ran meanwhile, as pi
|
|
42
|
+
* draws them.
|
|
40
43
|
*/
|
|
41
44
|
export declare function showWaiting(screen: WaitingScreen): void;
|
|
42
45
|
/** What of pi's session `unqueue` reaches. */
|
package/dist/chat-waiting.js
CHANGED
|
@@ -21,11 +21,14 @@ export class Shade {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Under the chat, each message the agent has not read yet, drawn as pi draws a message in the chat - shaded, and
|
|
24
|
-
* marked not read yet - in the order they were sent
|
|
24
|
+
* marked not read yet - in the order they were sent; under the output of any command the person ran meanwhile, as pi
|
|
25
|
+
* draws them.
|
|
25
26
|
*/
|
|
26
27
|
export function showWaiting(screen) {
|
|
27
28
|
const area = screen.pendingMessagesContainer;
|
|
28
29
|
area.clear();
|
|
30
|
+
for (const output of screen.pendingBashComponents ?? [])
|
|
31
|
+
area.addChild(output);
|
|
29
32
|
const { steering, followUp } = screen.getAllQueuedMessages();
|
|
30
33
|
const waiting = [...steering, ...followUp];
|
|
31
34
|
if (waiting.length === 0)
|
|
@@ -36,9 +39,9 @@ export function showWaiting(screen) {
|
|
|
36
39
|
const chat = screen.chatContainer;
|
|
37
40
|
screen.chatContainer = area;
|
|
38
41
|
try {
|
|
39
|
-
for (const text of waiting) {
|
|
40
|
-
// A line between it and
|
|
41
|
-
if (
|
|
42
|
+
for (const [index, text] of waiting.entries()) {
|
|
43
|
+
// A line between it and what is above it; pi puts one between messages itself.
|
|
44
|
+
if (index === 0)
|
|
42
45
|
area.addChild(new Spacer(1));
|
|
43
46
|
const before = area.children.length;
|
|
44
47
|
screen.addMessageToChat({ role: "user", content: [{ type: "text", text }], timestamp: Date.now() });
|
package/dist/chats.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { type ChatRole, type Conclusion, type Notice, type NoticeAnswer, type No
|
|
|
14
14
|
* One turri process is one session on one project, and holds up to MAX_CHATS chats: conversations, each with its own
|
|
15
15
|
* history, model, thinking level and questions, each working while another is shown. What they share is the
|
|
16
16
|
* session's: the one job registry and work loop the project's pulses run in - a pulse any chat starts is in every
|
|
17
|
-
* chat's side panel - the coding model,
|
|
17
|
+
* chat's side panel - the coding model, launches and the ledger.
|
|
18
18
|
*
|
|
19
19
|
* A chat is a pi session with turri's extension in it. The extension, built once for each, links itself to its chat
|
|
20
20
|
* here (`attach`); its tools, commands and handlers then run inside the chat's scope (chat-scope.ts), so a pulse knows
|
package/dist/chats.js
CHANGED
|
@@ -12,7 +12,7 @@ import { newNotice, noticeTask, SENTINEL, sentinelStartChoice, wentWrong } from
|
|
|
12
12
|
* One turri process is one session on one project, and holds up to MAX_CHATS chats: conversations, each with its own
|
|
13
13
|
* history, model, thinking level and questions, each working while another is shown. What they share is the
|
|
14
14
|
* session's: the one job registry and work loop the project's pulses run in - a pulse any chat starts is in every
|
|
15
|
-
* chat's side panel - the coding model,
|
|
15
|
+
* chat's side panel - the coding model, launches and the ledger.
|
|
16
16
|
*
|
|
17
17
|
* A chat is a pi session with turri's extension in it. The extension, built once for each, links itself to its chat
|
|
18
18
|
* here (`attach`); its tools, commands and handlers then run inside the chat's scope (chat-scope.ts), so a pulse knows
|
package/dist/extension.js
CHANGED
|
@@ -31,7 +31,6 @@ import { launchTool } from "./launch-tools.js";
|
|
|
31
31
|
import { createSessionLaunches, launchedDir, launchedNote, replacedNote } from "./launch-session.js";
|
|
32
32
|
import { describeLaunchLine, launchText } from "./launch-track.js";
|
|
33
33
|
import { checkedSpecs } from "./sentinel-check.js";
|
|
34
|
-
import { createSteeringStore, EVERY_MODULE, moduleNameOf, queueSectionOf, steeringFor } from "./regenerate/steer.js";
|
|
35
34
|
import { askedForCommandLine, refusal, selfInvocation, TOOLS_NOT_CLI } from "./self-invocation.js";
|
|
36
35
|
import { NEW_PROJECT } from "./new-project.js";
|
|
37
36
|
import { describeResolution, resolveModel } from "./regenerate/model-names.js";
|
|
@@ -745,7 +744,6 @@ function turriExtension(api, session, link) {
|
|
|
745
744
|
registerDrift(pi, cwd, jobs);
|
|
746
745
|
registerBind(pi, cwd, jobs, (plainFile) => turnOnConformance(session, plainFile));
|
|
747
746
|
registerLaunch(pi, cwd, jobs);
|
|
748
|
-
registerSteering(pi, cwd);
|
|
749
747
|
registerSideQuestions(pi, cwd, jobs);
|
|
750
748
|
// More chats beside this one, in the terminal: /chat, alt+n, alt+1…9 (chat-commands.ts).
|
|
751
749
|
if (session.terminal)
|
|
@@ -769,23 +767,58 @@ function turriExtension(api, session, link) {
|
|
|
769
767
|
// A skill that runs in the background: started, and the turn goes on; its end comes back to this chat once it is idle.
|
|
770
768
|
const skillRunEnds = skillRunDelivery(pi, link, contextNow);
|
|
771
769
|
pi.on("session_shutdown", (event) => {
|
|
772
|
-
if (event.reason
|
|
773
|
-
|
|
774
|
-
|
|
770
|
+
if (event.reason !== "quit")
|
|
771
|
+
return;
|
|
772
|
+
for (const waiting of backgroundSkillQueue.values())
|
|
773
|
+
for (const run of waiting.splice(0))
|
|
774
|
+
run.drop();
|
|
775
|
+
for (const controller of backgroundSkillRuns.values())
|
|
776
|
+
controller.abort();
|
|
775
777
|
});
|
|
776
778
|
const startInBackground = (skill, params, plainFile, ctx) => {
|
|
777
779
|
const key = `${cwd}\0${skill.name}`;
|
|
780
|
+
const kind = scriptKindOfSkill(skill.name);
|
|
781
|
+
const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
|
|
778
782
|
if (backgroundSkillRuns.has(key)) {
|
|
779
|
-
|
|
783
|
+
const waiting = backgroundSkillQueue.get(key) ?? [];
|
|
784
|
+
const runningFor = backgroundSkillFor.get(key);
|
|
785
|
+
// Another module's run waits its turn - its testing script counted as being written from now, so the modules that
|
|
786
|
+
// need it wait for it rather than start with another's. The same module's, or one for none, is the run under way.
|
|
787
|
+
if (plainFile === undefined || runningFor === undefined || runningFor === plainFile || waiting.some((run) => run.plainFile === plainFile)) {
|
|
788
|
+
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 } };
|
|
789
|
+
}
|
|
790
|
+
const configModule = configModuleFor(plainFile);
|
|
791
|
+
const held = kind !== undefined ? writingScript({ project: projectDirOf(plainFile), kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
792
|
+
waiting.push({
|
|
793
|
+
plainFile,
|
|
794
|
+
// Started before the hold is let go: the module is never seen with no script being written in between.
|
|
795
|
+
start: () => {
|
|
796
|
+
try {
|
|
797
|
+
startInBackground(skill, params, plainFile, ctx);
|
|
798
|
+
}
|
|
799
|
+
catch (error) {
|
|
800
|
+
const why = `did not start: ${error instanceof Error ? error.message : String(error)}`;
|
|
801
|
+
skillRunEnds.put({ skill: skill.name, ok: false, line: `${skill.name} ${why}.`, task: failedTask(skill.name, why, undefined, kind), ...runDetails(kind, shown) });
|
|
802
|
+
}
|
|
803
|
+
finally {
|
|
804
|
+
held();
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
drop: held,
|
|
808
|
+
});
|
|
809
|
+
backgroundSkillQueue.set(key, waiting);
|
|
810
|
+
return {
|
|
811
|
+
text: `${skill.name} is running in the background for ${relative(cwd, runningFor) || basename(runningFor)}; the run for ${shown} starts once it ends, and what it does comes back to this chat then.${kind !== undefined ? ` Until it has written its ${kind === "unit" ? "unit testing script" : "conformance testing script"}, the modules that need it wait for it.` : ""} Do not start it again.`,
|
|
812
|
+
details: { background: true, ...runDetails(kind, shown) },
|
|
813
|
+
};
|
|
780
814
|
}
|
|
781
815
|
const model = skill.model === "coding" ? jobModel(ctx, undefined, plainFile) : conversationModel(ctx);
|
|
782
816
|
const configModule = plainFile !== undefined ? configModuleFor(plainFile) : undefined;
|
|
783
|
-
const kind = scriptKindOfSkill(skill.name);
|
|
784
|
-
const shown = plainFile !== undefined ? relative(cwd, plainFile) || basename(plainFile) : undefined;
|
|
785
817
|
// While it writes a testing script, the modules that need it wait for it rather than fail for want of it.
|
|
786
818
|
const written = kind !== undefined ? writingScript({ project: plainFile !== undefined ? projectDirOf(plainFile) : cwd, kind, ...(configModule !== undefined ? { configModule } : {}) }) : () => { };
|
|
787
819
|
const controller = new AbortController();
|
|
788
820
|
backgroundSkillRuns.set(key, controller);
|
|
821
|
+
backgroundSkillFor.set(key, plainFile);
|
|
789
822
|
const context = [
|
|
790
823
|
conversationContext(ctx, params.context),
|
|
791
824
|
shown !== undefined ? `It is for ${shown}${configModule !== undefined ? `, built with ${moduleConfigFile(configModule)} over ${CONFIG_FILE}` : ""}.` : undefined,
|
|
@@ -829,6 +862,9 @@ function turriExtension(api, session, link) {
|
|
|
829
862
|
})
|
|
830
863
|
.finally(() => {
|
|
831
864
|
backgroundSkillRuns.delete(key);
|
|
865
|
+
backgroundSkillFor.delete(key);
|
|
866
|
+
// The next module's run, waiting its turn, starts before this one's hold is let go.
|
|
867
|
+
backgroundSkillQueue.get(key)?.shift()?.start();
|
|
832
868
|
written();
|
|
833
869
|
});
|
|
834
870
|
return {
|
|
@@ -1156,10 +1192,9 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1156
1192
|
wait: (ctx, asked) => shouldWait(ctx.mode, asked),
|
|
1157
1193
|
}));
|
|
1158
1194
|
// /regenerate: the same as the tool, from the person - a module brought up to its spec as it is now, cut into pulses
|
|
1159
|
-
// by the planner: one functional spec at a time, a few together or the whole module in one, as it judges.
|
|
1160
|
-
// follows the module is guidance for that plan, in the person's words.
|
|
1195
|
+
// by the planner: one functional spec at a time, a few together or the whole module in one, as it judges.
|
|
1161
1196
|
pi.registerCommand("regenerate", {
|
|
1162
|
-
description: "Regenerate a module from its ***plain as it is now, in pulses the planner cuts - named functional specs though they did not change, or all of it from scratch, its whole chain too when asked: /regenerate [module | file.plain] [module:func-id ...] [from scratch [whole chain]]
|
|
1197
|
+
description: "Regenerate a module from its ***plain as it is now, in pulses the planner cuts - named functional specs though they did not change, or all of it from scratch, its whole chain too when asked: /regenerate [module | file.plain] [module:func-id ...] [from scratch [whole chain]]",
|
|
1163
1198
|
handler: async (args, ctx) => {
|
|
1164
1199
|
const command = `/regenerate ${args.trim()}`.trim();
|
|
1165
1200
|
await echoCommand(pi, command);
|
|
@@ -1168,21 +1203,26 @@ function registerRegenerate(pi, cwd, jobs) {
|
|
|
1168
1203
|
if (picked === undefined)
|
|
1169
1204
|
return;
|
|
1170
1205
|
const { plainFile } = picked;
|
|
1171
|
-
// Functional specs named first, each as module:func-id, as on the command line
|
|
1172
|
-
const { funcIds: again, rest
|
|
1173
|
-
const
|
|
1206
|
+
// Functional specs named first, each as module:func-id, as on the command line.
|
|
1207
|
+
const { funcIds: again, rest } = funcIdsNamedFirst(picked.rest);
|
|
1208
|
+
const words = rest.join(" ").trim();
|
|
1174
1209
|
// From scratch - started over, its code deleted - asked in the person's words: started at once, as asked.
|
|
1175
|
-
const scratch = asksFromScratch(
|
|
1210
|
+
const scratch = asksFromScratch(words);
|
|
1176
1211
|
// The whole chain with it - "from scratch, the whole chain" - every module it requires built again from the bottom.
|
|
1177
|
-
const chain = scratch && asksWholeChain(
|
|
1212
|
+
const chain = scratch && asksWholeChain(words);
|
|
1178
1213
|
const module = basename(plainFile).replace(/\.plain$/, "");
|
|
1214
|
+
// Nothing but the functional specs and from scratch: the planner cuts the work as it judges, so other words are not dropped unsaid.
|
|
1215
|
+
if (words !== "" && !scratch) {
|
|
1216
|
+
say(`/regenerate takes functional specs, each as module:func-id, and "from scratch" with "whole chain" - not "${words}". Nothing was started.`, "warning");
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1179
1219
|
if (scratch && again.length > 0) {
|
|
1180
1220
|
say("Name functional specs or ask for it from scratch, not both: from scratch regenerates every one of them.", "warning");
|
|
1181
1221
|
return;
|
|
1182
1222
|
}
|
|
1183
1223
|
const loop = workLoopFor(jobs, cwd, ctx);
|
|
1184
1224
|
const model = jobModel(ctx, undefined, plainFile);
|
|
1185
|
-
const request = { ...(model !== undefined ? { model } : {})
|
|
1225
|
+
const request = { ...(model !== undefined ? { model } : {}) };
|
|
1186
1226
|
// Said at once, and kept in the chat: what follows takes a while - the planner is an agent - and the person sees it
|
|
1187
1227
|
// began, not a chat that stays empty until the first pulse starts. The plan is said under it once it is made.
|
|
1188
1228
|
say(scratch
|
|
@@ -1403,7 +1443,7 @@ function registerBind(pi, cwd, jobs, turnOn) {
|
|
|
1403
1443
|
const separately = asksOneByOne(words);
|
|
1404
1444
|
// From scratch - the tests written again, the code untouched - asked in the person's words; the whole chain's with it.
|
|
1405
1445
|
const scratch = asksFromScratch(words) ? (asksWholeChain(words) ? "chain" : "module") : undefined;
|
|
1406
|
-
// Nothing but the functional specs, from scratch and one by one:
|
|
1446
|
+
// Nothing but the functional specs, from scratch and one by one: other words are not dropped unsaid.
|
|
1407
1447
|
if (words !== "" && !separately && scratch === undefined) {
|
|
1408
1448
|
refuse(`/conform takes functional specs, each as module:func-id, "from scratch" with "whole chain" and "one by one" - not "${words}". Nothing was started.`);
|
|
1409
1449
|
return;
|
|
@@ -1796,6 +1836,10 @@ export function turnOnConformance(core, plainFile) {
|
|
|
1796
1836
|
}
|
|
1797
1837
|
/** The skills running in the background, by project and skill - one at a time each, whichever chat started it - with what stops them. */
|
|
1798
1838
|
const backgroundSkillRuns = new Map();
|
|
1839
|
+
/** The .plain file each run in `backgroundSkillRuns` is for. */
|
|
1840
|
+
const backgroundSkillFor = new Map();
|
|
1841
|
+
/** The runs for other modules waiting their turn, by project and skill: each started as the one before it ends, or dropped as turri quits. */
|
|
1842
|
+
const backgroundSkillQueue = new Map();
|
|
1799
1843
|
/**
|
|
1800
1844
|
* The model a pulse's agents run on: the one named on the call, checked now so a wrong name fails here and not minutes
|
|
1801
1845
|
* later in the background; else the coding model - `--coding-model`, or the module's config - else the conversation's.
|
|
@@ -1860,8 +1904,6 @@ function projectModel(ctx, plainFile) {
|
|
|
1860
1904
|
*/
|
|
1861
1905
|
/** The one work loop of a conversation's jobs: every tool that builds brings its modules up through it. */
|
|
1862
1906
|
const workLoops = new WeakMap();
|
|
1863
|
-
/** How the conversation wants the work planned, for the session - set with steer. */
|
|
1864
|
-
const steeringStore = createSteeringStore();
|
|
1865
1907
|
/** A session's launches, by its jobs: the launch track every chat's launch tool and every pulse's launch share. */
|
|
1866
1908
|
const sessionLaunches = new WeakMap();
|
|
1867
1909
|
function workLoopFor(jobs, cwd, ctx) {
|
|
@@ -1874,8 +1916,6 @@ function workLoopFor(jobs, cwd, ctx) {
|
|
|
1874
1916
|
modelFor: (plainFile) => projectModel(from.ctx, plainFile) ?? chatModelOf(from.ctx),
|
|
1875
1917
|
// The planner reasons about the whole of the work: it runs on the chat's model.
|
|
1876
1918
|
plannerModel: () => chatModelOf(from.ctx),
|
|
1877
|
-
// How the work is to be planned: the conversation's steering, and AGENTS.md's - read afresh each plan.
|
|
1878
|
-
steering: (plainFile) => steeringFor(plainFile, cwd, steeringStore),
|
|
1879
1919
|
// A pulse landed: its commit kept for the sentinel - and, under launch-after-pulse, launched in the background, the
|
|
1880
1920
|
// codebase's next pulse not waiting on it.
|
|
1881
1921
|
landed: (input) => sessionLaunches.get(jobs)?.landed(input),
|
|
@@ -1960,14 +2000,14 @@ function registerJobTools(pi, jobs, cwd) {
|
|
|
1960
2000
|
"the last failing test run with its output, the last review that sent the work back, the tool calls that failed, and where " +
|
|
1961
2001
|
"the whole log is; of an earlier session, told from the ledger; planned (planned-<module>-N), its cases and - the next pulse " +
|
|
1962
2002
|
"of its codebase - the whole prompt its coding agent will get, from the plan regenerate runs. With plain_file, a look " +
|
|
1963
|
-
"ahead: that module's work planned as regenerate plans it,
|
|
1964
|
-
"for regenerate, which then runs this plan unless the ***plain
|
|
2003
|
+
"ahead: that module's work planned as regenerate plans it, and kept - nothing started, its pulses waiting " +
|
|
2004
|
+
"for regenerate, which then runs this plan unless the ***plain changed - and what is planned listed. " +
|
|
1965
2005
|
"What is left to regenerate, without a plan, is drift's. Every generation of a module's code and tests is a commit in its " +
|
|
1966
2006
|
"history, read with git: git --git-dir=plain_modules/<module>/.plaingit log, and show <commit>.",
|
|
1967
2007
|
promptSnippet: "pulses: every pulse or one - earlier, running or planned - why one did not land, and with plain_file what will run next and its prompt",
|
|
1968
2008
|
promptGuidelines: [
|
|
1969
2009
|
"When a pulse failed or did not land, call pulses with its id before you explain it or change the spec: go by what happened, not by the report alone.",
|
|
1970
|
-
"Call pulses with plain_file when the user wants to see or check what will run before it does, then with a planned row's id for its prompt. To change the plan,
|
|
2010
|
+
"Call pulses with plain_file when the user wants to see or check what will run before it does, then with a planned row's id for its prompt. To change the plan, change the ***plain, then look again.",
|
|
1971
2011
|
],
|
|
1972
2012
|
parameters: Type.Object({
|
|
1973
2013
|
job_id: Type.Optional(Type.String({
|
|
@@ -2574,7 +2614,7 @@ function describeLookAhead(loop, statuses) {
|
|
|
2574
2614
|
const listed = rows.length > 0 ? `\n\nThe planned pulses - pulses with a row's id tells its cases and, for the next pulse of a codebase, the whole prompt its coding agent will get:\n${rows.map((row) => `${row.id} ${row.summary}`).join("\n")}` : "";
|
|
2575
2615
|
return (`${describeModules(statuses)}${listed}\n\n` +
|
|
2576
2616
|
"Nothing was started. What is planned here waits for regenerate, conform or /regenerate, which runs this plan as it is - unless " +
|
|
2577
|
-
"the ***plain
|
|
2617
|
+
"the ***plain changes first, when it is planned again. To change the plan, change the ***plain, then " +
|
|
2578
2618
|
"look again. Tell the user what will run and in what order - the parts they are likely to care about.");
|
|
2579
2619
|
}
|
|
2580
2620
|
/** A planned row, for the chat: what it is, and its prompt when it is the next pulse of its codebase. */
|
|
@@ -2615,64 +2655,6 @@ function registerCheckPlain(pi, cwd, dialogs, afterAnswer) {
|
|
|
2615
2655
|
for (const tool of createWebTools())
|
|
2616
2656
|
pi.registerTool(tool);
|
|
2617
2657
|
}
|
|
2618
|
-
/**
|
|
2619
|
-
* Steering the queue from the conversation: how the person wants the work cut into jobs and ordered, for the whole
|
|
2620
|
-
* project or one module, kept for the session and given to the planner with every plan - beside
|
|
2621
|
-
* what the project's AGENTS.md says of the queue (see render/steering.ts).
|
|
2622
|
-
*/
|
|
2623
|
-
function registerSteering(pi, cwd) {
|
|
2624
|
-
pi.registerTool({
|
|
2625
|
-
name: "steer",
|
|
2626
|
-
label: "Steer",
|
|
2627
|
-
description: "Say how the work is to be planned from now on - which functional specs are regenerated together, what goes first, how " +
|
|
2628
|
-
"big a pulse may be - for the whole project, or one module: every plan after this follows it as a strong preference, " +
|
|
2629
|
-
"within the planner's limits, for the rest of the session. It changes nothing queued by itself: the next plan of the " +
|
|
2630
|
-
"module follows it - regenerate makes one now. What the project's AGENTS.md says under a heading " +
|
|
2631
|
-
"naming the queue is followed too, with every plan.",
|
|
2632
|
-
promptSnippet: "steer how the work is planned, for the project or one module",
|
|
2633
|
-
promptGuidelines: [
|
|
2634
|
-
"When the user says how the work should be cut or ordered - 'build the batch worker's helpers with the worker', 'models first' - for more than one change, call steer with it in their words. For one change only, pass it as the guidance of regenerate.",
|
|
2635
|
-
"After steering, call regenerate to plan again. Where its reply lists what the plan did not do as asked, tell the user that and the reasons it gives - never a reason of your own.",
|
|
2636
|
-
],
|
|
2637
|
-
parameters: Type.Object({
|
|
2638
|
-
action: Type.Union([Type.Literal("add"), Type.Literal("set"), Type.Literal("clear"), Type.Literal("show")], {
|
|
2639
|
-
description: "add: one more wish; set: replace them all; clear: drop them; show: say what they are",
|
|
2640
|
-
}),
|
|
2641
|
-
text: Type.Optional(Type.String({ description: "The wish, in the user's words - for add and set" })),
|
|
2642
|
-
module: Type.Optional(Type.String({ description: "A module's .plain file or name. Omit: every module of the project" })),
|
|
2643
|
-
}),
|
|
2644
|
-
async execute(_id, params) {
|
|
2645
|
-
const scope = params.module !== undefined ? moduleNameOf(params.module) : EVERY_MODULE;
|
|
2646
|
-
const where = scope === EVERY_MODULE ? "every module" : scope;
|
|
2647
|
-
const text = params.text?.trim() ?? "";
|
|
2648
|
-
if ((params.action === "add" || params.action === "set") && text === "")
|
|
2649
|
-
throw new Error(`Say what to ${params.action}: text is empty.`);
|
|
2650
|
-
if (params.action === "add")
|
|
2651
|
-
steeringStore.set(scope, [...steeringStore.get(scope), text]);
|
|
2652
|
-
if (params.action === "set")
|
|
2653
|
-
steeringStore.set(scope, [text]);
|
|
2654
|
-
if (params.action === "clear")
|
|
2655
|
-
steeringStore.set(scope, []);
|
|
2656
|
-
const now = steeringStore.scopes().flatMap((key) => steeringStore.get(key).map((wish) => `- ${key === EVERY_MODULE ? "every module" : key}: ${wish}`));
|
|
2657
|
-
const agents = existsSync(join(cwd, "AGENTS.md")) ? queueSectionOf(readFileSync(join(cwd, "AGENTS.md"), "utf8")) : "";
|
|
2658
|
-
return {
|
|
2659
|
-
content: [
|
|
2660
|
-
{
|
|
2661
|
-
type: "text",
|
|
2662
|
-
text: [
|
|
2663
|
-
params.action === "show" ? "How the work is planned:" : `${params.action === "clear" ? "Cleared" : "Noted"} for ${where}. How the work is planned now:`,
|
|
2664
|
-
...(now.length > 0 ? now : ["- (nothing from the conversation)"]),
|
|
2665
|
-
...(agents !== "" ? ["", "And from AGENTS.md, every plan:", agents] : []),
|
|
2666
|
-
"",
|
|
2667
|
-
"The next plan of each module follows it; nothing planned changes until then.",
|
|
2668
|
-
].join("\n"),
|
|
2669
|
-
},
|
|
2670
|
-
],
|
|
2671
|
-
details: { scope, steering: now },
|
|
2672
|
-
};
|
|
2673
|
-
},
|
|
2674
|
-
});
|
|
2675
|
-
}
|
|
2676
2658
|
const SIDE_ENTRY = "turri_btw";
|
|
2677
2659
|
/** A message the person sent while a skill ran in the chat, read by the skill's agent: drawn as the message it is. */
|
|
2678
2660
|
const SKILL_MESSAGE_ENTRY = "turri_skill_message";
|
package/dist/identity.js
CHANGED
|
@@ -49,7 +49,7 @@ const IDENTITY_BEFORE = [
|
|
|
49
49
|
"they are talking to turri. What they should ask for, they ask you for, here.",
|
|
50
50
|
"",
|
|
51
51
|
"The person may have several chats with you open on this project at once, this one among them. What regenerates is",
|
|
52
|
-
"the same in every chat: the pulses and their plan,
|
|
52
|
+
"the same in every chat: the pulses and their plan, the engine's coding model and what was launched -",
|
|
53
53
|
"pulses lists every pulse, whichever chat asked for it. What was said in another chat is not in this one: when the",
|
|
54
54
|
"person speaks of it, ask.",
|
|
55
55
|
"",
|
package/dist/loop-tools.d.ts
CHANGED
|
@@ -9,15 +9,14 @@ import type { LaunchTrack } from "./launch-track.ts";
|
|
|
9
9
|
* own tools, on the conversation's loop, never copies of them.
|
|
10
10
|
*/
|
|
11
11
|
type AnyTool = ToolDefinition<any, any, any>;
|
|
12
|
-
/** How the queue is to be planned, for the work this call queues - see regenerate/steer.ts. */
|
|
13
|
-
export declare const GUIDANCE_PARAM: Type.TOptional<Type.TString>;
|
|
14
12
|
export declare const WORKING_DIR_PARAM: Type.TOptional<Type.TString>;
|
|
15
13
|
export declare const MODEL_PARAM: Type.TOptional<Type.TString>;
|
|
16
14
|
/**
|
|
17
15
|
* Why a module cannot be built with the config it would be built with: two of the modules it requires have a config
|
|
18
16
|
* file of their own (`configModuleFor`); or, in a project where modules have their own files, it has none - nor any
|
|
19
17
|
* module it requires - and config.turri.yaml alone names no unit testing script, so every pulse would stop for want of
|
|
20
|
-
* one. The files there are and the script each names, and what to do. Undefined when it can be built
|
|
18
|
+
* one. The files there are and the script each names, and what to do. Undefined when it can be built - and while a unit
|
|
19
|
+
* testing script is being written in the project, which may be its own: the work loop holds it until it has one.
|
|
21
20
|
*/
|
|
22
21
|
export declare function unbuildableConfig(plainFile: string): string | undefined;
|
|
23
22
|
/** `work`, once the module asked for can be built with the config it would be built with - refused before anything is planned otherwise (`unbuildableConfig`). */
|
package/dist/loop-tools.js
CHANGED
|
@@ -13,12 +13,8 @@ import { didNotLand } from "./regenerate/failure-reports.js";
|
|
|
13
13
|
import { runningLaunched, stopLaunched } from "./regenerate/launch.js";
|
|
14
14
|
import { projectDirOf } from "./regenerate/paths.js";
|
|
15
15
|
import { findTestScripts } from "./regenerate/test-scripts.js";
|
|
16
|
+
import { scriptBeingWritten } from "./regenerate/scripts-being-written.js";
|
|
16
17
|
import { surfaceOf } from "./surface.js";
|
|
17
|
-
/** How the queue is to be planned, for the work this call queues - see regenerate/steer.ts. */
|
|
18
|
-
export const GUIDANCE_PARAM = Type.Optional(Type.String({
|
|
19
|
-
description: "How to plan the queue for this work, in a sentence or two - which functional specs go together, what first - as " +
|
|
20
|
-
"the user said it, or as you understood it. A strong preference for the planner, within its limits. Omit when there is none.",
|
|
21
|
-
}));
|
|
22
18
|
export const WORKING_DIR_PARAM = Type.Optional(Type.String({
|
|
23
19
|
description: "The folder the .plain files are in, relative to where turri was started - as if it had been started there " +
|
|
24
20
|
"(e.g. \"plain\"). plain_file is then relative to it - hubspot.plain, not plain/hubspot.plain. Default: where " +
|
|
@@ -33,7 +29,8 @@ export const MODEL_PARAM = Type.Optional(Type.String({
|
|
|
33
29
|
* Why a module cannot be built with the config it would be built with: two of the modules it requires have a config
|
|
34
30
|
* file of their own (`configModuleFor`); or, in a project where modules have their own files, it has none - nor any
|
|
35
31
|
* module it requires - and config.turri.yaml alone names no unit testing script, so every pulse would stop for want of
|
|
36
|
-
* one. The files there are and the script each names, and what to do. Undefined when it can be built
|
|
32
|
+
* one. The files there are and the script each names, and what to do. Undefined when it can be built - and while a unit
|
|
33
|
+
* testing script is being written in the project, which may be its own: the work loop holds it until it has one.
|
|
37
34
|
*/
|
|
38
35
|
export function unbuildableConfig(plainFile) {
|
|
39
36
|
const root = projectDirOf(plainFile);
|
|
@@ -45,7 +42,7 @@ export function unbuildableConfig(plainFile) {
|
|
|
45
42
|
return error instanceof Error ? error.message : String(error);
|
|
46
43
|
}
|
|
47
44
|
const files = moduleConfigsOf(root);
|
|
48
|
-
if (files.length === 0 || own !== undefined || findTestScripts(root).unit !== undefined)
|
|
45
|
+
if (files.length === 0 || own !== undefined || findTestScripts(root).unit !== undefined || scriptBeingWritten(root, "unit"))
|
|
49
46
|
return undefined;
|
|
50
47
|
const scripts = files.map((each) => {
|
|
51
48
|
const unit = withConfigModule(each, () => findTestScripts(root).unit);
|
|
@@ -190,8 +187,7 @@ export function stopJob(jobs, named, reason, loop) {
|
|
|
190
187
|
// A spec diff's change is in the .plain files: stopping its render does not take it out of the spec.
|
|
191
188
|
const inSpec = target.kind === "regenerate"
|
|
192
189
|
? " Its change is still in the .plain files: nothing more is regenerated in that codebase until the spec changes or it is asked " +
|
|
193
|
-
"for again with regenerate - then it is regenerated with the rest. To drop the change, take it out of the spec and regenerate
|
|
194
|
-
"how the work is cut or ordered, use steer."
|
|
190
|
+
"for again with regenerate - then it is regenerated with the rest. To drop the change, take it out of the spec and regenerate."
|
|
195
191
|
: "";
|
|
196
192
|
return stopped.status === "stopped"
|
|
197
193
|
? `Stopped ${pulseName(target)} (${target.id}) before it started.${queued}${inSpec}`
|
|
@@ -241,7 +237,6 @@ export function regenerateTool(options) {
|
|
|
241
237
|
parameters: Type.Object({
|
|
242
238
|
plain_file: Type.Optional(Type.String({ description: "Path to the .plain file. Omitted: the module the project's config.turri.yaml names" })),
|
|
243
239
|
working_dir: WORKING_DIR_PARAM,
|
|
244
|
-
guidance: GUIDANCE_PARAM,
|
|
245
240
|
funcIds: Type.Optional(Type.Array(Type.String(), {
|
|
246
241
|
description: "Functional specs already built, each as module:func-id (todo:add-task), to regenerate though their spec did not change. Omitted: what the spec now differs from the code in",
|
|
247
242
|
})),
|
|
@@ -264,7 +259,7 @@ export function regenerateTool(options) {
|
|
|
264
259
|
throw new Error("Name funcIds or set from_scratch, not both: from scratch regenerates every one of them.");
|
|
265
260
|
const model = options.model !== undefined ? options.model(ctx, plainFile, given.model) : given.model;
|
|
266
261
|
const loop = options.loop(ctx);
|
|
267
|
-
const request = { ...(model !== undefined ? { model } : {})
|
|
262
|
+
const request = { ...(model !== undefined ? { model } : {}) };
|
|
268
263
|
const wait = options.wait !== undefined ? options.wait(ctx, given.wait) : given.wait === true;
|
|
269
264
|
const waiting = wait && options.jobs !== undefined ? { jobs: options.jobs, wait: startWait(options.jobs) } : undefined;
|
|
270
265
|
let statuses;
|
|
@@ -329,7 +324,7 @@ export function haltTool(options) {
|
|
|
329
324
|
promptSnippet: "halt a pulse, or a launch and what it started",
|
|
330
325
|
promptGuidelines: [
|
|
331
326
|
"Halt a pulse only when the user asks, or your instructions say to. Name which one, and say which pulses were queued behind it - they will now run.",
|
|
332
|
-
"Halting a planned row halts its whole module - one planned pulse cannot be taken out alone, as the plan is made again from the spec. To
|
|
327
|
+
"Halting a planned row halts its whole module - one planned pulse cannot be taken out alone, as the plan is made again from the spec. To drop work, change the spec.",
|
|
333
328
|
"A planned row for a module that is no longer in the project is halted the same way, and dropped.",
|
|
334
329
|
],
|
|
335
330
|
parameters: HALT_PARAMS,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type MarshalledPlainSource } from "../plain/spec.ts";
|
|
2
|
-
import { type Steering } from "./steer.ts";
|
|
3
2
|
import { type SpecChange, type SpecStep, type TestPlainPath } from "./spec-steps.ts";
|
|
4
3
|
/**
|
|
5
4
|
* The queue's work, cut into jobs of a size worth rendering.
|
|
@@ -30,8 +29,6 @@ export interface PlanInput {
|
|
|
30
29
|
base: MarshalledPlainSource;
|
|
31
30
|
/** What it ends on: the spec as the track sees it now. */
|
|
32
31
|
current: MarshalledPlainSource;
|
|
33
|
-
/** How the person wants the work cut and ordered. */
|
|
34
|
-
steering?: Steering[];
|
|
35
32
|
/** The module whose codebase it is: its own functional specs are given with it. */
|
|
36
33
|
moduleName?: string;
|
|
37
34
|
/** The module's .plain file, as the diffs name it, and its text - for the diffs' layout. */
|
|
@@ -123,12 +120,8 @@ export interface GroupAnswer {
|
|
|
123
120
|
change: number;
|
|
124
121
|
to: number | "first";
|
|
125
122
|
}>;
|
|
126
|
-
/** What of the person's wishes it did not follow, and why. */
|
|
127
|
-
notes?: string;
|
|
128
123
|
}
|
|
129
124
|
export interface PlaceInput {
|
|
130
|
-
/** How the person or the harness wants the queue planned. */
|
|
131
|
-
steering?: Steering[];
|
|
132
125
|
groups: Array<{
|
|
133
126
|
number: number;
|
|
134
127
|
title: string;
|
|
@@ -157,8 +150,6 @@ export interface PlaceAnswer {
|
|
|
157
150
|
req: number;
|
|
158
151
|
to: Target;
|
|
159
152
|
}>;
|
|
160
|
-
/** What of the person's wishes it did not follow, and why. */
|
|
161
|
-
notes?: string;
|
|
162
153
|
}
|
|
163
154
|
/**
|
|
164
155
|
* A group to title: the number the agent answers with, and its functional specs' text - or, for a pulse that makes the
|
|
@@ -190,7 +181,7 @@ export interface TitleAnswer {
|
|
|
190
181
|
* too, shown the edit's changes; without it, that pulse is titled by `editTitle`.
|
|
191
182
|
*/
|
|
192
183
|
export interface ChunkAgents {
|
|
193
|
-
group(specs: NewSpec[], check: (answer: GroupAnswer) => string[],
|
|
184
|
+
group(specs: NewSpec[], check: (answer: GroupAnswer) => string[], maxSpecs?: number, built?: BuiltChange[]): Promise<GroupAnswer | undefined>;
|
|
194
185
|
place(input: PlaceInput, check: (answer: PlaceAnswer) => string[]): Promise<PlaceAnswer | undefined>;
|
|
195
186
|
title?(groups: TitleGroup[], check: (answer: TitleAnswer) => string[], track: "code" | "conformance"): Promise<TitleAnswer | undefined>;
|
|
196
187
|
}
|
|
@@ -215,7 +206,7 @@ export declare function editTitle(changes: SpecChange[]): string;
|
|
|
215
206
|
*/
|
|
216
207
|
export declare function builtTitle(changes: SpecChange[]): string;
|
|
217
208
|
export declare function planChunks(input: PlanInput, agents?: ChunkAgents, notes?: string[]): Promise<DraftJob[]>;
|
|
218
|
-
export declare function groupPrompt(specs: NewSpec[],
|
|
209
|
+
export declare function groupPrompt(specs: NewSpec[], maxSpecs?: number, built?: BuiltChange[]): string;
|
|
219
210
|
export declare function placePrompt(input: PlaceInput): string;
|
|
220
211
|
export declare function titlePrompt(groups: TitleGroup[], track: "code" | "conformance"): string;
|
|
221
212
|
/** The chunking's agents, on a model - fresh for every plan. */
|