@adeildo/pi-look 5.15.0 → 6.0.1
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 +54 -44
- package/assets/preview.png +0 -0
- package/package.json +3 -2
- package/src/data/git.ts +1 -1
- package/src/data/github.ts +6 -17
- package/src/data/runner.ts +3 -4
- package/src/data/snapshot.ts +24 -13
- package/src/data/start-notes.ts +2 -6
- package/src/data/telemetry.ts +13 -16
- package/src/data/totals.ts +14 -73
- package/src/data/visits.ts +2 -3
- package/src/index.ts +66 -18
- package/src/render/diff.ts +104 -0
- package/src/render/fit.ts +1 -1
- package/src/render/format.ts +1 -2
- package/src/render/glyphs.ts +23 -10
- package/src/render/paint.ts +4 -4
- package/src/render/segments.ts +112 -33
- package/src/render/streaming.ts +17 -40
- package/src/render/tools.ts +4 -6
- package/src/settings.ts +5 -7
- package/src/ui/editor.ts +11 -8
- package/src/ui/footer.ts +4 -11
- package/src/ui/header.ts +25 -18
- package/src/ui/outputs.ts +5 -11
- package/src/ui/pi-entries.ts +29 -27
- package/src/ui/previews.ts +2 -6
- package/src/ui/queue.ts +8 -8
- package/src/ui/screen.ts +1 -8
- package/src/ui/tool-frame.ts +84 -91
- package/src/view/state.ts +97 -0
- package/src/view/transcript.ts +175 -0
- package/src/view/view.ts +161 -0
package/src/ui/header.ts
CHANGED
|
@@ -12,7 +12,8 @@ import { renderSegments, type SegmentId } from "../render/segments.ts";
|
|
|
12
12
|
import type { HeaderStyle } from "../settings.ts";
|
|
13
13
|
import type { Screen } from "./screen.ts";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
/** The π the start card draws, and the docs draw the project's icon from. */
|
|
16
|
+
export const PIXELS = [
|
|
16
17
|
"..............",
|
|
17
18
|
".############.",
|
|
18
19
|
"##############",
|
|
@@ -25,7 +26,7 @@ const PIXELS = [
|
|
|
25
26
|
".##.......####",
|
|
26
27
|
];
|
|
27
28
|
const LOGO = halfBlocks(PIXELS);
|
|
28
|
-
const LOGO_RAMP = EFFORT_LEVELS.slice(1);
|
|
29
|
+
export const LOGO_RAMP = EFFORT_LEVELS.slice(1);
|
|
29
30
|
const LOGO_COLUMN = 20;
|
|
30
31
|
const MIN_RIGHT = 34;
|
|
31
32
|
const MIN_CARD = 48;
|
|
@@ -40,9 +41,9 @@ export interface LoadedCounts {
|
|
|
40
41
|
export interface HeaderSource {
|
|
41
42
|
style(): HeaderStyle;
|
|
42
43
|
counts(): LoadedCounts;
|
|
43
|
-
/**
|
|
44
|
+
/** Undefined for the first session here. */
|
|
44
45
|
lastVisit(): LastVisit | undefined;
|
|
45
|
-
/**
|
|
46
|
+
/** Undefined while it is still being asked. */
|
|
46
47
|
github?(): GithubState | undefined;
|
|
47
48
|
}
|
|
48
49
|
|
|
@@ -51,22 +52,17 @@ interface Hint {
|
|
|
51
52
|
does: string;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
/**
|
|
55
|
+
/** Once per launch, one row of the art every step. */
|
|
55
56
|
const RISE_STEP_MS = 70;
|
|
56
57
|
const NOTES = 6;
|
|
57
|
-
/** How long a drawing of the card stands before it is drawn again. */
|
|
58
58
|
const REDRAW_MS = 1000;
|
|
59
|
-
/**
|
|
59
|
+
/** Read once from the package that ships it. */
|
|
60
60
|
export const HARNESS_VERSION = harnessVersion();
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* The start screen: the π, the folder and the model, and under them only what changed or waits on
|
|
64
|
-
* you since the last session here. See DESIGN.md.
|
|
65
|
-
*/
|
|
66
62
|
export class HeaderComponent implements Component {
|
|
67
63
|
readonly #screen: Screen;
|
|
68
64
|
readonly #source: HeaderSource;
|
|
69
|
-
/**
|
|
65
|
+
/** Without a terminal to redraw it, it stands from the start. */
|
|
70
66
|
readonly #born: number;
|
|
71
67
|
|
|
72
68
|
constructor(screen: Screen, source: HeaderSource, tui?: { requestRender(): void }) {
|
|
@@ -78,7 +74,7 @@ export class HeaderComponent implements Component {
|
|
|
78
74
|
setTimeout(() => tui.requestRender(), row * RISE_STEP_MS).unref?.();
|
|
79
75
|
}
|
|
80
76
|
|
|
81
|
-
/**
|
|
77
|
+
/** Kept for a moment: the card changes rarely and pi redraws on every keystroke. */
|
|
82
78
|
#drawn:
|
|
83
79
|
| { width: number; at: number; github: GithubState | undefined; lines: string[] }
|
|
84
80
|
| undefined;
|
|
@@ -88,7 +84,7 @@ export class HeaderComponent implements Component {
|
|
|
88
84
|
const github = this.#source.github?.();
|
|
89
85
|
const risen = now - this.#born > LOGO.length * RISE_STEP_MS;
|
|
90
86
|
const drawn = this.#drawn;
|
|
91
|
-
// GitHub answers after the card is up, and that
|
|
87
|
+
// GitHub answers after the card is up, and that must not wait for the next keystroke.
|
|
92
88
|
if (risen && drawn?.width === width && drawn.github === github && now - drawn.at < REDRAW_MS)
|
|
93
89
|
return drawn.lines;
|
|
94
90
|
const notes = startNotes(
|
|
@@ -120,8 +116,10 @@ export class HeaderComponent implements Component {
|
|
|
120
116
|
const snapshot = screen.snapshot();
|
|
121
117
|
const last = this.#source.lastVisit();
|
|
122
118
|
|
|
119
|
+
const name = this.#name(paint);
|
|
123
120
|
const right = [
|
|
124
121
|
"",
|
|
122
|
+
...(name === "" ? [] : [name]),
|
|
125
123
|
this.#segments(["path", "branch"], paint),
|
|
126
124
|
this.#segments(["model", "effort"], paint),
|
|
127
125
|
"",
|
|
@@ -167,7 +165,6 @@ export class HeaderComponent implements Component {
|
|
|
167
165
|
);
|
|
168
166
|
}
|
|
169
167
|
|
|
170
|
-
/** The art, its rows lit from the feet up while it rises. */
|
|
171
168
|
#logo(paint: Paint): string[] {
|
|
172
169
|
const risen = Math.floor((Date.now() - this.#born) / RISE_STEP_MS) + 1;
|
|
173
170
|
return LOGO.map((row, index) =>
|
|
@@ -225,7 +222,11 @@ export class HeaderComponent implements Component {
|
|
|
225
222
|
#compact(width: number, notes: readonly StartNote[]): string[] {
|
|
226
223
|
const paint = this.#screen.paint();
|
|
227
224
|
const separator = paint.dim(this.#screen.separator());
|
|
228
|
-
const first = [
|
|
225
|
+
const first = [
|
|
226
|
+
this.#title(paint),
|
|
227
|
+
this.#name(paint),
|
|
228
|
+
this.#segments(["model", "effort", "path", "branch"], paint),
|
|
229
|
+
]
|
|
229
230
|
.filter((part) => part !== "")
|
|
230
231
|
.join(separator);
|
|
231
232
|
const last = this.#source.lastVisit();
|
|
@@ -242,6 +243,14 @@ export class HeaderComponent implements Component {
|
|
|
242
243
|
return `${glyph}${paint.bold("-harness")} ${paint.dim(HARNESS_VERSION)}`;
|
|
243
244
|
}
|
|
244
245
|
|
|
246
|
+
/** The name the rooms and the remote page use for this session, with pi's /name beside it. */
|
|
247
|
+
#name(paint: Paint): string {
|
|
248
|
+
const word = this.#segments(["me"], paint);
|
|
249
|
+
const { sessionName } = this.#screen.snapshot();
|
|
250
|
+
if (word === "" || sessionName === undefined || sessionName === "") return word;
|
|
251
|
+
return `${word} ${paint.dim(sessionName)}`;
|
|
252
|
+
}
|
|
253
|
+
|
|
245
254
|
#segments(ids: readonly SegmentId[], paint: Paint): string {
|
|
246
255
|
const pieces = renderSegments(ids, {
|
|
247
256
|
snapshot: this.#screen.snapshot(),
|
|
@@ -291,7 +300,6 @@ export function halfBlocks(pixels: readonly string[]): string[] {
|
|
|
291
300
|
|
|
292
301
|
function pad(text: string, width: number): string {
|
|
293
302
|
const cells = visibleWidth(text);
|
|
294
|
-
// Measuring is cheap, and cutting a line that already fits is not.
|
|
295
303
|
if (cells <= width) return text + " ".repeat(width - cells);
|
|
296
304
|
const clipped = truncateToWidth(text, width, CUT);
|
|
297
305
|
return clipped + " ".repeat(Math.max(0, width - visibleWidth(clipped)));
|
|
@@ -300,7 +308,6 @@ function pad(text: string, width: number): string {
|
|
|
300
308
|
function center(text: string, width: number): string {
|
|
301
309
|
const cells = visibleWidth(text);
|
|
302
310
|
const fits = cells <= width;
|
|
303
|
-
// Measuring is cheap, and cutting a line that already fits is not.
|
|
304
311
|
const clipped = fits ? text : truncateToWidth(text, width, "");
|
|
305
312
|
const room = Math.max(0, width - (fits ? cells : visibleWidth(clipped)));
|
|
306
313
|
const before = Math.floor(room / 2);
|
package/src/ui/outputs.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// Alt+O:
|
|
2
|
-
// output cut in the transcript, and Ctrl+O opens every call at once; here one call opens at a time,
|
|
3
|
-
// and the arrows move between calls.
|
|
1
|
+
// Alt+O: one tool call's whole output in a scrollable frame, newest first; the arrows move between calls.
|
|
4
2
|
import { callTarget, CUT, frame, frameInner, FRAME_Y, GLYPH, type KeyHint } from "@adeildo/pi-kit";
|
|
5
3
|
import type { SessionEntry, Theme } from "@earendil-works/pi-coding-agent";
|
|
6
4
|
import {
|
|
@@ -11,16 +9,14 @@ import {
|
|
|
11
9
|
wrapTextWithAnsi,
|
|
12
10
|
} from "@earendil-works/pi-tui";
|
|
13
11
|
|
|
14
|
-
/** One call and what it printed. */
|
|
15
12
|
export interface Output {
|
|
16
13
|
tool: string;
|
|
17
|
-
/**
|
|
14
|
+
/** The path, the command, the query. */
|
|
18
15
|
target: string;
|
|
19
16
|
lines: string[];
|
|
20
17
|
failed: boolean;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
/** Every tool call on the branch that printed something, oldest first. */
|
|
24
20
|
export function outputsOf(branch: readonly SessionEntry[]): Output[] {
|
|
25
21
|
const calls = new Map<string, { tool: string; target: string }>();
|
|
26
22
|
const outputs: Output[] = [];
|
|
@@ -56,16 +52,15 @@ export interface OutputViewOptions {
|
|
|
56
52
|
close: () => void;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
|
-
/** The frame: one output at a time, newest first, scrolled with the arrows and the page keys. */
|
|
60
55
|
export class OutputView implements Component {
|
|
61
56
|
readonly #options: OutputViewOptions;
|
|
62
|
-
/**
|
|
57
|
+
/** Counted from the newest. */
|
|
63
58
|
#index = 0;
|
|
64
59
|
#scroll = 0;
|
|
65
60
|
#width = 80;
|
|
66
|
-
/**
|
|
61
|
+
/** Wrapped again only when it or the width changes. */
|
|
67
62
|
#wrapped: { output: Output; inner: number; lines: string[] } | undefined;
|
|
68
|
-
/**
|
|
63
|
+
/** Drawn again only when a key moved something. */
|
|
69
64
|
#drawn:
|
|
70
65
|
| { output: Output; width: number; scroll: number; page: number; lines: string[] }
|
|
71
66
|
| undefined;
|
|
@@ -133,7 +128,6 @@ export class OutputView implements Component {
|
|
|
133
128
|
this.#drawn = undefined;
|
|
134
129
|
}
|
|
135
130
|
|
|
136
|
-
/** The mark, the tool and what it pointed at, cut so the count beside it still fits. */
|
|
137
131
|
#title(output: Output): string {
|
|
138
132
|
const { theme } = this.#options;
|
|
139
133
|
const mark = output.failed ? theme.fg("error", GLYPH.cross) : theme.fg("success", GLYPH.check);
|
package/src/ui/pi-entries.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
// Pi's own entries in the
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
// loses the background, and sits against the edges. Pi has no hook for drawing these, so this wraps
|
|
5
|
-
// the render of each component.
|
|
6
|
-
import { ENTRY_CUT, ENTRY_X, entryFrame, type EntryFrame, GLYPH } from "@adeildo/pi-kit";
|
|
1
|
+
// Pi's own transcript entries in the harness frame instead of a background. Pi has no hook for
|
|
2
|
+
// drawing them, so this wraps each component's render.
|
|
3
|
+
import { CHANGES_CUT, CHANGES_X, entryFrame, type EntryFrame, GLYPH } from "@adeildo/pi-kit";
|
|
7
4
|
import {
|
|
8
5
|
BashExecutionComponent,
|
|
9
6
|
BranchSummaryMessageComponent,
|
|
@@ -18,18 +15,19 @@ import { stripTerminalSequences } from "@earendil-works/pi-tui";
|
|
|
18
15
|
import type { IconSet } from "../render/glyphs.ts";
|
|
19
16
|
import { isBlank } from "./tool-frame.ts";
|
|
20
17
|
|
|
21
|
-
/**
|
|
22
|
-
export type EntryPaint = () =>
|
|
18
|
+
/** Undefined leaves pi's entries as they are. `from` names the client a prompt came from. */
|
|
19
|
+
export type EntryPaint = () =>
|
|
20
|
+
| { theme: Theme; set: IconSet; you: boolean; from?: (text: string) => string | undefined }
|
|
21
|
+
| undefined;
|
|
23
22
|
|
|
24
23
|
const YOU: Readonly<Record<IconSet, string>> = {
|
|
25
24
|
nerd: "\u{f007}", // nf-fa-user
|
|
26
25
|
unicode: GLYPH.triangle,
|
|
27
26
|
ascii: ">",
|
|
28
27
|
};
|
|
29
|
-
/** The shell integration markers pi puts on
|
|
28
|
+
/** The shell integration markers pi puts on your message's first and last line. */
|
|
30
29
|
// oxlint-disable-next-line no-control-regex -- the markers are escape sequences
|
|
31
30
|
const MARKERS = /^(?:\u001b\]133;[^\u0007]*\u0007)*/;
|
|
32
|
-
/** Background colour codes, which pi paints its entries with. */
|
|
33
31
|
// oxlint-disable-next-line no-control-regex -- colour codes are escape sequences
|
|
34
32
|
const BACKGROUND = /\u001b\[(?:48;[25];[\d;]+|49|4[0-7]|10[0-7])m/g;
|
|
35
33
|
/** Pi's bracketed label, as `[compaction]`, which the frame's top edge replaces. */
|
|
@@ -38,11 +36,9 @@ const LABEL = /(\u001b\[1m)?\[[\w:.-]+\](\u001b\[22m)? ?/;
|
|
|
38
36
|
|
|
39
37
|
type Paint = NonNullable<ReturnType<EntryPaint>>;
|
|
40
38
|
|
|
41
|
-
/** A frame, and what of pi's own drawing it replaces. */
|
|
42
39
|
interface Framing extends EntryFrame {
|
|
43
|
-
/**
|
|
40
|
+
/** As `[compaction]`. */
|
|
44
41
|
label?: boolean;
|
|
45
|
-
/** The rules pi draws above and below a `!` command. */
|
|
46
42
|
rules?: boolean;
|
|
47
43
|
}
|
|
48
44
|
type Render = (width: number) => string[];
|
|
@@ -50,12 +46,14 @@ type Render = (width: number) => string[];
|
|
|
50
46
|
let installed = false;
|
|
51
47
|
let paint: EntryPaint = () => undefined;
|
|
52
48
|
|
|
53
|
-
/**
|
|
49
|
+
/** Calling it again only changes where the paint comes from. */
|
|
54
50
|
export function framePiEntries(source: EntryPaint): void {
|
|
55
51
|
paint = source;
|
|
56
52
|
if (installed) return;
|
|
57
53
|
installed = true;
|
|
58
|
-
wrap(UserMessageComponent, (
|
|
54
|
+
wrap(UserMessageComponent, (self, look) =>
|
|
55
|
+
look.you ? youFrame(look, fromOf(self, look)) : undefined,
|
|
56
|
+
);
|
|
59
57
|
wrap(CompactionSummaryMessageComponent, (_self, look) => pi(look, "compacted"));
|
|
60
58
|
wrap(BranchSummaryMessageComponent, (_self, look) => pi(look, "branch summary"));
|
|
61
59
|
wrap(SkillInvocationMessageComponent, (_self, look) => ({
|
|
@@ -64,7 +62,6 @@ export function framePiEntries(source: EntryPaint): void {
|
|
|
64
62
|
label: true,
|
|
65
63
|
}));
|
|
66
64
|
wrap(CustomMessageComponent, (self, look) => {
|
|
67
|
-
// A renderer of an extension draws its own message.
|
|
68
65
|
const own = self as unknown as { customComponent?: unknown; message: { customType: string } };
|
|
69
66
|
if (own.customComponent !== undefined) return undefined;
|
|
70
67
|
const top = look.theme.fg("muted", own.message.customType);
|
|
@@ -73,8 +70,17 @@ export function framePiEntries(source: EntryPaint): void {
|
|
|
73
70
|
wrap(BashExecutionComponent, (self, look) => shellFrame(self, look));
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
/** Asked once per message: the client is known before pi draws the prompt, and never changes. */
|
|
74
|
+
const sentFrom = new WeakMap<object, string | undefined>();
|
|
75
|
+
|
|
76
|
+
function fromOf(self: object, look: Paint): string | undefined {
|
|
77
|
+
if (!sentFrom.has(self)) sentFrom.set(self, look.from?.((self as { text?: string }).text ?? ""));
|
|
78
|
+
return sentFrom.get(self);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function youFrame(look: Paint, from: string | undefined): Framing {
|
|
82
|
+
const you = `${look.theme.fg("accent", YOU[look.set])} ${look.theme.fg("muted", "you")}`;
|
|
83
|
+
const top = from === undefined ? you : `${you} ${look.theme.fg("dim", `from ${from}`)}`;
|
|
78
84
|
return { top, color: "accent" };
|
|
79
85
|
}
|
|
80
86
|
|
|
@@ -116,11 +122,10 @@ function wrap(
|
|
|
116
122
|
const own = prototype.render;
|
|
117
123
|
prototype.render = function render(this: object, width: number) {
|
|
118
124
|
const look = paint();
|
|
119
|
-
const frame = look === undefined || width <
|
|
125
|
+
const frame = look === undefined || width < CHANGES_X * 2 ? undefined : frameOf(this, look);
|
|
120
126
|
if (look === undefined || frame === undefined) return own.call(this, width);
|
|
121
127
|
const source = own.call(this, width - 2);
|
|
122
|
-
//
|
|
123
|
-
// is only drawn again when they, the width or the paint change.
|
|
128
|
+
// Pi caches its own lines, so the frame redraws only when they, the width or the paint change.
|
|
124
129
|
const known = drawnBefore.get(this);
|
|
125
130
|
const key = `${width}\u0000${frame.top}\u0000${frame.bottom}\u0000${frame.color}`;
|
|
126
131
|
if (known?.key === key && known.theme === look.theme && sameLines(known.source, source))
|
|
@@ -132,7 +137,6 @@ function wrap(
|
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
interface Drawn {
|
|
135
|
-
/** The width and the frame's labels. */
|
|
136
140
|
key: string;
|
|
137
141
|
theme: Theme;
|
|
138
142
|
source: readonly string[];
|
|
@@ -148,7 +152,7 @@ function sameLines(a: readonly string[], b: readonly string[]): boolean {
|
|
|
148
152
|
return true;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
|
-
/**
|
|
155
|
+
/** Two columns narrower, with a column of padding each side. */
|
|
152
156
|
export function framed(
|
|
153
157
|
body: readonly string[],
|
|
154
158
|
width: number,
|
|
@@ -161,18 +165,16 @@ export function framed(
|
|
|
161
165
|
let lines = body.map((line) => line.replace(MARKERS, "").replace(BACKGROUND, ""));
|
|
162
166
|
if (rules) {
|
|
163
167
|
lines = lines.filter((line) => !/^\u2500+$/.test(stripTerminalSequences(line).trim()));
|
|
164
|
-
// The blank line between a command and what it printed.
|
|
165
168
|
const gap = lines.findIndex((line, index) => index > 0 && isBlank(line));
|
|
166
|
-
if (gap > 0 && gap < lines.length - 1) lines[gap] =
|
|
169
|
+
if (gap > 0 && gap < lines.length - 1) lines[gap] = CHANGES_CUT;
|
|
167
170
|
}
|
|
168
|
-
// The blank rows pi pads its entries with.
|
|
169
171
|
const trim = () => {
|
|
170
172
|
while (lines.length > 1 && isBlank(lines[0] ?? "")) lines.shift();
|
|
171
173
|
while (lines.length > 1 && isBlank(lines.at(-1) ?? "")) lines.pop();
|
|
172
174
|
};
|
|
173
175
|
trim();
|
|
174
176
|
if (label && lines[0] !== undefined) {
|
|
175
|
-
// Alone on its line it goes with the line
|
|
177
|
+
// Alone on its line it goes with the line; otherwise only the label goes, as `[skill] name`.
|
|
176
178
|
const alone = /^\[[\w:.-]+\]$/.test(stripTerminalSequences(lines[0]).trim());
|
|
177
179
|
if (alone) lines.shift();
|
|
178
180
|
else lines[0] = lines[0].replace(LABEL, "$2");
|
package/src/ui/previews.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
// What each look setting changes, drawn under the list in Alt+S
|
|
2
|
-
// selected: the marks of the icon set, the editor in the frame style, your message framed or not.
|
|
1
|
+
// What each look setting changes, drawn under the list in Alt+S.
|
|
3
2
|
import { entryFrame, GLYPH, type Json } from "@adeildo/pi-kit";
|
|
4
3
|
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
5
4
|
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
@@ -20,7 +19,6 @@ const TOOLS = [
|
|
|
20
19
|
"memory_write",
|
|
21
20
|
];
|
|
22
21
|
|
|
23
|
-
/** The tool marks and the phase marks of an icon set. */
|
|
24
22
|
export function iconsPreview(value: Json, theme: Theme): string[] {
|
|
25
23
|
const set = resolveIcons(value as IconMode).set;
|
|
26
24
|
const tools = TOOLS.map(
|
|
@@ -32,7 +30,6 @@ export function iconsPreview(value: Json, theme: Theme): string[] {
|
|
|
32
30
|
return [tools.slice(0, 4).join(" "), tools.slice(4).join(" "), "", phases.join(" ")];
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
/** The editor, in the frame's lines. */
|
|
36
33
|
export function framePreview(value: Json, theme: Theme, width: number): string[] {
|
|
37
34
|
const style = value as FrameStyle | "off";
|
|
38
35
|
const room = Math.min(WIDTH, width);
|
|
@@ -42,7 +39,7 @@ export function framePreview(value: Json, theme: Theme, width: number): string[]
|
|
|
42
39
|
theme.fg("dim", "pi's editor, as pi draws it, with the edges' information in the footer"),
|
|
43
40
|
];
|
|
44
41
|
const box = BOXES[style];
|
|
45
|
-
//
|
|
42
|
+
// Drawn with the frame's own border, so it cannot drift from the editor.
|
|
46
43
|
const edge = (which: "top" | "bottom", label: string, rest: string) =>
|
|
47
44
|
border(room, [{ text: label, priority: 1 }], [{ text: rest, priority: 2 }], {
|
|
48
45
|
box,
|
|
@@ -58,7 +55,6 @@ export function framePreview(value: Json, theme: Theme, width: number): string[]
|
|
|
58
55
|
];
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
/** Your message, framed or in pi's block. */
|
|
62
58
|
export function userFramePreview(value: Json, theme: Theme, width: number): string[] {
|
|
63
59
|
const room = Math.min(WIDTH, width);
|
|
64
60
|
const text = theme.fg("text", "commit with a semantic message and push");
|
package/src/ui/queue.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
// Pi lists them as plain grey lines and has no hook for drawing them, so this wraps its method.
|
|
5
|
-
import { CUT, drawnByWidth, ENTRY_X, entryFrame } from "@adeildo/pi-kit";
|
|
1
|
+
// Messages sent while the agent works, in a dashed frame above the editor. Pi has no hook for
|
|
2
|
+
// drawing them, so this wraps its method.
|
|
3
|
+
import { CUT, drawnByWidth, CHANGES_X, entryFrame } from "@adeildo/pi-kit";
|
|
6
4
|
import { InteractiveMode, type Theme } from "@earendil-works/pi-coding-agent";
|
|
7
5
|
import { type Component, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
8
6
|
|
|
9
|
-
/**
|
|
7
|
+
/** Undefined leaves pi's list as it is. */
|
|
10
8
|
export type QueuePaint = () => Theme | undefined;
|
|
11
9
|
|
|
12
10
|
interface Queued {
|
|
@@ -31,6 +29,9 @@ export function frameQueue(source: QueuePaint): void {
|
|
|
31
29
|
updatePendingMessagesDisplay(): void;
|
|
32
30
|
};
|
|
33
31
|
const own = prototype.updatePendingMessagesDisplay;
|
|
32
|
+
// Same guard as `peers/src/cleared.ts`: fail loudly if pi renames this method.
|
|
33
|
+
if (typeof own !== "function")
|
|
34
|
+
throw new Error("pi has no InteractiveMode.updatePendingMessagesDisplay: write to the pi");
|
|
34
35
|
prototype.updatePendingMessagesDisplay = function update(this: Host) {
|
|
35
36
|
const theme = paint();
|
|
36
37
|
if (theme === undefined) return own.call(this);
|
|
@@ -50,7 +51,7 @@ const LABEL = Math.max(...MODES.map(([label]) => label.length));
|
|
|
50
51
|
|
|
51
52
|
export function queueBlock(queued: Queued, key: string, theme: Theme): Component {
|
|
52
53
|
return drawnByWidth((width) => {
|
|
53
|
-
const room = Math.max(1, width -
|
|
54
|
+
const room = Math.max(1, width - CHANGES_X - LABEL - 2);
|
|
54
55
|
const rows = MODES.flatMap(([label, mode]) =>
|
|
55
56
|
queued[mode].map((text) => {
|
|
56
57
|
const color = label === "steer" ? "accent" : "muted";
|
|
@@ -66,7 +67,6 @@ export function queueBlock(queued: Queued, key: string, theme: Theme): Component
|
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
/** The first line, cut to the room, with a mark when there is more. */
|
|
70
70
|
function oneLine(text: string, room: number): string {
|
|
71
71
|
const lines = text.trim().split("\n");
|
|
72
72
|
const first = lines[0] ?? "";
|
package/src/ui/screen.ts
CHANGED
|
@@ -25,17 +25,10 @@ export interface Screen {
|
|
|
25
25
|
slot(name: SlotName): readonly SegmentId[];
|
|
26
26
|
frameStyle(): FrameStyle | "off";
|
|
27
27
|
cursor(): CursorStyle;
|
|
28
|
-
/** A line of what you type, with the skills it names colored. */
|
|
29
28
|
decorate(line: string): string;
|
|
30
|
-
/** True when a skills feature expands `/skill:` references. */
|
|
31
29
|
skills(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* How many times the screen was told that what it draws changed. Something that keeps a drawing
|
|
34
|
-
* for a moment compares this: a branch, a model or a probe that answered must not wait for the
|
|
35
|
-
* next keystroke to show up.
|
|
36
|
-
*/
|
|
30
|
+
/** Compared by anything that keeps a drawing, so a change does not wait for the next keystroke. */
|
|
37
31
|
revision(): number;
|
|
38
|
-
/** Records that something the screen draws changed, such as an event or a probe that answered. */
|
|
39
32
|
bump(): void;
|
|
40
33
|
}
|
|
41
34
|
|