@adeildo/pi-look 5.3.0 → 5.4.0
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/package.json +2 -2
- package/src/index.ts +17 -1
- package/src/ui/editor.ts +16 -1
- package/src/ui/screen.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adeildo/pi-look",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "Pi's start screen, a framed editor and the footer, redrawn around the data that matters and painted only with the theme's colours.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@adeildo/pi-kit": "5.
|
|
41
|
+
"@adeildo/pi-kit": "5.4.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@earendil-works/pi-ai": "*",
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
accountStateOf,
|
|
3
|
+
createApp,
|
|
4
|
+
defineFeature,
|
|
5
|
+
drawSkillRefs,
|
|
6
|
+
type FeatureScope,
|
|
7
|
+
SKILL_REF,
|
|
8
|
+
skillNames,
|
|
9
|
+
} from "@adeildo/pi-kit";
|
|
2
10
|
import type {
|
|
3
11
|
ExtensionAPI,
|
|
4
12
|
ExtensionContext,
|
|
@@ -298,6 +306,14 @@ function createScreen(
|
|
|
298
306
|
slot: (name) => slots[name].get(scope),
|
|
299
307
|
frameStyle: () => frame.get(scope),
|
|
300
308
|
cursor: () => cursor.get(scope),
|
|
309
|
+
decorate: (line) => {
|
|
310
|
+
const theme = live.ctx?.ui.theme;
|
|
311
|
+
if (theme === undefined) return line;
|
|
312
|
+
return drawSkillRefs(line, skillNames(scope.events), (name) =>
|
|
313
|
+
theme.fg("customMessageLabel", `${SKILL_REF}${name}`),
|
|
314
|
+
);
|
|
315
|
+
},
|
|
316
|
+
skills: () => skillNames(scope.events).length > 0,
|
|
301
317
|
};
|
|
302
318
|
}
|
|
303
319
|
|
package/src/ui/editor.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { skillQueryAt } from "@adeildo/pi-kit";
|
|
1
2
|
import { CustomEditor, type KeybindingsManager } from "@earendil-works/pi-coding-agent";
|
|
2
3
|
import {
|
|
3
4
|
type EditorTheme,
|
|
@@ -59,6 +60,14 @@ export class LookEditor extends CustomEditor {
|
|
|
59
60
|
this.tui.requestRender();
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
/** Pi opens its palette on `/` only at the start of a message. Further in, `/` lists the skills. */
|
|
64
|
+
override handleInput(data: string): void {
|
|
65
|
+
super.handleInput(data);
|
|
66
|
+
if (data !== "/" || this.isShowingAutocomplete() || !this.#screen.skills()) return;
|
|
67
|
+
const { line, col } = this.getCursor();
|
|
68
|
+
if (skillQueryAt(this.getLines(), line, col) !== undefined) openAutocomplete(this);
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
override handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
63
72
|
if (this.#inset === 0) return super.handleMouse(event);
|
|
64
73
|
return super.handleMouse({
|
|
@@ -146,7 +155,7 @@ export class LookEditor extends CustomEditor {
|
|
|
146
155
|
);
|
|
147
156
|
inside = false;
|
|
148
157
|
} else if (inside) {
|
|
149
|
-
const text = cursor === "block" ? line : withoutSoftwareCursor(line);
|
|
158
|
+
const text = this.#screen.decorate(cursor === "block" ? line : withoutSoftwareCursor(line));
|
|
150
159
|
result.push(`${left}${fill(text, inner)}${right}`);
|
|
151
160
|
} else {
|
|
152
161
|
result.push(`${" ".repeat(this.#inset)}${line}`);
|
|
@@ -165,6 +174,12 @@ export class LookEditor extends CustomEditor {
|
|
|
165
174
|
}
|
|
166
175
|
}
|
|
167
176
|
|
|
177
|
+
// The editor keeps the method that opens its list private. Nothing opens if a pi release renames it.
|
|
178
|
+
function openAutocomplete(editor: CustomEditor): void {
|
|
179
|
+
const open: unknown = Reflect.get(editor, "tryTriggerAutocomplete");
|
|
180
|
+
if (typeof open === "function") open.call(editor);
|
|
181
|
+
}
|
|
182
|
+
|
|
168
183
|
/** With the terminal's cursor showing, pi's inverted cell would be a second cursor. */
|
|
169
184
|
function withoutSoftwareCursor(line: string): string {
|
|
170
185
|
return line.replace(INVERTED_CELL, "$1");
|
package/src/ui/screen.ts
CHANGED
|
@@ -24,6 +24,10 @@ export interface Screen {
|
|
|
24
24
|
slot(name: SlotName): readonly SegmentId[];
|
|
25
25
|
frameStyle(): FrameStyle | "off";
|
|
26
26
|
cursor(): CursorStyle;
|
|
27
|
+
/** A line of what you type, with the skills it names colored. */
|
|
28
|
+
decorate(line: string): string;
|
|
29
|
+
/** True when a skills feature expands `/skill:` references. */
|
|
30
|
+
skills(): boolean;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
export function slotPieces(
|