@turri-dev/cli 0.4.2 → 0.4.3-next.3fc888b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/background-skills.d.ts +4 -1
- package/dist/background-skills.js +9 -1
- package/dist/capture/agents.d.ts +391 -0
- package/dist/capture/agents.js +338 -0
- package/dist/capture/area.d.ts +58 -0
- package/dist/capture/area.js +197 -0
- package/dist/capture/assemble.d.ts +122 -0
- package/dist/capture/assemble.js +452 -0
- package/dist/capture/capture.d.ts +116 -0
- package/dist/capture/capture.js +1281 -0
- package/dist/capture/chat.d.ts +29 -0
- package/dist/capture/chat.js +94 -0
- package/dist/capture/checks.d.ts +142 -0
- package/dist/capture/checks.js +643 -0
- package/dist/capture/config.d.ts +13 -0
- package/dist/capture/config.js +60 -0
- package/dist/capture/interface.d.ts +71 -0
- package/dist/capture/interface.js +199 -0
- package/dist/capture/map.d.ts +58 -0
- package/dist/capture/map.js +530 -0
- package/dist/capture/plan.d.ts +8 -0
- package/dist/capture/plan.js +13 -0
- package/dist/capture/progress.d.ts +109 -0
- package/dist/capture/progress.js +240 -0
- package/dist/capture/report.d.ts +75 -0
- package/dist/capture/report.js +268 -0
- package/dist/capture/scripts.d.ts +26 -0
- package/dist/capture/scripts.js +33 -0
- package/dist/capture/state.d.ts +299 -0
- package/dist/capture/state.js +43 -0
- package/dist/capture/trial.d.ts +34 -0
- package/dist/capture/trial.js +89 -0
- package/dist/capture-cli.d.ts +1 -0
- package/dist/capture-cli.js +77 -0
- package/dist/chat-commands.d.ts +2 -10
- package/dist/chat-commands.js +3 -57
- package/dist/chat-tab-header.d.ts +15 -0
- package/dist/chat-tab-header.js +78 -0
- package/dist/chat-tabs.d.ts +26 -0
- package/dist/chat-tabs.js +100 -0
- package/dist/chat-terminal.js +57 -8
- package/dist/chat-waiting.d.ts +4 -1
- package/dist/chat-waiting.js +7 -4
- package/dist/chats.d.ts +11 -6
- package/dist/chats.js +34 -20
- package/dist/cli.js +32 -14
- package/dist/config-edit.js +4 -2
- package/dist/config.d.ts +15 -2
- package/dist/config.js +62 -4
- package/dist/extension.d.ts +1 -0
- package/dist/extension.js +199 -55
- package/dist/identity.js +2 -1
- package/dist/init-config.js +2 -0
- package/dist/loop-cli.js +5 -1
- package/dist/loop-tools.js +5 -1
- package/dist/new-project.d.ts +5 -0
- package/dist/new-project.js +11 -0
- package/dist/pi-launch.js +2 -0
- package/dist/pi-themes.d.ts +3 -0
- package/dist/pi-themes.js +21 -0
- package/dist/pi.js +2 -2
- package/dist/plain-code-blocks.d.ts +14 -0
- package/dist/plain-code-blocks.js +56 -0
- package/dist/pointer-hover.d.ts +12 -0
- package/dist/pointer-hover.js +48 -0
- package/dist/question-dialog.d.ts +5 -0
- package/dist/question-dialog.js +20 -1
- package/dist/regenerate/command-check.js +80 -11
- package/dist/regenerate/job-panel.d.ts +5 -107
- package/dist/regenerate/job-panel.js +4 -289
- package/dist/regenerate/jobs-tree.d.ts +1 -0
- package/dist/regenerate/jobs-tree.js +5 -1
- package/dist/regenerate/loop.js +9 -1
- package/dist/regenerate/side-panel.d.ts +6 -1
- package/dist/regenerate/side-panel.js +158 -22
- package/dist/regenerate/spec-map-view.d.ts +11 -3
- package/dist/regenerate/spec-map-view.js +22 -2
- package/dist/regenerate/test-scripts.d.ts +5 -0
- package/dist/regenerate/test-scripts.js +4 -0
- package/dist/reopen.d.ts +29 -0
- package/dist/reopen.js +47 -0
- package/dist/resume-line.d.ts +4 -1
- package/dist/resume-line.js +5 -2
- package/dist/sentinel-chat.js +7 -2
- package/dist/sentinel.d.ts +1 -1
- package/dist/sentinel.js +3 -1
- package/dist/setup.js +9 -1
- package/dist/terminal-notifications.d.ts +31 -0
- package/dist/terminal-notifications.js +134 -0
- package/docs/README.md +2 -0
- package/docs/capture.md +207 -0
- package/docs/chats.md +8 -6
- package/docs/config.md +16 -3
- package/docs/development.md +4 -1
- package/docs/hosting.md +2 -2
- package/docs/launch.md +2 -2
- package/docs/regenerating.md +1 -1
- package/docs/sandbox.md +2 -2
- package/docs/sentinel.md +11 -11
- package/docs/theming.md +3 -3
- package/docs/using.md +10 -2
- package/genome/capture/capture.md +26 -0
- package/genome/capture/check-conventions.md +5 -0
- package/genome/capture/check-reference.md +11 -0
- package/genome/capture/compact.md +7 -0
- package/genome/capture/concepts.md +3 -0
- package/genome/capture/divide.md +9 -0
- package/genome/capture/feature.md +45 -0
- package/genome/capture/interface.md +9 -0
- package/genome/capture/modules.md +23 -0
- package/genome/capture/outline.md +11 -0
- package/genome/capture/readability.md +12 -0
- package/genome/capture/reference.md +10 -0
- package/genome/capture/split.md +9 -0
- package/genome/capture/survey.md +37 -0
- package/genome/capture/trial.md +18 -0
- package/genome/capture/verify.md +7 -0
- package/genome/rules/turri-regeneration.md +1 -1
- package/package.json +3 -3
|
@@ -12,6 +12,53 @@ export function createSidePanel(options) {
|
|
|
12
12
|
let drawnTree = { rows: [], rowStarts: [], lineCount: 0 };
|
|
13
13
|
let drawnMap = { rows: [], rowStarts: [], lineCount: 0 };
|
|
14
14
|
let pages = [];
|
|
15
|
+
let pressed;
|
|
16
|
+
// Hit regions for the last frame, in panel-local cells (the dock border is outside them).
|
|
17
|
+
const hits = new Map();
|
|
18
|
+
const hit = (y, target) => {
|
|
19
|
+
const row = hits.get(y);
|
|
20
|
+
if (row)
|
|
21
|
+
row.push(target);
|
|
22
|
+
else
|
|
23
|
+
hits.set(y, [target]);
|
|
24
|
+
};
|
|
25
|
+
let headerHeight = 0;
|
|
26
|
+
function hitLabels(drawn, first, y, height, width, target) {
|
|
27
|
+
drawn.rows.forEach((row, index) => {
|
|
28
|
+
const start = drawn.rowStarts[index] - first;
|
|
29
|
+
const end = Math.min(height, start + drawn.labelHeights[index]);
|
|
30
|
+
if (Math.max(0, start) >= end)
|
|
31
|
+
return;
|
|
32
|
+
const label = { ...target(row, index), x: 0, end: width };
|
|
33
|
+
for (let line = Math.max(0, start); line < end; line++)
|
|
34
|
+
hit(headerHeight + y + line, label);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const controls = (width) => {
|
|
38
|
+
if (width <= 0 || (!options.map && !options.dock))
|
|
39
|
+
return [];
|
|
40
|
+
const compact = options.notifications && width < 54;
|
|
41
|
+
const close = width >= 30 && !compact ? " × close " : width >= 3 ? " × " : "×";
|
|
42
|
+
const right = width - visibleWidth(close);
|
|
43
|
+
const buttons = [];
|
|
44
|
+
let x = 0;
|
|
45
|
+
if (options.map) {
|
|
46
|
+
const labels = [["map", "***plain"], ["pulses", "pulses"]];
|
|
47
|
+
if (options.notifications) {
|
|
48
|
+
const count = options.notifications.count();
|
|
49
|
+
labels.push(["notifications", `${width < 36 ? "notices" : "notifications"}${count ? ` ${count}` : ""}`]);
|
|
50
|
+
}
|
|
51
|
+
for (const [action, label] of labels) {
|
|
52
|
+
const text = truncateToWidth(` ${label} `, Math.max(0, right - x - 1), "");
|
|
53
|
+
if (!text)
|
|
54
|
+
break;
|
|
55
|
+
buttons.push({ action, text, x });
|
|
56
|
+
x += visibleWidth(text) + 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return [...buttons, { action: "close", text: close, x: right }];
|
|
60
|
+
};
|
|
61
|
+
const tabLabel = options.tabLabel ?? ((text, active) => active ? style.heading(text) : style.muted(text));
|
|
15
62
|
/** The keys back to the chat - and `s`, from over the screen to beside the chat and back. */
|
|
16
63
|
const backKeys = () => {
|
|
17
64
|
if (options.dock === undefined)
|
|
@@ -65,7 +112,7 @@ export function createSidePanel(options) {
|
|
|
65
112
|
/** The rule under the top. */
|
|
66
113
|
const rule = (width) => style.muted("─".repeat(Math.max(1, width)));
|
|
67
114
|
const renderPulses = (width, rows) => {
|
|
68
|
-
const keys = ["↑↓ move", "enter open/close", "←→", "o/c all", "pgup pgdn scroll", ...(options.map !== undefined ? ["p regen"] : []), ...backKeys()];
|
|
115
|
+
const keys = ["↑↓ move", "click/enter open/close", "←→", "o/c all", "pgup pgdn scroll", ...(options.map !== undefined ? ["p regen"] : []), ...backKeys()];
|
|
69
116
|
const top = topBlock([`${style.heading("pulses")}${waitingNote()}`], keys, width);
|
|
70
117
|
// Under the top: the rule, and a line of space - as the map has.
|
|
71
118
|
const bodyHeight = Math.max(3, rows - top.length - 2);
|
|
@@ -75,6 +122,10 @@ export function createSidePanel(options) {
|
|
|
75
122
|
const tree_ = jobsTreeLines([...options.jobs(), ...(options.earlier?.() ?? [])], tree, width, style);
|
|
76
123
|
drawnTree = { rows: tree_.rows, rowStarts: tree_.rowStarts, lineCount: tree_.lines.length };
|
|
77
124
|
keepCursorInView(tree, tree_.rowStarts, tree_.lines.length, bodyHeight);
|
|
125
|
+
hitLabels(tree_, tree.top, top.length + 2, bodyHeight, width, (row, index) => ({
|
|
126
|
+
key: `tree:${row.section}:${row.kind}:${row.kind !== "section" ? row.job.id : ""}:${row.kind === "file" ? row.file : ""}`,
|
|
127
|
+
pick: () => { tree.cursor = index; treeKey(tree, drawnTree.rows, "toggle"); },
|
|
128
|
+
}));
|
|
78
129
|
const visible = tree_.lines.slice(tree.top, tree.top + bodyHeight);
|
|
79
130
|
while (visible.length < bodyHeight)
|
|
80
131
|
visible.push("");
|
|
@@ -94,12 +145,19 @@ export function createSidePanel(options) {
|
|
|
94
145
|
const tabbed = pages.length > 1;
|
|
95
146
|
const page = shownPage(pages, map);
|
|
96
147
|
const discuss = page.stuck && options.discuss !== undefined ? [`${DISCUSS_KEY} talk it through in the chat`] : [];
|
|
97
|
-
const keys = [...discuss, "↑↓ move", "enter open/close", ...(tabbed ? ["←→ module"] : []), "o/c all", "pgup pgdn", "p pulses", ...backKeys()];
|
|
148
|
+
const keys = [...discuss, "↑↓ move", "click/enter open/close", ...(tabbed ? ["←→ module"] : []), "o/c all", "pgup pgdn", "p pulses", ...backKeys()];
|
|
98
149
|
// The legend's box in the upper right corner, over what is under it; too narrow a panel has none.
|
|
99
150
|
const box = width >= 60 ? legendBox(legendLines(page, style)) : [];
|
|
100
151
|
const room = box.length > 0 ? width - visibleWidth(box[0]) - 1 : width;
|
|
101
152
|
// The top line whole - it wraps beside the box; the tabs fit themselves, counting what does not fit.
|
|
102
|
-
const title = [specMapHeader(page, Number.MAX_SAFE_INTEGER, style, waitingNote())
|
|
153
|
+
const title = [specMapHeader(page, Number.MAX_SAFE_INTEGER, style, waitingNote())];
|
|
154
|
+
if (tabbed) {
|
|
155
|
+
const tabs = tabBar(pages, page, room, style, now);
|
|
156
|
+
const y = headerHeight + wrapTextWithAnsi(title[0], room).length;
|
|
157
|
+
for (const tab of tabs.targets)
|
|
158
|
+
hit(y, { key: `module:${tab.page.plainFile}`, x: tab.x, end: tab.end, pick: () => switchTab(pages, map, pages.indexOf(tab.page) - pages.indexOf(page)) });
|
|
159
|
+
title.push(tabs.line);
|
|
160
|
+
}
|
|
103
161
|
const top = topBlock(title, keys, room);
|
|
104
162
|
// Under the top: the rule, a line of space, and the columns' headings - two lines.
|
|
105
163
|
const bodyHeight = Math.max(3, rows - top.length - 4);
|
|
@@ -110,6 +168,19 @@ export function createSidePanel(options) {
|
|
|
110
168
|
const drawn = long ? specMapLines(pages, map, width - 2, style, options.jobs(), now) : first;
|
|
111
169
|
drawnMap = { rows: drawn.rows, rowStarts: drawn.rowStarts, lineCount: drawn.lines.length };
|
|
112
170
|
keepCursorInView(map, drawn.rowStarts, drawn.lines.length, bodyHeight);
|
|
171
|
+
const headings = columnHeadings(page, width, style);
|
|
172
|
+
const bodyY = top.length + 2 + headings.length;
|
|
173
|
+
hitLabels(drawn, map.top, bodyY, bodyHeight, long ? width - 2 : width, (row, index) => ({
|
|
174
|
+
key: `map:${row.key}`,
|
|
175
|
+
pick: () => { map.cursor = index; map.cursorKey = row.key; toggleMapRow(row); },
|
|
176
|
+
}));
|
|
177
|
+
// On a short header the legend can cover part of a body row as well.
|
|
178
|
+
for (let i = bodyY; i < box.length; i++) {
|
|
179
|
+
const y = headerHeight + i;
|
|
180
|
+
const row = hits.get(y);
|
|
181
|
+
if (row)
|
|
182
|
+
hits.set(y, row.map((target) => ({ ...target, end: Math.min(target.end, room) })));
|
|
183
|
+
}
|
|
113
184
|
const visible = drawn.lines.slice(map.top, map.top + bodyHeight).map((line) => truncateToWidth(line, long ? width - 2 : width));
|
|
114
185
|
while (visible.length < bodyHeight)
|
|
115
186
|
visible.push("");
|
|
@@ -120,7 +191,7 @@ export function createSidePanel(options) {
|
|
|
120
191
|
})()
|
|
121
192
|
: visible;
|
|
122
193
|
// The rule beside the box stops short of it.
|
|
123
|
-
return overBox([...top, rule(top.length < box.length ? room - 1 : width), "", ...
|
|
194
|
+
return overBox([...top, rule(top.length < box.length ? room - 1 : width), "", ...headings, ...body], box, width);
|
|
124
195
|
};
|
|
125
196
|
/** From the map to the pulse list: onto the pulse that regenerates the item under the cursor, when one does. */
|
|
126
197
|
const toPulses = () => {
|
|
@@ -155,6 +226,17 @@ export function createSidePanel(options) {
|
|
|
155
226
|
return;
|
|
156
227
|
}
|
|
157
228
|
};
|
|
229
|
+
const toggleMapRow = (target, open) => {
|
|
230
|
+
if (target === undefined || target.kind === "group")
|
|
231
|
+
return;
|
|
232
|
+
const to = open ?? !(target.kind === "import" ? target.open : map.open.has(target.key));
|
|
233
|
+
if (target.kind === "import")
|
|
234
|
+
map.imports.set(target.key.replace(/^import\n/, ""), to);
|
|
235
|
+
else if (to)
|
|
236
|
+
map.open.add(target.key);
|
|
237
|
+
else
|
|
238
|
+
map.open.delete(target.key);
|
|
239
|
+
};
|
|
158
240
|
/** A key in the map. */
|
|
159
241
|
const mapKey = (data) => {
|
|
160
242
|
const page = Math.max(1, lastBodyHeight - 1);
|
|
@@ -164,25 +246,12 @@ export function createSidePanel(options) {
|
|
|
164
246
|
map.cursor = Math.max(0, Math.min(rows.length - 1, to));
|
|
165
247
|
map.cursorKey = rows[map.cursor]?.key;
|
|
166
248
|
};
|
|
167
|
-
const isOpen = (target) => (target.kind === "item" ? map.open.has(target.key) : target.kind === "group" ? false : target.open);
|
|
168
|
-
const toggle = (target, open) => {
|
|
169
|
-
// A group's heading only says what is under it.
|
|
170
|
-
if (target === undefined || target.kind === "group")
|
|
171
|
-
return;
|
|
172
|
-
const to = open ?? !isOpen(target);
|
|
173
|
-
if (target.kind === "import")
|
|
174
|
-
map.imports.set(target.key.replace(/^import\n/, ""), to);
|
|
175
|
-
else if (to)
|
|
176
|
-
map.open.add(target.key);
|
|
177
|
-
else
|
|
178
|
-
map.open.delete(target.key);
|
|
179
|
-
};
|
|
180
249
|
if (matchesKey(data, Key.up))
|
|
181
250
|
move(map.cursor - 1);
|
|
182
251
|
else if (matchesKey(data, Key.down))
|
|
183
252
|
move(map.cursor + 1);
|
|
184
253
|
else if (matchesKey(data, Key.enter) || data === " ")
|
|
185
|
-
|
|
254
|
+
toggleMapRow(row);
|
|
186
255
|
// ←→ go from one module's tab to the next.
|
|
187
256
|
else if (matchesKey(data, Key.right))
|
|
188
257
|
switchTab(pages, map, 1);
|
|
@@ -190,7 +259,7 @@ export function createSidePanel(options) {
|
|
|
190
259
|
switchTab(pages, map, -1);
|
|
191
260
|
else if (data === "o" || data === "c")
|
|
192
261
|
for (const entry of rows)
|
|
193
|
-
|
|
262
|
+
toggleMapRow(entry, data === "o");
|
|
194
263
|
else if (data === DISCUSS_KEY && options.discuss !== undefined) {
|
|
195
264
|
const shown = shownPage(pages, map);
|
|
196
265
|
if (shown?.stuck === true)
|
|
@@ -211,15 +280,30 @@ export function createSidePanel(options) {
|
|
|
211
280
|
};
|
|
212
281
|
return {
|
|
213
282
|
render(width) {
|
|
214
|
-
|
|
283
|
+
hits.clear();
|
|
284
|
+
let bar = "";
|
|
285
|
+
let end = 0;
|
|
286
|
+
for (const { action, text, x } of controls(width)) {
|
|
287
|
+
bar += " ".repeat(x - end) + tabLabel(text, map.view === action, options.pointer?.target === `panel:${action}`, action === "close" ? "close" : "tab");
|
|
288
|
+
end = x + visibleWidth(text);
|
|
289
|
+
}
|
|
290
|
+
const header = bar ? [bar, ""] : [];
|
|
291
|
+
headerHeight = header.length;
|
|
292
|
+
const rows = Math.max(8, options.rows()) - header.length;
|
|
215
293
|
try {
|
|
216
|
-
|
|
294
|
+
if (map.view === "notifications" && options.notifications) {
|
|
295
|
+
const lines = options.notifications.render(width, rows).slice(0, rows);
|
|
296
|
+
return [...header, ...lines, ...new Array(rows - lines.length).fill("")];
|
|
297
|
+
}
|
|
298
|
+
return [...header, ...(map.view === "map" && options.map !== undefined ? renderMap(width, rows) : renderPulses(width, rows))];
|
|
217
299
|
}
|
|
218
300
|
catch (error) {
|
|
301
|
+
hits.clear();
|
|
219
302
|
// A frame that throws is never drawn - nor is anything after it: the screen would freeze. What failed is shown instead.
|
|
220
303
|
const top = topBlock([`${style.heading(map.view === "map" ? "regen" : "pulses")}${waitingNote()}`], [...(options.map !== undefined ? ["p the other view"] : []), ...backKeys()], width);
|
|
221
304
|
const lines = (error instanceof Error ? (error.stack ?? error.message) : String(error)).split("\n").slice(0, Math.max(1, rows - top.length - 1));
|
|
222
305
|
return [
|
|
306
|
+
...header,
|
|
223
307
|
...top,
|
|
224
308
|
rule(width),
|
|
225
309
|
...lines.map((line, index) => truncateToWidth(index === 0 ? style.error(`could not be drawn: ${line}`) : style.muted(line), width)),
|
|
@@ -228,6 +312,17 @@ export function createSidePanel(options) {
|
|
|
228
312
|
}
|
|
229
313
|
},
|
|
230
314
|
handleInput(data) {
|
|
315
|
+
if (map.view === "notifications" && options.notifications) {
|
|
316
|
+
if (!options.notifications.inDetail() && data === "p")
|
|
317
|
+
return toPulses();
|
|
318
|
+
if (!options.notifications.inDetail() && data === "s" && options.dock)
|
|
319
|
+
return options.dock.toggle();
|
|
320
|
+
return options.notifications.handleInput(data);
|
|
321
|
+
}
|
|
322
|
+
if (data === "n" && options.notifications) {
|
|
323
|
+
map.view = "notifications";
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
231
326
|
if (matchesKey(data, Key.escape)) {
|
|
232
327
|
options.back();
|
|
233
328
|
return;
|
|
@@ -274,8 +369,49 @@ export function createSidePanel(options) {
|
|
|
274
369
|
else if (matchesKey(data, Key.end) || data === "G")
|
|
275
370
|
tree.cursor = Math.max(0, drawnTree.rows.length - 1);
|
|
276
371
|
},
|
|
277
|
-
/**
|
|
372
|
+
/** View tabs switch on a click, and the wheel scrolls the panel wherever the keyboard is. */
|
|
278
373
|
handleMouse(event) {
|
|
374
|
+
const down = pressed;
|
|
375
|
+
if (event.type === "press" || event.type === "click")
|
|
376
|
+
pressed = undefined;
|
|
377
|
+
if (event.y === 0 && (event.type === "move" || (event.button === "left" && (event.type === "press" || event.type === "click")))) {
|
|
378
|
+
for (const { action, text, x } of controls(event.width)) {
|
|
379
|
+
if (event.x >= x && event.x < x + visibleWidth(text)) {
|
|
380
|
+
if (options.pointer)
|
|
381
|
+
options.pointer.target = `panel:${action}`;
|
|
382
|
+
if (event.type === "move")
|
|
383
|
+
return { handled: true, render: false };
|
|
384
|
+
if (event.type === "press")
|
|
385
|
+
pressed = action;
|
|
386
|
+
else if (action === down && action !== map.view) {
|
|
387
|
+
if (action === "close")
|
|
388
|
+
options.close();
|
|
389
|
+
else if (action === "notifications")
|
|
390
|
+
map.view = "notifications";
|
|
391
|
+
else if (action === "map")
|
|
392
|
+
toMap();
|
|
393
|
+
else
|
|
394
|
+
toPulses();
|
|
395
|
+
}
|
|
396
|
+
return { handled: true };
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (map.view === "notifications" && options.notifications) {
|
|
401
|
+
if (event.y < headerHeight)
|
|
402
|
+
return;
|
|
403
|
+
return options.notifications.handleMouse({ ...event, y: event.y - headerHeight, height: event.height - headerHeight });
|
|
404
|
+
}
|
|
405
|
+
if (event.button === "left" && (event.type === "press" || event.type === "click")) {
|
|
406
|
+
const target = hits.get(event.y)?.find(({ x, end }) => event.x >= x && event.x < end);
|
|
407
|
+
if (target) {
|
|
408
|
+
if (event.type === "press")
|
|
409
|
+
pressed = target.key;
|
|
410
|
+
else if (down === target.key)
|
|
411
|
+
target.pick();
|
|
412
|
+
return { handled: true };
|
|
413
|
+
}
|
|
414
|
+
}
|
|
279
415
|
if (event.type !== "wheel" || event.wheelDelta === undefined)
|
|
280
416
|
return undefined;
|
|
281
417
|
if (map.view === "map" && options.map !== undefined)
|
|
@@ -12,8 +12,8 @@ import type { TranscriptStyle } from "./transcript-view.ts";
|
|
|
12
12
|
* folded block each. A chain of many modules nested one in another was too deep to read, and too much to draw.
|
|
13
13
|
*/
|
|
14
14
|
export interface SpecMapState {
|
|
15
|
-
/** Which
|
|
16
|
-
view: "map" | "pulses";
|
|
15
|
+
/** Which tab the side panel shows. */
|
|
16
|
+
view: "map" | "pulses" | "notifications";
|
|
17
17
|
/** The row the cursor is on, and the key of what is there - it stays on the item when rows move. */
|
|
18
18
|
cursor: number;
|
|
19
19
|
cursorKey?: string;
|
|
@@ -70,7 +70,14 @@ export declare function switchTab(pages: MarkedPage[], state: SpecMapState, by:
|
|
|
70
70
|
* The tabs, a module each in the chain's order, the one shown marked - those regenerating spin, those stuck say so - fitted to
|
|
71
71
|
* `width` around the one shown, what does not fit counted at either end.
|
|
72
72
|
*/
|
|
73
|
-
export declare function tabBar(pages: MarkedPage[], shown: MarkedPage | undefined, width: number, style: TranscriptStyle, now: number):
|
|
73
|
+
export declare function tabBar(pages: MarkedPage[], shown: MarkedPage | undefined, width: number, style: TranscriptStyle, now: number): {
|
|
74
|
+
line: string;
|
|
75
|
+
targets: {
|
|
76
|
+
x: number;
|
|
77
|
+
end: number;
|
|
78
|
+
page: MarkedPage;
|
|
79
|
+
}[];
|
|
80
|
+
};
|
|
74
81
|
/**
|
|
75
82
|
* Where an item stands, as one mark on a ladder every item climbs: planned, working, regenerated, validating, conform - and needs
|
|
76
83
|
* you, off it - named in the legend in the panel's corner. The same mark means the same thing whatever the config says
|
|
@@ -123,6 +130,7 @@ export declare function specMapRows(pages: MarkedPage[], state: SpecMapState): M
|
|
|
123
130
|
export declare function specMapLines(pages: MarkedPage[], state: SpecMapState, width: number, style: TranscriptStyle, _jobs?: Job[], now?: number): {
|
|
124
131
|
lines: string[];
|
|
125
132
|
rowStarts: number[];
|
|
133
|
+
labelHeights: number[];
|
|
126
134
|
rows: MapRow[];
|
|
127
135
|
marks: LineMark[];
|
|
128
136
|
};
|
|
@@ -67,7 +67,23 @@ export function tabBar(pages, shown, width, style, now) {
|
|
|
67
67
|
if (from > 0 && visibleWidth(lineOf(from - 1, to)) <= width)
|
|
68
68
|
(from -= 1), (widened = true);
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
const full = lineOf(from, to);
|
|
71
|
+
const end = visibleWidth(full) > width ? Math.max(0, width - 1) : width;
|
|
72
|
+
const targets = [];
|
|
73
|
+
let x = 0;
|
|
74
|
+
const target = (text, index) => {
|
|
75
|
+
const next = x + visibleWidth(text);
|
|
76
|
+
if (x < end && pages[index])
|
|
77
|
+
targets.push({ x, end: Math.min(next, end), page: pages[index] });
|
|
78
|
+
x = next + 2;
|
|
79
|
+
};
|
|
80
|
+
if (from > 0)
|
|
81
|
+
target(`‹ ${from}`, from - 1);
|
|
82
|
+
for (let i = from; i < to; i++)
|
|
83
|
+
target(tabs[i] ?? "", i);
|
|
84
|
+
if (to < tabs.length)
|
|
85
|
+
target(`${tabs.length - to} ›`, to);
|
|
86
|
+
return { line: truncateToWidth(full, width, "…"), targets };
|
|
71
87
|
}
|
|
72
88
|
/** What needs the person - a stuck page, its `!` - in the warning colour: it waits on them, nothing is broken. */
|
|
73
89
|
const needs = (style) => style.warning ?? style.error;
|
|
@@ -427,6 +443,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
427
443
|
const lines = [];
|
|
428
444
|
const marks = [];
|
|
429
445
|
const rowStarts = [];
|
|
446
|
+
const labelHeights = [];
|
|
430
447
|
const add = (line, mark) => {
|
|
431
448
|
lines.push(line);
|
|
432
449
|
marks.push(mark);
|
|
@@ -455,6 +472,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
455
472
|
rowStarts.push(lines.length);
|
|
456
473
|
const text = `${INDENT.repeat(row.depth + 1)}${row.label}`;
|
|
457
474
|
add(`${pointer}${here ? style.heading(text) : style.muted(text)}`);
|
|
475
|
+
labelHeights.push(0); // A heading, with nothing to open.
|
|
458
476
|
underImport = true;
|
|
459
477
|
return;
|
|
460
478
|
}
|
|
@@ -468,6 +486,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
468
486
|
const items = page.items.filter((item) => item.file === row.file);
|
|
469
487
|
const text = `${row.open ? "▾" : "▸"} from ${row.file} · ${importSummary(items)}`;
|
|
470
488
|
add(`${pointer}${INDENT.repeat(row.depth + 1)}${here ? style.heading(text) : style.muted(text)}`);
|
|
489
|
+
labelHeights.push(1);
|
|
471
490
|
underImport = true;
|
|
472
491
|
return;
|
|
473
492
|
}
|
|
@@ -516,6 +535,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
516
535
|
if (heading !== undefined)
|
|
517
536
|
for (const line of hanging(body, first, room))
|
|
518
537
|
add(`${CONTINUED}${line}`, mark);
|
|
538
|
+
labelHeights.push(lines.length - rowStarts[index]);
|
|
519
539
|
// The first item that needs the person says what for, and how to go about it - opened or closed.
|
|
520
540
|
if (page.stuck && !toldWhy && rungOf(item) === "needsYou") {
|
|
521
541
|
toldWhy = true;
|
|
@@ -540,7 +560,7 @@ export function specMapLines(pages, state, width, style, _jobs = [], now = Date.
|
|
|
540
560
|
add(`${CONTINUED}${style.muted(`… ${changed.length - 4} more - enter opens it`)}`, mark);
|
|
541
561
|
}
|
|
542
562
|
});
|
|
543
|
-
return { lines, rowStarts, rows, marks };
|
|
563
|
+
return { lines, rowStarts, labelHeights, rows, marks };
|
|
544
564
|
}
|
|
545
565
|
/** How the strip and the minimap colour a mark. */
|
|
546
566
|
function paintOf(mark, style) {
|
|
@@ -88,6 +88,11 @@ export declare function staticChecksOnly(run: {
|
|
|
88
88
|
exitCode: number;
|
|
89
89
|
timedOut?: boolean;
|
|
90
90
|
}): boolean;
|
|
91
|
+
/** The skill that writes a testing script of a kind, and what the script is called in words. */
|
|
92
|
+
export declare function testingScriptSkill(kind: ScriptKind): {
|
|
93
|
+
skill: string;
|
|
94
|
+
what: string;
|
|
95
|
+
};
|
|
91
96
|
/** The kind of testing script a skill writes, by its name - one that writes none, undefined. */
|
|
92
97
|
export declare function scriptKindOfSkill(skill: string): ScriptKind | undefined;
|
|
93
98
|
/** Raised before a build starts when the script that would decide it is done is missing. */
|
|
@@ -193,6 +193,10 @@ const SKILL = {
|
|
|
193
193
|
unit: { skill: "implement-unit-testing-script", file: "run_unittests", what: "unit testing script" },
|
|
194
194
|
conformance: { skill: "implement-conformance-testing-script", file: "run_conformance_tests", what: "conformance testing script" },
|
|
195
195
|
};
|
|
196
|
+
/** The skill that writes a testing script of a kind, and what the script is called in words. */
|
|
197
|
+
export function testingScriptSkill(kind) {
|
|
198
|
+
return { skill: SKILL[kind].skill, what: SKILL[kind].what };
|
|
199
|
+
}
|
|
196
200
|
/** The kind of testing script a skill writes, by its name - one that writes none, undefined. */
|
|
197
201
|
export function scriptKindOfSkill(skill) {
|
|
198
202
|
return Object.keys(SKILL).find((kind) => SKILL[kind].skill === skill);
|
package/dist/reopen.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
|
|
3
|
+
* the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
|
|
4
|
+
* (cli.ts) starts the chat as a process of its own, with turri's theme, its screen and the folder's models, and names
|
|
5
|
+
* it a file to write in: a chat that is to open again elsewhere writes where, with what, and quits; `turri` reads it and
|
|
6
|
+
* starts the chat there as it started the first - the theme, the screen and that folder's models worked out the same.
|
|
7
|
+
* A chat `turri` did not start - a host's, a desktop app's - has no file, and is never offered it.
|
|
8
|
+
*/
|
|
9
|
+
/** The file the chat `turri` started writes where it is to open again. */
|
|
10
|
+
export declare const REOPEN_FILE_ENV = "TURRI_REOPEN_FILE";
|
|
11
|
+
/** Said to the chat opened again, at its start: the capture whose report it tells - what the capture said of itself. */
|
|
12
|
+
export declare const REOPENED_AFTER_CAPTURE = "TURRI_REOPENED_AFTER_CAPTURE";
|
|
13
|
+
export interface Reopening {
|
|
14
|
+
/** The folder the chat opens in. */
|
|
15
|
+
dir: string;
|
|
16
|
+
/** Its arguments, as `turri` takes them. */
|
|
17
|
+
args: string[];
|
|
18
|
+
/** What it is told at its start, in its environment. */
|
|
19
|
+
env: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
/** Whether this chat can open again in another folder: `turri` started it. */
|
|
22
|
+
export declare function canReopen(): boolean;
|
|
23
|
+
/** Ask `turri` to open the chat again in `dir` once it has quit - the caller quits it. False when it cannot (`canReopen`). */
|
|
24
|
+
export declare function reopenIn(dir: string, options?: {
|
|
25
|
+
args?: string[];
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
}): boolean;
|
|
28
|
+
/** What the chat that quit asked for, taken - its file removed - or undefined when it asked for nothing. */
|
|
29
|
+
export declare function takeReopening(file: string): Reopening | undefined;
|
package/dist/reopen.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
/**
|
|
3
|
+
* turri opened again in another folder, in the same terminal, once its chat has quit: a chat works on the project of
|
|
4
|
+
* the folder it was opened in, and after a capture the work is in another - `plain/`, a project of its own. `turri`
|
|
5
|
+
* (cli.ts) starts the chat as a process of its own, with turri's theme, its screen and the folder's models, and names
|
|
6
|
+
* it a file to write in: a chat that is to open again elsewhere writes where, with what, and quits; `turri` reads it and
|
|
7
|
+
* starts the chat there as it started the first - the theme, the screen and that folder's models worked out the same.
|
|
8
|
+
* A chat `turri` did not start - a host's, a desktop app's - has no file, and is never offered it.
|
|
9
|
+
*/
|
|
10
|
+
/** The file the chat `turri` started writes where it is to open again. */
|
|
11
|
+
export const REOPEN_FILE_ENV = "TURRI_REOPEN_FILE";
|
|
12
|
+
/** Said to the chat opened again, at its start: the capture whose report it tells - what the capture said of itself. */
|
|
13
|
+
export const REOPENED_AFTER_CAPTURE = "TURRI_REOPENED_AFTER_CAPTURE";
|
|
14
|
+
/** Whether this chat can open again in another folder: `turri` started it. */
|
|
15
|
+
export function canReopen() {
|
|
16
|
+
return (process.env[REOPEN_FILE_ENV] ?? "") !== "";
|
|
17
|
+
}
|
|
18
|
+
/** Ask `turri` to open the chat again in `dir` once it has quit - the caller quits it. False when it cannot (`canReopen`). */
|
|
19
|
+
export function reopenIn(dir, options = {}) {
|
|
20
|
+
const file = process.env[REOPEN_FILE_ENV];
|
|
21
|
+
if (file === undefined || file === "")
|
|
22
|
+
return false;
|
|
23
|
+
const reopening = { dir, args: options.args ?? [], env: options.env ?? {} };
|
|
24
|
+
writeFileSync(file, JSON.stringify(reopening));
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/** What the chat that quit asked for, taken - its file removed - or undefined when it asked for nothing. */
|
|
28
|
+
export function takeReopening(file) {
|
|
29
|
+
let text;
|
|
30
|
+
try {
|
|
31
|
+
text = readFileSync(file, "utf8");
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
rmSync(file, { force: true });
|
|
37
|
+
try {
|
|
38
|
+
const parsed = JSON.parse(text);
|
|
39
|
+
if (typeof parsed.dir !== "string" || !Array.isArray(parsed.args) || parsed.args.some((arg) => typeof arg !== "string"))
|
|
40
|
+
return undefined;
|
|
41
|
+
const env = Object.fromEntries(Object.entries(parsed.env ?? {}).filter((entry) => typeof entry[1] === "string"));
|
|
42
|
+
return { dir: parsed.dir, args: parsed.args, env };
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/resume-line.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* pi's lines on the way out that say how to resume the session - its label, then the command on a line of its own -
|
|
3
|
+
* left out: turri leaves nothing behind but the command run.
|
|
4
|
+
*/
|
|
2
5
|
export declare function withoutResumeLine(text: string): string;
|
package/dist/resume-line.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* pi's lines on the way out that say how to resume the session - its label, then the command on a line of its own -
|
|
3
|
+
* left out: turri leaves nothing behind but the command run.
|
|
4
|
+
*/
|
|
2
5
|
export function withoutResumeLine(text) {
|
|
3
|
-
return text.replace(/^(?:\x1b\[[0-9;]*m)*To resume this session
|
|
6
|
+
return text.replace(/^(?:\x1b\[[0-9;]*m)*To resume this session:(?:\x1b\[[0-9;]*m)*\n[^\n]*\n?/m, "");
|
|
4
7
|
}
|
package/dist/sentinel-chat.js
CHANGED
|
@@ -177,6 +177,8 @@ export function noticeDialogs(pi, session, link, context) {
|
|
|
177
177
|
pi.on("agent_settled", () => void ask());
|
|
178
178
|
return {
|
|
179
179
|
put(notice) {
|
|
180
|
+
if (session.terminal)
|
|
181
|
+
return; // The terminal centre received it, including the question whether to start.
|
|
180
182
|
try {
|
|
181
183
|
pi.appendEntry(NOTICE_ENTRY, notice);
|
|
182
184
|
}
|
|
@@ -191,13 +193,14 @@ export function noticeDialogs(pi, session, link, context) {
|
|
|
191
193
|
},
|
|
192
194
|
concluded(conclusion) {
|
|
193
195
|
try {
|
|
194
|
-
|
|
196
|
+
if (!session.terminal)
|
|
197
|
+
pi.appendEntry(CONCLUDED_ENTRY, conclusion);
|
|
195
198
|
}
|
|
196
199
|
catch {
|
|
197
200
|
/* the agent is still told */
|
|
198
201
|
}
|
|
199
202
|
// A host that shows the person the conclusion itself: the chat knows of it - in order, with no turn of its own.
|
|
200
|
-
const shown = session.host.pulseEndsShown === true;
|
|
203
|
+
const shown = session.terminal || session.host.pulseEndsShown === true;
|
|
201
204
|
void pi.sendMessage({
|
|
202
205
|
customType: "turri_sentinel_concluded",
|
|
203
206
|
content: concludedNote(conclusion, { shown }),
|
|
@@ -206,6 +209,8 @@ export function noticeDialogs(pi, session, link, context) {
|
|
|
206
209
|
}, shown ? { triggerTurn: false } : { triggerTurn: true, deliverAs: "followUp" });
|
|
207
210
|
},
|
|
208
211
|
over(notice) {
|
|
212
|
+
if (session.terminal)
|
|
213
|
+
return;
|
|
209
214
|
asking.get(notice.id)?.abort();
|
|
210
215
|
const at = waiting.indexOf(notice);
|
|
211
216
|
if (at !== -1)
|
package/dist/sentinel.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare function keepGuidance(cwd: string, text: string): void;
|
|
|
30
30
|
* What a chat of the person's is told of the pulses that end: told itself, of those asked for in it - or, with the
|
|
31
31
|
* sentinel on, nothing, the sentinel telling the person what needs them.
|
|
32
32
|
*/
|
|
33
|
-
export declare function pulseEndsBlock(sentinel: boolean): string;
|
|
33
|
+
export declare function pulseEndsBlock(sentinel: boolean, terminal?: boolean): string;
|
|
34
34
|
/**
|
|
35
35
|
* What the chat the person is in is told of a pulse that landed, with the sentinel on: that it landed, what the sentinel
|
|
36
36
|
* does with it - and to tell the person so, and do nothing else about it. `launching`: launch-after-pulse is on - it is
|
package/dist/sentinel.js
CHANGED
|
@@ -119,7 +119,9 @@ export function keepGuidance(cwd, text) {
|
|
|
119
119
|
* What a chat of the person's is told of the pulses that end: told itself, of those asked for in it - or, with the
|
|
120
120
|
* sentinel on, nothing, the sentinel telling the person what needs them.
|
|
121
121
|
*/
|
|
122
|
-
export function pulseEndsBlock(sentinel) {
|
|
122
|
+
export function pulseEndsBlock(sentinel, terminal = false) {
|
|
123
|
+
if (sentinel && terminal)
|
|
124
|
+
return "<pulse-ends>\nThe sentinel checks finished pulses. Their results, its conclusions and its notices go to the notification centre (/notifications). Do not announce them here. Answer if the person asks; when they accept a notice's action, do the task you are given.\n</pulse-ends>";
|
|
123
125
|
return sentinel
|
|
124
126
|
? [
|
|
125
127
|
"<pulse-ends>",
|
package/dist/setup.js
CHANGED
|
@@ -10,7 +10,7 @@ import { fetchLatest, newerThan, turrisOnPath, versionFindings } from "./turri-v
|
|
|
10
10
|
import { sandboxAvailable, sandboxWithAsync } from "./regenerate/os-sandbox.js";
|
|
11
11
|
import { findTestScripts, onThisMachine } from "./regenerate/test-scripts.js";
|
|
12
12
|
import { configKeyOptions, parseArgs } from "./cli-options.js";
|
|
13
|
-
import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf } from "./config.js";
|
|
13
|
+
import { CONFIG_FILE, hasProjectConfig, readProjectConfig, moduleConfigFile, configModuleOf, moduleConfigsOf, configProblems } from "./config.js";
|
|
14
14
|
import { checkModels, modelsInUse, piModelAccess } from "./model-check.js";
|
|
15
15
|
import { bedrockRegionFor, describeBedrockRegion, regionInGeography } from "./bedrock-region.js";
|
|
16
16
|
import { baseFilesAsync } from "./regenerate/base-folder.js";
|
|
@@ -230,6 +230,14 @@ async function allChecks(options) {
|
|
|
230
230
|
const project = options.dir;
|
|
231
231
|
if (project === undefined)
|
|
232
232
|
return checks;
|
|
233
|
+
// A config that does not parse is read as empty - every setting at its default, the models pi's own: said first.
|
|
234
|
+
checks.push(...configProblems(project).map((problem) => ({
|
|
235
|
+
level: "missing",
|
|
236
|
+
name: "Config",
|
|
237
|
+
detail: problem.text,
|
|
238
|
+
more: [`turri reads a config that does not parse as empty: none of ${problem.file} applies - not its models, not conformance tests, no other setting.`],
|
|
239
|
+
fix: `Set each key once in ${problem.file}, then run turri doctor again`,
|
|
240
|
+
})));
|
|
233
241
|
if (hasProjectConfig(project) || existsSync(join(project, "plain_modules")))
|
|
234
242
|
checks.push(...(await checkProject(project, { has: (command) => onThisMachine(command, env) !== undefined })));
|
|
235
243
|
if (hasProjectConfig(project))
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type TuiMouseEvent } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { TurriCore } from "./chats.ts";
|
|
3
|
+
import type { Conclusion, Notice } from "./notice.ts";
|
|
4
|
+
import { type DialogStyle } from "./question-dialog.ts";
|
|
5
|
+
/** The terminal session's inbox. A notice keeps its identity and live state from the session that answers it. */
|
|
6
|
+
export interface TerminalNotification {
|
|
7
|
+
title: string;
|
|
8
|
+
detail: string;
|
|
9
|
+
conclusion?: string;
|
|
10
|
+
notice?: Notice;
|
|
11
|
+
seen: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class TerminalNotifications {
|
|
14
|
+
readonly items: TerminalNotification[];
|
|
15
|
+
private readonly reviews;
|
|
16
|
+
get count(): number;
|
|
17
|
+
needsAnswer(item: TerminalNotification): boolean;
|
|
18
|
+
add(title: string, detail: string, notice?: Notice): void;
|
|
19
|
+
/** Only the sentinel's review shares a row. The pulse result and the question whether to start it are independent. */
|
|
20
|
+
private review;
|
|
21
|
+
put(notice: Notice, work?: Pick<Conclusion, "job" | "check">): void;
|
|
22
|
+
concluded(result: Conclusion): void;
|
|
23
|
+
}
|
|
24
|
+
/** The notifications tab. Opening or leaving a detail never answers its notice. Only an explicit choice does. */
|
|
25
|
+
export declare function notificationView(session: TurriCore, style: DialogStyle, leave: () => void): {
|
|
26
|
+
count: () => number;
|
|
27
|
+
inDetail: () => boolean;
|
|
28
|
+
render(width: number, available: number): readonly string[];
|
|
29
|
+
handleInput(data: string): void;
|
|
30
|
+
handleMouse: (event: TuiMouseEvent) => import("@earendil-works/pi-tui").TuiMouseEventResult | undefined;
|
|
31
|
+
};
|