omp-fabric 1.27.1 → 1.28.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/CHANGELOG.md +46 -0
- package/README.md +1 -1
- package/dist/chunks/{chunk-KIH3KLZU.js → chunk-C2YMZNT5.js} +5 -5
- package/dist/chunks/chunk-C2YMZNT5.js.map +7 -0
- package/dist/chunks/{chunk-OJZNMROB.js → chunk-DKXNUCM2.js} +36 -50
- package/dist/chunks/chunk-DKXNUCM2.js.map +7 -0
- package/dist/chunks/chunk-K3OSK6AX.js +132 -0
- package/dist/chunks/chunk-K3OSK6AX.js.map +7 -0
- package/dist/chunks/{chunk-2BOZMRT5.js → chunk-LK66YHVL.js} +32 -49
- package/dist/chunks/chunk-LK66YHVL.js.map +7 -0
- package/dist/chunks/chunk-MIGBZN2K.js +81 -0
- package/dist/chunks/chunk-MIGBZN2K.js.map +7 -0
- package/dist/chunks/chunk-O337ZL5J.js +277 -0
- package/dist/chunks/chunk-O337ZL5J.js.map +7 -0
- package/dist/chunks/chunk-T76MXSP4.js +32 -0
- package/dist/chunks/chunk-T76MXSP4.js.map +7 -0
- package/dist/chunks/{chunk-NOZBB266.js → chunk-XZIQGFF7.js} +9 -13
- package/dist/chunks/chunk-XZIQGFF7.js.map +7 -0
- package/dist/chunks/{chunk-4XLJPEI4.js → chunk-ZJ7HHWW4.js} +20 -41
- package/dist/chunks/chunk-ZJ7HHWW4.js.map +7 -0
- package/dist/core/approval-controller.d.ts.map +1 -1
- package/dist/fabric-exec-tool.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +12 -5
- package/dist/fabric-runtime-state.js.map +2 -2
- package/dist/host-compatibility.d.ts +1 -1
- package/dist/index.js +169 -164
- package/dist/index.js.map +3 -3
- package/dist/providers/omp-tools-provider.d.ts.map +1 -1
- package/dist/ui/arc-group.d.ts +1 -1
- package/dist/ui/arc-group.d.ts.map +1 -1
- package/dist/ui/code-preview-shell.d.ts +2 -2
- package/dist/ui/code-preview-shell.d.ts.map +1 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.d.ts +1 -5
- package/dist/ui/conversation-chrome.d.ts.map +1 -1
- package/dist/ui/conversation-chrome.js +2 -2
- package/dist/ui/conversation-queue.d.ts +3 -2
- package/dist/ui/conversation-queue.d.ts.map +1 -1
- package/dist/ui/conversation-render.d.ts +19 -23
- package/dist/ui/conversation-render.d.ts.map +1 -1
- package/dist/ui/conversation.d.ts +7 -17
- package/dist/ui/conversation.d.ts.map +1 -1
- package/dist/ui/conversation.js +317 -318
- package/dist/ui/conversation.js.map +3 -3
- package/dist/ui/core-tool-render.d.ts +1 -1
- package/dist/ui/core-tool-render.d.ts.map +1 -1
- package/dist/ui/dashboard-detail.d.ts +4 -4
- package/dist/ui/dashboard-detail.d.ts.map +1 -1
- package/dist/ui/dashboard-fabric-graph.d.ts +1 -1
- package/dist/ui/dashboard-fabric-graph.d.ts.map +1 -1
- package/dist/ui/dashboard-presentation.d.ts +1 -1
- package/dist/ui/dashboard-presentation.d.ts.map +1 -1
- package/dist/ui/dashboard.d.ts +8 -8
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +207 -343
- package/dist/ui/dashboard.js.map +3 -3
- package/dist/ui/diff-background.d.ts +1 -1
- package/dist/ui/diff-background.d.ts.map +1 -1
- package/dist/ui/fabric-actor-delivery-selector.d.ts +4 -4
- package/dist/ui/fabric-actor-delivery-selector.d.ts.map +1 -1
- package/dist/ui/fabric-actor-tool-selector.d.ts +5 -6
- package/dist/ui/fabric-actor-tool-selector.d.ts.map +1 -1
- package/dist/ui/fabric-host-event-selector.d.ts +4 -4
- package/dist/ui/fabric-host-event-selector.d.ts.map +1 -1
- package/dist/ui/fabric-model-selector.d.ts +4 -6
- package/dist/ui/fabric-model-selector.d.ts.map +1 -1
- package/dist/ui/fabric-render.d.ts +6 -6
- package/dist/ui/fabric-render.d.ts.map +1 -1
- package/dist/ui/fabric-thinking-selector.d.ts +4 -7
- package/dist/ui/fabric-thinking-selector.d.ts.map +1 -1
- package/dist/ui/highlight.d.ts +2 -13
- package/dist/ui/highlight.d.ts.map +1 -1
- package/dist/ui/row-balance.d.ts +6 -6
- package/dist/ui/row-balance.d.ts.map +1 -1
- package/dist/ui/settings.d.ts +6 -3
- package/dist/ui/settings.d.ts.map +1 -1
- package/dist/ui/settings.js +234 -112
- package/dist/ui/settings.js.map +3 -3
- package/dist/ui/state-file-preview.d.ts +1 -1
- package/dist/ui/state-file-preview.d.ts.map +1 -1
- package/dist/ui/tui/input.d.ts +16 -0
- package/dist/ui/tui/input.d.ts.map +1 -0
- package/dist/ui/tui/rows.d.ts +24 -0
- package/dist/ui/tui/rows.d.ts.map +1 -0
- package/dist/ui/tui/select-list.d.ts +28 -0
- package/dist/ui/tui/select-list.d.ts.map +1 -0
- package/dist/ui/tui/settings-list.d.ts +38 -0
- package/dist/ui/tui/settings-list.d.ts.map +1 -0
- package/dist/ui/tui/text-field.d.ts +40 -0
- package/dist/ui/tui/text-field.d.ts.map +1 -0
- package/dist/ui/tui/view.d.ts +26 -0
- package/dist/ui/tui/view.d.ts.map +1 -0
- package/dist/ui/widget.d.ts +3 -3
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/worker.js +9 -0
- package/dist/worker.js.map +2 -2
- package/docs/interface.md +3 -3
- package/package.json +11 -11
- package/dist/chunks/chunk-2BOZMRT5.js.map +0 -7
- package/dist/chunks/chunk-4XLJPEI4.js.map +0 -7
- package/dist/chunks/chunk-G2IBGGBM.js +0 -42
- package/dist/chunks/chunk-G2IBGGBM.js.map +0 -7
- package/dist/chunks/chunk-KIH3KLZU.js.map +0 -7
- package/dist/chunks/chunk-NOZBB266.js.map +0 -7
- package/dist/chunks/chunk-OJZNMROB.js.map +0 -7
- package/dist/ui/symbol-theme.d.ts +0 -3
- package/dist/ui/symbol-theme.d.ts.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/tui/view.ts"],
|
|
4
|
+
"sourcesContent": ["import { isUiNode, signal, type KeyEvent, type PasteEvent, UiNode, untrack } from \"@oh-my-pi/pi-tui\";\nimport { defineRolePainter } from \"@oh-my-pi/pi-tui/term/paint\";\nimport { renderBlock } from \"@oh-my-pi/pi-tui/term/render\";\nimport { defineRoleWidget } from \"@oh-my-pi/pi-tui/term/widgets\";\nimport type { Theme } from \"@oh-my-pi/pi-tui/theme/contract\";\nimport { truncate } from \"@oh-my-pi/pi-tui/text/width\";\n\nexport interface Rows {\n render(width: number): readonly string[];\n invalidate?(): void;\n}\n\nexport interface FabricView extends Rows {\n handleInput?(data: string): void;\n handleWheel?(rows: number): void;\n dispose?(): void;\n}\n\nexport interface FabricViewHost {\n requestRender(): void;\n size(): { readonly columns: number; readonly rows: number };\n}\n\nconst VIEW_ROLE = \"fabric.view\";\nconst WHEEL_ROWS = 3;\nconst mounted = new WeakMap<UiNode, { view: FabricView; paint: (width: number) => string[]; wheel: (rows: number) => void }>();\nlet roleRegistered = false;\n\nconst registerRole = (): void => {\n if (roleRegistered) return;\n roleRegistered = true;\n defineRolePainter(\"canvas\", VIEW_ROLE, (node, cx) => {\n const rows = mounted.get(node)?.paint(cx.width) ?? [];\n return { rows, hits: rows.length > 0 ? [{ row: 0, col: 0, width: cx.width, height: rows.length, node }] : [] };\n });\n defineRoleWidget(\"canvas\", VIEW_ROLE, {\n mouse(node, mouse) {\n const entry = mounted.get(node);\n if (!entry?.view.handleWheel || mouse.action !== \"press\") return false;\n if (mouse.button === \"wheel-up\") entry.wheel(-WHEEL_ROWS);\n else if (mouse.button === \"wheel-down\") entry.wheel(WHEEL_ROWS);\n else return false;\n return true;\n },\n });\n};\n\nexport const mountedView = (node: unknown): FabricView | undefined =>\n isUiNode(node) ? mounted.get(node)?.view : undefined;\n\nconst EMPTY_ROWS: Rows = { render: () => [] };\n\nexport const isRows = (value: unknown): value is Rows =>\n typeof value === \"object\" &&\n value !== null &&\n !Array.isArray(value) &&\n !isUiNode(value) &&\n \"render\" in value &&\n typeof value.render === \"function\";\n\nexport const asRows = (output: unknown, theme: Theme): Rows => {\n if (output === undefined || output === null || output === false || output === \"\") return EMPTY_ROWS;\n if (isRows(output)) return output;\n const node = isUiNode(output) ? output : new UiNode(\"col\", { children: output });\n return { render: (width) => renderBlock(node, width, { theme }).rows };\n};\n\nconst errorText = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\nexport const mountView = <V extends FabricView>(\n size: FabricViewHost[\"size\"],\n build: (host: FabricViewHost) => V,\n onError?: (error: unknown) => void,\n): { node: UiNode; view: V } => {\n registerRole();\n const revision = signal(0);\n const requestRender = (): void => revision.set(untrack(revision) + 1);\n const view = build({ requestRender, size });\n let paintFailed = false;\n const contain = (action: () => void): true => {\n try {\n action();\n } catch (error) {\n onError?.(error);\n }\n requestRender();\n return true;\n };\n const deliver = (data: string): boolean => contain(() => view.handleInput?.(data));\n const paint = (width: number): string[] => {\n revision();\n try {\n const rows = view.render(width).map((row) => truncate(row, width, \"\"));\n paintFailed = false;\n return rows;\n } catch (error) {\n if (!paintFailed) onError?.(error);\n paintFailed = true;\n return [truncate(`\u26A0 Fabric view failed to render: ${errorText(error)}`, width)];\n }\n };\n const node = new UiNode(\"canvas\", {\n paint,\n term: { role: VIEW_ROLE },\n onKey: (key: KeyEvent) => key.kind !== \"release\" && deliver(key.raw),\n onPaste: (paste: PasteEvent) => deliver(`\\x1b[200~${paste.text}\\x1b[201~`),\n });\n mounted.set(node, { view, paint, wheel: (rows) => contain(() => view.handleWheel?.(rows)) });\n return { node, view };\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU,QAAwC,QAAQ,eAAe;AAClF,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAEjC,SAAS,gBAAgB;AAkBzB,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,UAAU,oBAAI,QAAyG;AAC7H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@@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeTerminalInput,
|
|
3
|
+
typedText
|
|
4
|
+
} from "./chunk-T76MXSP4.js";
|
|
5
|
+
|
|
6
|
+
// src/ui/tui/text-field.ts
|
|
7
|
+
import { widgetActionOf } from "@oh-my-pi/pi-tui/term/keymap";
|
|
8
|
+
import { inverse } from "@oh-my-pi/pi-tui/theme/theme";
|
|
9
|
+
import { visibleWidth } from "@oh-my-pi/pi-tui/text/width";
|
|
10
|
+
var EDIT_ACTIONS = [
|
|
11
|
+
"editor.newLine",
|
|
12
|
+
"editor.cursorLeft",
|
|
13
|
+
"editor.cursorRight",
|
|
14
|
+
"editor.cursorWordLeft",
|
|
15
|
+
"editor.cursorWordRight",
|
|
16
|
+
"editor.cursorLineStart",
|
|
17
|
+
"editor.cursorLineEnd",
|
|
18
|
+
"editor.cursorUp",
|
|
19
|
+
"editor.cursorDown",
|
|
20
|
+
"editor.deleteCharBackward",
|
|
21
|
+
"editor.deleteCharForward",
|
|
22
|
+
"editor.deleteWordBackward",
|
|
23
|
+
"editor.deleteWordForward",
|
|
24
|
+
"editor.deleteToLineStart",
|
|
25
|
+
"editor.deleteToLineEnd",
|
|
26
|
+
"editor.yank",
|
|
27
|
+
"editor.undo"
|
|
28
|
+
];
|
|
29
|
+
var UNDO_LIMIT = 100;
|
|
30
|
+
var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
31
|
+
var graphemes = (text) => Array.from(segmenter.segment(text), (part) => part.segment);
|
|
32
|
+
var isWordChar = (grapheme) => /[\p{L}\p{N}_]/u.test(grapheme);
|
|
33
|
+
var TextField = class {
|
|
34
|
+
onSubmit;
|
|
35
|
+
onChange;
|
|
36
|
+
focused = true;
|
|
37
|
+
text = "";
|
|
38
|
+
cursor = 0;
|
|
39
|
+
killed = "";
|
|
40
|
+
undoStack = [];
|
|
41
|
+
preferredColumn;
|
|
42
|
+
lastCursorRow = 0;
|
|
43
|
+
multiline;
|
|
44
|
+
prompt;
|
|
45
|
+
constructor(options = {}) {
|
|
46
|
+
this.multiline = options.multiline ?? false;
|
|
47
|
+
this.prompt = options.prompt ?? (this.multiline ? "" : "> ");
|
|
48
|
+
}
|
|
49
|
+
getText() {
|
|
50
|
+
return this.text;
|
|
51
|
+
}
|
|
52
|
+
setText(text) {
|
|
53
|
+
const next = this.normalize(text);
|
|
54
|
+
if (next === this.text) return;
|
|
55
|
+
this.text = next;
|
|
56
|
+
this.cursor = next.length;
|
|
57
|
+
this.preferredColumn = void 0;
|
|
58
|
+
this.onChange?.(this.text);
|
|
59
|
+
}
|
|
60
|
+
get cursorRow() {
|
|
61
|
+
return this.lastCursorRow;
|
|
62
|
+
}
|
|
63
|
+
handleInput(data) {
|
|
64
|
+
for (const event of decodeTerminalInput(data)) {
|
|
65
|
+
if (event.type === "paste") this.insert(event.text);
|
|
66
|
+
else this.handleKey(event.key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
handleKey(key) {
|
|
70
|
+
if (key.id === "enter") {
|
|
71
|
+
this.onSubmit?.(this.text);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
const action = widgetActionOf(key.id, EDIT_ACTIONS);
|
|
75
|
+
if (action) return this.apply(action);
|
|
76
|
+
const typed = typedText(key);
|
|
77
|
+
if (typed === void 0) return false;
|
|
78
|
+
this.insert(typed);
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
render(width) {
|
|
82
|
+
return this.multiline ? this.renderLines(width) : [this.renderLine(width)];
|
|
83
|
+
}
|
|
84
|
+
apply(action) {
|
|
85
|
+
const before = this.text.slice(0, this.cursor);
|
|
86
|
+
const after = this.text.slice(this.cursor);
|
|
87
|
+
const lineStart = before.lastIndexOf("\n") + 1;
|
|
88
|
+
const lineEndOffset = after.indexOf("\n");
|
|
89
|
+
const lineEnd = lineEndOffset < 0 ? this.text.length : this.cursor + lineEndOffset;
|
|
90
|
+
switch (action) {
|
|
91
|
+
case "editor.newLine":
|
|
92
|
+
if (!this.multiline) return false;
|
|
93
|
+
this.insert("\n");
|
|
94
|
+
return true;
|
|
95
|
+
case "editor.cursorLeft":
|
|
96
|
+
return this.moveTo(this.cursor - (graphemes(before).at(-1)?.length ?? 0));
|
|
97
|
+
case "editor.cursorRight":
|
|
98
|
+
return this.moveTo(this.cursor + (graphemes(after)[0]?.length ?? 0));
|
|
99
|
+
case "editor.cursorWordLeft":
|
|
100
|
+
return this.moveTo(this.wordBoundaryBefore());
|
|
101
|
+
case "editor.cursorWordRight":
|
|
102
|
+
return this.moveTo(this.wordBoundaryAfter());
|
|
103
|
+
case "editor.cursorLineStart":
|
|
104
|
+
return this.moveTo(lineStart);
|
|
105
|
+
case "editor.cursorLineEnd":
|
|
106
|
+
return this.moveTo(lineEnd);
|
|
107
|
+
case "editor.cursorUp":
|
|
108
|
+
return this.moveVertical(-1);
|
|
109
|
+
case "editor.cursorDown":
|
|
110
|
+
return this.moveVertical(1);
|
|
111
|
+
case "editor.deleteCharBackward":
|
|
112
|
+
return this.remove(this.cursor - (graphemes(before).at(-1)?.length ?? 0), this.cursor, false);
|
|
113
|
+
case "editor.deleteCharForward":
|
|
114
|
+
return this.remove(this.cursor, this.cursor + (graphemes(after)[0]?.length ?? 0), false);
|
|
115
|
+
case "editor.deleteWordBackward":
|
|
116
|
+
return this.remove(this.wordBoundaryBefore(), this.cursor, true);
|
|
117
|
+
case "editor.deleteWordForward":
|
|
118
|
+
return this.remove(this.cursor, this.wordBoundaryAfter(), true);
|
|
119
|
+
case "editor.deleteToLineStart":
|
|
120
|
+
return this.remove(lineStart === this.cursor && lineStart > 0 ? lineStart - 1 : lineStart, this.cursor, true);
|
|
121
|
+
case "editor.deleteToLineEnd":
|
|
122
|
+
return this.remove(this.cursor, lineEnd === this.cursor && lineEnd < this.text.length ? lineEnd + 1 : lineEnd, true);
|
|
123
|
+
case "editor.yank":
|
|
124
|
+
if (this.killed === "") return false;
|
|
125
|
+
this.insert(this.killed);
|
|
126
|
+
return true;
|
|
127
|
+
case "editor.undo": {
|
|
128
|
+
const previous = this.undoStack.pop();
|
|
129
|
+
if (!previous) return false;
|
|
130
|
+
this.text = previous.text;
|
|
131
|
+
this.cursor = previous.cursor;
|
|
132
|
+
this.preferredColumn = void 0;
|
|
133
|
+
this.onChange?.(this.text);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
normalize(text) {
|
|
141
|
+
const unified = text.replace(/\r\n?/g, "\n");
|
|
142
|
+
return this.multiline ? unified : unified.replace(/\n/g, " ");
|
|
143
|
+
}
|
|
144
|
+
remember() {
|
|
145
|
+
this.undoStack.push({ text: this.text, cursor: this.cursor });
|
|
146
|
+
if (this.undoStack.length > UNDO_LIMIT) this.undoStack.shift();
|
|
147
|
+
}
|
|
148
|
+
insert(raw) {
|
|
149
|
+
const text = this.normalize(raw);
|
|
150
|
+
if (text === "") return;
|
|
151
|
+
this.remember();
|
|
152
|
+
this.text = `${this.text.slice(0, this.cursor)}${text}${this.text.slice(this.cursor)}`;
|
|
153
|
+
this.cursor += text.length;
|
|
154
|
+
this.preferredColumn = void 0;
|
|
155
|
+
this.onChange?.(this.text);
|
|
156
|
+
}
|
|
157
|
+
remove(from, to, kill) {
|
|
158
|
+
if (to <= from) return false;
|
|
159
|
+
this.remember();
|
|
160
|
+
if (kill) this.killed = this.text.slice(from, to);
|
|
161
|
+
this.text = `${this.text.slice(0, from)}${this.text.slice(to)}`;
|
|
162
|
+
this.cursor = from;
|
|
163
|
+
this.preferredColumn = void 0;
|
|
164
|
+
this.onChange?.(this.text);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
moveTo(offset) {
|
|
168
|
+
this.cursor = Math.max(0, Math.min(offset, this.text.length));
|
|
169
|
+
this.preferredColumn = void 0;
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
moveVertical(direction) {
|
|
173
|
+
if (!this.multiline) return false;
|
|
174
|
+
const lines = this.text.split("\n");
|
|
175
|
+
let row = 0;
|
|
176
|
+
let offset = 0;
|
|
177
|
+
while (row < lines.length - 1 && offset + lines[row].length < this.cursor) {
|
|
178
|
+
offset += lines[row].length + 1;
|
|
179
|
+
row++;
|
|
180
|
+
}
|
|
181
|
+
const target = row + direction;
|
|
182
|
+
if (target < 0 || target >= lines.length) return false;
|
|
183
|
+
const column = this.preferredColumn ?? visibleWidth(this.text.slice(offset, this.cursor));
|
|
184
|
+
const targetStart = direction < 0 ? offset - lines[target].length - 1 : offset + lines[row].length + 1;
|
|
185
|
+
let position = targetStart;
|
|
186
|
+
let width = 0;
|
|
187
|
+
for (const grapheme of graphemes(lines[target])) {
|
|
188
|
+
const next = width + visibleWidth(grapheme);
|
|
189
|
+
if (next > column) break;
|
|
190
|
+
width = next;
|
|
191
|
+
position += grapheme.length;
|
|
192
|
+
}
|
|
193
|
+
this.cursor = position;
|
|
194
|
+
this.preferredColumn = column;
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
wordBoundaryBefore() {
|
|
198
|
+
const parts = graphemes(this.text.slice(0, this.cursor));
|
|
199
|
+
let index = parts.length;
|
|
200
|
+
while (index > 0 && !isWordChar(parts[index - 1])) index--;
|
|
201
|
+
while (index > 0 && isWordChar(parts[index - 1])) index--;
|
|
202
|
+
return parts.slice(0, index).join("").length;
|
|
203
|
+
}
|
|
204
|
+
wordBoundaryAfter() {
|
|
205
|
+
const parts = graphemes(this.text.slice(this.cursor));
|
|
206
|
+
let index = 0;
|
|
207
|
+
while (index < parts.length && !isWordChar(parts[index])) index++;
|
|
208
|
+
while (index < parts.length && isWordChar(parts[index])) index++;
|
|
209
|
+
return this.cursor + parts.slice(0, index).join("").length;
|
|
210
|
+
}
|
|
211
|
+
caret(grapheme) {
|
|
212
|
+
return this.focused ? inverse(grapheme) : grapheme;
|
|
213
|
+
}
|
|
214
|
+
renderLine(width) {
|
|
215
|
+
const room = Math.max(1, width - visibleWidth(this.prompt));
|
|
216
|
+
const before = graphemes(this.text.slice(0, this.cursor));
|
|
217
|
+
const after = graphemes(this.text.slice(this.cursor));
|
|
218
|
+
const atCursor = after.shift() ?? " ";
|
|
219
|
+
let used = visibleWidth(atCursor);
|
|
220
|
+
const left = [];
|
|
221
|
+
for (let index = before.length - 1; index >= 0 && used + visibleWidth(before[index]) <= room; index--) {
|
|
222
|
+
left.unshift(before[index]);
|
|
223
|
+
used += visibleWidth(before[index]);
|
|
224
|
+
}
|
|
225
|
+
const right = [];
|
|
226
|
+
for (const grapheme of after) {
|
|
227
|
+
if (used + visibleWidth(grapheme) > room) break;
|
|
228
|
+
right.push(grapheme);
|
|
229
|
+
used += visibleWidth(grapheme);
|
|
230
|
+
}
|
|
231
|
+
this.lastCursorRow = 0;
|
|
232
|
+
return `${this.prompt}${left.join("")}${this.caret(atCursor)}${right.join("")}`;
|
|
233
|
+
}
|
|
234
|
+
renderLines(width) {
|
|
235
|
+
const room = Math.max(1, width - visibleWidth(this.prompt));
|
|
236
|
+
const indent = " ".repeat(visibleWidth(this.prompt));
|
|
237
|
+
const rows = [];
|
|
238
|
+
let offset = 0;
|
|
239
|
+
this.lastCursorRow = 0;
|
|
240
|
+
for (const line of this.text.split("\n")) {
|
|
241
|
+
let row = "";
|
|
242
|
+
let used = 0;
|
|
243
|
+
let position = offset;
|
|
244
|
+
const cursorOnLine = this.cursor >= offset && this.cursor <= offset + line.length;
|
|
245
|
+
const flush = () => {
|
|
246
|
+
rows.push(`${rows.length === 0 ? this.prompt : indent}${row}`);
|
|
247
|
+
row = "";
|
|
248
|
+
used = 0;
|
|
249
|
+
};
|
|
250
|
+
for (const grapheme of graphemes(line)) {
|
|
251
|
+
const cells = visibleWidth(grapheme);
|
|
252
|
+
if (used + cells > room && used > 0) flush();
|
|
253
|
+
if (position === this.cursor) {
|
|
254
|
+
this.lastCursorRow = rows.length;
|
|
255
|
+
row += this.caret(grapheme);
|
|
256
|
+
} else {
|
|
257
|
+
row += grapheme;
|
|
258
|
+
}
|
|
259
|
+
used += cells;
|
|
260
|
+
position += grapheme.length;
|
|
261
|
+
}
|
|
262
|
+
if (cursorOnLine && this.cursor === offset + line.length) {
|
|
263
|
+
if (used + 1 > room && used > 0) flush();
|
|
264
|
+
this.lastCursorRow = rows.length;
|
|
265
|
+
row += this.caret(" ");
|
|
266
|
+
}
|
|
267
|
+
flush();
|
|
268
|
+
offset += line.length + 1;
|
|
269
|
+
}
|
|
270
|
+
return rows;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export {
|
|
275
|
+
TextField
|
|
276
|
+
};
|
|
277
|
+
//# sourceMappingURL=chunk-O337ZL5J.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/tui/text-field.ts"],
|
|
4
|
+
"sourcesContent": ["import type { KeyEvent } from \"@oh-my-pi/pi-tui\";\nimport { widgetActionOf, type WidgetAction } from \"@oh-my-pi/pi-tui/term/keymap\";\nimport { inverse } from \"@oh-my-pi/pi-tui/theme/theme\";\nimport { visibleWidth } from \"@oh-my-pi/pi-tui/text/width\";\nimport { decodeTerminalInput, typedText } from \"./input.js\";\nimport type { Rows } from \"./view.js\";\n\ninterface TextFieldOptions {\n multiline?: boolean;\n prompt?: string;\n}\n\ninterface Snapshot {\n text: string;\n cursor: number;\n}\n\nconst EDIT_ACTIONS: readonly WidgetAction[] = [\n \"editor.newLine\",\n \"editor.cursorLeft\",\n \"editor.cursorRight\",\n \"editor.cursorWordLeft\",\n \"editor.cursorWordRight\",\n \"editor.cursorLineStart\",\n \"editor.cursorLineEnd\",\n \"editor.cursorUp\",\n \"editor.cursorDown\",\n \"editor.deleteCharBackward\",\n \"editor.deleteCharForward\",\n \"editor.deleteWordBackward\",\n \"editor.deleteWordForward\",\n \"editor.deleteToLineStart\",\n \"editor.deleteToLineEnd\",\n \"editor.yank\",\n \"editor.undo\",\n];\n\nconst UNDO_LIMIT = 100;\nconst segmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\nconst graphemes = (text: string): string[] => Array.from(segmenter.segment(text), (part) => part.segment);\nconst isWordChar = (grapheme: string): boolean => /[\\p{L}\\p{N}_]/u.test(grapheme);\n\nexport class TextField implements Rows {\n onSubmit: ((text: string) => void) | undefined;\n onChange: ((text: string) => void) | undefined;\n focused = true;\n private text = \"\";\n private cursor = 0;\n private killed = \"\";\n private readonly undoStack: Snapshot[] = [];\n private preferredColumn: number | undefined;\n private lastCursorRow = 0;\n private readonly multiline: boolean;\n private readonly prompt: string;\n\n constructor(options: TextFieldOptions = {}) {\n this.multiline = options.multiline ?? false;\n this.prompt = options.prompt ?? (this.multiline ? \"\" : \"> \");\n }\n\n getText(): string {\n return this.text;\n }\n\n setText(text: string): void {\n const next = this.normalize(text);\n if (next === this.text) return;\n this.text = next;\n this.cursor = next.length;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n }\n\n get cursorRow(): number {\n return this.lastCursorRow;\n }\n\n handleInput(data: string): void {\n for (const event of decodeTerminalInput(data)) {\n if (event.type === \"paste\") this.insert(event.text);\n else this.handleKey(event.key);\n }\n }\n\n handleKey(key: KeyEvent): boolean {\n if (key.id === \"enter\") {\n this.onSubmit?.(this.text);\n return true;\n }\n const action = widgetActionOf(key.id, EDIT_ACTIONS);\n if (action) return this.apply(action);\n const typed = typedText(key);\n if (typed === undefined) return false;\n this.insert(typed);\n return true;\n }\n\n render(width: number): string[] {\n return this.multiline ? this.renderLines(width) : [this.renderLine(width)];\n }\n\n private apply(action: WidgetAction): boolean {\n const before = this.text.slice(0, this.cursor);\n const after = this.text.slice(this.cursor);\n const lineStart = before.lastIndexOf(\"\\n\") + 1;\n const lineEndOffset = after.indexOf(\"\\n\");\n const lineEnd = lineEndOffset < 0 ? this.text.length : this.cursor + lineEndOffset;\n switch (action) {\n case \"editor.newLine\":\n if (!this.multiline) return false;\n this.insert(\"\\n\");\n return true;\n case \"editor.cursorLeft\":\n return this.moveTo(this.cursor - (graphemes(before).at(-1)?.length ?? 0));\n case \"editor.cursorRight\":\n return this.moveTo(this.cursor + (graphemes(after)[0]?.length ?? 0));\n case \"editor.cursorWordLeft\":\n return this.moveTo(this.wordBoundaryBefore());\n case \"editor.cursorWordRight\":\n return this.moveTo(this.wordBoundaryAfter());\n case \"editor.cursorLineStart\":\n return this.moveTo(lineStart);\n case \"editor.cursorLineEnd\":\n return this.moveTo(lineEnd);\n case \"editor.cursorUp\":\n return this.moveVertical(-1);\n case \"editor.cursorDown\":\n return this.moveVertical(1);\n case \"editor.deleteCharBackward\":\n return this.remove(this.cursor - (graphemes(before).at(-1)?.length ?? 0), this.cursor, false);\n case \"editor.deleteCharForward\":\n return this.remove(this.cursor, this.cursor + (graphemes(after)[0]?.length ?? 0), false);\n case \"editor.deleteWordBackward\":\n return this.remove(this.wordBoundaryBefore(), this.cursor, true);\n case \"editor.deleteWordForward\":\n return this.remove(this.cursor, this.wordBoundaryAfter(), true);\n case \"editor.deleteToLineStart\":\n return this.remove(lineStart === this.cursor && lineStart > 0 ? lineStart - 1 : lineStart, this.cursor, true);\n case \"editor.deleteToLineEnd\":\n return this.remove(this.cursor, lineEnd === this.cursor && lineEnd < this.text.length ? lineEnd + 1 : lineEnd, true);\n case \"editor.yank\":\n if (this.killed === \"\") return false;\n this.insert(this.killed);\n return true;\n case \"editor.undo\": {\n const previous = this.undoStack.pop();\n if (!previous) return false;\n this.text = previous.text;\n this.cursor = previous.cursor;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n return true;\n }\n default:\n return false;\n }\n }\n\n private normalize(text: string): string {\n const unified = text.replace(/\\r\\n?/g, \"\\n\");\n return this.multiline ? unified : unified.replace(/\\n/g, \" \");\n }\n\n private remember(): void {\n this.undoStack.push({ text: this.text, cursor: this.cursor });\n if (this.undoStack.length > UNDO_LIMIT) this.undoStack.shift();\n }\n\n private insert(raw: string): void {\n const text = this.normalize(raw);\n if (text === \"\") return;\n this.remember();\n this.text = `${this.text.slice(0, this.cursor)}${text}${this.text.slice(this.cursor)}`;\n this.cursor += text.length;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n }\n\n private remove(from: number, to: number, kill: boolean): boolean {\n if (to <= from) return false;\n this.remember();\n if (kill) this.killed = this.text.slice(from, to);\n this.text = `${this.text.slice(0, from)}${this.text.slice(to)}`;\n this.cursor = from;\n this.preferredColumn = undefined;\n this.onChange?.(this.text);\n return true;\n }\n\n private moveTo(offset: number): boolean {\n this.cursor = Math.max(0, Math.min(offset, this.text.length));\n this.preferredColumn = undefined;\n return true;\n }\n\n private moveVertical(direction: -1 | 1): boolean {\n if (!this.multiline) return false;\n const lines = this.text.split(\"\\n\");\n let row = 0;\n let offset = 0;\n while (row < lines.length - 1 && offset + lines[row]!.length < this.cursor) {\n offset += lines[row]!.length + 1;\n row++;\n }\n const target = row + direction;\n if (target < 0 || target >= lines.length) return false;\n const column = this.preferredColumn ?? visibleWidth(this.text.slice(offset, this.cursor));\n const targetStart = direction < 0\n ? offset - lines[target]!.length - 1\n : offset + lines[row]!.length + 1;\n let position = targetStart;\n let width = 0;\n for (const grapheme of graphemes(lines[target]!)) {\n const next = width + visibleWidth(grapheme);\n if (next > column) break;\n width = next;\n position += grapheme.length;\n }\n this.cursor = position;\n this.preferredColumn = column;\n return true;\n }\n\n private wordBoundaryBefore(): number {\n const parts = graphemes(this.text.slice(0, this.cursor));\n let index = parts.length;\n while (index > 0 && !isWordChar(parts[index - 1]!)) index--;\n while (index > 0 && isWordChar(parts[index - 1]!)) index--;\n return parts.slice(0, index).join(\"\").length;\n }\n\n private wordBoundaryAfter(): number {\n const parts = graphemes(this.text.slice(this.cursor));\n let index = 0;\n while (index < parts.length && !isWordChar(parts[index]!)) index++;\n while (index < parts.length && isWordChar(parts[index]!)) index++;\n return this.cursor + parts.slice(0, index).join(\"\").length;\n }\n\n private caret(grapheme: string): string {\n return this.focused ? inverse(grapheme) : grapheme;\n }\n\n private renderLine(width: number): string {\n const room = Math.max(1, width - visibleWidth(this.prompt));\n const before = graphemes(this.text.slice(0, this.cursor));\n const after = graphemes(this.text.slice(this.cursor));\n const atCursor = after.shift() ?? \" \";\n let used = visibleWidth(atCursor);\n const left: string[] = [];\n for (let index = before.length - 1; index >= 0 && used + visibleWidth(before[index]!) <= room; index--) {\n left.unshift(before[index]!);\n used += visibleWidth(before[index]!);\n }\n const right: string[] = [];\n for (const grapheme of after) {\n if (used + visibleWidth(grapheme) > room) break;\n right.push(grapheme);\n used += visibleWidth(grapheme);\n }\n this.lastCursorRow = 0;\n return `${this.prompt}${left.join(\"\")}${this.caret(atCursor)}${right.join(\"\")}`;\n }\n\n private renderLines(width: number): string[] {\n const room = Math.max(1, width - visibleWidth(this.prompt));\n const indent = \" \".repeat(visibleWidth(this.prompt));\n const rows: string[] = [];\n let offset = 0;\n this.lastCursorRow = 0;\n for (const line of this.text.split(\"\\n\")) {\n let row = \"\";\n let used = 0;\n let position = offset;\n const cursorOnLine = this.cursor >= offset && this.cursor <= offset + line.length;\n const flush = (): void => {\n rows.push(`${rows.length === 0 ? this.prompt : indent}${row}`);\n row = \"\";\n used = 0;\n };\n for (const grapheme of graphemes(line)) {\n const cells = visibleWidth(grapheme);\n if (used + cells > room && used > 0) flush();\n if (position === this.cursor) {\n this.lastCursorRow = rows.length;\n row += this.caret(grapheme);\n } else {\n row += grapheme;\n }\n used += cells;\n position += grapheme.length;\n }\n if (cursorOnLine && this.cursor === offset + line.length) {\n if (used + 1 > room && used > 0) flush();\n this.lastCursorRow = rows.length;\n row += this.caret(\" \");\n }\n flush();\n offset += line.length + 1;\n }\n return rows;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AACA,SAAS,sBAAyC;AAClD,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAc7B,IAAM,eAAwC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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AAQ;AACnC,YAAI,OAAO,QAAQ,QAAQ,OAAO,EAAG,OAAM;AAC3C,YAAI,aAAa,KAAK,QAAQ;AAC5B,eAAK,gBAAgB,KAAK;AAC1B,iBAAO,KAAK,MAAM,QAAQ;AAAA,QAC5B,OAAO;AACL,iBAAO;AAAA,QACT;AACA,gBAAQ;AACR,oBAAY,SAAS;AAAA,MACvB;AACA,UAAI,gBAAgB,KAAK,WAAW,SAAS,KAAK,QAAQ;AACxD,YAAI,OAAO,IAAI,QAAQ,OAAO,EAAG,OAAM;AACvC,aAAK,gBAAgB,KAAK;AAC1B,eAAO,KAAK,MAAM,GAAG;AAAA,MACvB;AACA,YAAM;AACN,gBAAU,KAAK,SAAS;AAAA,IAC1B;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/ui/tui/input.ts
|
|
2
|
+
import { decodeInput } from "@oh-my-pi/pi-tui/driver/input/decoder";
|
|
3
|
+
import { widgetKeyMatches } from "@oh-my-pi/pi-tui/term/keymap";
|
|
4
|
+
var MODIFIED = /^(?:ctrl|alt|super)\+/;
|
|
5
|
+
var decodeTerminalInput = (data) => {
|
|
6
|
+
const result = [];
|
|
7
|
+
for (const event of decodeInput(data)) {
|
|
8
|
+
if (event.type === "key" && event.key.kind !== "release") result.push({ type: "key", key: event.key });
|
|
9
|
+
else if (event.type === "paste") result.push({ type: "paste", text: event.paste.text });
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
var keyOf = (data) => {
|
|
14
|
+
const events = decodeTerminalInput(data);
|
|
15
|
+
const first = events[0];
|
|
16
|
+
return events.length === 1 && first?.type === "key" ? first.key : void 0;
|
|
17
|
+
};
|
|
18
|
+
var isKey = (data, id) => keyOf(data)?.id === id;
|
|
19
|
+
var isAction = (data, action) => {
|
|
20
|
+
const key = keyOf(data);
|
|
21
|
+
return key !== void 0 && widgetKeyMatches(key, action);
|
|
22
|
+
};
|
|
23
|
+
var typedText = (key) => key.text !== void 0 && key.text !== "" && !MODIFIED.test(key.id) ? key.text : void 0;
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
decodeTerminalInput,
|
|
27
|
+
keyOf,
|
|
28
|
+
isKey,
|
|
29
|
+
isAction,
|
|
30
|
+
typedText
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=chunk-T76MXSP4.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/tui/input.ts"],
|
|
4
|
+
"sourcesContent": ["import type { KeyEvent } from \"@oh-my-pi/pi-tui\";\nimport { decodeInput } from \"@oh-my-pi/pi-tui/driver/input/decoder\";\nimport { type WidgetAction, widgetKeyMatches } from \"@oh-my-pi/pi-tui/term/keymap\";\n\ntype TerminalInput =\n | { readonly type: \"key\"; readonly key: KeyEvent }\n | { readonly type: \"paste\"; readonly text: string };\n\nconst MODIFIED = /^(?:ctrl|alt|super)\\+/;\n\nexport const decodeTerminalInput = (data: string): TerminalInput[] => {\n const result: TerminalInput[] = [];\n for (const event of decodeInput(data)) {\n if (event.type === \"key\" && event.key.kind !== \"release\") result.push({ type: \"key\", key: event.key });\n else if (event.type === \"paste\") result.push({ type: \"paste\", text: event.paste.text });\n }\n return result;\n};\n\nexport const keyOf = (data: string): KeyEvent | undefined => {\n const events = decodeTerminalInput(data);\n const first = events[0];\n return events.length === 1 && first?.type === \"key\" ? first.key : undefined;\n};\n\nexport const isKey = (data: string, id: string): boolean => keyOf(data)?.id === id;\n\nexport const isAction = (data: string, action: WidgetAction): boolean => {\n const key = keyOf(data);\n return key !== undefined && widgetKeyMatches(key, action);\n};\n\nexport const typedText = (key: KeyEvent): string | undefined =>\n key.text !== undefined && key.text !== \"\" && !MODIFIED.test(key.id) ? key.text : undefined;\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,mBAAmB;AAC5B,SAA4B,wBAAwB;AAMpD,IAAM,WAAW;AAEV,IAAM,sBAAsB,CAAC,SAAkC;AACpE,QAAM,SAA0B,CAAC;AACjC,aAAW,SAAS,YAAY,IAAI,GAAG;AACrC,QAAI,MAAM,SAAS,SAAS,MAAM,IAAI,SAAS,UAAW,QAAO,KAAK,EAAE,MAAM,OAAO,KAAK,MAAM,IAAI,CAAC;AAAA,aAC5F,MAAM,SAAS,QAAS,QAAO,KAAK,EAAE,MAAM,SAAS,MAAM,MAAM,MAAM,KAAK,CAAC;AAAA,EACxF;AACA,SAAO;AACT;AAEO,IAAM,QAAQ,CAAC,SAAuC;AAC3D,QAAM,SAAS,oBAAoB,IAAI;AACvC,QAAM,QAAQ,OAAO,CAAC;AACtB,SAAO,OAAO,WAAW,KAAK,OAAO,SAAS,QAAQ,MAAM,MAAM;AACpE;AAEO,IAAM,QAAQ,CAAC,MAAc,OAAwB,MAAM,IAAI,GAAG,OAAO;AAEzE,IAAM,WAAW,CAAC,MAAc,WAAkC;AACvE,QAAM,MAAM,MAAM,IAAI;AACtB,SAAO,QAAQ,UAAa,iBAAiB,KAAK,MAAM;AAC1D;AAEO,IAAM,YAAY,CAAC,QACxB,IAAI,SAAS,UAAa,IAAI,SAAS,MAAM,CAAC,SAAS,KAAK,IAAI,EAAE,IAAI,IAAI,OAAO;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatTokens,
|
|
3
3
|
safeText
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-C2YMZNT5.js";
|
|
5
5
|
|
|
6
6
|
// src/ui/conversation-chrome.ts
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import path from "node:path";
|
|
9
|
-
import {
|
|
9
|
+
import { truncate, visibleWidth } from "@oh-my-pi/pi-tui/text/width";
|
|
10
10
|
async function readConversationAppearance(cwd, agentDir, projectTrusted) {
|
|
11
|
-
const [{ Settings }, { cfgHideThinkingBlock }
|
|
11
|
+
const [{ Settings }, { cfgHideThinkingBlock }] = await Promise.all([
|
|
12
12
|
import("@oh-my-pi/pi-coding-agent/config/settings"),
|
|
13
|
-
import("@oh-my-pi/pi-coding-agent/session/settings")
|
|
14
|
-
import("@oh-my-pi/pi-coding-agent/modes/settings")
|
|
13
|
+
import("@oh-my-pi/pi-coding-agent/session/settings")
|
|
15
14
|
]);
|
|
16
15
|
const settings = projectTrusted ? await Settings.loadReadOnly({ cwd, agentDir }) : Settings.isolated();
|
|
17
16
|
return {
|
|
18
17
|
editorPaddingX: 0,
|
|
19
|
-
|
|
20
|
-
codeBlockIndent: " ",
|
|
21
|
-
hideThinkingBlock: cfgHideThinkingBlock.get(settings) === true,
|
|
22
|
-
showImages: cfgTerminalShowImages.get(settings) === true
|
|
18
|
+
hideThinkingBlock: cfgHideThinkingBlock.get(settings) === true
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
var footerPath = (cwd) => {
|
|
@@ -45,11 +41,11 @@ function conversationFooter(target, theme, width) {
|
|
|
45
41
|
stats.push(target.contextWindow ? `?/${formatTokens(target.contextWindow)} ctx` : "ctx ?");
|
|
46
42
|
const model = safeText(target.model ?? `${target.runner ?? ""} model unavailable`).trim();
|
|
47
43
|
const thinking = target.thinking ? ` \u2022 ${safeText(target.thinking === "off" ? "thinking off" : target.thinking)}` : "";
|
|
48
|
-
const left =
|
|
49
|
-
const right =
|
|
44
|
+
const left = truncate(stats.join(" "), width);
|
|
45
|
+
const right = truncate(`${model}${thinking}`, Math.max(0, width - visibleWidth(left) - 2), "");
|
|
50
46
|
const gap = " ".repeat(Math.max(0, width - visibleWidth(left) - visibleWidth(right)));
|
|
51
47
|
return [
|
|
52
|
-
|
|
48
|
+
truncate(theme.fg("dim", pwd), width),
|
|
53
49
|
theme.fg("dim", `${left}${gap}${right}`)
|
|
54
50
|
];
|
|
55
51
|
}
|
|
@@ -58,4 +54,4 @@ export {
|
|
|
58
54
|
readConversationAppearance,
|
|
59
55
|
conversationFooter
|
|
60
56
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
57
|
+
//# sourceMappingURL=chunk-XZIQGFF7.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/conversation-chrome.ts"],
|
|
4
|
+
"sourcesContent": ["import { homedir } from \"node:os\";\nimport path from \"node:path\";\nimport type { Theme } from \"@oh-my-pi/pi-tui/theme/contract\";\nimport { truncate, visibleWidth } from \"@oh-my-pi/pi-tui/text/width\";\nimport { formatTokens, safeText } from \"./format.js\";\nimport type { FabricConversationTarget } from \"./conversation.js\";\n\nexport interface FabricConversationAppearance {\n editorPaddingX: number;\n hideThinkingBlock?: boolean;\n}\n\n/** Read OMP appearance settings; cwd and agentDir apply only to trusted project loading. */\nexport async function readConversationAppearance(cwd: string, agentDir: string, projectTrusted: boolean): Promise<FabricConversationAppearance> {\n const [{ Settings }, { cfgHideThinkingBlock }] = await Promise.all([\n import(\"@oh-my-pi/pi-coding-agent/config/settings\"),\n import(\"@oh-my-pi/pi-coding-agent/session/settings\"),\n ]);\n const settings = projectTrusted\n ? await Settings.loadReadOnly({ cwd, agentDir })\n : Settings.isolated();\n return {\n editorPaddingX: 0,\n hideThinkingBlock: cfgHideThinkingBlock.get(settings) === true,\n };\n}\n\nconst footerPath = (cwd: string): string => {\n const home = homedir();\n if (cwd === home) return \"~\";\n return cwd.startsWith(`${home}${path.sep}`) ? `~${cwd.slice(home.length)}` : cwd;\n};\n\n/** Native-shaped footer backed by this participant, never by Main's session stats. */\nexport function conversationFooter(target: FabricConversationTarget | undefined, theme: Theme, width: number): string[] {\n if (!target || width <= 0) return [];\n const location = target.cwd ? footerPath(target.cwd) : \"cwd unavailable\";\n const branch = target.branch ? ` (${target.branch})` : \"\";\n const pwd = safeText(`${location}${branch} \u2022 ${target.name}`);\n const stats = [safeText(target.status)];\n if (target.usage) {\n const usage = target.usage;\n // Agent usage is run-scoped; actor values describe the current/last activation.\n stats.push(\"run\", `\u2191${formatTokens(usage.input)}`, `\u2193${formatTokens(usage.output)}`);\n if (usage.cacheRead > 0) stats.push(`R${formatTokens(usage.cacheRead)}`);\n if (usage.cacheWrite > 0) stats.push(`W${formatTokens(usage.cacheWrite)}`);\n if (Number.isFinite(usage.cost)) stats.push(`$${usage.cost.toFixed(3)}`);\n } else {\n stats.push(\"usage unavailable\");\n }\n // Cumulative run tokens are not current context occupancy. Do not invent a percentage.\n stats.push(target.contextWindow ? `?/${formatTokens(target.contextWindow)} ctx` : \"ctx ?\");\n const model = safeText(target.model ?? `${target.runner ?? \"\"} model unavailable`).trim();\n const thinking = target.thinking ? ` \u2022 ${safeText(target.thinking === \"off\" ? \"thinking off\" : target.thinking)}` : \"\";\n const left = truncate(stats.join(\" \"), width);\n const right = truncate(`${model}${thinking}`, Math.max(0, width - visibleWidth(left) - 2), \"\");\n const gap = \" \".repeat(Math.max(0, width - visibleWidth(left) - visibleWidth(right)));\n return [\n truncate(theme.fg(\"dim\", pwd), width),\n theme.fg(\"dim\", `${left}${gap}${right}`),\n ];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AAAA,SAAS,eAAe;AACxB,OAAO,UAAU;AAEjB,SAAS,UAAU,oBAAoB;AAUvC,eAAsB,2BAA2B,KAAa,UAAkB,gBAAgE;AAC9I,QAAM,CAAC,EAAE,SAAS,GAAG,EAAE,qBAAqB,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACjE,OAAO,2CAA2C;AAAA,IAClD,OAAO,4CAA4C;AAAA,EACrD,CAAC;AACD,QAAM,WAAW,iBACb,MAAM,SAAS,aAAa,EAAE,KAAK,SAAS,CAAC,IAC7C,SAAS,SAAS;AACtB,SAAO;AAAA,IACL,gBAAgB;AAAA,IAChB,mBAAmB,qBAAqB,IAAI,QAAQ,MAAM;AAAA,EAC5D;AACF;AAEA,IAAM,aAAa,CAAC,QAAwB;AAC1C,QAAM,OAAO,QAAQ;AACrB,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AM,QAAQ,SAAS,GAAG,KAAK,GAAG,QAAQ,IAAI,KAAK,IAAI,GAAG,QAAQ,aAAa,IAAI,IAAI,CAAC,GAAG,EAAE;AAC7F,QAAM,MAAM,IAAI,OAAO,KAAK,IAAI,GAAG,QAAQ,aAAa,IAAI,IAAI,aAAa,KAAK,CAAC,CAAC;AACpF,SAAO;AAAA,IACL,SAAS,MAAM,GAAG,OAAO,GAAG,GAAG,KAAK;AAAA,IACpC,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,GAAG,GAAG,KAAK,EAAE;AAAA,EACzC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -304,22 +304,12 @@ var ansi256ToRgb = (index) => {
|
|
|
304
304
|
const gray = 8 + 10 * (Math.min(index, 255) - 232);
|
|
305
305
|
return { r: gray, g: gray, b: gray };
|
|
306
306
|
};
|
|
307
|
-
var parseAnsiBgColor = (sequence) => {
|
|
308
|
-
const truecolor = sequence.match(/\x1b\[4?8;2;(\d+);(\d+);(\d+)m/);
|
|
309
|
-
if (truecolor) {
|
|
310
|
-
return { r: Number(truecolor[1]), g: Number(truecolor[2]), b: Number(truecolor[3]) };
|
|
311
|
-
}
|
|
312
|
-
const indexed = sequence.match(/\x1b\[4?8;5;(\d+)m/);
|
|
313
|
-
if (indexed) return ansi256ToRgb(Number(indexed[1]));
|
|
314
|
-
return void 0;
|
|
315
|
-
};
|
|
316
307
|
var relativeLuminance = ({ r, g, b }) => (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
|
|
317
308
|
var classifyOmpTheme = (theme, env = process.env) => {
|
|
318
309
|
const name = theme?.name?.trim().toLowerCase();
|
|
319
310
|
if (name === "light") return "light";
|
|
320
311
|
if (name === "dark") return "dark";
|
|
321
|
-
|
|
322
|
-
if (background) return relativeLuminance(background) >= 0.5 ? "light" : "dark";
|
|
312
|
+
if (theme?.dark !== void 0) return theme.dark ? "dark" : "light";
|
|
323
313
|
const colorFgBg = env.COLORFGBG;
|
|
324
314
|
if (colorFgBg) {
|
|
325
315
|
const index = colorFgBg.split(";").map((part) => Number.parseInt(part, 10)).filter((part) => Number.isInteger(part) && part >= 0 && part <= 255).at(-1);
|
|
@@ -972,7 +962,7 @@ var formatToolCallDuration = (startedAt, endedAt) => {
|
|
|
972
962
|
import { diffLines } from "diff";
|
|
973
963
|
|
|
974
964
|
// src/ui/diff-background.ts
|
|
975
|
-
import {
|
|
965
|
+
import { truncate, visibleWidth } from "@oh-my-pi/pi-tui/text/width";
|
|
976
966
|
var DIFF_ADD_MARKER = "\0PI_DIFF_ADD\0";
|
|
977
967
|
var DIFF_REMOVE_MARKER = "\0PI_DIFF_REMOVE\0";
|
|
978
968
|
var markDiffLine = (kind, line) => (kind === "add" ? DIFF_ADD_MARKER : DIFF_REMOVE_MARKER) + line;
|
|
@@ -1016,11 +1006,9 @@ var fallbackDiffBg = (kind, intensity) => {
|
|
|
1016
1006
|
return intensity === "medium" ? "\x1B[48;2;78;36;40m" : "\x1B[48;2;50;24;30m";
|
|
1017
1007
|
};
|
|
1018
1008
|
var deriveDiffBg = (kind, theme, intensity) => {
|
|
1019
|
-
const
|
|
1020
|
-
const fg = themed?.getFgAnsi?.(kind === "add" ? "toolDiffAdded" : "toolDiffRemoved");
|
|
1021
|
-
const fgRgb = parseAnsiRgb(fg ?? "");
|
|
1009
|
+
const fgRgb = themeRgb(theme, kind === "add" ? "toolDiffAdded" : "toolDiffRemoved");
|
|
1022
1010
|
if (!fgRgb) return void 0;
|
|
1023
|
-
const base =
|
|
1011
|
+
const base = themeRgb(theme, kind === "add" ? "toolSuccessBg" : "toolErrorBg") ?? themeRgb(theme, "toolSuccessBg") ?? (observedThemeVariant() === "light" ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 });
|
|
1024
1012
|
return `\x1B[48;2;${Math.round(base.r + (fgRgb.r - base.r) * intensity)};${Math.round(base.g + (fgRgb.g - base.g) * intensity)};${Math.round(base.b + (fgRgb.b - base.b) * intensity)}m`;
|
|
1025
1013
|
};
|
|
1026
1014
|
var PRINTABLE_ASCII_RE = /^[\x20-\x7e]*$/;
|
|
@@ -1068,7 +1056,7 @@ var wrapDiffAnsiToWidth = (text, width, maxRows = 3, continuationPrefix = "") =>
|
|
|
1068
1056
|
rowWidth = 0;
|
|
1069
1057
|
}
|
|
1070
1058
|
if (segmentWidth > width && rowWidth === 0) {
|
|
1071
|
-
const clipped =
|
|
1059
|
+
const clipped = truncate(segment, width, "");
|
|
1072
1060
|
if (clipped) {
|
|
1073
1061
|
row += clipped;
|
|
1074
1062
|
rowWidth += visibleWidth(clipped);
|
|
@@ -1088,12 +1076,12 @@ var wrapDiffAnsiToWidth = (text, width, maxRows = 3, continuationPrefix = "") =>
|
|
|
1088
1076
|
};
|
|
1089
1077
|
var truncateWrappedRow = (row, rowWidth, width) => {
|
|
1090
1078
|
if (rowWidth <= width && TRUNCATION_SAFE_RE.test(row)) return row;
|
|
1091
|
-
return
|
|
1079
|
+
return truncate(row, width, "");
|
|
1092
1080
|
};
|
|
1093
1081
|
var truncateLastRow = (rows, width) => {
|
|
1094
1082
|
const last = rows.at(-1) ?? "";
|
|
1095
1083
|
if (visibleWidth(last) >= width && width > 1) {
|
|
1096
|
-
rows[rows.length - 1] =
|
|
1084
|
+
rows[rows.length - 1] = truncate(last, width - 1, "") + "\u203A";
|
|
1097
1085
|
}
|
|
1098
1086
|
return rows;
|
|
1099
1087
|
};
|
|
@@ -1124,12 +1112,10 @@ var updateAnsiState = (current, sequence) => {
|
|
|
1124
1112
|
return current + sequence;
|
|
1125
1113
|
};
|
|
1126
1114
|
var replaceAnsi = (current, pattern, replacement) => current.replace(pattern, "") + replacement;
|
|
1127
|
-
var
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
if (indexed) return ansi256ToRgb(Number(indexed[1]));
|
|
1132
|
-
return void 0;
|
|
1115
|
+
var themeRgb = (theme, key) => {
|
|
1116
|
+
if (!theme?.has(key)) return void 0;
|
|
1117
|
+
const match = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(theme.hex(key));
|
|
1118
|
+
return match ? { r: Number.parseInt(match[1], 16), g: Number.parseInt(match[2], 16), b: Number.parseInt(match[3], 16) } : void 0;
|
|
1133
1119
|
};
|
|
1134
1120
|
|
|
1135
1121
|
// src/ui/word-diff/normalize.ts
|
|
@@ -3423,7 +3409,7 @@ var renderDiff = (diff, filePath, theme, options, limitOverride) => {
|
|
|
3423
3409
|
const safe = escapeControlChars3(raw);
|
|
3424
3410
|
const trimmed = safe.trim();
|
|
3425
3411
|
if (trimmed === "...") return theme.fg("muted", " --- unchanged lines hidden ---");
|
|
3426
|
-
if (trimmed.startsWith("@@")) return theme.fg("accent", theme.
|
|
3412
|
+
if (trimmed.startsWith("@@")) return theme.fg("accent", theme.style("strong", safe));
|
|
3427
3413
|
if (trimmed.startsWith("---") || trimmed.startsWith("+++") || trimmed.startsWith("diff ") || trimmed.startsWith("index ")) {
|
|
3428
3414
|
return theme.fg("muted", safe);
|
|
3429
3415
|
}
|
|
@@ -3970,7 +3956,7 @@ var renderCoreToolBody = (audit, theme, options) => {
|
|
|
3970
3956
|
var coreToolTitle = (audit, theme, options) => {
|
|
3971
3957
|
observeOmpTheme(theme);
|
|
3972
3958
|
if (!coreToolRendererEnabled(audit, options.settings) || !audit.tool) return null;
|
|
3973
|
-
const title = theme.fg("toolTitle", theme.
|
|
3959
|
+
const title = theme.fg("toolTitle", theme.style("strong", audit.tool));
|
|
3974
3960
|
const timing = options.settings.toolCallTiming ? formatToolCallDuration(audit.startedAt, audit.endedAt) : void 0;
|
|
3975
3961
|
const filePath = argString(audit, "path") ?? "";
|
|
3976
3962
|
if (audit.tool === "bash") {
|
|
@@ -4030,12 +4016,8 @@ var coreToolTitle = (audit, theme, options) => {
|
|
|
4030
4016
|
|
|
4031
4017
|
// src/ui/fabric-render.ts
|
|
4032
4018
|
import { createHash } from "node:crypto";
|
|
4033
|
-
import {
|
|
4034
|
-
|
|
4035
|
-
truncateToWidth as truncateToWidth2,
|
|
4036
|
-
visibleWidth as visibleWidth2,
|
|
4037
|
-
wrapTextWithAnsi
|
|
4038
|
-
} from "@oh-my-pi/pi-tui";
|
|
4019
|
+
import { getKeybindings } from "@oh-my-pi/pi-coding-agent/config/keybindings/keybindings";
|
|
4020
|
+
import { truncate as truncate2, visibleWidth as visibleWidth2, wrap } from "@oh-my-pi/pi-tui/text/width";
|
|
4039
4021
|
var configuredDiffWrapRows = Number.parseInt(
|
|
4040
4022
|
process.env.CODE_PREVIEW_DIFF_WRAP_ROWS ?? "",
|
|
4041
4023
|
10
|
|
@@ -4094,7 +4076,7 @@ var safeTerminalText = (value) => value.replace(/[\u0000-\u0008\u000b-\u001f\u00
|
|
|
4094
4076
|
return `\\x${code}`;
|
|
4095
4077
|
});
|
|
4096
4078
|
var truncateBoundedLine = (line, width) => {
|
|
4097
|
-
const truncated =
|
|
4079
|
+
const truncated = truncate2(line, width, "");
|
|
4098
4080
|
if (visibleWidth2(line) <= width) return truncated;
|
|
4099
4081
|
if (truncated.endsWith(FULL_SGR_RESET)) {
|
|
4100
4082
|
return truncated.slice(0, -FULL_SGR_RESET.length) + TEXT_SGR_RESET;
|
|
@@ -4128,10 +4110,7 @@ var BoundedLineList = class _BoundedLineList {
|
|
|
4128
4110
|
const { kind, line } = parseMarkedDiffLine(rawLine);
|
|
4129
4111
|
if (!kind) {
|
|
4130
4112
|
const continuationIndent = width > 2 ? " " : "";
|
|
4131
|
-
const wrapped =
|
|
4132
|
-
line,
|
|
4133
|
-
Math.max(1, width - visibleWidth2(continuationIndent))
|
|
4134
|
-
);
|
|
4113
|
+
const wrapped = wrap(line, Math.max(1, width - visibleWidth2(continuationIndent)));
|
|
4135
4114
|
if (wrapped.length === 0) wrapped.push("");
|
|
4136
4115
|
const limit = Math.max(1, this.wrapRowLimit ?? wrapped.length);
|
|
4137
4116
|
const kept = wrapped.slice(0, limit);
|
|
@@ -4210,7 +4189,7 @@ var visibleMulticallAudits = (audits, expanded) => {
|
|
|
4210
4189
|
function expandHint(theme) {
|
|
4211
4190
|
let keys = [];
|
|
4212
4191
|
try {
|
|
4213
|
-
keys = getKeybindings().
|
|
4192
|
+
keys = getKeybindings().keysFor(EXPAND_KEYBINDING);
|
|
4214
4193
|
} catch {
|
|
4215
4194
|
keys = [];
|
|
4216
4195
|
}
|
|
@@ -4560,7 +4539,7 @@ var nestedCallTitleText = (audit, theme, invalidate, core) => {
|
|
|
4560
4539
|
const provider = audit.provider ?? ref.split(".")[0] ?? ref;
|
|
4561
4540
|
const tool = audit.tool ?? ref.split(".")[1] ?? ref;
|
|
4562
4541
|
const toolLabel = provider === "judgment" && tool === "ask" ? "judgment.ask" : tool;
|
|
4563
|
-
const title = theme.fg("toolTitle", theme.
|
|
4542
|
+
const title = theme.fg("toolTitle", theme.style("strong", toolLabel));
|
|
4564
4543
|
const args = audit.args ?? {};
|
|
4565
4544
|
const providerDetail = providerCallDetail(
|
|
4566
4545
|
provider,
|
|
@@ -5112,4 +5091,4 @@ export {
|
|
|
5112
5091
|
formatJsonAsYaml,
|
|
5113
5092
|
formatFabricValue
|
|
5114
5093
|
};
|
|
5115
|
-
//# sourceMappingURL=chunk-
|
|
5094
|
+
//# sourceMappingURL=chunk-ZJ7HHWW4.js.map
|