@turri-dev/cli 0.4.3-next.3fc888b → 0.4.3-next.7ada234
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/capture/agents.d.ts +21 -6
- package/dist/capture/agents.js +49 -8
- package/dist/capture/assemble.d.ts +4 -14
- package/dist/capture/assemble.js +19 -18
- package/dist/capture/capture.d.ts +3 -3
- package/dist/capture/capture.js +67 -33
- package/dist/capture/checks.js +7 -1
- package/dist/capture/config.d.ts +1 -1
- package/dist/capture/config.js +16 -10
- package/dist/capture/interface.js +1 -1
- package/dist/capture/map.d.ts +0 -2
- package/dist/capture/map.js +1 -1
- package/dist/capture/models.d.ts +4 -0
- package/dist/capture/models.js +16 -0
- package/dist/capture/plan.d.ts +2 -3
- package/dist/capture/plan.js +9 -9
- package/dist/capture/progress.d.ts +3 -1
- package/dist/capture/progress.js +28 -2
- package/dist/capture/python-interface.d.ts +3 -0
- package/dist/capture/python-interface.js +17 -0
- package/dist/capture/report.js +2 -2
- package/dist/capture/runners.d.ts +6 -0
- package/dist/capture/runners.js +59 -0
- package/dist/capture/scripts.d.ts +1 -1
- package/dist/capture/scripts.js +5 -0
- package/dist/capture/state.d.ts +11 -0
- package/dist/capture-cli.js +4 -4
- package/dist/chat-tab-header.d.ts +3 -2
- package/dist/chat-tab-header.js +22 -9
- package/dist/chat-terminal.js +22 -4
- package/dist/chats.d.ts +3 -0
- package/dist/chats.js +14 -2
- package/dist/config-edit.js +4 -3
- package/dist/config.d.ts +1 -1
- package/dist/config.js +8 -7
- package/dist/extension.d.ts +1 -1
- package/dist/extension.js +40 -16
- package/dist/init-config.d.ts +4 -1
- package/dist/init-config.js +31 -6
- package/dist/pi.d.ts +2 -2
- package/dist/pi.js +2 -2
- package/dist/question-dialog.d.ts +2 -2
- package/dist/question-dialog.js +10 -6
- package/dist/regenerate/agent-env.js +5 -1
- package/dist/terminal-notifications.d.ts +8 -2
- package/dist/terminal-notifications.js +45 -15
- package/docs/capture.md +31 -11
- package/docs/chats.md +3 -1
- package/docs/config.md +4 -3
- package/docs/sandbox.md +2 -0
- package/docs/sentinel.md +1 -1
- package/genome/capture/check-reference.md +1 -0
- package/genome/capture/modules.md +2 -0
- package/genome/capture/python-interface.py +111 -0
- package/genome/capture/runners/python-requirements.sh +67 -0
- package/genome/capture/survey.md +2 -0
- package/genome/capture/trial.md +1 -1
- package/package.json +1 -1
package/dist/chats.js
CHANGED
|
@@ -86,6 +86,8 @@ export function createChats(options) {
|
|
|
86
86
|
const listeners = new Set();
|
|
87
87
|
let driver;
|
|
88
88
|
let shownId;
|
|
89
|
+
let welcomeChat;
|
|
90
|
+
let welcomeDismissed = false;
|
|
89
91
|
/** The chat whose extension pi is building now. */
|
|
90
92
|
let attaching;
|
|
91
93
|
/** Chats are opened one at a time: each one's extension is built while it is the one attaching. */
|
|
@@ -160,6 +162,8 @@ export function createChats(options) {
|
|
|
160
162
|
};
|
|
161
163
|
const newChat = (title, role) => {
|
|
162
164
|
const id = randomUUID().slice(0, 8);
|
|
165
|
+
if (role === undefined)
|
|
166
|
+
welcomeChat ??= id;
|
|
163
167
|
const chat = {
|
|
164
168
|
id,
|
|
165
169
|
scope: { id, asking: new Set() },
|
|
@@ -217,6 +221,13 @@ export function createChats(options) {
|
|
|
217
221
|
get terminal() {
|
|
218
222
|
return driver?.terminal === true;
|
|
219
223
|
},
|
|
224
|
+
welcomeVisible: (id) => !core.terminal || (!welcomeDismissed && welcomeChat === id),
|
|
225
|
+
dismissWelcome() {
|
|
226
|
+
if (!core.terminal || welcomeDismissed)
|
|
227
|
+
return;
|
|
228
|
+
welcomeDismissed = true;
|
|
229
|
+
changed();
|
|
230
|
+
},
|
|
220
231
|
chats: () => chats.map((chat) => ({ id: chat.id, title: titleFor(chat), status: statusOf(chat), shown: chat.id === shownId, ...(chat.role !== undefined ? { role: chat.role } : {}) })),
|
|
221
232
|
session: (id) => chats.find((chat) => chat.id === id)?.session,
|
|
222
233
|
decline(id) {
|
|
@@ -389,8 +400,9 @@ export function createChats(options) {
|
|
|
389
400
|
sentinelOn: () => driver !== undefined && wantsSentinel(),
|
|
390
401
|
jobFinished(job) {
|
|
391
402
|
if (core.terminal) {
|
|
392
|
-
const
|
|
393
|
-
|
|
403
|
+
const didNotPass = job.status === "succeeded" && wentWrong(job);
|
|
404
|
+
const result = job.status === "succeeded" ? didNotPass ? "did not pass" : "finished" : job.status;
|
|
405
|
+
core.notifications.add(`${pulseName(job)} · ${result} after ${formatDuration(job)}`, job.error ?? job.report ?? job.note ?? "", { warning: job.status === "failed" || didNotPass });
|
|
394
406
|
changed();
|
|
395
407
|
}
|
|
396
408
|
// The question was settled in config.turri.yaml while it was open: what it held goes as the file now says.
|
package/dist/config-edit.js
CHANGED
|
@@ -23,7 +23,8 @@ const ROLE_ABOUT = {
|
|
|
23
23
|
sentinel: "the sentinel: checks every finished pulse and tests what is launched",
|
|
24
24
|
planner: "cuts the work into pulses",
|
|
25
25
|
capture: "captures an existing codebase into ***plain",
|
|
26
|
-
"capture-
|
|
26
|
+
"capture-exploration": "gathers facts and extracts the interface from the original code",
|
|
27
|
+
"capture-analysis": "checks evidence, outlines features and tries scenarios on the original",
|
|
27
28
|
diagnosis: "looks into a pulse that failed for good",
|
|
28
29
|
launch: "the launch agent",
|
|
29
30
|
coding: "writes the code - as coding-model, which it wins over",
|
|
@@ -42,7 +43,7 @@ export function settings(rules = []) {
|
|
|
42
43
|
key: `models.${role}`,
|
|
43
44
|
about: `the ${role} role's model and thinking - ${ROLE_ABOUT[role]}`,
|
|
44
45
|
kind: "model",
|
|
45
|
-
unset: role === "default" ? "harness-model's, for the conversation's side; coding-model's for the rest" : role === "capture-
|
|
46
|
+
unset: role === "default" ? "harness-model's, for the conversation's side; coding-model's for the rest" : role === "capture-exploration" ? "Haiku low on Claude; otherwise coding-model, low" : role === "capture-analysis" ? "Sonnet low on Claude; otherwise coding-model, low" : role === "capture" ? "Opus medium on Claude; otherwise harness-model, medium" : "default's",
|
|
46
47
|
effect: role === "chat" ? "now" : "next-pulse",
|
|
47
48
|
...(role === "chat" ? { projectOnly: true } : {}),
|
|
48
49
|
},
|
|
@@ -50,7 +51,7 @@ export function settings(rules = []) {
|
|
|
50
51
|
key: `models.${role}.turn-limit`,
|
|
51
52
|
about: `seconds each turn of the ${role} role's agents has - 0 for none`,
|
|
52
53
|
kind: "number",
|
|
53
|
-
unset: role
|
|
54
|
+
unset: role.startsWith("capture-") ? "capture's, else default's, else turn-limit" : "default's, else turn-limit",
|
|
54
55
|
effect: "next-pulse",
|
|
55
56
|
options: SECONDS,
|
|
56
57
|
min: 0,
|
package/dist/config.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export interface ModelChoice {
|
|
|
143
143
|
* The code fixer of a conformance run and the repair agent are coding agents; the unit-test and conformance arbiters
|
|
144
144
|
* are both `arbiter`.
|
|
145
145
|
*/
|
|
146
|
-
export declare const AGENT_ROLES: readonly ["chat", "sentinel", "planner", "capture", "capture-analysis", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
|
|
146
|
+
export declare const AGENT_ROLES: readonly ["chat", "sentinel", "planner", "capture-exploration", "capture-analysis", "capture", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
|
|
147
147
|
export type AgentRole = (typeof AGENT_ROLES)[number];
|
|
148
148
|
/**
|
|
149
149
|
* How hard each role thinks when nothing names a level - not the config's `models:`, nor a `:level` on the model it is
|
package/dist/config.js
CHANGED
|
@@ -303,7 +303,7 @@ export const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhig
|
|
|
303
303
|
* The code fixer of a conformance run and the repair agent are coding agents; the unit-test and conformance arbiters
|
|
304
304
|
* are both `arbiter`.
|
|
305
305
|
*/
|
|
306
|
-
export const AGENT_ROLES = ["chat", "sentinel", "planner", "capture", "capture-analysis", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
|
|
306
|
+
export const AGENT_ROLES = ["chat", "sentinel", "planner", "capture-exploration", "capture-analysis", "capture", "diagnosis", "launch", "coding", "conformance", "explorer", "reviewer", "test-reviewer", "judge", "arbiter", "debugger"];
|
|
307
307
|
/**
|
|
308
308
|
* How hard each role thinks when nothing names a level - not the config's `models:`, nor a `:level` on the model it is
|
|
309
309
|
* given. The agents that do the work - write the code and the tests, explore, launch - think little: they work from a
|
|
@@ -323,13 +323,14 @@ export const ROLE_THINKING = {
|
|
|
323
323
|
planner: "medium",
|
|
324
324
|
capture: "medium",
|
|
325
325
|
"capture-analysis": "low",
|
|
326
|
+
"capture-exploration": "low",
|
|
326
327
|
diagnosis: "medium",
|
|
327
328
|
};
|
|
328
329
|
/** The roles on the conversation's side: without their own entry they take the chat's model, not `default`. */
|
|
329
330
|
// The launch is not: it follows steps - a script, a start command - and runs on the coding model, thinking low. Nor
|
|
330
331
|
// is the diagnosis: a post-mortem of a job that failed, read by the person - it runs on the coding model, thinking medium.
|
|
331
|
-
// Capture
|
|
332
|
-
const CHAT_SIDE = ["chat", "sentinel", "planner"
|
|
332
|
+
// Capture has its own three tiers, resolved by capture/models.ts.
|
|
333
|
+
const CHAT_SIDE = ["chat", "sentinel", "planner"];
|
|
333
334
|
function isThinkingLevel(value) {
|
|
334
335
|
return typeof value === "string" && THINKING_LEVELS.includes(value);
|
|
335
336
|
}
|
|
@@ -409,9 +410,9 @@ export function roleModel(config, role) {
|
|
|
409
410
|
return undefined;
|
|
410
411
|
const models = config.models ?? {};
|
|
411
412
|
const own = choiceOf(models[role]);
|
|
412
|
-
//
|
|
413
|
-
if (role === "capture-analysis")
|
|
414
|
-
return
|
|
413
|
+
// Capture supplies its tier defaults; do not inherit a writer's model or thinking for exploration or analysis.
|
|
414
|
+
if (role === "capture-exploration" || role === "capture-analysis" || role === "capture")
|
|
415
|
+
return own;
|
|
415
416
|
// The debugger looks at the coding agent's failure: without its own entry it runs on the model it is given - a stronger one.
|
|
416
417
|
if (role === "debugger")
|
|
417
418
|
return own;
|
|
@@ -423,7 +424,7 @@ export function roleModel(config, role) {
|
|
|
423
424
|
/** How long each turn of a role's agents may take, in milliseconds: its own, `default`'s, `turn-limit:`'s - or undefined, the harness's default. */
|
|
424
425
|
export function roleTurnLimitMs(config, role) {
|
|
425
426
|
const models = config.models ?? {};
|
|
426
|
-
const seconds = (role !== undefined ? models[role]?.turnLimit : undefined) ?? (role
|
|
427
|
+
const seconds = (role !== undefined ? models[role]?.turnLimit : undefined) ?? (role?.startsWith("capture-") ? models.capture?.turnLimit : undefined) ?? models.default?.turnLimit ?? config.turnLimit;
|
|
427
428
|
return seconds !== undefined ? seconds * 1000 : undefined;
|
|
428
429
|
}
|
|
429
430
|
/** A whole number of at least 1, as the config gives it - or nothing. */
|
package/dist/extension.d.ts
CHANGED
|
@@ -206,4 +206,4 @@ export declare const shownFrame: () => number;
|
|
|
206
206
|
* jellyfish stops for the rest of the session - swimming, whole, drawn once more if it was not, rather than on whatever
|
|
207
207
|
* frame it was at, a polyp half grown.
|
|
208
208
|
*/
|
|
209
|
-
export declare function animateJellyfish(ctx: ExtensionContext): void;
|
|
209
|
+
export declare function animateJellyfish(ctx: ExtensionContext, visible?: () => boolean): void;
|
package/dist/extension.js
CHANGED
|
@@ -24,7 +24,7 @@ import { runCapture } from "./capture/capture.js";
|
|
|
24
24
|
import { captureEnded, captureFailed, captureGoesOn, captureOpenQuestion, captureRefusal, captureStartedText, readReopenedAfterCapture, reopenedAfterCapture } from "./capture/chat.js";
|
|
25
25
|
import { reportFile as captureReportFile } from "./capture/state.js";
|
|
26
26
|
import { canReopen, REOPENED_AFTER_CAPTURE, reopenIn } from "./reopen.js";
|
|
27
|
-
import { captureStatusLines } from "./capture/progress.js";
|
|
27
|
+
import { captureStatusLines, duration } from "./capture/progress.js";
|
|
28
28
|
import { highlightPlainCodeBlocks } from "./plain-code-blocks.js";
|
|
29
29
|
import { createAskUserTool } from "./tools.js";
|
|
30
30
|
import { asksFromScratch, asksWholeChain, driftTool, endWait, fromWorkingDir, haltLaunched, haltTool, loopReply, startWait, toldByWaitingCall, MODEL_PARAM, regenerateTool, stopJob, WAIT_PARAM, whenBuildable, WORKING_DIR_PARAM } from "./loop-tools.js";
|
|
@@ -57,6 +57,7 @@ import { createSidePanel } from "./regenerate/side-panel.js";
|
|
|
57
57
|
import { createSpecMapSource, defaultMapFiles } from "./regenerate/spec-map.js";
|
|
58
58
|
import { createSpecMapState } from "./regenerate/spec-map-view.js";
|
|
59
59
|
import { notificationView } from "./terminal-notifications.js";
|
|
60
|
+
import { BANNER_ENTRY } from "./chat-tab-header.js";
|
|
60
61
|
import { createJobsTreeState, selectJob } from "./regenerate/jobs-tree.js";
|
|
61
62
|
import { describeDiagnosis, diagnoseFailure } from "./regenerate/diagnose.js";
|
|
62
63
|
import { HISTORY_DIR, historyLog } from "./regenerate/lineage.js";
|
|
@@ -602,6 +603,8 @@ function turriExtension(api, session, link, busy) {
|
|
|
602
603
|
});
|
|
603
604
|
pi.on("session_start", (_event, ctx) => {
|
|
604
605
|
lastContext = ctx;
|
|
606
|
+
if (session.terminal && session.welcomeVisible(link.id) && ctx.sessionManager.getBranch().some((entry) => (entry.type === "message" && entry.message.role === "user") || (entry.type === "custom" && entry.customType === COMMAND_OUTCOME)))
|
|
607
|
+
session.dismissWelcome();
|
|
605
608
|
});
|
|
606
609
|
pi.on("before_agent_start", (_event, ctx) => {
|
|
607
610
|
lastContext = ctx;
|
|
@@ -664,6 +667,8 @@ function turriExtension(api, session, link, busy) {
|
|
|
664
667
|
/** While a skill runs in this chat: what passes the person's message to its agent. */
|
|
665
668
|
let skillMessage;
|
|
666
669
|
pi.on("input", (event) => {
|
|
670
|
+
if (event.source === "interactive" && (event.text.trim() || event.images?.length))
|
|
671
|
+
session.dismissWelcome();
|
|
667
672
|
if (event.source !== "extension")
|
|
668
673
|
lastUserMessage = event.text;
|
|
669
674
|
// A skill running in this chat holds its agent for the whole run: what the person types meanwhile is for the
|
|
@@ -741,7 +746,7 @@ function turriExtension(api, session, link, busy) {
|
|
|
741
746
|
};
|
|
742
747
|
pi.on("agent_end", endTurnCapture);
|
|
743
748
|
pi.on("agent_settled", endTurnCapture);
|
|
744
|
-
registerBranding(pi, discoveredSkills);
|
|
749
|
+
registerBranding(pi, discoveredSkills, () => session.welcomeVisible(link.id));
|
|
745
750
|
registerInterviewLog(pi);
|
|
746
751
|
registerJobTools(pi, session);
|
|
747
752
|
// The skills the person starts themselves - a project's, marked command-only: each has its command, and cultivate starts it only
|
|
@@ -1325,6 +1330,16 @@ export function funcIdsNamedFirst(words) {
|
|
|
1325
1330
|
export function asksOneByOne(words) {
|
|
1326
1331
|
return /\b(one[\s-]+(by|at)[\s-]+(one|a[\s-]+time)|separately|each[\s-]+(on[\s-]+its[\s-]+own|alone))\b/i.test(words);
|
|
1327
1332
|
}
|
|
1333
|
+
/** Keep a command's output in the transcript without adding a message to the model's context. */
|
|
1334
|
+
function showCommandEntry(pi, ctx, entry) {
|
|
1335
|
+
try {
|
|
1336
|
+
pi.appendEntry(COMMAND_OUTCOME, entry);
|
|
1337
|
+
}
|
|
1338
|
+
catch {
|
|
1339
|
+
if (ctx.hasUI)
|
|
1340
|
+
ctx.ui.notify(entry.text, entry.level);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1328
1343
|
/**
|
|
1329
1344
|
* What a slash command showed the person: kept in the chat, where they read it, and put in the conversation as well -
|
|
1330
1345
|
* unseen there - so that when they speak of it next ("fix it"), the agent knows what they saw. A command runs outside
|
|
@@ -1334,14 +1349,7 @@ export function asksOneByOne(words) {
|
|
|
1334
1349
|
export function shownAfterCommand(pi, ctx, command, text, level,
|
|
1335
1350
|
/** The command is in the chat already, above it (echoCommand): the text alone. */
|
|
1336
1351
|
echoed = false, react) {
|
|
1337
|
-
|
|
1338
|
-
pi.appendEntry(COMMAND_OUTCOME, { command, text, level, ...(echoed ? { echoed } : {}) });
|
|
1339
|
-
}
|
|
1340
|
-
catch {
|
|
1341
|
-
// Shown for a moment all the same.
|
|
1342
|
-
if (ctx.hasUI)
|
|
1343
|
-
ctx.ui.notify(text, level);
|
|
1344
|
-
}
|
|
1352
|
+
showCommandEntry(pi, ctx, { command, text, level, ...(echoed ? { echoed } : {}) });
|
|
1345
1353
|
const content = `The person ran ${command}, and was shown:\n${text}${react !== undefined ? `\n\n${react}` : ""}`;
|
|
1346
1354
|
if (react === undefined)
|
|
1347
1355
|
void pi.sendMessage({ customType: COMMAND_OUTCOME, content, display: false });
|
|
@@ -2434,7 +2442,10 @@ function sidePanelOf(session) {
|
|
|
2434
2442
|
// Opened, it reads the files again at once: they may have changed while it was closed.
|
|
2435
2443
|
specMap.refresh();
|
|
2436
2444
|
const view = createSidePanel({
|
|
2437
|
-
...(session.terminal ? { notifications: notificationView(session, {
|
|
2445
|
+
...(session.terminal ? { notifications: notificationView(session, {
|
|
2446
|
+
accent: (text) => theme.fg("accent", text), muted: (text) => theme.fg("muted", text), bold: (text) => theme.bold(text),
|
|
2447
|
+
warning: (text) => theme.fg("warning", text), button: (text, selected) => buttonLabel(theme, text, selected, false, "panel"),
|
|
2448
|
+
}, back) } : {}),
|
|
2438
2449
|
pointer: terminalPointer(tui.terminal),
|
|
2439
2450
|
tabLabel: (text, active, hovered, role) => buttonLabel(theme, text, active, hovered, role),
|
|
2440
2451
|
jobs: () => shownJobs(jobs),
|
|
@@ -2756,6 +2767,15 @@ function registerCapture(pi, cwd, ends) {
|
|
|
2756
2767
|
status = next;
|
|
2757
2768
|
redrawNow?.();
|
|
2758
2769
|
};
|
|
2770
|
+
// The same milestones as the CLI, kept in the chat that started the capture. Tool activity stays in the widget.
|
|
2771
|
+
const started = Date.now();
|
|
2772
|
+
const progress = (line) => {
|
|
2773
|
+
if (controller.signal.aborted)
|
|
2774
|
+
return;
|
|
2775
|
+
const elapsed = duration(Date.now() - started);
|
|
2776
|
+
const spent = status && status.cost > 0 ? ` · $${status.cost.toFixed(2)}` : "";
|
|
2777
|
+
showCommandEntry(pi, ctx, { command, text: `capture · ${elapsed}${spent} · ${line}`, level: "info", echoed: true });
|
|
2778
|
+
};
|
|
2759
2779
|
// The captured project starts as the config in use here, with the chat's model and thinking of the moment, and the
|
|
2760
2780
|
// coding model turri was started with, where it says otherwise.
|
|
2761
2781
|
const codingModel = process.env[CODING_MODEL_ENV];
|
|
@@ -2764,7 +2784,7 @@ function registerCapture(pi, cwd, ends) {
|
|
|
2764
2784
|
...(model !== undefined ? { model, harnessModel: `${model}:${pi.getThinkingLevel()}` } : {}),
|
|
2765
2785
|
...(codingModel !== undefined && codingModel !== "" ? { codingModel } : {}),
|
|
2766
2786
|
};
|
|
2767
|
-
void captureConsole(() => runCapture({ root, signal: controller.signal, watch, ...configured }))
|
|
2787
|
+
void captureConsole(() => runCapture({ root, signal: controller.signal, progress, watch, ...configured }))
|
|
2768
2788
|
.then(async ({ result }) => {
|
|
2769
2789
|
if (ctx.hasUI)
|
|
2770
2790
|
ctx.ui.setWidget(CAPTURE_WIDGET, undefined);
|
|
@@ -3088,7 +3108,6 @@ function recentUserMessages(ctx, limit) {
|
|
|
3088
3108
|
}
|
|
3089
3109
|
return said.slice(-limit);
|
|
3090
3110
|
}
|
|
3091
|
-
const BANNER_ENTRY = "turri_banner";
|
|
3092
3111
|
/**
|
|
3093
3112
|
* The name on the door.
|
|
3094
3113
|
*
|
|
@@ -3103,7 +3122,7 @@ const BANNER_ENTRY = "turri_banner";
|
|
|
3103
3122
|
export function chatRulesBlock(rules = loadRules(join(PACKAGE_ROOT, "genome", "rules"))) {
|
|
3104
3123
|
return renderRulesBlock(rules);
|
|
3105
3124
|
}
|
|
3106
|
-
function registerBranding(pi, skills) {
|
|
3125
|
+
function registerBranding(pi, skills, welcomeVisible) {
|
|
3107
3126
|
pi.registerCommand("stdlib", {
|
|
3108
3127
|
description: "List the ***plain standard library: the stacks a spec can import instead of writing its implementation reqs.",
|
|
3109
3128
|
handler: async (_args, ctx) => {
|
|
@@ -3146,7 +3165,8 @@ function registerBranding(pi, skills) {
|
|
|
3146
3165
|
pi.on("session_start", (_event, ctx) => {
|
|
3147
3166
|
if (ctx.hasUI) {
|
|
3148
3167
|
padTheScreen(ctx);
|
|
3149
|
-
|
|
3168
|
+
if (welcomeVisible())
|
|
3169
|
+
animateJellyfish(ctx, welcomeVisible);
|
|
3150
3170
|
// ***plain an agent shows in the chat, highlighted in the theme of the moment.
|
|
3151
3171
|
highlightPlainCodeBlocks(() => ctx.ui.theme);
|
|
3152
3172
|
}
|
|
@@ -3201,13 +3221,17 @@ let jellyfishTimer;
|
|
|
3201
3221
|
* jellyfish stops for the rest of the session - swimming, whole, drawn once more if it was not, rather than on whatever
|
|
3202
3222
|
* frame it was at, a polyp half grown.
|
|
3203
3223
|
*/
|
|
3204
|
-
export function animateJellyfish(ctx) {
|
|
3224
|
+
export function animateJellyfish(ctx, visible = () => true) {
|
|
3205
3225
|
if (jellyfishTimer !== undefined)
|
|
3206
3226
|
clearInterval(jellyfishTimer);
|
|
3207
3227
|
jellyfishTimer = undefined;
|
|
3208
3228
|
ctx.ui.setWidget(JELLYFISH_CLOCK_KEY, (tui) => {
|
|
3209
3229
|
drawOverlaysBesidePicture(tui);
|
|
3210
3230
|
const timer = setInterval(() => {
|
|
3231
|
+
if (!visible()) {
|
|
3232
|
+
clearInterval(timer);
|
|
3233
|
+
return;
|
|
3234
|
+
}
|
|
3211
3235
|
if (tui.render(tui.terminal.columns).length > tui.terminal.rows) {
|
|
3212
3236
|
clearInterval(timer);
|
|
3213
3237
|
if (shownFrame() !== JELLYFISH_SEQUENCE[JELLYFISH_REST]) {
|
package/dist/init-config.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type CatalogueModel, type ModelCatalogue } from "./model-check.ts";
|
|
|
4
4
|
* write the code - so a new project starts with a choice that works rather than an empty file. It asks which vendor's
|
|
5
5
|
* models you use and fills in theirs. Every other setting is written out with the value turri uses for it (DEFAULTS),
|
|
6
6
|
* so the file says how the project is built; the optional ones, which have no value of their own - the testing
|
|
7
|
-
* scripts, `module`, `judge-model
|
|
7
|
+
* scripts, `module`, `judge-model` - are there commented out, with an example. The three capture models are active.
|
|
8
8
|
*
|
|
9
9
|
* Then it says what to do next: where the file is - turri reads it from that folder and the folders below it, nowhere
|
|
10
10
|
* else - and how to sign in to the vendor so pi, which turri runs on, can reach the models.
|
|
@@ -128,6 +128,9 @@ export declare function defaultParallel(cores?: number): number;
|
|
|
128
128
|
export declare function quickStartConfig(vendor?: Vendor, bedrock?: BedrockChoice, models?: ModelSet): string;
|
|
129
129
|
/** The quick start config for the mix of vendors: what turri wrote before it asked. */
|
|
130
130
|
export declare const QUICK_START_CONFIG: string;
|
|
131
|
+
/** A capture without a config starts with init-config's settings. Resolve an omitted model from the vendor's pair,
|
|
132
|
+
* including the maker and geography on Bedrock, just as the wizard does. */
|
|
133
|
+
export declare function quickStartForCapture(harness?: string, coding?: string): Promise<string>;
|
|
131
134
|
/** A vendor from what was typed: its number in the list, or its name. */
|
|
132
135
|
export declare function vendorOf(answer: string): Vendor | undefined;
|
|
133
136
|
/** Bedrock's maker from what was typed: its number in the list - with no catalogue, 1 Anthropic, 2 OpenAI - or its name. */
|
package/dist/init-config.js
CHANGED
|
@@ -4,10 +4,11 @@ import { basename, join, resolve } from "node:path";
|
|
|
4
4
|
import { createInterface } from "node:readline/promises";
|
|
5
5
|
import { load as loadYaml } from "js-yaml";
|
|
6
6
|
import { adoptLegacyConfig, CONFIG_FILE, CONFIG_KEYS, LEGACY_CONFIG_FILE, ROLE_THINKING } from "./config.js";
|
|
7
|
-
import { withTopLevelValue } from "./config-edit.js";
|
|
7
|
+
import { currentValue, withSetting, withTopLevelValue } from "./config-edit.js";
|
|
8
8
|
import { brand } from "./brand.js";
|
|
9
9
|
import { closestModels, piModelCatalogue } from "./model-check.js";
|
|
10
10
|
import { EXTENSION_PROVIDERS } from "./installed-providers.js";
|
|
11
|
+
import { captureDefaults } from "./capture/models.js";
|
|
11
12
|
/** The geographies turri's own pair for each maker is served in - the first the default. Every other: bedrockMakers. */
|
|
12
13
|
export const BEDROCK_REGIONS = {
|
|
13
14
|
anthropic: ["global", "us", "eu", "jp", "au"],
|
|
@@ -345,13 +346,13 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
|
|
|
345
346
|
"",
|
|
346
347
|
"# Optional: each agent role's own model, thinking and turn limit. Without it, every role runs on coding-model and the",
|
|
347
348
|
"# conversation's side on harness-model, each thinking as written here. What an entry leaves out it takes from default.",
|
|
348
|
-
"#
|
|
349
|
+
"# Capture uses three tiers: gather facts, analyse evidence, then reason and write.",
|
|
350
|
+
"models:",
|
|
351
|
+
...Object.entries(captureDefaults(harness, coding)).map(([name, choice]) => ` ${name}: ${choice.model}:${choice.thinking}`),
|
|
349
352
|
`# default: ${coding}`,
|
|
350
353
|
`${column(`# chat: ${harness}`, 72)}# the conversation - as harness-model, which it wins over`,
|
|
351
354
|
`${column(`# sentinel: ${harness}`, 72)}# the sentinel: checks every finished pulse and tests what is launched`,
|
|
352
355
|
role("planner", harness, "cuts the work into pulses"),
|
|
353
|
-
role("capture", harness, "captures an existing codebase into ***plain"),
|
|
354
|
-
role("capture-analysis", coding, "extracts the interface reference and outlines features during capture"),
|
|
355
356
|
role("diagnosis", harness, "looks into a pulse that failed for good"),
|
|
356
357
|
role("launch", coding, "the launch agent: turri launch's, the chat's and launch-after-pulse's"),
|
|
357
358
|
`${column(`# coding: { model: ${coding}, thinking: ${ROLE_THINKING.coding}, turn-limit: 180 }`, 72)}# as coding-model, which it wins over`,
|
|
@@ -367,6 +368,24 @@ export function quickStartConfig(vendor = "other", bedrock, models) {
|
|
|
367
368
|
}
|
|
368
369
|
/** The quick start config for the mix of vendors: what turri wrote before it asked. */
|
|
369
370
|
export const QUICK_START_CONFIG = quickStartConfig("other");
|
|
371
|
+
/** A capture without a config starts with init-config's settings. Resolve an omitted model from the vendor's pair,
|
|
372
|
+
* including the maker and geography on Bedrock, just as the wizard does. */
|
|
373
|
+
export async function quickStartForCapture(harness, coding) {
|
|
374
|
+
if (harness && coding)
|
|
375
|
+
return quickStartConfig("other", undefined, { harness, coding, strong: harness });
|
|
376
|
+
const spec = harness ?? coding;
|
|
377
|
+
const provider = spec?.split("/")[0] ?? (process.env.AWS_BEARER_TOKEN_BEDROCK || process.env.AWS_PROFILE || process.env.CLAUDE_CODE_USE_BEDROCK === "1" ? "amazon-bedrock" : "other");
|
|
378
|
+
// A custom provider has no default pair. Stay on its named model rather than switching providers.
|
|
379
|
+
if (!Object.hasOwn(VENDORS, provider) && spec)
|
|
380
|
+
return quickStartConfig("other", undefined, { harness: spec, coding: spec, strong: spec });
|
|
381
|
+
const vendor = provider;
|
|
382
|
+
const place = vendor === "amazon-bedrock" && spec ? bedrockPlaceOf(spec) : undefined;
|
|
383
|
+
const chosen = await chosenModels({ vendor, ...(place ? { bedrock: { maker: place.maker, region: place.geography } } : {}) });
|
|
384
|
+
if ("problem" in chosen)
|
|
385
|
+
throw new Error(chosen.problem);
|
|
386
|
+
const models = chosen.models;
|
|
387
|
+
return quickStartConfig(vendor, chosen.bedrock, { ...models, harness: harness ?? models.harness, coding: coding ?? models.coding });
|
|
388
|
+
}
|
|
370
389
|
/** A vendor from what was typed: its number in the list, or its name. */
|
|
371
390
|
export function vendorOf(answer) {
|
|
372
391
|
const typed = answer.trim().toLowerCase();
|
|
@@ -599,9 +618,14 @@ export async function initConfig(dir, options = {}) {
|
|
|
599
618
|
const lines = modelLines(harness, coding);
|
|
600
619
|
// A new file takes what a config.yaml beside it - another tool's, say - says that turri reads too: its testing scripts, say.
|
|
601
620
|
const shared = existing ? { carried: [], left: [] } : sharedWithLegacy(folder);
|
|
602
|
-
|
|
621
|
+
let config = existing
|
|
603
622
|
? withModels(readFileSync(path, "utf8"), lines)
|
|
604
623
|
: shared.carried.reduce((text, [key, value]) => withTopLevelValue(text, key, value), quickStartConfig(vendor, bedrock, models));
|
|
624
|
+
for (const [role, choice] of Object.entries(captureDefaults(harness, coding))) {
|
|
625
|
+
const key = `models.${role}`;
|
|
626
|
+
if (currentValue(config, key) === undefined)
|
|
627
|
+
config = withSetting(config, key, `${choice.model}:${choice.thinking}`);
|
|
628
|
+
}
|
|
605
629
|
writeFileSync(path, config);
|
|
606
630
|
const here = resolve(process.cwd()) === folder;
|
|
607
631
|
const [talk, code] = [harness, coding].map((model, at) => `${model}:${at === 0 ? HARNESS_THINKING : ROLE_THINKING.coding}`);
|
|
@@ -610,10 +634,11 @@ export async function initConfig(dir, options = {}) {
|
|
|
610
634
|
message: [
|
|
611
635
|
"",
|
|
612
636
|
`${brand.success("✓")} ${existing ? `Set the two models in ${brand.bold(path)}` : `Wrote ${brand.bold(path)}`}`,
|
|
613
|
-
` ${brand.muted(`with ${whose(vendor, models, given)}${existing ? " - everything else in it left as it was (--force writes it all again)" : ""}`)}`,
|
|
637
|
+
` ${brand.muted(`with ${whose(vendor, models, given)}${existing ? " - missing capture tiers filled in, everything else in it left as it was (--force writes it all again)" : ""}`)}`,
|
|
614
638
|
"",
|
|
615
639
|
` ${brand.muted("you talk to")} ${talk}`,
|
|
616
640
|
` ${brand.muted("it codes")} ${code}`,
|
|
641
|
+
...["capture-exploration", "capture-analysis", "capture"].map(role => ` ${brand.muted(role)} ${currentValue(config, `models.${role}`)}`),
|
|
617
642
|
...(shared.carried.length > 0
|
|
618
643
|
? [
|
|
619
644
|
"",
|
package/dist/pi.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export declare function inheritProviders(source: () => ModelRegistry | undefined
|
|
|
47
47
|
* agent to load when one fits; an agent turri starts has one job, and turri runs its gated skills itself,
|
|
48
48
|
* giving each step to an agent as its task. The conversation keeps them.
|
|
49
49
|
*/
|
|
50
|
-
export declare function subAgentResources(cwd: string, withRules: boolean, system?: string): Promise<DefaultResourceLoader>;
|
|
50
|
+
export declare function subAgentResources(cwd: string, withRules: boolean | readonly string[], system?: string): Promise<DefaultResourceLoader>;
|
|
51
51
|
/** Raised when the provider itself failed, rather than the agent producing a poor answer. */
|
|
52
52
|
export declare class ProviderError extends Error {
|
|
53
53
|
constructor(message: string);
|
|
@@ -181,7 +181,7 @@ export declare function createExecutor(opts: {
|
|
|
181
181
|
*/
|
|
182
182
|
model?: string;
|
|
183
183
|
/** Give it the ***plain rules - for agents that write or edit specs, not code. */
|
|
184
|
-
rules?: boolean;
|
|
184
|
+
rules?: boolean | readonly string[];
|
|
185
185
|
/** Continue the session saved in this file, instead of starting a new one. */
|
|
186
186
|
resumeFrom?: string;
|
|
187
187
|
/** Save its session to disk, debug mode or not: it is picked back up later (a skill's run, resumed). */
|
package/dist/pi.js
CHANGED
|
@@ -92,7 +92,7 @@ const RULES_DIR = join(dirname(dirname(fileURLToPath(import.meta.url))), "genome
|
|
|
92
92
|
*/
|
|
93
93
|
export async function subAgentResources(cwd, withRules, system) {
|
|
94
94
|
// Less any the project leaves out (rules-off).
|
|
95
|
-
const rules = withRules ? renderRulesBlock(loadRules(RULES_DIR, readProjectConfig(projectRootOf(cwd)).rulesOff ?? [])) : "";
|
|
95
|
+
const rules = withRules ? renderRulesBlock(loadRules(RULES_DIR, readProjectConfig(projectRootOf(cwd)).rulesOff ?? []).filter(rule => withRules === true || withRules.includes(rule.name))) : "";
|
|
96
96
|
const extra = [rules, system ?? ""].filter((part) => part !== "");
|
|
97
97
|
const loader = new DefaultResourceLoader({
|
|
98
98
|
cwd,
|
|
@@ -761,7 +761,7 @@ export async function createExecutor(opts) {
|
|
|
761
761
|
// What an agent is shown never holds a credential the project passed: each value is its name (masking.ts).
|
|
762
762
|
customTools: guardRepeats(maskToolResults(withListArguments(withEnvironmentErrors)), () => session, opts.budget),
|
|
763
763
|
sessionManager,
|
|
764
|
-
resourceLoader: await subAgentResources(opts.cwd, opts.rules
|
|
764
|
+
resourceLoader: await subAgentResources(opts.cwd, opts.rules ?? false, [opts.system, opts.task].filter((part) => part !== undefined && part !== "").join("\n\n") || undefined),
|
|
765
765
|
});
|
|
766
766
|
if (opts.task !== undefined)
|
|
767
767
|
pendingTask.set(session, opts.task);
|
|
@@ -18,8 +18,8 @@ export interface QuestionDialogOptions {
|
|
|
18
18
|
question: string;
|
|
19
19
|
/** The choices. Without them, a line to type the answer on. */
|
|
20
20
|
options?: string[];
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/** Draw choices as clickable buttons in the side panel. The padding belongs to the button. */
|
|
22
|
+
choiceButton?(text: string, selected: boolean): string;
|
|
23
23
|
/** The choice the cursor starts on. */
|
|
24
24
|
selected?: number;
|
|
25
25
|
/** The terminal's height, for the window the brief scrolls in. */
|
package/dist/question-dialog.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Input, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
1
|
+
import { Input, matchesKey, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
2
2
|
/** Lines kept for the conversation above the dialog, so it never takes the whole screen. */
|
|
3
3
|
const KEPT_ABOVE = 4;
|
|
4
4
|
/** **bold** and `code`, as the brief's markdown means them. */
|
|
@@ -69,14 +69,17 @@ export class QuestionDialog {
|
|
|
69
69
|
? this.input.render(inner)
|
|
70
70
|
: // A long option wraps, its lines under its first, rather than cut off where the person cannot read it.
|
|
71
71
|
choices.flatMap((choice, index) => wrapTextWithAnsi(choice, Math.max(1, inner - 2)).map((line, at) => {
|
|
72
|
-
if (this.options.
|
|
73
|
-
|
|
72
|
+
if (this.options.choiceButton) {
|
|
73
|
+
const label = ` ${line} `;
|
|
74
|
+
this.choiceLines.push({ index, width: visibleWidth(label) });
|
|
75
|
+
return this.options.choiceButton(label, index === this.selected);
|
|
76
|
+
}
|
|
74
77
|
const shown = `${at === 0 && index === this.selected ? "›" : " "} ${line}`;
|
|
75
78
|
return index === this.selected ? style.accent(shown) : shown;
|
|
76
79
|
}));
|
|
77
80
|
const hint = this.input !== undefined
|
|
78
81
|
? "enter answers · esc dismisses · ctrl+c declines"
|
|
79
|
-
: "↑↓ choose · enter picks · esc dismisses · ctrl+c declines";
|
|
82
|
+
: this.options.choiceButton ? "↑↓ select · enter or click · esc back" : "↑↓ choose · enter picks · esc dismisses · ctrl+c declines";
|
|
80
83
|
// The brief gets what the question, the options and the hints leave of the screen.
|
|
81
84
|
const fixed = question.length + body.length + 5;
|
|
82
85
|
const room = Math.max(3, this.options.rows() - KEPT_ABOVE - fixed);
|
|
@@ -139,8 +142,9 @@ export class QuestionDialog {
|
|
|
139
142
|
}
|
|
140
143
|
}
|
|
141
144
|
handleMouse(event) {
|
|
142
|
-
if (this.options.
|
|
143
|
-
const
|
|
145
|
+
if (this.options.choiceButton && event.button === "left" && (event.type === "press" || event.type === "click")) {
|
|
146
|
+
const row = this.choiceLines[event.y - this.choiceTop];
|
|
147
|
+
const index = row && event.x >= 2 && event.x < 2 + row.width ? row.index : undefined;
|
|
144
148
|
const down = this.pressed;
|
|
145
149
|
this.pressed = event.type === "press" ? index : undefined;
|
|
146
150
|
if (index === undefined)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
|
-
import { basename, join, resolve } from "node:path";
|
|
4
|
+
import { basename, delimiter, dirname, join, resolve } from "node:path";
|
|
5
5
|
import { DEFAULT_CACHE_KEEP_MB, readProjectConfig, configModuleOf } from "../config.js";
|
|
6
6
|
import { registerSecrets } from "./masking.js";
|
|
7
7
|
import { projectRootOf, modulesScratchDir } from "./paths.js";
|
|
@@ -94,6 +94,10 @@ export function agentEnvironment(moduleDir, options = {}) {
|
|
|
94
94
|
if (ALLOWED.includes(key) || ALLOWED_PREFIXES.some((prefix) => key.startsWith(prefix)))
|
|
95
95
|
env[key] = value;
|
|
96
96
|
}
|
|
97
|
+
// The caller's activated venv is not an agent toolchain. Its bin is on PATH but its config and site-packages are outside
|
|
98
|
+
// the fence. Use the next installed Python; an agent may still create and activate its own venv inside its workspace.
|
|
99
|
+
if (env.PATH)
|
|
100
|
+
env.PATH = env.PATH.split(delimiter).filter((dir) => !(["bin", "scripts"].includes(basename(dir).toLowerCase()) && existsSync(join(dirname(dir), "pyvenv.cfg")))).join(delimiter);
|
|
97
101
|
for (const [key, inHome] of Object.entries(TOOLCHAIN_LOCATORS)) {
|
|
98
102
|
const given = hostEnv[key];
|
|
99
103
|
if (given !== undefined && given !== "")
|
|
@@ -7,6 +7,7 @@ export interface TerminalNotification {
|
|
|
7
7
|
title: string;
|
|
8
8
|
detail: string;
|
|
9
9
|
conclusion?: string;
|
|
10
|
+
warning?: boolean;
|
|
10
11
|
notice?: Notice;
|
|
11
12
|
seen: boolean;
|
|
12
13
|
}
|
|
@@ -15,17 +16,22 @@ export declare class TerminalNotifications {
|
|
|
15
16
|
private readonly reviews;
|
|
16
17
|
get count(): number;
|
|
17
18
|
needsAnswer(item: TerminalNotification): boolean;
|
|
18
|
-
add(title: string, detail: string,
|
|
19
|
+
add(title: string, detail: string, options?: Pick<TerminalNotification, "notice" | "warning">): void;
|
|
19
20
|
/** Only the sentinel's review shares a row. The pulse result and the question whether to start it are independent. */
|
|
20
21
|
private review;
|
|
21
22
|
put(notice: Notice, work?: Pick<Conclusion, "job" | "check">): void;
|
|
22
23
|
concluded(result: Conclusion): void;
|
|
23
24
|
}
|
|
24
25
|
/** The notifications tab. Opening or leaving a detail never answers its notice. Only an explicit choice does. */
|
|
25
|
-
|
|
26
|
+
interface NotificationStyle extends DialogStyle {
|
|
27
|
+
warning(text: string): string;
|
|
28
|
+
button(text: string, selected: boolean): string;
|
|
29
|
+
}
|
|
30
|
+
export declare function notificationView(session: TurriCore, style: NotificationStyle, leave: () => void): {
|
|
26
31
|
count: () => number;
|
|
27
32
|
inDetail: () => boolean;
|
|
28
33
|
render(width: number, available: number): readonly string[];
|
|
29
34
|
handleInput(data: string): void;
|
|
30
35
|
handleMouse: (event: TuiMouseEvent) => import("@earendil-works/pi-tui").TuiMouseEventResult | undefined;
|
|
31
36
|
};
|
|
37
|
+
export {};
|