@turri-dev/cli 0.4.3-next.620bae9 → 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.
Files changed (122) hide show
  1. package/README.md +1 -0
  2. package/dist/background-skills.d.ts +4 -1
  3. package/dist/background-skills.js +9 -1
  4. package/dist/capture/agents.d.ts +406 -0
  5. package/dist/capture/agents.js +379 -0
  6. package/dist/capture/area.d.ts +58 -0
  7. package/dist/capture/area.js +197 -0
  8. package/dist/capture/assemble.d.ts +112 -0
  9. package/dist/capture/assemble.js +453 -0
  10. package/dist/capture/capture.d.ts +116 -0
  11. package/dist/capture/capture.js +1315 -0
  12. package/dist/capture/chat.d.ts +29 -0
  13. package/dist/capture/chat.js +94 -0
  14. package/dist/capture/checks.d.ts +142 -0
  15. package/dist/capture/checks.js +649 -0
  16. package/dist/capture/config.d.ts +13 -0
  17. package/dist/capture/config.js +66 -0
  18. package/dist/capture/interface.d.ts +71 -0
  19. package/dist/capture/interface.js +199 -0
  20. package/dist/capture/map.d.ts +56 -0
  21. package/dist/capture/map.js +530 -0
  22. package/dist/capture/models.d.ts +4 -0
  23. package/dist/capture/models.js +16 -0
  24. package/dist/capture/plan.d.ts +7 -0
  25. package/dist/capture/plan.js +13 -0
  26. package/dist/capture/progress.d.ts +111 -0
  27. package/dist/capture/progress.js +266 -0
  28. package/dist/capture/python-interface.d.ts +3 -0
  29. package/dist/capture/python-interface.js +17 -0
  30. package/dist/capture/report.d.ts +75 -0
  31. package/dist/capture/report.js +268 -0
  32. package/dist/capture/runners.d.ts +6 -0
  33. package/dist/capture/runners.js +59 -0
  34. package/dist/capture/scripts.d.ts +26 -0
  35. package/dist/capture/scripts.js +38 -0
  36. package/dist/capture/state.d.ts +310 -0
  37. package/dist/capture/state.js +43 -0
  38. package/dist/capture/trial.d.ts +34 -0
  39. package/dist/capture/trial.js +89 -0
  40. package/dist/capture-cli.d.ts +1 -0
  41. package/dist/capture-cli.js +77 -0
  42. package/dist/chat-tab-header.d.ts +3 -2
  43. package/dist/chat-tab-header.js +22 -9
  44. package/dist/chat-tabs.d.ts +7 -1
  45. package/dist/chat-tabs.js +10 -6
  46. package/dist/chat-terminal.js +27 -6
  47. package/dist/chats.d.ts +14 -8
  48. package/dist/chats.js +46 -20
  49. package/dist/cli.js +32 -14
  50. package/dist/config-edit.js +5 -2
  51. package/dist/config.d.ts +15 -2
  52. package/dist/config.js +62 -3
  53. package/dist/extension.d.ts +2 -1
  54. package/dist/extension.js +225 -68
  55. package/dist/identity.js +2 -1
  56. package/dist/init-config.d.ts +4 -1
  57. package/dist/init-config.js +31 -4
  58. package/dist/loop-cli.js +5 -1
  59. package/dist/loop-tools.js +5 -1
  60. package/dist/new-project.d.ts +5 -0
  61. package/dist/new-project.js +11 -0
  62. package/dist/pi-launch.js +2 -0
  63. package/dist/pi-themes.d.ts +3 -0
  64. package/dist/pi-themes.js +21 -0
  65. package/dist/pi.d.ts +2 -2
  66. package/dist/pi.js +4 -4
  67. package/dist/plain-code-blocks.d.ts +14 -0
  68. package/dist/plain-code-blocks.js +56 -0
  69. package/dist/pointer-hover.d.ts +1 -1
  70. package/dist/pointer-hover.js +4 -0
  71. package/dist/question-dialog.d.ts +5 -0
  72. package/dist/question-dialog.js +26 -3
  73. package/dist/regenerate/agent-env.js +5 -1
  74. package/dist/regenerate/command-check.js +80 -11
  75. package/dist/regenerate/job-panel.d.ts +5 -107
  76. package/dist/regenerate/job-panel.js +4 -289
  77. package/dist/regenerate/loop.js +9 -1
  78. package/dist/regenerate/side-panel.d.ts +2 -0
  79. package/dist/regenerate/side-panel.js +32 -5
  80. package/dist/regenerate/spec-map-view.d.ts +2 -2
  81. package/dist/regenerate/test-scripts.d.ts +5 -0
  82. package/dist/regenerate/test-scripts.js +4 -0
  83. package/dist/reopen.d.ts +29 -0
  84. package/dist/reopen.js +47 -0
  85. package/dist/sentinel-chat.js +7 -2
  86. package/dist/sentinel.d.ts +1 -1
  87. package/dist/sentinel.js +3 -1
  88. package/dist/setup.js +9 -1
  89. package/dist/terminal-notifications.d.ts +37 -0
  90. package/dist/terminal-notifications.js +164 -0
  91. package/docs/README.md +2 -0
  92. package/docs/capture.md +227 -0
  93. package/docs/chats.md +6 -3
  94. package/docs/config.md +18 -4
  95. package/docs/development.md +4 -1
  96. package/docs/hosting.md +2 -2
  97. package/docs/launch.md +2 -2
  98. package/docs/regenerating.md +1 -1
  99. package/docs/sandbox.md +4 -2
  100. package/docs/sentinel.md +11 -11
  101. package/docs/theming.md +3 -3
  102. package/docs/using.md +7 -3
  103. package/genome/capture/capture.md +26 -0
  104. package/genome/capture/check-conventions.md +5 -0
  105. package/genome/capture/check-reference.md +12 -0
  106. package/genome/capture/compact.md +7 -0
  107. package/genome/capture/concepts.md +3 -0
  108. package/genome/capture/divide.md +9 -0
  109. package/genome/capture/feature.md +45 -0
  110. package/genome/capture/interface.md +9 -0
  111. package/genome/capture/modules.md +25 -0
  112. package/genome/capture/outline.md +11 -0
  113. package/genome/capture/python-interface.py +111 -0
  114. package/genome/capture/readability.md +12 -0
  115. package/genome/capture/reference.md +10 -0
  116. package/genome/capture/runners/python-requirements.sh +67 -0
  117. package/genome/capture/split.md +9 -0
  118. package/genome/capture/survey.md +39 -0
  119. package/genome/capture/trial.md +18 -0
  120. package/genome/capture/verify.md +7 -0
  121. package/genome/rules/turri-regeneration.md +1 -1
  122. package/package.json +1 -1
