archymedes-cli 2.3.0 → 2.5.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/dist/{archymedes-aj30app4.mjs → archymedes-06fh0z84.mjs} +370 -159
- package/dist/{archymedes-d5wqcmdr.mjs → archymedes-0jxzsh4z.mjs} +97 -97
- package/dist/archymedes-130jt0wr.mjs +1231 -0
- package/dist/{archymedes-twbks7g3.mjs → archymedes-138genyy.mjs} +214 -5
- package/dist/{archymedes-h13ap0za.mjs → archymedes-1g1y6q74.mjs} +1 -1
- package/dist/{archymedes-dz59nvw7.mjs → archymedes-2kvjaajw.mjs} +21 -11
- package/dist/{archymedes-g8y3rt6t.mjs → archymedes-5vhvv8kr.mjs} +332 -9
- package/dist/{archymedes-4kx65anz.mjs → archymedes-a3ms7jvr.mjs} +43 -12
- package/dist/{archymedes-tsne2m7p.mjs → archymedes-bmtdqqwt.mjs} +2 -2
- package/dist/{archymedes-sf9t1hz9.mjs → archymedes-d3azqkay.mjs} +176 -77
- package/dist/archymedes-main.mjs +31312 -28352
- package/dist/archymedes-w4bjfye7.mjs +280 -0
- package/dist/{editor-screen-g08zzt70.mjs → editor-screen-e01mn7dd.mjs} +49 -14
- package/dist/{factory-7vtm2fed.mjs → factory-hyv8agr0.mjs} +326 -326
- package/dist/{file-screen-ma9yxq2b.mjs → file-screen-stcxznwy.mjs} +11 -9
- package/dist/{guide-screen-gd129txd.mjs → guide-screen-w5nb9sry.mjs} +10 -8
- package/dist/{index-qvgcwsvm.mjs → index-teq1cta4.mjs} +1 -1
- package/dist/{node-mdgzx68h.mjs → node-0fh63p8z.mjs} +7 -7
- package/dist/pager-screen-aamt6xv0.mjs +155 -0
- package/dist/projection-x6x6hm9t.mjs +248 -0
- package/dist/{sandbox-templates-9jcjws23.mjs → sandbox-templates-8sd1psez.mjs} +2 -2
- package/dist/workspace-screen-62k6hnq7.mjs +70 -0
- package/package.json +2 -2
- package/dist/archymedes-a10k8yrk.mjs +0 -464
- package/dist/workspace-screen-8cwk6jz9.mjs +0 -241
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "archymedes-cli",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Archymedes CLI
|
|
3
|
+
"version": "2.5.0",
|
|
4
|
+
"description": "Archymedes CLI — a coding agent that shows its work. Runs against your working tree or an isolated remote sandbox, with guarded approvals, git checkpoints, and exact, measured cost accounting.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
7
|
"coding-agent",
|
|
@@ -1,464 +0,0 @@
|
|
|
1
|
-
// src/theme/theme.ts
|
|
2
|
-
var BLUEPRINT = `
|
|
3
|
-
/* Blueprint navy, chalk-white ink and an amber pencil — the original drafting table. */
|
|
4
|
-
@theme blueprint {
|
|
5
|
-
--primary: #7cc5ff;
|
|
6
|
-
--secondary: #9fb4e8;
|
|
7
|
-
--accent: #ffcf6b;
|
|
8
|
-
--bg: #0a1524;
|
|
9
|
-
--surface: #122135;
|
|
10
|
-
--text: #e8eefb;
|
|
11
|
-
--text-muted: #6f89b0;
|
|
12
|
-
--success: #79dfa6;
|
|
13
|
-
--warning: #ffcf6b;
|
|
14
|
-
--error: #ff8f7a;
|
|
15
|
-
--border: round;
|
|
16
|
-
--border-color: #24406a;
|
|
17
|
-
--border-focus: #7cc5ff;
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
var PARCHMENT = `
|
|
21
|
-
/* The same drawing inked on paper, for a light terminal. */
|
|
22
|
-
@theme parchment {
|
|
23
|
-
--primary: #2f5fbf;
|
|
24
|
-
--secondary: #5a4a86;
|
|
25
|
-
--accent: #9a6a00;
|
|
26
|
-
--bg: #faf6ec;
|
|
27
|
-
--surface: #f1eadd;
|
|
28
|
-
--text: #1b1a16;
|
|
29
|
-
--text-muted: #6a6252;
|
|
30
|
-
--success: #196a44;
|
|
31
|
-
--warning: #8a5300;
|
|
32
|
-
--error: #b3243b;
|
|
33
|
-
--border: round;
|
|
34
|
-
--border-color: #d8cfb8;
|
|
35
|
-
--border-focus: #2f5fbf;
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
var CHALKBOARD = `
|
|
39
|
-
/* A slate: near-black green, chalk white, chalk yellow — for terminals with contrast to spare. */
|
|
40
|
-
@theme chalkboard {
|
|
41
|
-
--primary: #9fe8d8;
|
|
42
|
-
--secondary: #d8d0b0;
|
|
43
|
-
--accent: #ffe066;
|
|
44
|
-
--bg: #0d1a15;
|
|
45
|
-
--surface: #16271f;
|
|
46
|
-
--text: #f2efe4;
|
|
47
|
-
--text-muted: #86987f;
|
|
48
|
-
--success: #7ef2b0;
|
|
49
|
-
--warning: #ffd166;
|
|
50
|
-
--error: #ff7a7a;
|
|
51
|
-
--border: single;
|
|
52
|
-
--border-color: #2c443a;
|
|
53
|
-
--border-focus: #ffe066;
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
var HIGH_CONTRAST = `
|
|
57
|
-
/* Maximum separation, named colours only — for low vision and for terminals with a fixed palette. */
|
|
58
|
-
@theme high-contrast {
|
|
59
|
-
--primary: brightCyan;
|
|
60
|
-
--secondary: brightMagenta;
|
|
61
|
-
--accent: brightYellow;
|
|
62
|
-
--bg: black;
|
|
63
|
-
--surface: black;
|
|
64
|
-
--text: brightWhite;
|
|
65
|
-
--text-muted: white;
|
|
66
|
-
--success: brightGreen;
|
|
67
|
-
--warning: brightYellow;
|
|
68
|
-
--error: brightRed;
|
|
69
|
-
--border: single;
|
|
70
|
-
--border-color: white;
|
|
71
|
-
--border-focus: brightCyan;
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
var ARCHYMEDES = `
|
|
75
|
-
/* Bronze instruments, limestone ink and olive accents on charcoal — Archymedes's own. */
|
|
76
|
-
@theme archymedes {
|
|
77
|
-
--primary: #e7bb78;
|
|
78
|
-
--secondary: #b9c59a;
|
|
79
|
-
--accent: #e5a58c;
|
|
80
|
-
--bg: #191815;
|
|
81
|
-
--surface: #25231e;
|
|
82
|
-
--text: #f2ecdf;
|
|
83
|
-
--text-muted: #aaa18f;
|
|
84
|
-
--success: #b5cc96;
|
|
85
|
-
--warning: #efc778;
|
|
86
|
-
--error: #f29686;
|
|
87
|
-
--border: single;
|
|
88
|
-
--border-color: #736956;
|
|
89
|
-
--border-focus: #e7bb78;
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
var RAINBOW = `
|
|
93
|
-
/* Every hue at once — the opening art and the thinking spinner sweep the full spectrum. */
|
|
94
|
-
@theme rainbow {
|
|
95
|
-
--primary: #ff5f5f;
|
|
96
|
-
--secondary: #5fd7ff;
|
|
97
|
-
--accent: #ffd75f;
|
|
98
|
-
--bg: #0c0c0c;
|
|
99
|
-
--surface: #161616;
|
|
100
|
-
--text: #f2f2f2;
|
|
101
|
-
--text-muted: #9a9a9a;
|
|
102
|
-
--success: #5fff87;
|
|
103
|
-
--warning: #ffaf5f;
|
|
104
|
-
--error: #ff3b3b;
|
|
105
|
-
--border: double;
|
|
106
|
-
--border-color: #8a8a8a;
|
|
107
|
-
--border-focus: #d75fff;
|
|
108
|
-
}
|
|
109
|
-
`;
|
|
110
|
-
var BUILTIN_THEME_SOURCES = {
|
|
111
|
-
archymedes: ARCHYMEDES,
|
|
112
|
-
blueprint: BLUEPRINT,
|
|
113
|
-
parchment: PARCHMENT,
|
|
114
|
-
chalkboard: CHALKBOARD,
|
|
115
|
-
"high-contrast": HIGH_CONTRAST,
|
|
116
|
-
rainbow: RAINBOW
|
|
117
|
-
};
|
|
118
|
-
var DEFAULT_THEME_NAME = "archymedes";
|
|
119
|
-
var NAMED_COLORS = {
|
|
120
|
-
black: 0,
|
|
121
|
-
red: 1,
|
|
122
|
-
green: 2,
|
|
123
|
-
yellow: 3,
|
|
124
|
-
blue: 4,
|
|
125
|
-
magenta: 5,
|
|
126
|
-
cyan: 6,
|
|
127
|
-
white: 7,
|
|
128
|
-
brightblack: 8,
|
|
129
|
-
brightred: 9,
|
|
130
|
-
brightgreen: 10,
|
|
131
|
-
brightyellow: 11,
|
|
132
|
-
brightblue: 12,
|
|
133
|
-
brightmagenta: 13,
|
|
134
|
-
brightcyan: 14,
|
|
135
|
-
brightwhite: 15,
|
|
136
|
-
gray: 8,
|
|
137
|
-
grey: 8
|
|
138
|
-
};
|
|
139
|
-
function parseColor(value) {
|
|
140
|
-
const text = value.trim();
|
|
141
|
-
const named = NAMED_COLORS[text.toLowerCase().replace(/[\s_-]/g, "")];
|
|
142
|
-
if (named !== undefined)
|
|
143
|
-
return named;
|
|
144
|
-
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(text);
|
|
145
|
-
if (!hex)
|
|
146
|
-
return;
|
|
147
|
-
const digits = hex[1];
|
|
148
|
-
const full = digits.length === 3 ? digits.split("").map((digit) => digit + digit).join("") : digits;
|
|
149
|
-
return {
|
|
150
|
-
r: Number.parseInt(full.slice(0, 2), 16),
|
|
151
|
-
g: Number.parseInt(full.slice(2, 4), 16),
|
|
152
|
-
b: Number.parseInt(full.slice(4, 6), 16)
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function rgbTo256({ r, g, b }) {
|
|
156
|
-
const level = (value) => {
|
|
157
|
-
if (value < 48)
|
|
158
|
-
return 0;
|
|
159
|
-
if (value < 115)
|
|
160
|
-
return 1;
|
|
161
|
-
return Math.min(5, Math.round((value - 35) / 40));
|
|
162
|
-
};
|
|
163
|
-
const cubeIndex = 16 + 36 * level(r) + 6 * level(g) + level(b);
|
|
164
|
-
const cubeValue = (step) => step === 0 ? 0 : 55 + step * 40;
|
|
165
|
-
const cube = { r: cubeValue(level(r)), g: cubeValue(level(g)), b: cubeValue(level(b)) };
|
|
166
|
-
const greyAverage = (r + g + b) / 3;
|
|
167
|
-
const greyStep = Math.max(0, Math.min(23, Math.round((greyAverage - 8) / 10)));
|
|
168
|
-
const greyValue = 8 + greyStep * 10;
|
|
169
|
-
const grey = { r: greyValue, g: greyValue, b: greyValue };
|
|
170
|
-
return distance({ r, g, b }, grey) < distance({ r, g, b }, cube) ? 232 + greyStep : cubeIndex;
|
|
171
|
-
}
|
|
172
|
-
function distance(a, b) {
|
|
173
|
-
return (a.r - b.r) ** 2 + (a.g - b.g) ** 2 + (a.b - b.b) ** 2;
|
|
174
|
-
}
|
|
175
|
-
function colorCode(value, depth) {
|
|
176
|
-
if (depth === "none")
|
|
177
|
-
return "";
|
|
178
|
-
const parsed = parseColor(value);
|
|
179
|
-
if (parsed === undefined)
|
|
180
|
-
return "";
|
|
181
|
-
if (typeof parsed === "number")
|
|
182
|
-
return parsed < 8 ? `\x1B[${30 + parsed}m` : `\x1B[${90 + parsed - 8}m`;
|
|
183
|
-
return depth === "truecolor" ? `\x1B[38;2;${parsed.r};${parsed.g};${parsed.b}m` : `\x1B[38;5;${rgbTo256(parsed)}m`;
|
|
184
|
-
}
|
|
185
|
-
function rainbowHex(t) {
|
|
186
|
-
const hue = (t % 1 + 1) % 1 * 360;
|
|
187
|
-
const c = 0.5;
|
|
188
|
-
const x = c * (1 - Math.abs(hue / 60 % 2 - 1));
|
|
189
|
-
const m = 0.6 - c / 2;
|
|
190
|
-
const [r1, g1, b1] = hue < 60 ? [c, x, 0] : hue < 120 ? [x, c, 0] : hue < 180 ? [0, c, x] : hue < 240 ? [0, x, c] : hue < 300 ? [x, 0, c] : [c, 0, x];
|
|
191
|
-
const channel = (value) => Math.round((value + m) * 255).toString(16).padStart(2, "0");
|
|
192
|
-
return `#${channel(r1)}${channel(g1)}${channel(b1)}`;
|
|
193
|
-
}
|
|
194
|
-
function rainbowText(text, depth, phase = 0) {
|
|
195
|
-
if (depth === "none")
|
|
196
|
-
return text;
|
|
197
|
-
const characters = [...text];
|
|
198
|
-
let out = "";
|
|
199
|
-
let open;
|
|
200
|
-
characters.forEach((character, index) => {
|
|
201
|
-
if (character === " ") {
|
|
202
|
-
if (open !== undefined) {
|
|
203
|
-
out += "\x1B[0m";
|
|
204
|
-
open = undefined;
|
|
205
|
-
}
|
|
206
|
-
out += character;
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const code = colorCode(rainbowHex(phase + index / 12), depth);
|
|
210
|
-
if (code !== open) {
|
|
211
|
-
out += code;
|
|
212
|
-
open = code;
|
|
213
|
-
}
|
|
214
|
-
out += character;
|
|
215
|
-
});
|
|
216
|
-
return open === undefined ? out : `${out}\x1B[0m`;
|
|
217
|
-
}
|
|
218
|
-
var DEFAULT_TOKENS = {
|
|
219
|
-
primary: "cyan",
|
|
220
|
-
secondary: "blue",
|
|
221
|
-
accent: "yellow",
|
|
222
|
-
bg: "black",
|
|
223
|
-
surface: "black",
|
|
224
|
-
text: "white",
|
|
225
|
-
textMuted: "brightBlack",
|
|
226
|
-
success: "green",
|
|
227
|
-
warning: "yellow",
|
|
228
|
-
error: "red",
|
|
229
|
-
border: "round",
|
|
230
|
-
borderColor: "brightBlack",
|
|
231
|
-
borderFocus: "cyan"
|
|
232
|
-
};
|
|
233
|
-
var TOKEN_NAMES = {
|
|
234
|
-
primary: "primary",
|
|
235
|
-
secondary: "secondary",
|
|
236
|
-
accent: "accent",
|
|
237
|
-
bg: "bg",
|
|
238
|
-
background: "bg",
|
|
239
|
-
surface: "surface",
|
|
240
|
-
text: "text",
|
|
241
|
-
fg: "text",
|
|
242
|
-
"text-muted": "textMuted",
|
|
243
|
-
muted: "textMuted",
|
|
244
|
-
success: "success",
|
|
245
|
-
warning: "warning",
|
|
246
|
-
error: "error",
|
|
247
|
-
border: "border",
|
|
248
|
-
"border-color": "borderColor",
|
|
249
|
-
"border-focus": "borderFocus",
|
|
250
|
-
highlight: "secondary"
|
|
251
|
-
};
|
|
252
|
-
function parseThemeSource(source) {
|
|
253
|
-
const themes = [];
|
|
254
|
-
const withoutLineComments = source.replace(/(^|\s)\/\/[^\n]*/g, "$1");
|
|
255
|
-
const blockPattern = /(?:\/\*([\s\S]*?)\*\/\s*)?@theme\s+([A-Za-z0-9_-]+)\s*\{([^}]*)\}/g;
|
|
256
|
-
for (const match of withoutLineComments.matchAll(blockPattern)) {
|
|
257
|
-
const description = (match[1] ?? "").replace(/\s+/g, " ").trim();
|
|
258
|
-
const tokens = { ...DEFAULT_TOKENS };
|
|
259
|
-
for (const declaration of match[3].matchAll(/(?:--|\$)([a-z0-9-]+)\s*:\s*([^;}]+)[;]?/gi)) {
|
|
260
|
-
const key = TOKEN_NAMES[declaration[1].toLowerCase()];
|
|
261
|
-
if (key)
|
|
262
|
-
tokens[key] = declaration[2].trim();
|
|
263
|
-
}
|
|
264
|
-
themes.push({ name: match[2], description, tokens });
|
|
265
|
-
}
|
|
266
|
-
return themes;
|
|
267
|
-
}
|
|
268
|
-
function builtinThemes() {
|
|
269
|
-
return Object.values(BUILTIN_THEME_SOURCES).flatMap((source) => parseThemeSource(source));
|
|
270
|
-
}
|
|
271
|
-
function findBuiltinTheme(name) {
|
|
272
|
-
return builtinThemes().find((theme) => theme.name.toLowerCase() === name.trim().toLowerCase());
|
|
273
|
-
}
|
|
274
|
-
function borderStyleOf(value) {
|
|
275
|
-
const text = value.trim().toLowerCase();
|
|
276
|
-
return text === "single" || text === "double" || text === "none" ? text : "round";
|
|
277
|
-
}
|
|
278
|
-
function buildPalette(theme, depth) {
|
|
279
|
-
const code = (value) => colorCode(value, depth);
|
|
280
|
-
return {
|
|
281
|
-
theme: theme.name,
|
|
282
|
-
depth,
|
|
283
|
-
primary: code(theme.tokens.primary),
|
|
284
|
-
secondary: code(theme.tokens.secondary),
|
|
285
|
-
accent: code(theme.tokens.accent),
|
|
286
|
-
text: code(theme.tokens.text),
|
|
287
|
-
muted: code(theme.tokens.textMuted),
|
|
288
|
-
success: code(theme.tokens.success),
|
|
289
|
-
warning: code(theme.tokens.warning),
|
|
290
|
-
error: code(theme.tokens.error),
|
|
291
|
-
border: code(theme.tokens.borderColor),
|
|
292
|
-
borderFocus: code(theme.tokens.borderFocus),
|
|
293
|
-
borderStyle: borderStyleOf(theme.tokens.border),
|
|
294
|
-
bg: theme.tokens.bg,
|
|
295
|
-
surface: theme.tokens.surface,
|
|
296
|
-
tokens: theme.tokens
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
var EXTERNAL_MARK = "\x1B[35m";
|
|
300
|
-
var ANSI_PALETTE = buildPalette({ name: "ansi", description: "", tokens: DEFAULT_TOKENS }, "ansi256");
|
|
301
|
-
function roleCode(role, palette, depth) {
|
|
302
|
-
if (depth === "none")
|
|
303
|
-
return "";
|
|
304
|
-
return palette?.[role] || ANSI_PALETTE[role];
|
|
305
|
-
}
|
|
306
|
-
var NO_COLOR_PALETTE = buildPalette(findBuiltinTheme(DEFAULT_THEME_NAME) ?? { name: DEFAULT_THEME_NAME, description: "", tokens: DEFAULT_TOKENS }, "none");
|
|
307
|
-
|
|
308
|
-
// src/text/ansi.ts
|
|
309
|
-
var RESET = "\x1B[0m";
|
|
310
|
-
var BOLD = "\x1B[1m";
|
|
311
|
-
var DIM = "\x1B[2m";
|
|
312
|
-
var ITALIC = "\x1B[3m";
|
|
313
|
-
var STRIKE = "\x1B[9m";
|
|
314
|
-
var REVERSE = "\x1B[7m";
|
|
315
|
-
function paint(text, code, depth) {
|
|
316
|
-
return depth === "none" || code === "" ? text : `${code}${text}${RESET}`;
|
|
317
|
-
}
|
|
318
|
-
function paintAll(text, codes, depth) {
|
|
319
|
-
return depth === "none" || codes.length === 0 ? text : `${codes.join("")}${text}${RESET}`;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// src/text/glyphs.ts
|
|
323
|
-
var UNICODE_GLYPHS = {
|
|
324
|
-
starGlyphs: [".", "·", "✧", "✦", "✶"],
|
|
325
|
-
spinnerFrames: [" ◜ ", " ◠ ", " ◝ ", " ◞ ", " ◡ ", " ◟ "],
|
|
326
|
-
star: "✦",
|
|
327
|
-
starDim: "✧",
|
|
328
|
-
check: "✓",
|
|
329
|
-
cross: "✗",
|
|
330
|
-
pending: "⋯",
|
|
331
|
-
prompt: "❯",
|
|
332
|
-
caret: "›",
|
|
333
|
-
bullet: "•",
|
|
334
|
-
ellipsis: "…",
|
|
335
|
-
middot: "·",
|
|
336
|
-
elbow: "⎿",
|
|
337
|
-
boxTopLeft: "╭",
|
|
338
|
-
boxTopRight: "╮",
|
|
339
|
-
boxBottomLeft: "╰",
|
|
340
|
-
boxBottomRight: "╯",
|
|
341
|
-
boxHorizontal: "─",
|
|
342
|
-
boxVertical: "│",
|
|
343
|
-
boxTeeLeft: "├",
|
|
344
|
-
boxTeeRight: "┤",
|
|
345
|
-
boxCross: "┼",
|
|
346
|
-
circleEmpty: "○",
|
|
347
|
-
circleHalf: "◐",
|
|
348
|
-
circleFull: "●",
|
|
349
|
-
checkbox: "☐",
|
|
350
|
-
checkboxDone: "☑",
|
|
351
|
-
paused: "⏸",
|
|
352
|
-
cancelled: "⊘",
|
|
353
|
-
treeBranch: "├─",
|
|
354
|
-
treeLast: "╰─",
|
|
355
|
-
treeTrunk: "│ ",
|
|
356
|
-
collapsed: "▸",
|
|
357
|
-
expanded: "▾",
|
|
358
|
-
arrowUp: "↑",
|
|
359
|
-
arrowLeft: "←",
|
|
360
|
-
arrowRight: "→",
|
|
361
|
-
arrowDown: "↓",
|
|
362
|
-
plus: "+",
|
|
363
|
-
minus: "-",
|
|
364
|
-
warning: "!",
|
|
365
|
-
effectWorkspace: "✎",
|
|
366
|
-
effectExternal: "◎",
|
|
367
|
-
sparkLevels: ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"]
|
|
368
|
-
};
|
|
369
|
-
var ASCII_GLYPHS = {
|
|
370
|
-
starGlyphs: [".", ".", "+", "*", "*"],
|
|
371
|
-
spinnerFrames: ["-", "\\", "|", "/"],
|
|
372
|
-
star: "*",
|
|
373
|
-
starDim: "+",
|
|
374
|
-
check: "+",
|
|
375
|
-
cross: "x",
|
|
376
|
-
pending: "~",
|
|
377
|
-
prompt: ">",
|
|
378
|
-
caret: ">",
|
|
379
|
-
bullet: "-",
|
|
380
|
-
ellipsis: "...",
|
|
381
|
-
middot: "-",
|
|
382
|
-
elbow: "\\",
|
|
383
|
-
boxTopLeft: "+",
|
|
384
|
-
boxTopRight: "+",
|
|
385
|
-
boxBottomLeft: "+",
|
|
386
|
-
boxBottomRight: "+",
|
|
387
|
-
boxHorizontal: "-",
|
|
388
|
-
boxVertical: "|",
|
|
389
|
-
boxTeeLeft: "+",
|
|
390
|
-
boxTeeRight: "+",
|
|
391
|
-
boxCross: "+",
|
|
392
|
-
circleEmpty: "o",
|
|
393
|
-
circleHalf: "*",
|
|
394
|
-
circleFull: "*",
|
|
395
|
-
checkbox: "[ ]",
|
|
396
|
-
checkboxDone: "[x]",
|
|
397
|
-
paused: "=",
|
|
398
|
-
cancelled: "x",
|
|
399
|
-
treeBranch: "|-",
|
|
400
|
-
treeLast: "`-",
|
|
401
|
-
treeTrunk: "| ",
|
|
402
|
-
collapsed: ">",
|
|
403
|
-
expanded: "v",
|
|
404
|
-
arrowUp: "^",
|
|
405
|
-
arrowLeft: "<-",
|
|
406
|
-
arrowRight: "->",
|
|
407
|
-
arrowDown: "v",
|
|
408
|
-
plus: "+",
|
|
409
|
-
minus: "-",
|
|
410
|
-
warning: "!",
|
|
411
|
-
effectWorkspace: "w",
|
|
412
|
-
effectExternal: "e",
|
|
413
|
-
sparkLevels: [" ", ".", ":", "-", "=", "+", "*", "#"]
|
|
414
|
-
};
|
|
415
|
-
var ROUND_BORDER = { topLeft: "╭", topRight: "╮", bottomLeft: "╰", bottomRight: "╯", horizontal: "─", vertical: "│", teeLeft: "├", teeRight: "┤", cross: "┼" };
|
|
416
|
-
var SINGLE_BORDER = { topLeft: "┌", topRight: "┐", bottomLeft: "└", bottomRight: "┘", horizontal: "─", vertical: "│", teeLeft: "├", teeRight: "┤", cross: "┼" };
|
|
417
|
-
var DOUBLE_BORDER = { topLeft: "╔", topRight: "╗", bottomLeft: "╚", bottomRight: "╝", horizontal: "═", vertical: "║", teeLeft: "╠", teeRight: "╣", cross: "╬" };
|
|
418
|
-
var ASCII_BORDER = { topLeft: "+", topRight: "+", bottomLeft: "+", bottomRight: "+", horizontal: "-", vertical: "|", teeLeft: "+", teeRight: "+", cross: "+" };
|
|
419
|
-
function borderGlyphsFor(style, glyphs) {
|
|
420
|
-
if (glyphs === ASCII_GLYPHS)
|
|
421
|
-
return ASCII_BORDER;
|
|
422
|
-
if (style === "single")
|
|
423
|
-
return SINGLE_BORDER;
|
|
424
|
-
if (style === "double")
|
|
425
|
-
return DOUBLE_BORDER;
|
|
426
|
-
return ROUND_BORDER;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// src/text/text-width.ts
|
|
430
|
-
var ANSI = /\x1b\[[0-9;]*m/g;
|
|
431
|
-
var PRINTABLE_ASCII = /^[\x20-\x7e]*$/;
|
|
432
|
-
function visibleWidth(text) {
|
|
433
|
-
if (PRINTABLE_ASCII.test(text))
|
|
434
|
-
return text.length;
|
|
435
|
-
let width = 0;
|
|
436
|
-
for (const character of text.includes("\x1B") ? text.replace(ANSI, "") : text) {
|
|
437
|
-
const code = character.codePointAt(0) ?? 0;
|
|
438
|
-
if (code >= 768 && code <= 879)
|
|
439
|
-
continue;
|
|
440
|
-
width += isWide(code) ? 2 : 1;
|
|
441
|
-
}
|
|
442
|
-
return width;
|
|
443
|
-
}
|
|
444
|
-
function isWide(code) {
|
|
445
|
-
return code >= 4352 && code <= 4447 || code >= 11904 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65135 || code >= 65280 && code <= 65376 || code >= 127744 && code <= 129535;
|
|
446
|
-
}
|
|
447
|
-
function clipTo(text, width, glyphs = UNICODE_GLYPHS) {
|
|
448
|
-
if (width <= 0)
|
|
449
|
-
return "";
|
|
450
|
-
if (visibleWidth(text) <= width)
|
|
451
|
-
return text;
|
|
452
|
-
const mark = visibleWidth(glyphs.ellipsis) < width ? glyphs.ellipsis : "";
|
|
453
|
-
const budget = width - visibleWidth(mark);
|
|
454
|
-
let out = "";
|
|
455
|
-
const segments = typeof Intl.Segmenter === "function" ? [...new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text)].map((entry) => entry.segment) : [...text];
|
|
456
|
-
for (const segment of segments) {
|
|
457
|
-
if (visibleWidth(out + segment) > budget)
|
|
458
|
-
break;
|
|
459
|
-
out += segment;
|
|
460
|
-
}
|
|
461
|
-
return `${out}${mark}`;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
export { RESET, BOLD, DIM, ITALIC, STRIKE, REVERSE, paint, paintAll, UNICODE_GLYPHS, ASCII_GLYPHS, borderGlyphsFor, visibleWidth, clipTo, BUILTIN_THEME_SOURCES, parseColor, rgbTo256, rainbowText, parseThemeSource, EXTERNAL_MARK, ANSI_PALETTE, roleCode, NO_COLOR_PALETTE };
|