@narumitw/pi-starship 0.60.1 → 0.62.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/README.md +63 -6
- package/dist/chunks/chunk-43VIENBN.ts +1586 -0
- package/dist/chunks/chunk-43VIENBN.ts.map +7 -0
- package/dist/chunks/chunk-HPZTMIZS.ts +646 -0
- package/dist/chunks/chunk-HPZTMIZS.ts.map +7 -0
- package/dist/chunks/chunk-IYDZ3R2T.ts +69 -0
- package/dist/chunks/chunk-IYDZ3R2T.ts.map +7 -0
- package/dist/chunks/chunk-KP33I6BR.ts +579 -0
- package/dist/chunks/chunk-KP33I6BR.ts.map +7 -0
- package/dist/chunks/{chunk-KZZKGGFW.ts → chunk-PWTSHSP3.ts} +853 -1001
- package/dist/chunks/chunk-PWTSHSP3.ts.map +7 -0
- package/dist/chunks/{chunk-PD457PX5.ts → chunk-S2KBLHE2.ts} +75 -10
- package/dist/chunks/chunk-S2KBLHE2.ts.map +7 -0
- package/dist/chunks/chunk-XQUIQO2G.ts +20 -0
- package/dist/chunks/chunk-XQUIQO2G.ts.map +7 -0
- package/dist/chunks/{chunk-ADX4CY27.ts → chunk-XTLQ4WUL.ts} +1 -1
- package/dist/chunks/chunk-XTLQ4WUL.ts.map +7 -0
- package/dist/chunks/{cloud-EPAEV4ZB.ts → cloud-J2ZOE3HE.ts} +6 -2
- package/dist/chunks/cloud-J2ZOE3HE.ts.map +7 -0
- package/dist/chunks/command-configuration-menu-S2LXCOJG.ts +147 -0
- package/dist/chunks/command-configuration-menu-S2LXCOJG.ts.map +7 -0
- package/dist/chunks/command-settings-chat-O34BEU4X.ts +1041 -0
- package/dist/chunks/command-settings-chat-O34BEU4X.ts.map +7 -0
- package/dist/chunks/commands-ZYIJVIEJ.ts +1022 -0
- package/dist/chunks/commands-ZYIJVIEJ.ts.map +7 -0
- package/dist/chunks/{deployment-7J54EHNR.ts → deployment-NOJ2KCLI.ts} +85 -5
- package/dist/chunks/deployment-NOJ2KCLI.ts.map +7 -0
- package/dist/chunks/{development-IWJAAAEV.ts → development-T3XXVVDP.ts} +67 -15
- package/dist/chunks/development-T3XXVVDP.ts.map +7 -0
- package/dist/chunks/directory-OX6BWJZA.ts +31 -0
- package/dist/chunks/directory-OX6BWJZA.ts.map +7 -0
- package/dist/chunks/{execution-P4WZALW2.ts → execution-R2OHIP2L.ts} +8 -4
- package/dist/chunks/execution-R2OHIP2L.ts.map +7 -0
- package/dist/chunks/jujutsu-XLDYKSX2.ts +174 -0
- package/dist/chunks/jujutsu-XLDYKSX2.ts.map +7 -0
- package/dist/chunks/languages-CBQNNYXM.ts +262 -0
- package/dist/chunks/languages-CBQNNYXM.ts.map +7 -0
- package/dist/chunks/{package-H24VJEX3.ts → package-7KVAK3TC.ts} +6 -2
- package/dist/chunks/package-7KVAK3TC.ts.map +7 -0
- package/dist/chunks/system-574MHB4R.ts +165 -0
- package/dist/chunks/system-574MHB4R.ts.map +7 -0
- package/dist/index.ts +558 -150
- package/dist/index.ts.map +4 -4
- package/package.json +5 -1
- package/skills/configure-pi-starship/SKILL.md +14 -0
- package/skills/configure-pi-starship/references/configuration.md +109 -24
- package/skills/configure-pi-starship/references/module-catalog.md +278 -25
- package/skills/configure-pi-starship/references/modules.md +213 -36
- package/skills/configure-pi-starship/references/runtime-and-security.md +88 -28
- package/src/command-configuration-menu.ts +155 -0
- package/src/command-configuration.ts +9 -84
- package/src/command-preview.ts +3 -3
- package/src/command-settings-chat.ts +210 -0
- package/src/commands.ts +54 -98
- package/src/config/module-options.ts +112 -0
- package/src/config.ts +17 -53
- package/src/effective-config.ts +5 -4
- package/src/format/bounded-regex.ts +66 -0
- package/src/format/version.ts +24 -0
- package/src/modules/catalog.ts +10 -0
- package/src/modules/cloud.ts +1 -0
- package/src/modules/deployment.ts +8 -0
- package/src/modules/development.ts +20 -2
- package/src/modules/directory.ts +171 -51
- package/src/modules/execution.ts +2 -0
- package/src/modules/git/branch.ts +19 -4
- package/src/modules/git/commit.ts +9 -2
- package/src/modules/git/metrics.ts +9 -4
- package/src/modules/git/runtime.ts +122 -33
- package/src/modules/git/state.ts +23 -2
- package/src/modules/git/status-templates.ts +58 -0
- package/src/modules/git/status.ts +96 -30
- package/src/modules/jujutsu.ts +225 -0
- package/src/modules/languages.ts +26 -2
- package/src/modules/package.ts +1 -0
- package/src/modules/render.ts +42 -16
- package/src/modules/system.ts +54 -0
- package/src/modules/time-format.ts +188 -0
- package/src/modules/time.ts +11 -5
- package/src/modules/types.ts +42 -4
- package/src/pi-starship.ts +56 -12
- package/src/profile-store.ts +5 -0
- package/src/runtime/cloud.ts +3 -0
- package/src/runtime/command.ts +1 -1
- package/src/runtime/deployment.ts +120 -4
- package/src/runtime/development.ts +86 -13
- package/src/runtime/directory.ts +33 -0
- package/src/runtime/execution.ts +12 -2
- package/src/runtime/helpers.ts +57 -8
- package/src/runtime/jujutsu.ts +225 -0
- package/src/runtime/languages.ts +106 -19
- package/src/runtime/package.ts +3 -0
- package/src/runtime/system.ts +202 -0
- package/src/runtime/types.ts +3 -0
- package/src/runtime/version-requirements.ts +30 -0
- package/src/runtime/workspace.ts +12 -1
- package/src/settings-agent.ts +80 -0
- package/src/settings-chat-transcript.ts +140 -0
- package/src/settings-chat-ui.ts +426 -0
- package/src/settings-draft.ts +260 -0
- package/src/settings-snapshots.ts +41 -0
- package/dist/chunks/chunk-ADX4CY27.ts.map +0 -7
- package/dist/chunks/chunk-KZZKGGFW.ts.map +0 -7
- package/dist/chunks/chunk-PD457PX5.ts.map +0 -7
- package/dist/chunks/cloud-EPAEV4ZB.ts.map +0 -7
- package/dist/chunks/commands-C2VJ6ZBN.ts +0 -3374
- package/dist/chunks/commands-C2VJ6ZBN.ts.map +0 -7
- package/dist/chunks/deployment-7J54EHNR.ts.map +0 -7
- package/dist/chunks/development-IWJAAAEV.ts.map +0 -7
- package/dist/chunks/execution-P4WZALW2.ts.map +0 -7
- package/dist/chunks/languages-JO6R2PHL.ts +0 -168
- package/dist/chunks/languages-JO6R2PHL.ts.map +0 -7
- package/dist/chunks/package-H24VJEX3.ts.map +0 -7
- package/src/command-inspector.ts +0 -41
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- the generated entry uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/format/style.ts
|
|
5
|
+
import { backgroundAnsi, foregroundAnsi } from "@earendil-works/pi-tui";
|
|
6
|
+
|
|
7
|
+
// src/format/terminal-safety.ts
|
|
8
|
+
import { sanitizeTerminalDocument } from "@narumitw/pi-tui-kit/terminal-document";
|
|
9
|
+
var PREFIX = "\x1B]8;;";
|
|
10
|
+
var BEL = "\x07";
|
|
11
|
+
var ST = "\x1B\\";
|
|
12
|
+
function sanitizeFormatText(value) {
|
|
13
|
+
let output = "";
|
|
14
|
+
let offset = 0;
|
|
15
|
+
let cursor = 0;
|
|
16
|
+
while (cursor < value.length) {
|
|
17
|
+
const start = value.indexOf(PREFIX, cursor);
|
|
18
|
+
if (start < 0) break;
|
|
19
|
+
const opening = findTerminator(value, start + PREFIX.length);
|
|
20
|
+
if (!opening) break;
|
|
21
|
+
const closing = findLinkEnd(value, opening.end);
|
|
22
|
+
if (!closing) break;
|
|
23
|
+
cursor = closing.end;
|
|
24
|
+
const url = safeHyperlinkUrl(value.slice(start + PREFIX.length, opening.start));
|
|
25
|
+
if (!url) continue;
|
|
26
|
+
output += sanitizePlainText(value.slice(offset, start));
|
|
27
|
+
const label = sanitizePlainText(value.slice(opening.end, closing.start));
|
|
28
|
+
if (label) {
|
|
29
|
+
const openTerminator = value.slice(opening.start, opening.end);
|
|
30
|
+
const closeTerminator = value.slice(closing.start + PREFIX.length, closing.end);
|
|
31
|
+
output += `${PREFIX}${url}${openTerminator}${label}${PREFIX}${closeTerminator}`;
|
|
32
|
+
}
|
|
33
|
+
offset = closing.end;
|
|
34
|
+
}
|
|
35
|
+
return output + sanitizePlainText(value.slice(offset));
|
|
36
|
+
}
|
|
37
|
+
function sanitizePlainText(value) {
|
|
38
|
+
return sanitizeTerminalDocument(value).replace(/\t/gu, " ");
|
|
39
|
+
}
|
|
40
|
+
function terminatorEnd(value, start) {
|
|
41
|
+
if (value.startsWith(BEL, start)) return start + BEL.length;
|
|
42
|
+
if (value.startsWith(ST, start)) return start + ST.length;
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function findTerminator(value, start) {
|
|
46
|
+
for (let index = start; index < value.length; index += 1) {
|
|
47
|
+
const end = terminatorEnd(value, index);
|
|
48
|
+
if (end !== void 0) return { start: index, end };
|
|
49
|
+
}
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
function findLinkEnd(value, start) {
|
|
53
|
+
let index = value.indexOf(PREFIX, start);
|
|
54
|
+
while (index >= 0) {
|
|
55
|
+
const end = terminatorEnd(value, index + PREFIX.length);
|
|
56
|
+
if (end !== void 0) return { start: index, end };
|
|
57
|
+
index = value.indexOf(PREFIX, index + PREFIX.length);
|
|
58
|
+
}
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
function safeHyperlinkUrl(value) {
|
|
62
|
+
if (value.length > 4096 || Array.from(value).some((character) => {
|
|
63
|
+
const code = character.codePointAt(0) ?? 0;
|
|
64
|
+
return code <= 31 || code >= 127 && code <= 159 || code >= 55296 && code <= 57343;
|
|
65
|
+
}))
|
|
66
|
+
return void 0;
|
|
67
|
+
try {
|
|
68
|
+
const url = new URL(value);
|
|
69
|
+
if (url.protocol !== "http:" && url.protocol !== "https:" || url.username || url.password) return void 0;
|
|
70
|
+
const normalized = url.toString();
|
|
71
|
+
return normalized.length <= 4096 ? normalized : void 0;
|
|
72
|
+
} catch {
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// src/format/theme-colors.ts
|
|
78
|
+
var THEME_ROLES = {
|
|
79
|
+
accent: true,
|
|
80
|
+
border: true,
|
|
81
|
+
borderAccent: true,
|
|
82
|
+
borderMuted: true,
|
|
83
|
+
success: true,
|
|
84
|
+
error: true,
|
|
85
|
+
warning: true,
|
|
86
|
+
muted: true,
|
|
87
|
+
dim: true,
|
|
88
|
+
text: true,
|
|
89
|
+
thinkingText: true,
|
|
90
|
+
scrollbarTrack: true,
|
|
91
|
+
scrollbarThumb: true,
|
|
92
|
+
selectedBg: true,
|
|
93
|
+
searchMatchBg: true,
|
|
94
|
+
searchMatchText: true,
|
|
95
|
+
userMessageBg: true,
|
|
96
|
+
userMessageText: true,
|
|
97
|
+
customMessageBg: true,
|
|
98
|
+
customMessageText: true,
|
|
99
|
+
customMessageLabel: true,
|
|
100
|
+
toolPendingBg: true,
|
|
101
|
+
toolSuccessBg: true,
|
|
102
|
+
toolErrorBg: true,
|
|
103
|
+
toolTitle: true,
|
|
104
|
+
toolOutput: true,
|
|
105
|
+
mdHeading: true,
|
|
106
|
+
mdLink: true,
|
|
107
|
+
mdLinkUrl: true,
|
|
108
|
+
mdCode: true,
|
|
109
|
+
mdCodeBlock: true,
|
|
110
|
+
mdCodeBlockBorder: true,
|
|
111
|
+
mdQuote: true,
|
|
112
|
+
mdQuoteBorder: true,
|
|
113
|
+
mdHr: true,
|
|
114
|
+
mdListBullet: true,
|
|
115
|
+
toolDiffAdded: true,
|
|
116
|
+
toolDiffRemoved: true,
|
|
117
|
+
toolDiffContext: true,
|
|
118
|
+
syntaxComment: true,
|
|
119
|
+
syntaxKeyword: true,
|
|
120
|
+
syntaxFunction: true,
|
|
121
|
+
syntaxVariable: true,
|
|
122
|
+
syntaxString: true,
|
|
123
|
+
syntaxNumber: true,
|
|
124
|
+
syntaxType: true,
|
|
125
|
+
syntaxOperator: true,
|
|
126
|
+
syntaxPunctuation: true,
|
|
127
|
+
thinkingOff: true,
|
|
128
|
+
thinkingMinimal: true,
|
|
129
|
+
thinkingLow: true,
|
|
130
|
+
thinkingMedium: true,
|
|
131
|
+
thinkingHigh: true,
|
|
132
|
+
thinkingXhigh: true,
|
|
133
|
+
thinkingMax: true,
|
|
134
|
+
bashMode: true
|
|
135
|
+
};
|
|
136
|
+
function isThemeRole(role) {
|
|
137
|
+
return Object.hasOwn(THEME_ROLES, role);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// src/format/style.ts
|
|
141
|
+
function isFillChunk(chunk) {
|
|
142
|
+
return "type" in chunk && chunk.type === "fill";
|
|
143
|
+
}
|
|
144
|
+
var NAMED_COLORS = /* @__PURE__ */ new Set([
|
|
145
|
+
"black",
|
|
146
|
+
"red",
|
|
147
|
+
"green",
|
|
148
|
+
"yellow",
|
|
149
|
+
"blue",
|
|
150
|
+
"purple",
|
|
151
|
+
"cyan",
|
|
152
|
+
"white",
|
|
153
|
+
"bright-black",
|
|
154
|
+
"bright-red",
|
|
155
|
+
"bright-green",
|
|
156
|
+
"bright-yellow",
|
|
157
|
+
"bright-blue",
|
|
158
|
+
"bright-purple",
|
|
159
|
+
"bright-cyan",
|
|
160
|
+
"bright-white"
|
|
161
|
+
]);
|
|
162
|
+
var FOREGROUND_CODES = {
|
|
163
|
+
black: 30,
|
|
164
|
+
red: 31,
|
|
165
|
+
green: 32,
|
|
166
|
+
yellow: 33,
|
|
167
|
+
blue: 34,
|
|
168
|
+
purple: 35,
|
|
169
|
+
cyan: 36,
|
|
170
|
+
white: 37,
|
|
171
|
+
"bright-black": 90,
|
|
172
|
+
"bright-red": 91,
|
|
173
|
+
"bright-green": 92,
|
|
174
|
+
"bright-yellow": 93,
|
|
175
|
+
"bright-blue": 94,
|
|
176
|
+
"bright-purple": 95,
|
|
177
|
+
"bright-cyan": 96,
|
|
178
|
+
"bright-white": 97
|
|
179
|
+
};
|
|
180
|
+
function isValidStyle(styleString, palette = {}) {
|
|
181
|
+
return parseStyleResult(styleString, palette).valid;
|
|
182
|
+
}
|
|
183
|
+
function parseStyleResult(styleString, palette = {}) {
|
|
184
|
+
const tokens = styleString.split(/\s+/u).filter(Boolean).map(normalizeStyleToken);
|
|
185
|
+
if (tokens.some(({ token, foreground }) => foreground && token === "none")) {
|
|
186
|
+
return { valid: true, style: void 0 };
|
|
187
|
+
}
|
|
188
|
+
const style = {};
|
|
189
|
+
for (const { token, foreground } of tokens) {
|
|
190
|
+
if (applyModifier(style, token)) continue;
|
|
191
|
+
if (token === "prev_fg" || token === "prev_bg") {
|
|
192
|
+
const source = token === "prev_fg" ? "foreground" : "background";
|
|
193
|
+
if (foreground) style.foregroundPrevious = source;
|
|
194
|
+
else style.backgroundPrevious = source;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const color = parseColor(token, palette);
|
|
198
|
+
if (!foreground && !color && !token.toLowerCase().startsWith("pi:")) {
|
|
199
|
+
delete style.background;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
if (!color) return { valid: false, style: void 0 };
|
|
203
|
+
if (foreground) style.foreground = color;
|
|
204
|
+
else style.background = color;
|
|
205
|
+
}
|
|
206
|
+
return { valid: true, style };
|
|
207
|
+
}
|
|
208
|
+
function parseStyle(styleString, palette = {}) {
|
|
209
|
+
return parseStyleResult(styleString, palette).style;
|
|
210
|
+
}
|
|
211
|
+
function normalizeStyleToken(rawToken) {
|
|
212
|
+
if (/^fg:/iu.test(rawToken)) {
|
|
213
|
+
return { token: normalizeColorToken(rawToken.replace(/^(?:fg:)+/iu, "")), foreground: true };
|
|
214
|
+
}
|
|
215
|
+
if (/^bg:/iu.test(rawToken)) {
|
|
216
|
+
return { token: normalizeColorToken(rawToken.replace(/^(?:bg:)+/iu, "")), foreground: false };
|
|
217
|
+
}
|
|
218
|
+
return { token: normalizeColorToken(rawToken), foreground: true };
|
|
219
|
+
}
|
|
220
|
+
function normalizeColorToken(token) {
|
|
221
|
+
return /^pi:/iu.test(token) ? `pi:${token.slice(3)}` : token.toLowerCase();
|
|
222
|
+
}
|
|
223
|
+
function applyModifier(style, token) {
|
|
224
|
+
switch (token) {
|
|
225
|
+
case "bold":
|
|
226
|
+
style.bold = true;
|
|
227
|
+
return true;
|
|
228
|
+
case "italic":
|
|
229
|
+
style.italic = true;
|
|
230
|
+
return true;
|
|
231
|
+
case "underline":
|
|
232
|
+
style.underline = true;
|
|
233
|
+
return true;
|
|
234
|
+
case "dimmed":
|
|
235
|
+
style.dimmed = true;
|
|
236
|
+
return true;
|
|
237
|
+
case "inverted":
|
|
238
|
+
style.inverted = true;
|
|
239
|
+
return true;
|
|
240
|
+
case "blink":
|
|
241
|
+
style.blink = true;
|
|
242
|
+
return true;
|
|
243
|
+
case "hidden":
|
|
244
|
+
style.hidden = true;
|
|
245
|
+
return true;
|
|
246
|
+
case "strikethrough":
|
|
247
|
+
style.strikethrough = true;
|
|
248
|
+
return true;
|
|
249
|
+
default:
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function parseColor(token, palette = {}) {
|
|
254
|
+
const paletteKey = token.toLowerCase();
|
|
255
|
+
const paletteValue = Object.hasOwn(palette, paletteKey) ? palette[paletteKey] : void 0;
|
|
256
|
+
if (paletteValue !== void 0) return parseColor(normalizeColorToken(paletteValue), {});
|
|
257
|
+
token = normalizeColorToken(token);
|
|
258
|
+
if (token.startsWith("pi:")) {
|
|
259
|
+
const role = token.slice(3);
|
|
260
|
+
return isThemeRole(role) ? { kind: "theme", role } : void 0;
|
|
261
|
+
}
|
|
262
|
+
if (NAMED_COLORS.has(token)) {
|
|
263
|
+
return { kind: "named", name: token };
|
|
264
|
+
}
|
|
265
|
+
if (/^\d{1,3}$/u.test(token)) {
|
|
266
|
+
const value = Number(token);
|
|
267
|
+
return value <= 255 ? { kind: "fixed", value } : void 0;
|
|
268
|
+
}
|
|
269
|
+
const rgb = /^#([0-9a-f]{6})$/iu.exec(token);
|
|
270
|
+
if (!rgb?.[1]) return void 0;
|
|
271
|
+
return {
|
|
272
|
+
kind: "rgb",
|
|
273
|
+
red: Number.parseInt(rgb[1].slice(0, 2), 16),
|
|
274
|
+
green: Number.parseInt(rgb[1].slice(2, 4), 16),
|
|
275
|
+
blue: Number.parseInt(rgb[1].slice(4, 6), 16)
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function renderChunksToAnsi(chunks, trueColor = true, themeColors) {
|
|
279
|
+
const runs = [];
|
|
280
|
+
let previous;
|
|
281
|
+
for (const chunk of chunks) {
|
|
282
|
+
if (isFillChunk(chunk)) continue;
|
|
283
|
+
const style = resolveStyle(chunk.style, previous);
|
|
284
|
+
const text = sanitizeFormatText(chunk.text);
|
|
285
|
+
const last = runs.at(-1);
|
|
286
|
+
if (text && last && stylesEqual(last.style, style)) last.text += text;
|
|
287
|
+
else if (text) runs.push({ text, style });
|
|
288
|
+
previous = style;
|
|
289
|
+
}
|
|
290
|
+
return runs.map(({ text, style }) => {
|
|
291
|
+
const codes = ansiCodes(style, trueColor);
|
|
292
|
+
const prefix = themeColorAnsi(style.foreground, false, trueColor, themeColors) + themeColorAnsi(style.background, true, trueColor, themeColors) + (codes.length > 0 ? `\x1B[${codes.join(";")}m` : "");
|
|
293
|
+
return prefix ? `${prefix}${text}\x1B[0m` : text;
|
|
294
|
+
}).join("");
|
|
295
|
+
}
|
|
296
|
+
function stylesEqual(left, right) {
|
|
297
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
298
|
+
}
|
|
299
|
+
function resolveStyle(style, previous) {
|
|
300
|
+
if (!style) return {};
|
|
301
|
+
const { foregroundPrevious, backgroundPrevious, ...resolved } = style;
|
|
302
|
+
return {
|
|
303
|
+
...resolved,
|
|
304
|
+
foreground: resolveColor(style.foreground, foregroundPrevious, previous),
|
|
305
|
+
background: resolveColor(style.background, backgroundPrevious, previous)
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function resolveColor(fallback, source, previous) {
|
|
309
|
+
if (!source || !previous) return fallback;
|
|
310
|
+
return source === "foreground" ? previous.foreground : previous.background;
|
|
311
|
+
}
|
|
312
|
+
function ansiCodes(style, trueColor) {
|
|
313
|
+
const codes = [];
|
|
314
|
+
if (style.foreground) codes.push(...colorCodes(style.foreground, false, trueColor));
|
|
315
|
+
if (style.background) codes.push(...colorCodes(style.background, true, trueColor));
|
|
316
|
+
if (style.bold) codes.push("1");
|
|
317
|
+
if (style.dimmed) codes.push("2");
|
|
318
|
+
if (style.italic) codes.push("3");
|
|
319
|
+
if (style.underline) codes.push("4");
|
|
320
|
+
if (style.blink) codes.push("5");
|
|
321
|
+
if (style.inverted) codes.push("7");
|
|
322
|
+
if (style.hidden) codes.push("8");
|
|
323
|
+
if (style.strikethrough) codes.push("9");
|
|
324
|
+
return codes;
|
|
325
|
+
}
|
|
326
|
+
function themeColorAnsi(color, background, trueColor, themeColors) {
|
|
327
|
+
if (color?.kind !== "theme" || !themeColors) return "";
|
|
328
|
+
const mode = trueColor ? "truecolor" : "256color";
|
|
329
|
+
return (background ? backgroundAnsi : foregroundAnsi)(themeColors[color.role], mode);
|
|
330
|
+
}
|
|
331
|
+
function colorCodes(color, background, trueColor) {
|
|
332
|
+
if (color.kind === "theme") return [];
|
|
333
|
+
if (color.kind === "named") {
|
|
334
|
+
const foreground = FOREGROUND_CODES[color.name];
|
|
335
|
+
return [`${background ? foreground + 10 : foreground}`];
|
|
336
|
+
}
|
|
337
|
+
if (color.kind === "fixed") return [background ? "48" : "38", "5", `${color.value}`];
|
|
338
|
+
if (!trueColor) {
|
|
339
|
+
return [background ? "48" : "38", "5", `${rgbToAnsi256(color.red, color.green, color.blue)}`];
|
|
340
|
+
}
|
|
341
|
+
return [background ? "48" : "38", "2", `${color.red}`, `${color.green}`, `${color.blue}`];
|
|
342
|
+
}
|
|
343
|
+
function rgbToAnsi256(red, green, blue) {
|
|
344
|
+
const channels = [red, green, blue].map((value) => Math.round(value / 255 * 5));
|
|
345
|
+
return 16 + 36 * (channels[0] ?? 0) + 6 * (channels[1] ?? 0) + (channels[2] ?? 0);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/format/formatter.ts
|
|
349
|
+
var FormatSyntaxError = class extends Error {
|
|
350
|
+
offset;
|
|
351
|
+
constructor(message, offset) {
|
|
352
|
+
super(`${message} at offset ${offset}`);
|
|
353
|
+
this.name = "FormatSyntaxError";
|
|
354
|
+
this.offset = offset;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
var FUNCTIONAL = /* @__PURE__ */ new Set(["[", "]", "(", ")", "\\", "$"]);
|
|
358
|
+
function parseFormat(format) {
|
|
359
|
+
const parser = new FormatParser(format);
|
|
360
|
+
const nodes = parser.parseNodes();
|
|
361
|
+
if (!parser.done()) throw new FormatSyntaxError("Unexpected character", parser.offset());
|
|
362
|
+
return nodes;
|
|
363
|
+
}
|
|
364
|
+
var FormatParser = class {
|
|
365
|
+
constructor(input) {
|
|
366
|
+
this.input = input;
|
|
367
|
+
}
|
|
368
|
+
input;
|
|
369
|
+
index = 0;
|
|
370
|
+
offset() {
|
|
371
|
+
return this.index;
|
|
372
|
+
}
|
|
373
|
+
done() {
|
|
374
|
+
return this.index === this.input.length;
|
|
375
|
+
}
|
|
376
|
+
parseNodes(end) {
|
|
377
|
+
const nodes = [];
|
|
378
|
+
let text = "";
|
|
379
|
+
const flushText = () => {
|
|
380
|
+
if (!text) return;
|
|
381
|
+
nodes.push({ type: "text", value: text });
|
|
382
|
+
text = "";
|
|
383
|
+
};
|
|
384
|
+
while (!this.done()) {
|
|
385
|
+
const current = this.input[this.index];
|
|
386
|
+
if (current === end) {
|
|
387
|
+
flushText();
|
|
388
|
+
this.index += 1;
|
|
389
|
+
return nodes;
|
|
390
|
+
}
|
|
391
|
+
if (current === "\\") {
|
|
392
|
+
const escaped = this.input[this.index + 1];
|
|
393
|
+
if (!escaped || !FUNCTIONAL.has(escaped)) {
|
|
394
|
+
throw new FormatSyntaxError("Invalid escape", this.index);
|
|
395
|
+
}
|
|
396
|
+
text += escaped;
|
|
397
|
+
this.index += 2;
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
if (current === "$") {
|
|
401
|
+
flushText();
|
|
402
|
+
nodes.push({ type: "variable", name: this.parseVariable() });
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
if (current === "[") {
|
|
406
|
+
flushText();
|
|
407
|
+
this.index += 1;
|
|
408
|
+
const children = this.parseNodes("]");
|
|
409
|
+
if (this.input[this.index] !== "(") {
|
|
410
|
+
throw new FormatSyntaxError("Text group requires a style", this.index);
|
|
411
|
+
}
|
|
412
|
+
this.index += 1;
|
|
413
|
+
nodes.push({ type: "group", children, style: this.parseStyleNodes() });
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (current === "(") {
|
|
417
|
+
flushText();
|
|
418
|
+
this.index += 1;
|
|
419
|
+
nodes.push({ type: "conditional", children: this.parseNodes(")") });
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (current === "]" || current === ")") {
|
|
423
|
+
throw new FormatSyntaxError(`Unexpected ${current}`, this.index);
|
|
424
|
+
}
|
|
425
|
+
text += current;
|
|
426
|
+
this.index += 1;
|
|
427
|
+
}
|
|
428
|
+
if (end) throw new FormatSyntaxError(`Missing ${end}`, this.index);
|
|
429
|
+
flushText();
|
|
430
|
+
return nodes;
|
|
431
|
+
}
|
|
432
|
+
parseVariable() {
|
|
433
|
+
const start = this.index;
|
|
434
|
+
this.index += 1;
|
|
435
|
+
if (this.input[this.index] === "{") {
|
|
436
|
+
this.index += 1;
|
|
437
|
+
const nameStart = this.index;
|
|
438
|
+
while (!this.done() && this.input[this.index] !== "}") {
|
|
439
|
+
const current = this.input[this.index];
|
|
440
|
+
if (!current || FUNCTIONAL.has(current) || current === "{") {
|
|
441
|
+
throw new FormatSyntaxError("Invalid scoped variable", this.index);
|
|
442
|
+
}
|
|
443
|
+
this.index += 1;
|
|
444
|
+
}
|
|
445
|
+
if (this.done() || this.index === nameStart) {
|
|
446
|
+
throw new FormatSyntaxError("Unclosed scoped variable", start);
|
|
447
|
+
}
|
|
448
|
+
const name = this.input.slice(nameStart, this.index);
|
|
449
|
+
this.index += 1;
|
|
450
|
+
return name;
|
|
451
|
+
}
|
|
452
|
+
const match = /^[A-Za-z_][A-Za-z0-9_]*/u.exec(this.input.slice(this.index));
|
|
453
|
+
if (!match) throw new FormatSyntaxError("Invalid variable", start);
|
|
454
|
+
this.index += match[0].length;
|
|
455
|
+
return match[0];
|
|
456
|
+
}
|
|
457
|
+
parseStyleNodes() {
|
|
458
|
+
const nodes = [];
|
|
459
|
+
let text = "";
|
|
460
|
+
const flushText = () => {
|
|
461
|
+
if (!text) return;
|
|
462
|
+
nodes.push({ type: "text", value: text });
|
|
463
|
+
text = "";
|
|
464
|
+
};
|
|
465
|
+
while (!this.done()) {
|
|
466
|
+
const current = this.input[this.index];
|
|
467
|
+
if (current === ")") {
|
|
468
|
+
flushText();
|
|
469
|
+
this.index += 1;
|
|
470
|
+
return nodes;
|
|
471
|
+
}
|
|
472
|
+
if (current === "$") {
|
|
473
|
+
flushText();
|
|
474
|
+
nodes.push({ type: "variable", name: this.parseVariable() });
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
if (current === "(" || current === "[" || current === "]" || current === "\\") {
|
|
478
|
+
throw new FormatSyntaxError("Invalid style character", this.index);
|
|
479
|
+
}
|
|
480
|
+
text += current;
|
|
481
|
+
this.index += 1;
|
|
482
|
+
}
|
|
483
|
+
throw new FormatSyntaxError("Missing )", this.index);
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
function formatVariables(nodes) {
|
|
487
|
+
const variables = /* @__PURE__ */ new Set();
|
|
488
|
+
for (const node of nodes) {
|
|
489
|
+
if (node.type === "variable") variables.add(node.name);
|
|
490
|
+
else if (node.type === "group" || node.type === "conditional") {
|
|
491
|
+
for (const variable of formatVariables(node.children)) variables.add(variable);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return variables;
|
|
495
|
+
}
|
|
496
|
+
function styleVariables(nodes) {
|
|
497
|
+
const variables = /* @__PURE__ */ new Set();
|
|
498
|
+
for (const node of nodes) {
|
|
499
|
+
if (node.type === "group") {
|
|
500
|
+
for (const part of node.style) {
|
|
501
|
+
if (part.type === "variable") variables.add(part.name);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
if (node.type === "group" || node.type === "conditional") {
|
|
505
|
+
for (const variable of styleVariables(node.children)) variables.add(variable);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return variables;
|
|
509
|
+
}
|
|
510
|
+
function renderFormat(nodes, options) {
|
|
511
|
+
return renderNodes(nodes, options, void 0);
|
|
512
|
+
}
|
|
513
|
+
function renderNodes(nodes, options, inheritedStyle) {
|
|
514
|
+
const chunks = [];
|
|
515
|
+
for (const node of nodes) {
|
|
516
|
+
switch (node.type) {
|
|
517
|
+
case "text":
|
|
518
|
+
chunks.push({ text: sanitizeFormatText(node.value), style: inheritedStyle });
|
|
519
|
+
break;
|
|
520
|
+
case "variable":
|
|
521
|
+
chunks.push(...chunksForValue(ownValue(options.variables, node.name), inheritedStyle));
|
|
522
|
+
break;
|
|
523
|
+
case "conditional":
|
|
524
|
+
if (conditionalVisible(node.children, options.variables)) {
|
|
525
|
+
chunks.push(...renderNodes(node.children, options, inheritedStyle));
|
|
526
|
+
}
|
|
527
|
+
break;
|
|
528
|
+
case "group": {
|
|
529
|
+
const styleString = node.style.map((part) => part.type === "text" ? part.value : ownValue(options.styleVariables, part.name) ?? "").join("");
|
|
530
|
+
const style = parseStyle(styleString, options.palette);
|
|
531
|
+
const rendered = renderNodes(node.children, options, style);
|
|
532
|
+
if (node.children.length === 0) chunks.push({ text: "", style });
|
|
533
|
+
else chunks.push(...rendered);
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
return chunks;
|
|
539
|
+
}
|
|
540
|
+
function ownValue(record, key) {
|
|
541
|
+
return record && Object.hasOwn(record, key) ? record[key] : void 0;
|
|
542
|
+
}
|
|
543
|
+
function chunksForValue(value, inheritedStyle) {
|
|
544
|
+
if (value === void 0) return [];
|
|
545
|
+
if (typeof value === "string") return [{ text: sanitizeFormatText(value), style: inheritedStyle }];
|
|
546
|
+
return value.map(
|
|
547
|
+
(chunk) => isFillChunk(chunk) ? {
|
|
548
|
+
type: "fill",
|
|
549
|
+
pattern: chunk.pattern.map((part) => ({
|
|
550
|
+
...part,
|
|
551
|
+
text: sanitizeFormatText(part.text),
|
|
552
|
+
style: part.style ?? inheritedStyle
|
|
553
|
+
}))
|
|
554
|
+
} : { ...chunk, text: sanitizeFormatText(chunk.text), style: chunk.style ?? inheritedStyle }
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
function conditionalVisible(nodes, variables) {
|
|
558
|
+
for (const variable of formatVariables(nodes)) {
|
|
559
|
+
const value = ownValue(variables, variable);
|
|
560
|
+
if (typeof value === "string" ? sanitizeFormatText(value).length > 0 : value?.some((chunk) => isFillChunk(chunk) || sanitizeFormatText(chunk.text).length > 0)) {
|
|
561
|
+
return true;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export {
|
|
568
|
+
sanitizeFormatText,
|
|
569
|
+
isFillChunk,
|
|
570
|
+
isValidStyle,
|
|
571
|
+
parseStyle,
|
|
572
|
+
parseColor,
|
|
573
|
+
renderChunksToAnsi,
|
|
574
|
+
parseFormat,
|
|
575
|
+
formatVariables,
|
|
576
|
+
styleVariables,
|
|
577
|
+
renderFormat
|
|
578
|
+
};
|
|
579
|
+
//# sourceMappingURL=chunk-KP33I6BR.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/format/style.ts", "../../src/format/terminal-safety.ts", "../../src/format/theme-colors.ts", "../../src/format/formatter.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ThemeToken } from \"@earendil-works/pi-coding-agent\";\nimport { backgroundAnsi, foregroundAnsi } from \"@earendil-works/pi-tui\";\nimport { sanitizeFormatText } from \"./terminal-safety.js\";\nimport { isThemeRole, type ThemeColors } from \"./theme-colors.js\";\n\nexport type NamedColor =\n | \"black\"\n | \"red\"\n | \"green\"\n | \"yellow\"\n | \"blue\"\n | \"purple\"\n | \"cyan\"\n | \"white\"\n | \"bright-black\"\n | \"bright-red\"\n | \"bright-green\"\n | \"bright-yellow\"\n | \"bright-blue\"\n | \"bright-purple\"\n | \"bright-cyan\"\n | \"bright-white\";\n\nexport type ColorSpec =\n | { kind: \"named\"; name: NamedColor }\n | { kind: \"fixed\"; value: number }\n | { kind: \"rgb\"; red: number; green: number; blue: number }\n | { kind: \"theme\"; role: ThemeToken };\n\nexport type PreviousColorSource = \"foreground\" | \"background\";\n\nexport interface TextStyle {\n foreground?: ColorSpec;\n background?: ColorSpec;\n foregroundPrevious?: PreviousColorSource;\n backgroundPrevious?: PreviousColorSource;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n dimmed?: boolean;\n inverted?: boolean;\n blink?: boolean;\n hidden?: boolean;\n strikethrough?: boolean;\n}\n\nexport type StyleParseResult = { valid: true; style: TextStyle | undefined } | { valid: false; style: undefined };\n\nexport interface StyledChunk {\n text: string;\n style?: TextStyle;\n}\n\nexport interface FillChunk {\n type: \"fill\";\n pattern: readonly StyledChunk[];\n}\n\nexport type LayoutChunk = StyledChunk | FillChunk;\n\nexport function isFillChunk(chunk: LayoutChunk): chunk is FillChunk {\n return \"type\" in chunk && chunk.type === \"fill\";\n}\n\nexport type ColorPalette = Readonly<Record<string, string>>;\n\nconst NAMED_COLORS = new Set<NamedColor>([\n \"black\",\n \"red\",\n \"green\",\n \"yellow\",\n \"blue\",\n \"purple\",\n \"cyan\",\n \"white\",\n \"bright-black\",\n \"bright-red\",\n \"bright-green\",\n \"bright-yellow\",\n \"bright-blue\",\n \"bright-purple\",\n \"bright-cyan\",\n \"bright-white\",\n]);\n\nconst FOREGROUND_CODES: Record<NamedColor, number> = {\n black: 30,\n red: 31,\n green: 32,\n yellow: 33,\n blue: 34,\n purple: 35,\n cyan: 36,\n white: 37,\n \"bright-black\": 90,\n \"bright-red\": 91,\n \"bright-green\": 92,\n \"bright-yellow\": 93,\n \"bright-blue\": 94,\n \"bright-purple\": 95,\n \"bright-cyan\": 96,\n \"bright-white\": 97,\n};\n\nexport function isValidStyle(styleString: string, palette: ColorPalette = {}): boolean {\n return parseStyleResult(styleString, palette).valid;\n}\n\nexport function parseStyleResult(styleString: string, palette: ColorPalette = {}): StyleParseResult {\n const tokens = styleString.split(/\\s+/u).filter(Boolean).map(normalizeStyleToken);\n if (tokens.some(({ token, foreground }) => foreground && token === \"none\")) {\n return { valid: true, style: undefined };\n }\n\n const style: TextStyle = {};\n for (const { token, foreground } of tokens) {\n if (applyModifier(style, token)) continue;\n if (token === \"prev_fg\" || token === \"prev_bg\") {\n const source = token === \"prev_fg\" ? \"foreground\" : \"background\";\n if (foreground) style.foregroundPrevious = source;\n else style.backgroundPrevious = source;\n continue;\n }\n const color = parseColor(token, palette);\n if (!foreground && !color && !token.toLowerCase().startsWith(\"pi:\")) {\n delete style.background;\n continue;\n }\n if (!color) return { valid: false, style: undefined };\n if (foreground) style.foreground = color;\n else style.background = color;\n }\n return { valid: true, style };\n}\n\nexport function parseStyle(styleString: string, palette: ColorPalette = {}): TextStyle | undefined {\n return parseStyleResult(styleString, palette).style;\n}\n\nfunction normalizeStyleToken(rawToken: string): { token: string; foreground: boolean } {\n if (/^fg:/iu.test(rawToken)) {\n return { token: normalizeColorToken(rawToken.replace(/^(?:fg:)+/iu, \"\")), foreground: true };\n }\n if (/^bg:/iu.test(rawToken)) {\n return { token: normalizeColorToken(rawToken.replace(/^(?:bg:)+/iu, \"\")), foreground: false };\n }\n return { token: normalizeColorToken(rawToken), foreground: true };\n}\n\nfunction normalizeColorToken(token: string): string {\n return /^pi:/iu.test(token) ? `pi:${token.slice(3)}` : token.toLowerCase();\n}\n\nfunction applyModifier(style: TextStyle, token: string): boolean {\n switch (token) {\n case \"bold\":\n style.bold = true;\n return true;\n case \"italic\":\n style.italic = true;\n return true;\n case \"underline\":\n style.underline = true;\n return true;\n case \"dimmed\":\n style.dimmed = true;\n return true;\n case \"inverted\":\n style.inverted = true;\n return true;\n case \"blink\":\n style.blink = true;\n return true;\n case \"hidden\":\n style.hidden = true;\n return true;\n case \"strikethrough\":\n style.strikethrough = true;\n return true;\n default:\n return false;\n }\n}\n\nexport function parseColor(token: string, palette: ColorPalette = {}): ColorSpec | undefined {\n // Legacy style lookups lowercase palette names, including names that now look\n // like Pi references. Palette values remain direct colors, never aliases.\n const paletteKey = token.toLowerCase();\n const paletteValue = Object.hasOwn(palette, paletteKey) ? palette[paletteKey] : undefined;\n if (paletteValue !== undefined) return parseColor(normalizeColorToken(paletteValue), {});\n token = normalizeColorToken(token);\n if (token.startsWith(\"pi:\")) {\n const role = token.slice(3);\n return isThemeRole(role) ? { kind: \"theme\", role } : undefined;\n }\n if (NAMED_COLORS.has(token as NamedColor)) {\n return { kind: \"named\", name: token as NamedColor };\n }\n if (/^\\d{1,3}$/u.test(token)) {\n const value = Number(token);\n return value <= 255 ? { kind: \"fixed\", value } : undefined;\n }\n const rgb = /^#([0-9a-f]{6})$/iu.exec(token);\n if (!rgb?.[1]) return undefined;\n return {\n kind: \"rgb\",\n red: Number.parseInt(rgb[1].slice(0, 2), 16),\n green: Number.parseInt(rgb[1].slice(2, 4), 16),\n blue: Number.parseInt(rgb[1].slice(4, 6), 16),\n };\n}\n\ninterface ResolvedStyle\n extends Omit<TextStyle, \"foreground\" | \"background\" | \"foregroundPrevious\" | \"backgroundPrevious\"> {\n foreground?: ColorSpec;\n background?: ColorSpec;\n}\n\nexport function renderChunksToAnsi(\n chunks: readonly LayoutChunk[],\n trueColor = true,\n themeColors?: ThemeColors,\n): string {\n const runs: Array<{ text: string; style: ResolvedStyle }> = [];\n let previous: ResolvedStyle | undefined;\n for (const chunk of chunks) {\n if (isFillChunk(chunk)) continue;\n const style = resolveStyle(chunk.style, previous);\n const text = sanitizeFormatText(chunk.text);\n const last = runs.at(-1);\n if (text && last && stylesEqual(last.style, style)) last.text += text;\n else if (text) runs.push({ text, style });\n previous = style;\n }\n return runs\n .map(({ text, style }) => {\n const codes = ansiCodes(style, trueColor);\n const prefix =\n themeColorAnsi(style.foreground, false, trueColor, themeColors) +\n themeColorAnsi(style.background, true, trueColor, themeColors) +\n (codes.length > 0 ? `\\u001b[${codes.join(\";\")}m` : \"\");\n return prefix ? `${prefix}${text}\\u001b[0m` : text;\n })\n .join(\"\");\n}\n\nfunction stylesEqual(left: ResolvedStyle, right: ResolvedStyle): boolean {\n return JSON.stringify(left) === JSON.stringify(right);\n}\n\nfunction resolveStyle(style: TextStyle | undefined, previous: ResolvedStyle | undefined): ResolvedStyle {\n if (!style) return {};\n const { foregroundPrevious, backgroundPrevious, ...resolved } = style;\n return {\n ...resolved,\n foreground: resolveColor(style.foreground, foregroundPrevious, previous),\n background: resolveColor(style.background, backgroundPrevious, previous),\n };\n}\n\nfunction resolveColor(\n fallback: ColorSpec | undefined,\n source: PreviousColorSource | undefined,\n previous: ResolvedStyle | undefined,\n): ColorSpec | undefined {\n if (!source || !previous) return fallback;\n return source === \"foreground\" ? previous.foreground : previous.background;\n}\n\nfunction ansiCodes(style: ResolvedStyle, trueColor: boolean): string[] {\n const codes: string[] = [];\n if (style.foreground) codes.push(...colorCodes(style.foreground, false, trueColor));\n if (style.background) codes.push(...colorCodes(style.background, true, trueColor));\n if (style.bold) codes.push(\"1\");\n if (style.dimmed) codes.push(\"2\");\n if (style.italic) codes.push(\"3\");\n if (style.underline) codes.push(\"4\");\n if (style.blink) codes.push(\"5\");\n if (style.inverted) codes.push(\"7\");\n if (style.hidden) codes.push(\"8\");\n if (style.strikethrough) codes.push(\"9\");\n return codes;\n}\n\nfunction themeColorAnsi(\n color: ColorSpec | undefined,\n background: boolean,\n trueColor: boolean,\n themeColors: ThemeColors | undefined,\n): string {\n // Non-UI callers (for example, plain module inspection and width measurement)\n // need no active theme. Keep the renderer pure and omit unresolved colors.\n if (color?.kind !== \"theme\" || !themeColors) return \"\";\n const mode = trueColor ? \"truecolor\" : \"256color\";\n return (background ? backgroundAnsi : foregroundAnsi)(themeColors[color.role], mode);\n}\n\nfunction colorCodes(color: ColorSpec, background: boolean, trueColor: boolean): string[] {\n if (color.kind === \"theme\") return [];\n if (color.kind === \"named\") {\n const foreground = FOREGROUND_CODES[color.name];\n return [`${background ? foreground + 10 : foreground}`];\n }\n if (color.kind === \"fixed\") return [background ? \"48\" : \"38\", \"5\", `${color.value}`];\n if (!trueColor) {\n return [background ? \"48\" : \"38\", \"5\", `${rgbToAnsi256(color.red, color.green, color.blue)}`];\n }\n return [background ? \"48\" : \"38\", \"2\", `${color.red}`, `${color.green}`, `${color.blue}`];\n}\n\nfunction rgbToAnsi256(red: number, green: number, blue: number): number {\n const channels = [red, green, blue].map((value) => Math.round((value / 255) * 5));\n return 16 + 36 * (channels[0] ?? 0) + 6 * (channels[1] ?? 0) + (channels[2] ?? 0);\n}\n", "import { sanitizeTerminalDocument } from \"@narumitw/pi-tui-kit/terminal-document\";\n\nconst PREFIX = \"\\u001b]8;;\";\nconst BEL = \"\\u0007\";\nconst ST = \"\\u001b\\\\\";\n\n/** Preserve layout and supported HTTP(S) links, never arbitrary terminal controls. */\nexport function sanitizeFormatText(value: string): string {\n let output = \"\";\n let offset = 0;\n let cursor = 0;\n while (cursor < value.length) {\n const start = value.indexOf(PREFIX, cursor);\n if (start < 0) break;\n const opening = findTerminator(value, start + PREFIX.length);\n if (!opening) break;\n const closing = findLinkEnd(value, opening.end);\n if (!closing) break;\n cursor = closing.end;\n const url = safeHyperlinkUrl(value.slice(start + PREFIX.length, opening.start));\n if (!url) continue;\n output += sanitizePlainText(value.slice(offset, start));\n const label = sanitizePlainText(value.slice(opening.end, closing.start));\n if (label) {\n const openTerminator = value.slice(opening.start, opening.end);\n const closeTerminator = value.slice(closing.start + PREFIX.length, closing.end);\n output += `${PREFIX}${url}${openTerminator}${label}${PREFIX}${closeTerminator}`;\n }\n offset = closing.end;\n }\n return output + sanitizePlainText(value.slice(offset));\n}\n\nfunction sanitizePlainText(value: string): string {\n return sanitizeTerminalDocument(value).replace(/\\t/gu, \" \");\n}\n\nfunction terminatorEnd(value: string, start: number): number | undefined {\n if (value.startsWith(BEL, start)) return start + BEL.length;\n if (value.startsWith(ST, start)) return start + ST.length;\n return undefined;\n}\n\nfunction findTerminator(value: string, start: number): { start: number; end: number } | undefined {\n for (let index = start; index < value.length; index += 1) {\n const end = terminatorEnd(value, index);\n if (end !== undefined) return { start: index, end };\n }\n return undefined;\n}\n\nfunction findLinkEnd(value: string, start: number): { start: number; end: number } | undefined {\n let index = value.indexOf(PREFIX, start);\n while (index >= 0) {\n const end = terminatorEnd(value, index + PREFIX.length);\n if (end !== undefined) return { start: index, end };\n index = value.indexOf(PREFIX, index + PREFIX.length);\n }\n return undefined;\n}\n\n/** Match the URL policy used by the GitHub collector before generating OSC 8. */\nfunction safeHyperlinkUrl(value: string): string | undefined {\n if (\n value.length > 4_096 ||\n Array.from(value).some((character) => {\n const code = character.codePointAt(0) ?? 0;\n return code <= 0x1f || (code >= 0x7f && code <= 0x9f) || (code >= 0xd800 && code <= 0xdfff);\n })\n )\n return undefined;\n try {\n const url = new URL(value);\n if ((url.protocol !== \"http:\" && url.protocol !== \"https:\") || url.username || url.password) return undefined;\n const normalized = url.toString();\n return normalized.length <= 4_096 ? normalized : undefined;\n } catch {\n return undefined;\n }\n}\n", "import type { Theme, ThemeToken } from \"@earendil-works/pi-coding-agent\";\n\nexport type ThemeColors = Theme[\"colors\"];\n\n// Pi exports ThemeToken as a type, but has no public runtime token registry.\n// Exhaustiveness keeps validation aligned with the installed public API without\n// reading the active theme before Pi initializes it.\nconst THEME_ROLES = {\n accent: true,\n border: true,\n borderAccent: true,\n borderMuted: true,\n success: true,\n error: true,\n warning: true,\n muted: true,\n dim: true,\n text: true,\n thinkingText: true,\n scrollbarTrack: true,\n scrollbarThumb: true,\n selectedBg: true,\n searchMatchBg: true,\n searchMatchText: true,\n userMessageBg: true,\n userMessageText: true,\n customMessageBg: true,\n customMessageText: true,\n customMessageLabel: true,\n toolPendingBg: true,\n toolSuccessBg: true,\n toolErrorBg: true,\n toolTitle: true,\n toolOutput: true,\n mdHeading: true,\n mdLink: true,\n mdLinkUrl: true,\n mdCode: true,\n mdCodeBlock: true,\n mdCodeBlockBorder: true,\n mdQuote: true,\n mdQuoteBorder: true,\n mdHr: true,\n mdListBullet: true,\n toolDiffAdded: true,\n toolDiffRemoved: true,\n toolDiffContext: true,\n syntaxComment: true,\n syntaxKeyword: true,\n syntaxFunction: true,\n syntaxVariable: true,\n syntaxString: true,\n syntaxNumber: true,\n syntaxType: true,\n syntaxOperator: true,\n syntaxPunctuation: true,\n thinkingOff: true,\n thinkingMinimal: true,\n thinkingLow: true,\n thinkingMedium: true,\n thinkingHigh: true,\n thinkingXhigh: true,\n thinkingMax: true,\n bashMode: true,\n} satisfies Record<ThemeToken, true>;\n\nexport function isThemeRole(role: string): role is ThemeToken {\n return Object.hasOwn(THEME_ROLES, role);\n}\n", "import { type ColorPalette, isFillChunk, type LayoutChunk, parseStyle, type TextStyle } from \"./style.js\";\nimport { sanitizeFormatText } from \"./terminal-safety.js\";\n\nexport type FormatNode =\n | { type: \"text\"; value: string }\n | { type: \"variable\"; name: string }\n | { type: \"group\"; children: FormatNode[]; style: StyleNode[] }\n | { type: \"conditional\"; children: FormatNode[] };\n\nexport type StyleNode = { type: \"text\"; value: string } | { type: \"variable\"; name: string };\nexport type FormatValue = string | readonly LayoutChunk[] | undefined;\n\nexport interface RenderFormatOptions {\n variables: Readonly<Record<string, FormatValue>>;\n styleVariables?: Readonly<Record<string, string | undefined>>;\n palette?: ColorPalette;\n}\n\nexport class FormatSyntaxError extends Error {\n readonly offset: number;\n\n constructor(message: string, offset: number) {\n super(`${message} at offset ${offset}`);\n this.name = \"FormatSyntaxError\";\n this.offset = offset;\n }\n}\n\nconst FUNCTIONAL = new Set([\"[\", \"]\", \"(\", \")\", \"\\\\\", \"$\"]);\n\nexport function parseFormat(format: string): FormatNode[] {\n const parser = new FormatParser(format);\n const nodes = parser.parseNodes();\n if (!parser.done()) throw new FormatSyntaxError(\"Unexpected character\", parser.offset());\n return nodes;\n}\n\nclass FormatParser {\n private index = 0;\n\n constructor(private readonly input: string) {}\n\n offset() {\n return this.index;\n }\n\n done() {\n return this.index === this.input.length;\n }\n\n parseNodes(end?: \"]\" | \")\"): FormatNode[] {\n const nodes: FormatNode[] = [];\n let text = \"\";\n const flushText = () => {\n if (!text) return;\n nodes.push({ type: \"text\", value: text });\n text = \"\";\n };\n\n while (!this.done()) {\n const current = this.input[this.index];\n if (current === end) {\n flushText();\n this.index += 1;\n return nodes;\n }\n if (current === \"\\\\\") {\n const escaped = this.input[this.index + 1];\n if (!escaped || !FUNCTIONAL.has(escaped)) {\n throw new FormatSyntaxError(\"Invalid escape\", this.index);\n }\n text += escaped;\n this.index += 2;\n continue;\n }\n if (current === \"$\") {\n flushText();\n nodes.push({ type: \"variable\", name: this.parseVariable() });\n continue;\n }\n if (current === \"[\") {\n flushText();\n this.index += 1;\n const children = this.parseNodes(\"]\");\n if (this.input[this.index] !== \"(\") {\n throw new FormatSyntaxError(\"Text group requires a style\", this.index);\n }\n this.index += 1;\n nodes.push({ type: \"group\", children, style: this.parseStyleNodes() });\n continue;\n }\n if (current === \"(\") {\n flushText();\n this.index += 1;\n nodes.push({ type: \"conditional\", children: this.parseNodes(\")\") });\n continue;\n }\n if (current === \"]\" || current === \")\") {\n throw new FormatSyntaxError(`Unexpected ${current}`, this.index);\n }\n text += current;\n this.index += 1;\n }\n\n if (end) throw new FormatSyntaxError(`Missing ${end}`, this.index);\n flushText();\n return nodes;\n }\n\n private parseVariable(): string {\n const start = this.index;\n this.index += 1;\n if (this.input[this.index] === \"{\") {\n this.index += 1;\n const nameStart = this.index;\n while (!this.done() && this.input[this.index] !== \"}\") {\n const current = this.input[this.index];\n if (!current || FUNCTIONAL.has(current) || current === \"{\") {\n throw new FormatSyntaxError(\"Invalid scoped variable\", this.index);\n }\n this.index += 1;\n }\n if (this.done() || this.index === nameStart) {\n throw new FormatSyntaxError(\"Unclosed scoped variable\", start);\n }\n const name = this.input.slice(nameStart, this.index);\n this.index += 1;\n return name;\n }\n const match = /^[A-Za-z_][A-Za-z0-9_]*/u.exec(this.input.slice(this.index));\n if (!match) throw new FormatSyntaxError(\"Invalid variable\", start);\n this.index += match[0].length;\n return match[0];\n }\n\n private parseStyleNodes(): StyleNode[] {\n const nodes: StyleNode[] = [];\n let text = \"\";\n const flushText = () => {\n if (!text) return;\n nodes.push({ type: \"text\", value: text });\n text = \"\";\n };\n while (!this.done()) {\n const current = this.input[this.index];\n if (current === \")\") {\n flushText();\n this.index += 1;\n return nodes;\n }\n if (current === \"$\") {\n flushText();\n nodes.push({ type: \"variable\", name: this.parseVariable() });\n continue;\n }\n if (current === \"(\" || current === \"[\" || current === \"]\" || current === \"\\\\\") {\n throw new FormatSyntaxError(\"Invalid style character\", this.index);\n }\n text += current;\n this.index += 1;\n }\n throw new FormatSyntaxError(\"Missing )\", this.index);\n }\n}\n\nexport function formatVariables(nodes: readonly FormatNode[]): Set<string> {\n const variables = new Set<string>();\n for (const node of nodes) {\n if (node.type === \"variable\") variables.add(node.name);\n else if (node.type === \"group\" || node.type === \"conditional\") {\n for (const variable of formatVariables(node.children)) variables.add(variable);\n }\n }\n return variables;\n}\n\nexport function styleVariables(nodes: readonly FormatNode[]): Set<string> {\n const variables = new Set<string>();\n for (const node of nodes) {\n if (node.type === \"group\") {\n for (const part of node.style) {\n if (part.type === \"variable\") variables.add(part.name);\n }\n }\n if (node.type === \"group\" || node.type === \"conditional\") {\n for (const variable of styleVariables(node.children)) variables.add(variable);\n }\n }\n return variables;\n}\n\nexport function renderFormat(nodes: readonly FormatNode[], options: RenderFormatOptions): LayoutChunk[] {\n return renderNodes(nodes, options, undefined);\n}\n\nfunction renderNodes(\n nodes: readonly FormatNode[],\n options: RenderFormatOptions,\n inheritedStyle: TextStyle | undefined,\n): LayoutChunk[] {\n const chunks: LayoutChunk[] = [];\n for (const node of nodes) {\n switch (node.type) {\n case \"text\":\n chunks.push({ text: sanitizeFormatText(node.value), style: inheritedStyle });\n break;\n case \"variable\":\n chunks.push(...chunksForValue(ownValue(options.variables, node.name), inheritedStyle));\n break;\n case \"conditional\":\n if (conditionalVisible(node.children, options.variables)) {\n chunks.push(...renderNodes(node.children, options, inheritedStyle));\n }\n break;\n case \"group\": {\n const styleString = node.style\n .map((part) => (part.type === \"text\" ? part.value : (ownValue(options.styleVariables, part.name) ?? \"\")))\n .join(\"\");\n const style = parseStyle(styleString, options.palette);\n const rendered = renderNodes(node.children, options, style);\n if (node.children.length === 0) chunks.push({ text: \"\", style });\n else chunks.push(...rendered);\n break;\n }\n }\n }\n return chunks;\n}\n\nfunction ownValue<T>(record: Readonly<Record<string, T>> | undefined, key: string): T | undefined {\n return record && Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nfunction chunksForValue(value: FormatValue, inheritedStyle: TextStyle | undefined): LayoutChunk[] {\n if (value === undefined) return [];\n if (typeof value === \"string\") return [{ text: sanitizeFormatText(value), style: inheritedStyle }];\n return value.map((chunk) =>\n isFillChunk(chunk)\n ? {\n type: \"fill\" as const,\n pattern: chunk.pattern.map((part) => ({\n ...part,\n text: sanitizeFormatText(part.text),\n style: part.style ?? inheritedStyle,\n })),\n }\n : { ...chunk, text: sanitizeFormatText(chunk.text), style: chunk.style ?? inheritedStyle },\n );\n}\n\nfunction conditionalVisible(nodes: readonly FormatNode[], variables: Readonly<Record<string, FormatValue>>): boolean {\n for (const variable of formatVariables(nodes)) {\n const value = ownValue(variables, variable);\n if (\n typeof value === \"string\"\n ? sanitizeFormatText(value).length > 0\n : value?.some((chunk) => isFillChunk(chunk) || sanitizeFormatText(chunk.text).length > 0)\n ) {\n return true;\n }\n }\n return false;\n}\n"],
|
|
5
|
+
"mappings": ";;;;AACA,SAAS,gBAAgB,sBAAsB;;;ACD/C,SAAS,gCAAgC;AAEzC,IAAM,SAAS;AACf,IAAM,MAAM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