@@ -1,122 +1,20 @@
1
- import { type Color } from "@earendil-works/pi-tui";
2
- import { type Job } from "./jobs.ts";
3
- /**
4
- * The live panel above the editor while background work runs.
5
- *
6
- * One block per running job: what it is and how long it has been going, the stage it is
7
- * at, what is happening this second, and the last things its agents did. What waits is not
8
- * in it - the side panel lists the queue. It disappears when nothing is running - the finished
9
- * job announces itself in the transcript instead.
10
- *
11
- * It is drawn as a component rather than handed over as lines, because pi cuts a list of
12
- * lines off at ten. Instead it sizes itself: compact by default, and the agents' trace in full
13
- * while tool output is expanded - pi's own ctrl+o, which the person already uses to see more of
14
- * what the agent did. What finished stays counted either way: the side panel lists it.
15
- */
16
- export declare const JOB_PANEL_KEY = "turri-jobs";
17
- /**
18
- * The key that opens the side panel on its jobs, and goes back to it. Not ctrl+j: a terminal without the Kitty keyboard
19
- * protocol sends ctrl+j as a line feed - what it sends for shift+enter too, and what a dialog reads as enter - so it
20
- * would answer a question, and take a new line from the editor. ctrl+h is the byte old terminals sent for backspace;
21
- * every terminal now sends backspace as DEL, which pi never takes for ctrl+h, so it is free - in pi, and in a dialog.
22
- */
1
+ import type { Job } from "./jobs.ts";
2
+ /** Opens the side panel; ctrl+j would conflict with the editor's newline. */
23
3
  export declare const PANEL_KEY = "ctrl+h";
24
- /**
25
- * Each key in the line under the panel - ctrl+o, ctrl+h - breathes until it is first pressed: fully there, a little
26
- * faint, and back, so it reads as something to press, not as text. Once every BREATH_MS, redrawn every BREATH_TICK_MS
27
- * while the panel shows and a key still breathes, at most BREATH_FADE of the way from the text's colour to the dim one.
28
- * Pressed once, it stays still for the rest of the process; the other breathes on.
29
- */
30
- export declare const BREATH_MS = 2400;
31
- /** The keys of the line, by what they do: pressed once, each stops breathing. */
32
- export type PanelKey = "trace" | "peek";
33
- /** A key of the line was pressed - ctrl+o, or the side panel opened: it stops breathing. */
34
- export declare function keyPressed(key: PanelKey): void;
35
- export declare function breathes(key: PanelKey): boolean;
36
- /** For tests: every key breathing again. */
37
- export declare function resetKeysForTests(): void;
38
- /** How faint a breathing key is at `now`: 0, fully there, at the start of each breath, BREATH_FADE halfway through. */
39
- export declare function breath(now: number): number;
40
4
  export declare function spinner(now: number): string;
41
- /**
42
- * What finished, a line a module - the module that finished last on top, its name, then its pulses newest first -
43
- * fitted to `width`: the newest that fit, the rest counted as earlier. The side panel lists every one.
44
- */
45
- export declare function finishedLines(finished: Job[], width: number | undefined, marks?: MarkPaint): string[];
46
- /** A pulse that ran to its end and whose build did not pass - stopped at a gate - is not a success. */
5
+ /** A pulse that ran to its end and whose build did not pass is not a success. */
47
6
  export declare function didNotPass(job: Job): boolean;
48
- /** How a finished pulse's mark is coloured: green it passed, red it failed or did not pass, amber it was stopped. */
49
- export interface MarkPaint {
7
+ interface MarkPaint {
50
8
  success(text: string): string;
51
9
  error(text: string): string;
52
10
  warning(text: string): string;
53
11
  }
54
- /** A finished pulse's mark, in the colour of how it ended. */
55
12
  export declare function finishedMark(job: Job, paint?: MarkPaint): string;
56
- /** What a pulse cost, as its line says it: " · $0.12", or nothing when the price is not known. */
57
13
  export declare function pulseCost(job: Job): string;
58
- /**
59
- * One line saying what a spec change does: the files, the lines added and removed, and the
60
- * first line it adds - usually the concept or the functional spec it is about.
61
- */
62
- /** How a diff is coloured: added lines green, removed lines red. Plain when there is no theme. */
63
14
  export interface DiffStyle {
64
15
  added(text: string): string;
65
16
  removed(text: string): string;
66
17
  }
18
+ /** One line saying what a spec change does: the files, the lines added and removed, and the first line it adds. */
67
19
  export declare function summarizeDiff(diff: string, style?: DiffStyle): string;
68
- /** The lines of a diff worth reading in a panel: the hunks, not the headers. */
69
- /**
70
- * A line of the panel wrapped to its width, its continuations under its text: indented as far as it is,
71
- * and past the rule of a diff box when it is in one.
72
- */
73
- export declare function wrapKeepingIndent(line: string, width: number): string[];
74
- /** A diff's colours for the +/- alone, when there is nothing to highlight with. */
75
- export interface PanelOptions {
76
- /** Everything, rather than the compact view. */
77
- expanded?: boolean;
78
- now?: number;
79
- width?: number;
80
- /** The lines of help about ctrl+o and the side panel - left out where they do not apply, as in the side panel itself. */
81
- hints?: boolean;
82
- /** How the finished pulses' marks are coloured. */
83
- marks?: MarkPaint;
84
- /** How each key of the line is painted - breathing until it is pressed, in the TUI. */
85
- keys?: (key: PanelKey, text: string) => string;
86
- }
87
- export declare function jobPanelLines(jobs: Job[], options?: PanelOptions): string[];
88
- interface Redrawable {
89
- requestRender(): void;
90
- }
91
- /** What of pi's theme the panel paints with: the diff's colours and bands, and ***plain's colours in it. */
92
- interface PanelTheme {
93
- fg(color: "toolDiffAdded" | "toolDiffRemoved" | "success" | "error" | "warning", text: string): string;
94
- /** Whether it is made for a dark or a light surface, and how many colours the terminal has: the diff's palette. */
95
- appearance?: "dark" | "light";
96
- getColorMode?(): string;
97
- /** Each token's concrete colour - what the line of keys breathes between. */
98
- colors?: Readonly<Record<string, Color>>;
99
- }
100
- /**
101
- * The keys of the line, painted at `now`'s breath: one not pressed yet in the text's colour mixed toward the dim one, one
102
- * pressed as it is. Plain where the theme has no colours to mix.
103
- */
104
- export declare function breathing(theme: PanelTheme, now: number): (key: PanelKey, text: string) => string;
105
- /** The parts of pi's TUI the panel needs: enough to draw, redraw, and ask about ctrl+o. */
106
- export interface PanelUI {
107
- setWidget(key: string, content: ((tui: Redrawable, theme: PanelTheme) => {
108
- render(width: number): string[];
109
- invalidate(): void;
110
- }) | undefined, options?: {
111
- placement?: "aboveEditor" | "belowEditor";
112
- }): void;
113
- getToolsExpanded(): boolean;
114
- }
115
- export interface JobPanel {
116
- /** Where to draw. Until this is set there is no UI, and the panel does nothing. */
117
- attach(ui: PanelUI): void;
118
- /** Redraw soon, e.g. because a job changed. */
119
- refresh(): void;
120
- }
121
- export declare function createJobPanel(list: () => Job[]): JobPanel;
122
20
  export {};
@@ -1,98 +1,14 @@
1
- import { foregroundAnsi, mixColors, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
- import { formatDuration, formatElapsed, pulseName } from "./jobs.js";
3
- /**
4
- * The live panel above the editor while background work runs.
5
- *
6
- * One block per running job: what it is and how long it has been going, the stage it is
7
- * at, what is happening this second, and the last things its agents did. What waits is not
8
- * in it - the side panel lists the queue. It disappears when nothing is running - the finished
9
- * job announces itself in the transcript instead.
10
- *
11
- * It is drawn as a component rather than handed over as lines, because pi cuts a list of
12
- * lines off at ten. Instead it sizes itself: compact by default, and the agents' trace in full
13
- * while tool output is expanded - pi's own ctrl+o, which the person already uses to see more of
14
- * what the agent did. What finished stays counted either way: the side panel lists it.
15
- */
16
- export const JOB_PANEL_KEY = "turri-jobs";
17
- /**
18
- * The key that opens the side panel on its jobs, and goes back to it. Not ctrl+j: a terminal without the Kitty keyboard
19
- * protocol sends ctrl+j as a line feed - what it sends for shift+enter too, and what a dialog reads as enter - so it
20
- * would answer a question, and take a new line from the editor. ctrl+h is the byte old terminals sent for backspace;
21
- * every terminal now sends backspace as DEL, which pi never takes for ctrl+h, so it is free - in pi, and in a dialog.
22
- */
1
+ /** Opens the side panel; ctrl+j would conflict with the editor's newline. */
23
2
  export const PANEL_KEY = "ctrl+h";
24
- const TICK_MS = 1000;
25
- /**
26
- * Each key in the line under the panel - ctrl+o, ctrl+h - breathes until it is first pressed: fully there, a little
27
- * faint, and back, so it reads as something to press, not as text. Once every BREATH_MS, redrawn every BREATH_TICK_MS
28
- * while the panel shows and a key still breathes, at most BREATH_FADE of the way from the text's colour to the dim one.
29
- * Pressed once, it stays still for the rest of the process; the other breathes on.
30
- */
31
- export const BREATH_MS = 2400;
32
- const BREATH_TICK_MS = 100;
33
- const BREATH_FADE = 0.6;
34
- const pressed = new Set();
35
- /** A key of the line was pressed - ctrl+o, or the side panel opened: it stops breathing. */
36
- export function keyPressed(key) {
37
- pressed.add(key);
38
- }
39
- export function breathes(key) {
40
- return !pressed.has(key);
41
- }
42
- /** For tests: every key breathing again. */
43
- export function resetKeysForTests() {
44
- pressed.clear();
45
- }
46
- /** How faint a breathing key is at `now`: 0, fully there, at the start of each breath, BREATH_FADE halfway through. */
47
- export function breath(now) {
48
- const phase = (now % BREATH_MS) / BREATH_MS;
49
- return BREATH_FADE * (0.5 - 0.5 * Math.cos(2 * Math.PI * phase));
50
- }
51
- /** Tool-call progress arrives many times a second; the screen does not need to. */
52
- const REDRAW_MS = 100;
53
- /** Activity lines per running job while compact. */
54
- const COMPACT_ACTIVITY = 2;
55
- /**
56
- * A spinner rather than a disclosure arrow: a `▸` promises something opens when you pick
57
- * it. The frame follows the clock, so it moves on every redraw, including the tick.
58
- */
59
3
  const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
60
4
  export function spinner(now) {
61
5
  return SPINNER[Math.floor(now / 1000) % SPINNER.length];
62
6
  }
63
- /** A finished pulse in its module's line: its mark, number and kind - `✓ 3 regenerate`. What it regenerated is in the side panel. */
64
- function finishedItem(job, marks) {
65
- if (job.module === undefined || job.pulse === undefined)
66
- return `${finishedMark(job, marks)} ${pulseName(job)}`;
67
- return `${finishedMark(job, marks)} ${job.pulse} ${job.kind}`;
68
- }
69
- /**
70
- * What finished, a line a module - the module that finished last on top, its name, then its pulses newest first -
71
- * fitted to `width`: the newest that fit, the rest counted as earlier. The side panel lists every one.
72
- */
73
- export function finishedLines(finished, width, marks = PLAIN_MARKS) {
74
- const byModule = new Map();
75
- for (const job of [...finished].sort((a, b) => (b.finishedAt ?? 0) - (a.finishedAt ?? 0) || b.sequence - a.sequence)) {
76
- const key = job.module ?? job.kind;
77
- byModule.set(key, [...(byModule.get(key) ?? []), job]);
78
- }
79
- const pad = Math.max(...[...byModule.keys()].map((name) => visibleWidth(name)));
80
- return [...byModule].map(([name, jobs]) => {
81
- const head = ` ${name}${" ".repeat(pad - visibleWidth(name))} `;
82
- const items = jobs.map((job) => finishedItem(job, marks));
83
- const lineOf = (shown) => `${head}${items.slice(0, shown).join(" · ")}${shown < items.length ? ` · … ${items.length - shown} earlier` : ""}`;
84
- let shown = items.length;
85
- while (width !== undefined && shown > 1 && visibleWidth(lineOf(shown)) > width)
86
- shown -= 1;
87
- return lineOf(shown);
88
- });
89
- }
90
- /** A pulse that ran to its end and whose build did not pass - stopped at a gate - is not a success. */
7
+ /** A pulse that ran to its end and whose build did not pass is not a success. */
91
8
  export function didNotPass(job) {
92
9
  return job.status === "succeeded" && job.details?.passed === false;
93
10
  }
94
11
  const PLAIN_MARKS = { success: (text) => text, error: (text) => text, warning: (text) => text };
95
- /** A finished pulse's mark, in the colour of how it ended. */
96
12
  export function finishedMark(job, paint = PLAIN_MARKS) {
97
13
  if (didNotPass(job) || job.status === "failed")
98
14
  return paint.error("✗");
@@ -100,18 +16,11 @@ export function finishedMark(job, paint = PLAIN_MARKS) {
100
16
  return paint.warning("■");
101
17
  return paint.success("✓");
102
18
  }
103
- /** What a pulse cost, as its line says it: " · $0.12", or nothing when the price is not known. */
104
19
  export function pulseCost(job) {
105
20
  return job.usage.cost > 0 ? ` · $${job.usage.cost.toFixed(2)}` : "";
106
21
  }
107
- /**
108
- * Jobs whose tool draws its own progress widget, which already shows the functional spec being
109
- * built: the panel leaves it out, so it is not written twice.
110
- */
111
- const SPEC_SHOWN_BY_WIDGET = new Set(["regenerate"]);
112
- /** Spec lines shown per running job while expanded. */
113
- const EXPANDED_SPEC_LINES = 30;
114
22
  const PLAIN_DIFF = { added: (text) => text, removed: (text) => text };
23
+ /** One line saying what a spec change does: the files, the lines added and removed, and the first line it adds. */
115
24
  export function summarizeDiff(diff, style = PLAIN_DIFF) {
116
25
  const files = new Set();
117
26
  let added = 0;
@@ -136,204 +45,10 @@ export function summarizeDiff(diff, style = PLAIN_DIFF) {
136
45
  else if (line.startsWith("-")) {
137
46
  removed += 1;
138
47
  const text = line.slice(1).replace(/^- /, "").trim();
139
- if (firstRemoved === undefined && text !== "" && !/^\*\*\*.*\*\*\*$/.test(text))
48
+ if (firstRemoved === undefined && text !== "")
140
49
  firstRemoved = text;
141
50
  }
142
51
  }
143
- // What it adds, when it adds anything; what it takes out, when that is all it does.
144
52
  const what = first !== undefined ? ` · ${first}` : firstRemoved !== undefined ? ` · removes: ${firstRemoved}` : "";
145
53
  return `${[...files].join(", ")} ${style.added(`+${added}`)} ${style.removed(`−${removed}`)}${what}`;
146
54
  }
147
- /** The lines of a diff worth reading in a panel: the hunks, not the headers. */
148
- /**
149
- * A line of the panel wrapped to its width, its continuations under its text: indented as far as it is,
150
- * and past the rule of a diff box when it is in one.
151
- */
152
- export function wrapKeepingIndent(line, width) {
153
- if (visibleWidth(line) <= width)
154
- return [line];
155
- const plain = line.replace(/\x1b\[[0-9;]*m/g, "");
156
- const indent = /^(\s*(?:│ )?)/.exec(plain)?.[1] ?? "";
157
- // Inside a diff box its rule goes on down the continuations; elsewhere, blanks.
158
- const lead = indent;
159
- const inner = Math.max(10, width - indent.length);
160
- const [first = "", ...rest] = wrapTextWithAnsi(line, width);
161
- return [first, ...rest.flatMap((part) => wrapTextWithAnsi(part, inner)).map((part) => `${lead}${part}`)];
162
- }
163
- export function jobPanelLines(jobs, options = {}) {
164
- const now = options.now ?? Date.now();
165
- const expanded = options.expanded === true;
166
- // Newest first, as every list of pulses is.
167
- const inOrder = [...jobs].sort((a, b) => b.sequence - a.sequence);
168
- const running = inOrder.filter((job) => job.status === "running").sort((a, b) => b.startedAt - a.startedAt || b.sequence - a.sequence);
169
- // A module whose work is being planned: the planner is an agent, and takes a while - shown at once, as work going on.
170
- const planning = inOrder.filter((job) => job.status === "queued" && job.planning !== undefined);
171
- // Nothing running or being planned: no panel - what waits and what finished are in the side panel.
172
- if (running.length === 0 && planning.length === 0)
173
- return [];
174
- const finished = inOrder.filter((job) => (job.status === "succeeded" || job.status === "failed" || job.status === "stopped") && job.replacedBy === undefined);
175
- const lines = [];
176
- // What finished, on top - a line a module, newest first - and a rule under it: what runs now is below, by the input.
177
- if (finished.length > 0) {
178
- lines.push(...finishedLines(finished, options.width, options.marks ?? PLAIN_MARKS));
179
- lines.push(` ${"─".repeat(Math.max(10, (options.width ?? 80) - 4))}`);
180
- }
181
- for (const [index, job] of running.entries()) {
182
- if (index > 0)
183
- lines.push("");
184
- // Its module, how long and what it has cost: what it is doing follows.
185
- lines.push(`${spinner(now)} ${pulseName(job)} · ${formatDuration(job)}${pulseCost(job)}`);
186
- // What it is on now, and for how long - beside the job's own time, which is the whole of it.
187
- const onIt = job.building?.since !== undefined ? ` · ${formatElapsed(now - job.building.since)}` : "";
188
- if (job.building !== undefined && SPEC_SHOWN_BY_WIDGET.has(job.kind)) {
189
- // The module widget shows its text; the panel, how long it has taken so far.
190
- lines.push(` ${job.building.label}${onIt}`);
191
- }
192
- else if (job.building !== undefined) {
193
- const text = job.building.text.split("\n").filter((line) => line.trim() !== "");
194
- if (!expanded) {
195
- const more = text.length > 1 ? ` (+${text.length - 1} line${text.length === 2 ? "" : "s"} · ctrl+o)` : "";
196
- lines.push(` ${job.building.label}${onIt}: ${(text[0] ?? "").trim()}${more}`);
197
- }
198
- else {
199
- lines.push(` ${job.building.label}${onIt}:`);
200
- for (const line of text.slice(0, EXPANDED_SPEC_LINES))
201
- lines.push(` │ ${line}`);
202
- if (text.length > EXPANDED_SPEC_LINES)
203
- lines.push(` │ … ${text.length - EXPANDED_SPEC_LINES} more lines - ${PANEL_KEY} shows it all`);
204
- }
205
- }
206
- const activity = expanded ? job.activity : job.activity.slice(-COMPACT_ACTIVITY);
207
- for (const line of activity)
208
- lines.push(` ${line}`);
209
- if (job.now !== undefined) {
210
- const seconds = Math.max(0, Math.round((now - job.now.since) / 1000));
211
- lines.push(` … ${job.now.label} · ${seconds}s`);
212
- }
213
- }
214
- for (const job of planning) {
215
- if (lines.length > 0 && running.length > 0)
216
- lines.push("");
217
- lines.push(`${spinner(now)} ${job.module ?? job.summary} · planning the pulses · ${formatElapsed(now - job.planning.since)}`);
218
- lines.push(" working out what to regenerate and cutting it into pulses - the first starts once it is done");
219
- }
220
- // Always a line of help: how to see more here, and how to inspect the jobs in the side panel.
221
- if (options.hints === false) {
222
- // The side panel shows it all already, and says its own keys.
223
- }
224
- else {
225
- // Set apart from the trace above it.
226
- lines.push("");
227
- const key = options.keys ?? ((_key, text) => text);
228
- lines.push(` ${key("trace", `ctrl+o to ${expanded ? "collapse" : "expand"} the trace`)} · ${key("peek", `${PANEL_KEY} to peek at regen`)}`);
229
- }
230
- // A line is one row of the screen: a newline in one - an agent's words, a command - would draw past what the renderer
231
- // tracks and stay on the screen, so each part is a row of its own.
232
- return lines.flatMap((line) => line.split(/\r?\n/));
233
- }
234
- /**
235
- * The keys of the line, painted at `now`'s breath: one not pressed yet in the text's colour mixed toward the dim one, one
236
- * pressed as it is. Plain where the theme has no colours to mix.
237
- */
238
- export function breathing(theme, now) {
239
- const text = theme.colors?.text;
240
- const dim = theme.colors?.dim ?? theme.colors?.muted;
241
- const mode = theme.getColorMode?.();
242
- if (text === undefined || dim === undefined || (mode !== "truecolor" && mode !== "256color"))
243
- return (_key, line) => line;
244
- const ansi = foregroundAnsi(mixColors(text, dim, breath(now)), mode);
245
- return (key, line) => (breathes(key) ? `${ansi}${line}\x1b[39m` : line);
246
- }
247
- export function createJobPanel(list) {
248
- let ui;
249
- let tui;
250
- let mounted = false;
251
- let timer;
252
- /** The keys breathing: a redraw a tick of it, while the panel shows and a key still breathes. */
253
- let breathTimer;
254
- /** Whether the trace was open when the panel was first drawn. */
255
- let firstExpanded;
256
- let pending;
257
- const active = () => list().some((job) => job.status === "running" || job.status === "queued");
258
- const draw = () => {
259
- if (ui === undefined)
260
- return;
261
- const target = ui;
262
- try {
263
- if (active() && !mounted) {
264
- mounted = true;
265
- target.setWidget(JOB_PANEL_KEY, (next, theme) => {
266
- tui = next;
267
- return {
268
- // Laid out on every render, so ctrl+o takes effect on the very next frame.
269
- render: (width) => {
270
- const expanded = target.getToolsExpanded();
271
- // ctrl+o turns the trace open or closed: once it is not as it first was, ctrl+o was pressed.
272
- if (firstExpanded === undefined)
273
- firstExpanded = expanded;
274
- else if (expanded !== firstExpanded)
275
- keyPressed("trace");
276
- const marks = { success: (text) => theme.fg("success", text), error: (text) => theme.fg("error", text), warning: (text) => theme.fg("warning", text) };
277
- const lines = jobPanelLines(list(), { expanded, width, marks, keys: breathing(theme, Date.now()) });
278
- // Opened, nothing is cut off: every line wraps. Closed, a line each - the panel stays short.
279
- return expanded ? lines.flatMap((line) => wrapKeepingIndent(line, width)) : lines.map((line) => truncateToWidth(line, width));
280
- },
281
- invalidate() { },
282
- };
283
- }, { placement: "aboveEditor" });
284
- }
285
- else if (!active() && mounted) {
286
- mounted = false;
287
- tui = undefined;
288
- target.setWidget(JOB_PANEL_KEY, undefined);
289
- }
290
- else {
291
- tui?.requestRender();
292
- }
293
- }
294
- catch {
295
- // The panel is a convenience; losing it must not fail the work it shows.
296
- }
297
- // The elapsed time moves even when the agents are quiet - a long model call is exactly
298
- // when someone looks to see whether anything is happening.
299
- if (mounted && timer === undefined) {
300
- timer = setInterval(draw, TICK_MS);
301
- timer.unref?.();
302
- breathTimer = setInterval(() => {
303
- // Both pressed: nothing breathes, and the panel is drawn as often as before.
304
- if (!breathes("trace") && !breathes("peek")) {
305
- clearInterval(breathTimer);
306
- breathTimer = undefined;
307
- return;
308
- }
309
- tui?.requestRender();
310
- }, BREATH_TICK_MS);
311
- breathTimer.unref?.();
312
- }
313
- else if (!mounted && timer !== undefined) {
314
- clearInterval(timer);
315
- timer = undefined;
316
- if (breathTimer !== undefined)
317
- clearInterval(breathTimer);
318
- breathTimer = undefined;
319
- }
320
- };
321
- return {
322
- attach(next) {
323
- // A new session starts with pi's widgets cleared, so whatever was mounted is gone.
324
- ui = next;
325
- mounted = false;
326
- tui = undefined;
327
- draw();
328
- },
329
- refresh() {
330
- if (pending !== undefined)
331
- return;
332
- pending = setTimeout(() => {
333
- pending = undefined;
334
- draw();
335
- }, REDRAW_MS);
336
- pending.unref?.();
337
- },
338
- };
339
- }
@@ -1151,7 +1151,8 @@ export function createWorkLoop(options) {
1151
1151
  const own = (jobs) => (jobs ?? []).filter((job) => job !== running);
1152
1152
  // A track being planned again shows as that, not as its plan before - and a module asked for, from that moment, as
1153
1153
  // its code being planned: its code deleted, what is left worked out, before the planner runs.
1154
- const planningTrack = state.running === undefined ? (state.planning ?? (preparing.has(tipEntry(state).moduleName) ? "code" : undefined)) : undefined;
1154
+ // One waiting for a module below it is shown waiting, asked for or not: nothing plans it until that one is built.
1155
+ const planningTrack = state.running === undefined ? (state.planning ?? (preparing.has(tipEntry(state).moduleName) && state.waitsFor === undefined ? "code" : undefined)) : undefined;
1155
1156
  const replanning = planningTrack;
1156
1157
  const jobs = [
1157
1158
  ...(running !== undefined ? [running] : []),
@@ -1267,6 +1268,13 @@ export function createWorkLoop(options) {
1267
1268
  state.lookedAhead = undefined;
1268
1269
  // Asked for again: its conformance tests are written for every functional spec with scenarios, not only those conform named.
1269
1270
  state.conformanceOnly = undefined;
1271
+ // A module below it not built at all: it waits for that one, said at once - the looks go bottom first, each the
1272
+ // planner's time, and until its own it would show as being planned. Its look says it again, or moves it on.
1273
+ const below = state.running === undefined ? state.chain.slice(0, -1).find((entry) => modules.has(entry.buildDir) && !started(entry)) : undefined;
1274
+ if (below !== undefined && state.waitsFor === undefined) {
1275
+ state.waitsFor = below.moduleName;
1276
+ state.why = `waiting for ${below.moduleName}: the code it is built on is not built yet`;
1277
+ }
1270
1278
  }
1271
1279
  await tick();
1272
1280
  return [...new Set(states)].map(statusOf);
@@ -5,6 +5,7 @@ import type { MarkedPage } from "./spec-map.ts";
5
5
  import { type SpecMapState } from "./spec-map-view.ts";
6
6
  import type { TranscriptStyle } from "./transcript-view.ts";
7
7
  import type { ButtonPaint, PointerHover } from "../pointer-hover.ts";
8
+ import type { notificationView } from "../terminal-notifications.ts";
8
9
  /**
9
10
  * The side panel: the spec and how far the code has been regenerated, beside the conversation rather than instead of
10
11
  * it.
@@ -22,6 +23,7 @@ export interface SidePanelOptions {
22
23
  earlier?: () => Job[];
23
24
  /** The regeneration's pages. Not given: the pulse list alone. */
24
25
  map?: () => MarkedPage[];
26
+ notifications?: ReturnType<typeof notificationView>;
25
27
  pointer?: PointerHover;
26
28
  tabLabel?: ButtonPaint;
27
29
  /** Rows the panel may use. */
@@ -37,14 +37,19 @@ export function createSidePanel(options) {
37
37
  const controls = (width) => {
38
38
  if (width <= 0 || (!options.map && !options.dock))
39
39
  return [];
40
- const close = width >= 30 ? " × close " : width >= 3 ? " × " : "×";
40
+ const compact = options.notifications && width < 54;
41
+ const close = width >= 30 && !compact ? " × close " : width >= 3 ? " × " : "×";
41
42
  const right = width - visibleWidth(close);
42
43
  const buttons = [];
43
44
  let x = 0;
44
45
  if (options.map) {
45
- for (const [action, label] of [["map", "***plain"], ["pulses", "pulses"]]) {
46
- const marker = width >= 30 ? (map.view === action ? "▸ " : " ") : "";
47
- const text = truncateToWidth(` ${marker}${label} `, Math.max(0, right - x - 1), "");
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), "");
48
53
  if (!text)
49
54
  break;
50
55
  buttons.push({ action, text, x });
@@ -282,10 +287,14 @@ export function createSidePanel(options) {
282
287
  bar += " ".repeat(x - end) + tabLabel(text, map.view === action, options.pointer?.target === `panel:${action}`, action === "close" ? "close" : "tab");
283
288
  end = x + visibleWidth(text);
284
289
  }
285
- const header = bar ? [bar] : [];
290
+ const header = bar ? [bar, ""] : [];
286
291
  headerHeight = header.length;
287
292
  const rows = Math.max(8, options.rows()) - header.length;
288
293
  try {
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
+ }
289
298
  return [...header, ...(map.view === "map" && options.map !== undefined ? renderMap(width, rows) : renderPulses(width, rows))];
290
299
  }
291
300
  catch (error) {
@@ -303,6 +312,17 @@ export function createSidePanel(options) {
303
312
  }
304
313
  },
305
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
+ }
306
326
  if (matchesKey(data, Key.escape)) {
307
327
  options.back();
308
328
  return;
@@ -366,6 +386,8 @@ export function createSidePanel(options) {
366
386
  else if (action === down && action !== map.view) {
367
387
  if (action === "close")
368
388
  options.close();
389
+ else if (action === "notifications")
390
+ map.view = "notifications";
369
391
  else if (action === "map")
370
392
  toMap();
371
393
  else
@@ -375,6 +397,11 @@ export function createSidePanel(options) {
375
397
  }
376
398
  }
377
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
+ }
378
405
  if (event.button === "left" && (event.type === "press" || event.type === "click")) {
379
406
  const target = hits.get(event.y)?.find(({ x, end }) => event.x >= x && event.x < end);
380
407
  if (target) {
@@ -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 view the side panel shows: the map, or the pulse list. */
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;
@@ -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);
@@ -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;