@xynogen/pix-pretty 2.0.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/batch.ts +24 -0
- package/src/index.ts +1 -3
- package/src/renderers.ts +15 -16
- package/src/shell-tool.ts +146 -22
- package/src/tool-card.ts +232 -0
- package/src/tui.ts +52 -0
- package/src/types.ts +23 -22
- package/src/utils.ts +60 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xynogen/pix-pretty",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -34,17 +34,18 @@
|
|
|
34
34
|
"./shell-tool": "./src/shell-tool.ts",
|
|
35
35
|
"./command-preview": "./src/command-preview.ts",
|
|
36
36
|
"./tool-status": "./src/tool-status.ts",
|
|
37
|
+
"./tool-card": "./src/tool-card.ts",
|
|
37
38
|
"./test-utils": "./src/test-utils.ts",
|
|
38
39
|
"./transient-error": "./src/transient-error.ts",
|
|
39
40
|
"./chips": "./src/chips.ts",
|
|
40
|
-
"./grammar-consent": "./src/grammar-consent.ts"
|
|
41
|
+
"./grammar-consent": "./src/grammar-consent.ts",
|
|
42
|
+
"./tui": "./src/tui.ts"
|
|
41
43
|
},
|
|
42
44
|
"scripts": {
|
|
43
45
|
"test": "bun test"
|
|
44
46
|
},
|
|
45
47
|
"files": [
|
|
46
48
|
"src",
|
|
47
|
-
"!src/**/*.test.*",
|
|
48
49
|
"README.md",
|
|
49
50
|
"LICENSE"
|
|
50
51
|
],
|
|
@@ -72,7 +73,7 @@
|
|
|
72
73
|
"access": "public"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"@xynogen/pix-runtime": "^0.
|
|
76
|
+
"@xynogen/pix-runtime": "^0.21.0",
|
|
76
77
|
"chalk": "^4.1.2",
|
|
77
78
|
"cli-highlight": "^2.1.11",
|
|
78
79
|
"@ff-labs/fff-node": "^0.10.6",
|
package/src/batch.ts
CHANGED
|
@@ -34,6 +34,30 @@ export function sliceBatchTargets(targets: string[]): { targets: string[]; omitt
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export type BatchOutcome<R> = { target: string; result: R } | { target: string; error: string };
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Run every target in parallel. One target's failure becomes its `error` (via `describe`), so
|
|
41
|
+
* the rest still report; an abort rethrows, so a cancelled batch stops as a whole.
|
|
42
|
+
*/
|
|
43
|
+
export function runBatch<R>(
|
|
44
|
+
targets: string[],
|
|
45
|
+
run: (target: string, index: number) => Promise<R>,
|
|
46
|
+
signal: AbortSignal | undefined,
|
|
47
|
+
describe: (error: unknown, target: string) => string | Promise<string>,
|
|
48
|
+
): Promise<BatchOutcome<R>[]> {
|
|
49
|
+
return Promise.all(
|
|
50
|
+
targets.map(async (target, index) => {
|
|
51
|
+
try {
|
|
52
|
+
return { target, result: await run(target, index) };
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (signal?.aborted) throw error;
|
|
55
|
+
return { target, error: await describe(error, target) };
|
|
56
|
+
}
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
37
61
|
/** Minimal JSON-schema object shape we touch when adding a batch field. */
|
|
38
62
|
export interface SchemaObject {
|
|
39
63
|
properties: Record<string, unknown>;
|
package/src/index.ts
CHANGED
|
@@ -16,7 +16,6 @@ import { clearHighlightCache } from "./highlight.ts";
|
|
|
16
16
|
import { initIconMode } from "./icon-persist.ts";
|
|
17
17
|
import { installOrderedWidgets } from "./ordered-widgets.ts";
|
|
18
18
|
import { installOverlayImages } from "./overlay-images.ts";
|
|
19
|
-
import type { PiPrettyApi } from "./types.ts";
|
|
20
19
|
|
|
21
20
|
export default function piPrettyExtension(pi: ExtensionAPI): void {
|
|
22
21
|
installOverlayImages();
|
|
@@ -30,7 +29,6 @@ export default function piPrettyExtension(pi: ExtensionAPI): void {
|
|
|
30
29
|
restore = undefined;
|
|
31
30
|
});
|
|
32
31
|
});
|
|
33
|
-
const prettyPi = pi as unknown as PiPrettyApi;
|
|
34
32
|
clearHighlightCache();
|
|
35
33
|
|
|
36
34
|
// ── Icon mode ───────────────────────────────────────────
|
|
@@ -41,5 +39,5 @@ export default function piPrettyExtension(pi: ExtensionAPI): void {
|
|
|
41
39
|
// ── FFF slash commands ──────────────────────────────────────────────
|
|
42
40
|
// fffState is a module-level singleton shared with pix-grep/pix-find.
|
|
43
41
|
// Commands become available once pix-grep initialises the finder.
|
|
44
|
-
registerFffCommands(
|
|
42
|
+
registerFffCommands(pi, fffState);
|
|
45
43
|
}
|
package/src/renderers.ts
CHANGED
|
@@ -49,6 +49,9 @@ export async function renderFileContent(
|
|
|
49
49
|
const show = lines.slice(0, maxLines);
|
|
50
50
|
const lg = lang(filePath);
|
|
51
51
|
const hl = await hlBlock(show.join("\n"), lg, theme);
|
|
52
|
+
// A cut preview fades its last code rows. Only the code fades; the gutter stays solid.
|
|
53
|
+
const codeRows = show.map((line, i) => hl[i] ?? line);
|
|
54
|
+
const body = theme && total > maxLines ? fadeTail(codeRows, theme) : codeRows;
|
|
52
55
|
|
|
53
56
|
const tw = options.width ?? termW();
|
|
54
57
|
const startLine = offset;
|
|
@@ -60,9 +63,9 @@ export async function renderFileContent(
|
|
|
60
63
|
const out: string[] = [];
|
|
61
64
|
out.push(rule(tw));
|
|
62
65
|
|
|
63
|
-
for (let i = 0; i <
|
|
66
|
+
for (let i = 0; i < body.length; i++) {
|
|
64
67
|
const ln = startLine + i;
|
|
65
|
-
const code =
|
|
68
|
+
const code = body[i] ?? "";
|
|
66
69
|
if (options.wrapLongLines && visibleWidth(code) > cw) {
|
|
67
70
|
// Expanded view: no tail is hidden. First row carries the line number,
|
|
68
71
|
// continuation rows indent under the gutter so the code column aligns.
|
|
@@ -78,8 +81,6 @@ export async function renderFileContent(
|
|
|
78
81
|
out.push(`${lnum(ln, nw)} ${FG_RULE}│${RST} ${display}${RST}`);
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
// A cut preview fades its last code rows (rule row 0 stays as is).
|
|
82
|
-
if (theme && total > maxLines) out.splice(1, Infinity, ...fadeTail(out.slice(1), theme));
|
|
83
84
|
out.push(rule(tw));
|
|
84
85
|
if (total > maxLines) {
|
|
85
86
|
const more = `${BODY_PAD}… ${pluralize(total - maxLines, "more line")} (${total} total) `;
|
|
@@ -151,21 +152,19 @@ function renderLsTree(
|
|
|
151
152
|
const max = ctx?.expanded ? total : MAX_PREVIEW_LINES;
|
|
152
153
|
const show = lines.slice(0, max);
|
|
153
154
|
|
|
154
|
-
|
|
155
|
-
const entry =
|
|
156
|
-
const isLast = i === show.length - 1 && total <= max;
|
|
157
|
-
const prefix = isLast ? "└── " : "├── ";
|
|
158
|
-
const connector = `${FG_RULE}${prefix}${RST}`;
|
|
159
|
-
|
|
155
|
+
const names = show.map((line) => {
|
|
156
|
+
const entry = line.trim();
|
|
160
157
|
const isDir = entry.endsWith("/");
|
|
161
158
|
const name = isDir ? entry.slice(0, -1) : entry;
|
|
162
159
|
const icon = isDir ? dirIcon(theme) : fileIcon(name, theme);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
160
|
+
return `${icon}${entryColor(isDir, name, theme)}`;
|
|
161
|
+
});
|
|
162
|
+
// A cut preview fades its last entries. Only the names fade; the tree connectors stay solid.
|
|
163
|
+
const body = theme && total > max ? fadeTail(names, theme) : names;
|
|
164
|
+
body.forEach((name, i) => {
|
|
165
|
+
const isLast = i === show.length - 1 && total <= max;
|
|
166
|
+
out.push(`${FG_RULE}${isLast ? "└── " : "├── "}${RST}${name}`);
|
|
167
|
+
});
|
|
169
168
|
if (total > max) {
|
|
170
169
|
out.push(
|
|
171
170
|
`${FG_RULE}└── ${RST}${FG_DIM}… ${pluralize(total - max, "more entry", "more entries")} ${RST}${theme ? expandHint(theme, ctx) : ""}`,
|
package/src/shell-tool.ts
CHANGED
|
@@ -12,9 +12,7 @@ import type { AgentToolUpdateCallback, ExtensionContext } from "@earendil-works/
|
|
|
12
12
|
import { type CollapseState, tickCollapse } from "@xynogen/pix-runtime/collapse";
|
|
13
13
|
import { resolveBaseBackground } from "./ansi.ts";
|
|
14
14
|
import { collapsedCommandRow, commandPreview } from "./command-preview.ts";
|
|
15
|
-
import { MAX_PREVIEW_LINES } from "./config.ts";
|
|
16
15
|
import { renderBashOutput } from "./renderers.ts";
|
|
17
|
-
import { fadeRowsOf } from "./text.ts";
|
|
18
16
|
import type { ToolContext } from "./tools/context.ts";
|
|
19
17
|
import type {
|
|
20
18
|
BashParams,
|
|
@@ -28,21 +26,18 @@ import {
|
|
|
28
26
|
BODY_PAD,
|
|
29
27
|
bodyLine,
|
|
30
28
|
dotJoin,
|
|
31
|
-
fadeRulePaint,
|
|
32
29
|
fillToolBackground,
|
|
33
30
|
frameToolResult,
|
|
34
31
|
getErrorMessage,
|
|
35
32
|
getTextContent,
|
|
36
33
|
hideCollapsedToolCall,
|
|
37
34
|
isTextContent,
|
|
38
|
-
|
|
35
|
+
outputBodyRows,
|
|
39
36
|
renderRow,
|
|
40
37
|
renderTitle,
|
|
41
38
|
renderToolError,
|
|
42
|
-
|
|
39
|
+
reuseText,
|
|
43
40
|
setResultDetails,
|
|
44
|
-
termW,
|
|
45
|
-
unframeToolResult,
|
|
46
41
|
} from "./utils.ts";
|
|
47
42
|
import { formatDuration } from "./widget-format.ts";
|
|
48
43
|
|
|
@@ -149,7 +144,7 @@ export function registerShellTool(
|
|
|
149
144
|
renderCall(args: BashParams, theme: ThemeLike, renderCtx: RenderContextLike) {
|
|
150
145
|
resolveBaseBackground(theme);
|
|
151
146
|
const displayCmdRaw = (args.command ?? "").trim();
|
|
152
|
-
const text = renderCtx.lastComponent
|
|
147
|
+
const text = reuseText(renderCtx.lastComponent, TextComponent);
|
|
153
148
|
const label = renderTitle(theme, name, renderCtx);
|
|
154
149
|
const collapseState = renderCtx.state as CollapseState;
|
|
155
150
|
if (hideCollapsedToolCall(collapseState, renderCtx.expanded, (value) => text.setText(value)))
|
|
@@ -175,7 +170,7 @@ export function registerShellTool(
|
|
|
175
170
|
renderCtx: RenderContextLike,
|
|
176
171
|
) {
|
|
177
172
|
resolveBaseBackground(theme);
|
|
178
|
-
const text =
|
|
173
|
+
const text = reuseText(renderCtx.lastComponent, TextComponent);
|
|
179
174
|
const d = result.details as Record<string, unknown> | undefined;
|
|
180
175
|
const isPartial = (_opt as { isPartial?: boolean } | undefined)?.isPartial === true;
|
|
181
176
|
const completed = () => frameToolResult(text, theme, renderCtx.isError);
|
|
@@ -221,29 +216,18 @@ export function registerShellTool(
|
|
|
221
216
|
const normalizedText = normalizeShellText(d.text as string);
|
|
222
217
|
const { summary } = renderBashOutput(normalizedText, d.exitCode as number | null, theme);
|
|
223
218
|
const lines = normalizedText ? normalizedText.split("\n") : [];
|
|
224
|
-
const lineCount = lines.length;
|
|
225
219
|
|
|
226
220
|
if (!normalizedText) {
|
|
227
221
|
text.setText(fillToolBackground(summary));
|
|
228
222
|
return isPartial ? text : completed();
|
|
229
223
|
}
|
|
230
224
|
|
|
231
|
-
const maxShow = renderCtx.expanded ? lineCount : MAX_PREVIEW_LINES;
|
|
232
|
-
const footer =
|
|
233
|
-
lineCount > maxShow ? [moreLines(lineCount - maxShow, theme, renderCtx)] : [];
|
|
234
225
|
// Every result (including single-line) is framed; the rules follow exit
|
|
235
226
|
// status: green ok, red failure. The `✓ exit N` header is dropped — the
|
|
236
227
|
// collapsed row already carries status.
|
|
237
228
|
const exitCode = d.exitCode as number | null;
|
|
238
|
-
const
|
|
239
|
-
const
|
|
240
|
-
// Fade the last preview rows instead of a hard cut before the "… N more" row.
|
|
241
|
-
const body = fadeRowsOf(
|
|
242
|
-
lines.slice(0, maxShow + 1).map((line) => bodyLine(line, theme)),
|
|
243
|
-
theme,
|
|
244
|
-
maxShow,
|
|
245
|
-
);
|
|
246
|
-
const out = isPartial ? [...body, ...footer] : ruleFrame(body, footer, termW(), paint);
|
|
229
|
+
const status = exitCode === null || exitCode === 0 ? "success" : "error";
|
|
230
|
+
const out = outputBodyRows(lines, theme, renderCtx, status, isPartial);
|
|
247
231
|
text.setText(fillToolBackground(out.join("\n")));
|
|
248
232
|
return text;
|
|
249
233
|
}
|
|
@@ -266,3 +250,143 @@ export function registerShellTool(
|
|
|
266
250
|
},
|
|
267
251
|
});
|
|
268
252
|
}
|
|
253
|
+
|
|
254
|
+
// ── Approval-gated command tools (ssh_run, sudo_run) ─────────────────────────
|
|
255
|
+
|
|
256
|
+
/** Lifecycle of a command that waits for user approval, then runs once. */
|
|
257
|
+
export type GatedCommandOutcome =
|
|
258
|
+
| "awaiting-approval"
|
|
259
|
+
| "running"
|
|
260
|
+
| "success"
|
|
261
|
+
| "denied"
|
|
262
|
+
| "timed-out"
|
|
263
|
+
| "cancelled"
|
|
264
|
+
| "error";
|
|
265
|
+
|
|
266
|
+
/** The result fields every gated command tool reports. */
|
|
267
|
+
export interface GatedCommandDetails {
|
|
268
|
+
command: string;
|
|
269
|
+
outcome: GatedCommandOutcome;
|
|
270
|
+
exitCode?: number;
|
|
271
|
+
lineCount?: number;
|
|
272
|
+
truncated?: boolean;
|
|
273
|
+
errorKind?: string;
|
|
274
|
+
_render?: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export type GatedCancellationKind = "denied" | "timeout" | "missing-password" | "aborted";
|
|
278
|
+
|
|
279
|
+
/** A closed approval overlay (timeout, deny, or no password) as an outcome plus a message. */
|
|
280
|
+
export function gatedCancellation(action: string): {
|
|
281
|
+
outcome: "timed-out" | "denied" | "cancelled";
|
|
282
|
+
cancellationKind: GatedCancellationKind;
|
|
283
|
+
text: string;
|
|
284
|
+
} {
|
|
285
|
+
if (action === "timeout")
|
|
286
|
+
return {
|
|
287
|
+
outcome: "timed-out",
|
|
288
|
+
cancellationKind: "timeout",
|
|
289
|
+
text: "Cancelled — Timed out — auto-denied.",
|
|
290
|
+
};
|
|
291
|
+
if (action === "denied")
|
|
292
|
+
return { outcome: "denied", cancellationKind: "denied", text: "Cancelled — Denied by user." };
|
|
293
|
+
return {
|
|
294
|
+
outcome: "cancelled",
|
|
295
|
+
cancellationKind: "missing-password",
|
|
296
|
+
text: "Cancelled — Cancelled — no password entered.",
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** One line of untrusted text: controls and runs of whitespace fold to single spaces. */
|
|
301
|
+
export function safeOneLine(value: string): string {
|
|
302
|
+
return value
|
|
303
|
+
.replace(/[\u0000-\u001f\u007f-\u009f]+/g, " ")
|
|
304
|
+
.replace(/\s+/g, " ")
|
|
305
|
+
.trim();
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Collapsed-row meta: the terminal outcome, else exit code, extras, line count, truncation. */
|
|
309
|
+
export function gatedCommandMeta(
|
|
310
|
+
details: GatedCommandDetails,
|
|
311
|
+
errorLabels: Record<string, string>,
|
|
312
|
+
extras: Array<string | false | undefined> = [],
|
|
313
|
+
): string {
|
|
314
|
+
if (details.outcome === "denied") return "denied";
|
|
315
|
+
if (details.outcome === "timed-out") return "timed out";
|
|
316
|
+
if (details.outcome === "cancelled") return "cancelled";
|
|
317
|
+
const label = details.errorKind ? errorLabels[details.errorKind] : undefined;
|
|
318
|
+
if (label) return label;
|
|
319
|
+
const hasLines = typeof details.lineCount === "number" && details.lineCount > 0;
|
|
320
|
+
return dotJoin([
|
|
321
|
+
typeof details.exitCode === "number" && `exit ${details.exitCode}`,
|
|
322
|
+
...extras,
|
|
323
|
+
hasLines && `${details.lineCount} ${details.lineCount === 1 ? "line" : "lines"}`,
|
|
324
|
+
details.truncated && "truncated",
|
|
325
|
+
]);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Result card for a gated command once its details are known: collapsed row when finished,
|
|
330
|
+
* a muted status line while waiting or running, the diagnostic on failure, else the output.
|
|
331
|
+
*/
|
|
332
|
+
export function renderGatedCommandResult(
|
|
333
|
+
result: ToolResultLike,
|
|
334
|
+
details: GatedCommandDetails,
|
|
335
|
+
opts: { name: string; target: string; meta: string },
|
|
336
|
+
isPartial: boolean,
|
|
337
|
+
theme: ThemeLike,
|
|
338
|
+
renderCtx: RenderContextLike,
|
|
339
|
+
) {
|
|
340
|
+
const text = reuseText(renderCtx.lastComponent);
|
|
341
|
+
const completed = (isError: boolean) => frameToolResult(text, theme, isError);
|
|
342
|
+
const status = details.outcome === "success" ? "success" : "error";
|
|
343
|
+
const running = details.outcome === "awaiting-approval" || details.outcome === "running";
|
|
344
|
+
|
|
345
|
+
if (
|
|
346
|
+
!isPartial &&
|
|
347
|
+
!running &&
|
|
348
|
+
tickCollapse(
|
|
349
|
+
opts.name,
|
|
350
|
+
renderCtx.state as CollapseState,
|
|
351
|
+
renderCtx.invalidate,
|
|
352
|
+
renderCtx.expanded,
|
|
353
|
+
)
|
|
354
|
+
) {
|
|
355
|
+
return collapsedCommandRow(
|
|
356
|
+
renderRow(theme, opts.name, opts.target, opts.meta, status).trimEnd(),
|
|
357
|
+
safeOneLine(details.command),
|
|
358
|
+
theme,
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (running) {
|
|
363
|
+
text.setText(
|
|
364
|
+
fillToolBackground(`${BODY_PAD}${theme.fg("muted", getTextContent(result) || "working")}`),
|
|
365
|
+
);
|
|
366
|
+
return text;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (details.outcome !== "success" && details.errorKind !== "exit-code") {
|
|
370
|
+
const diagnostic = getTextContent(result) || "Error";
|
|
371
|
+
text.setText(
|
|
372
|
+
details.outcome === "error"
|
|
373
|
+
? renderToolError(diagnostic, theme)
|
|
374
|
+
: fillToolBackground(`${BODY_PAD}${theme.fg("warning", diagnostic)}`),
|
|
375
|
+
);
|
|
376
|
+
return isPartial ? text : completed(true);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
const code = typeof details.exitCode === "number" ? details.exitCode : null;
|
|
380
|
+
const rendered = typeof details._render === "string" ? details._render : "";
|
|
381
|
+
if (!rendered) {
|
|
382
|
+
const { summary } = renderBashOutput(rendered, code, theme);
|
|
383
|
+
text.setText(fillToolBackground(`${BODY_PAD}${summary}`));
|
|
384
|
+
return isPartial ? text : completed(details.outcome !== "success");
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Every result (including single-line) is framed; the rules follow exit status: green ok,
|
|
388
|
+
// red failure. The `✓ exit N` header is dropped — the collapsed row already carries status.
|
|
389
|
+
const rows = outputBodyRows(rendered.split("\n"), theme, renderCtx, status, isPartial);
|
|
390
|
+
text.setText(fillToolBackground(rows.join("\n")));
|
|
391
|
+
return text;
|
|
392
|
+
}
|
package/src/tool-card.ts
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-card — the call row and result card every self-rendered tool shares.
|
|
3
|
+
*
|
|
4
|
+
* One place owns the order: a bare or partial error first, then the auto-collapsed
|
|
5
|
+
* row, then a structured error, then the tool's own body inside the result frame.
|
|
6
|
+
* A tool supplies only what differs: which details are its own, the collapsed row
|
|
7
|
+
* text, and the body.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { Box, Markdown } from "@earendil-works/pi-tui";
|
|
11
|
+
import { type CollapseState, tickCollapse } from "@xynogen/pix-runtime/collapse";
|
|
12
|
+
import { resolveBaseBackground } from "./ansi.ts";
|
|
13
|
+
import { fadeRowsOf } from "./text.ts";
|
|
14
|
+
import { getMarkdownTheme } from "./tui.ts";
|
|
15
|
+
import type {
|
|
16
|
+
RenderContextLike,
|
|
17
|
+
TextComponentCtor,
|
|
18
|
+
TextComponentLike,
|
|
19
|
+
ThemeLike,
|
|
20
|
+
ToolResultLike,
|
|
21
|
+
} from "./types.ts";
|
|
22
|
+
import {
|
|
23
|
+
BODY_PAD,
|
|
24
|
+
bodyLine,
|
|
25
|
+
type CollapsedToolStatus,
|
|
26
|
+
frameToolResult,
|
|
27
|
+
getTextContent,
|
|
28
|
+
hideCollapsedToolCall,
|
|
29
|
+
moreLines,
|
|
30
|
+
renderCollapsed,
|
|
31
|
+
renderRow,
|
|
32
|
+
renderToolError,
|
|
33
|
+
reuseText,
|
|
34
|
+
} from "./utils.ts";
|
|
35
|
+
|
|
36
|
+
type RenderState = Record<string, string | undefined>;
|
|
37
|
+
|
|
38
|
+
export interface ToolCardBody<D, S extends RenderState> {
|
|
39
|
+
d: D | undefined;
|
|
40
|
+
result: ToolResultLike<D>;
|
|
41
|
+
text: TextComponentLike;
|
|
42
|
+
theme: ThemeLike;
|
|
43
|
+
ctx: RenderContextLike<S>;
|
|
44
|
+
isPartial: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ToolCardSpec<D, S extends RenderState> {
|
|
48
|
+
/** Tool name: the collapse key and the collapsed row title. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** True for details this tool produced. An error that carries them still renders as a card. */
|
|
51
|
+
owns(d: D | undefined): boolean;
|
|
52
|
+
/** Collapsed row target and success summary. A failed call shows "failed" instead. */
|
|
53
|
+
collapsed(d: D | undefined): { target: string; summary: string };
|
|
54
|
+
/** Set the expanded body. Return "framed" when the body drew its own frame. */
|
|
55
|
+
body(input: ToolCardBody<D, S>): "framed" | undefined;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** `renderResult` for a self-rendered tool card. */
|
|
59
|
+
export function toolCardRenderer<D = Record<string, unknown>, S extends RenderState = RenderState>(
|
|
60
|
+
TextComponent: TextComponentCtor,
|
|
61
|
+
spec: ToolCardSpec<D, S>,
|
|
62
|
+
) {
|
|
63
|
+
return (
|
|
64
|
+
result: ToolResultLike<D>,
|
|
65
|
+
options: { isPartial?: boolean } | undefined,
|
|
66
|
+
theme: ThemeLike,
|
|
67
|
+
ctx: RenderContextLike<S>,
|
|
68
|
+
) => {
|
|
69
|
+
resolveBaseBackground(theme);
|
|
70
|
+
const text = reuseText(ctx.lastComponent, TextComponent);
|
|
71
|
+
const d = result.details ?? undefined;
|
|
72
|
+
const isPartial = options?.isPartial === true;
|
|
73
|
+
const completed = () => frameToolResult(text, theme, ctx.isError);
|
|
74
|
+
const showError = () => text.setText(renderToolError(getTextContent(result) || "Error", theme));
|
|
75
|
+
|
|
76
|
+
if (ctx.isError && (!spec.owns(d) || isPartial)) {
|
|
77
|
+
showError();
|
|
78
|
+
return isPartial ? text : completed();
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
!isPartial &&
|
|
82
|
+
tickCollapse(spec.name, ctx.state as CollapseState, ctx.invalidate, ctx.expanded)
|
|
83
|
+
) {
|
|
84
|
+
const { target, summary } = spec.collapsed(d);
|
|
85
|
+
const failed = ctx.isError;
|
|
86
|
+
text.setText(
|
|
87
|
+
renderCollapsed(
|
|
88
|
+
theme,
|
|
89
|
+
spec.name,
|
|
90
|
+
target,
|
|
91
|
+
failed ? "failed" : summary,
|
|
92
|
+
failed ? "error" : "success",
|
|
93
|
+
),
|
|
94
|
+
);
|
|
95
|
+
return text;
|
|
96
|
+
}
|
|
97
|
+
if (ctx.isError) {
|
|
98
|
+
showError();
|
|
99
|
+
return completed();
|
|
100
|
+
}
|
|
101
|
+
const framed = spec.body({ d, result, text, theme, ctx, isPartial });
|
|
102
|
+
return framed === "framed" || isPartial ? text : completed();
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** `renderCall` for a self-rendered tool: hidden once its result collapsed, else `line`. */
|
|
107
|
+
export function toolCallRenderer<A, S extends RenderState = RenderState>(
|
|
108
|
+
TextComponent: TextComponentCtor,
|
|
109
|
+
line: (args: A, theme: ThemeLike, ctx: RenderContextLike<S>) => string,
|
|
110
|
+
) {
|
|
111
|
+
return (args: A, theme: ThemeLike, ctx: RenderContextLike<S>) => {
|
|
112
|
+
resolveBaseBackground(theme);
|
|
113
|
+
const text = reuseText(ctx.lastComponent, TextComponent);
|
|
114
|
+
if (hideCollapsedToolCall(ctx.state as CollapseState, ctx.expanded, (v) => text.setText(v)))
|
|
115
|
+
return text;
|
|
116
|
+
text.setText(line(args, theme, ctx));
|
|
117
|
+
return text;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A tool whose result body is fetched/searched text: a preview while collapsed, all when expanded. */
|
|
122
|
+
export interface BodyCardSpec<D> {
|
|
123
|
+
/** Tool name: the collapse key and the default collapsed-row title. */
|
|
124
|
+
tool: string;
|
|
125
|
+
/** Collapsed-row title when it differs from `tool`. */
|
|
126
|
+
title?: string;
|
|
127
|
+
/** Collapsed-row target and summary; both default to empty. */
|
|
128
|
+
target?(d: D): string;
|
|
129
|
+
meta?(d: D): string;
|
|
130
|
+
status?(d: D): CollapsedToolStatus;
|
|
131
|
+
/** Preview budget in rows while collapsed; expanding shows everything. Default 16. */
|
|
132
|
+
maxPreviewLines?: number;
|
|
133
|
+
/** Render a successful body as Markdown (fades its tail) instead of dim text. */
|
|
134
|
+
markdown?: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* `renderResult` for a text-body tool: error and empty states first, then the auto-collapsed
|
|
139
|
+
* row, then the body — dim text, or Markdown for `spec.markdown` — inside the result frame.
|
|
140
|
+
*/
|
|
141
|
+
export function bodyCardRenderer<D = Record<string, unknown>, S extends RenderState = RenderState>(
|
|
142
|
+
TextComponent: TextComponentCtor,
|
|
143
|
+
spec: BodyCardSpec<D>,
|
|
144
|
+
) {
|
|
145
|
+
const maxPreview = spec.maxPreviewLines ?? 16;
|
|
146
|
+
const dimBody = (
|
|
147
|
+
body: string,
|
|
148
|
+
theme: ThemeLike,
|
|
149
|
+
ctx: RenderContextLike<S>,
|
|
150
|
+
expanded: boolean,
|
|
151
|
+
) => {
|
|
152
|
+
const lines = body.split("\n");
|
|
153
|
+
const shown = expanded ? lines.length : maxPreview;
|
|
154
|
+
const out = fadeRowsOf(
|
|
155
|
+
lines.slice(0, shown + 1).map((line) => bodyLine(line, theme, (l) => theme.fg("dim", l))),
|
|
156
|
+
theme,
|
|
157
|
+
shown,
|
|
158
|
+
);
|
|
159
|
+
const hidden = lines.length - shown;
|
|
160
|
+
if (hidden > 0) out.push(moreLines(hidden, theme, ctx));
|
|
161
|
+
return out.join("\n");
|
|
162
|
+
};
|
|
163
|
+
const markdownBody = (
|
|
164
|
+
body: string,
|
|
165
|
+
theme: ThemeLike,
|
|
166
|
+
ctx: RenderContextLike<S>,
|
|
167
|
+
expanded: boolean,
|
|
168
|
+
) => {
|
|
169
|
+
const view = new Box(0, 0);
|
|
170
|
+
const page = new Markdown(body, 3, 0, getMarkdownTheme(), {
|
|
171
|
+
color: (value) => theme.fg("dim", value),
|
|
172
|
+
});
|
|
173
|
+
if (expanded) view.addChild(page);
|
|
174
|
+
// Fade the last preview rows of the rendered page instead of a hard cut.
|
|
175
|
+
else
|
|
176
|
+
view.addChild({
|
|
177
|
+
invalidate: () => page.invalidate(),
|
|
178
|
+
render: (width: number) => {
|
|
179
|
+
const rows = page.render(width);
|
|
180
|
+
const hidden = rows.length - maxPreview;
|
|
181
|
+
const shownRows = fadeRowsOf(rows, theme, maxPreview);
|
|
182
|
+
return hidden > 0 ? [...shownRows, moreLines(hidden, theme, ctx)] : shownRows;
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
return view;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
return (
|
|
189
|
+
result: ToolResultLike,
|
|
190
|
+
options: { isPartial?: boolean; expanded?: boolean } | undefined,
|
|
191
|
+
theme: ThemeLike,
|
|
192
|
+
ctx: RenderContextLike<S>,
|
|
193
|
+
) => {
|
|
194
|
+
resolveBaseBackground(theme);
|
|
195
|
+
const text = reuseText(ctx.lastComponent, TextComponent);
|
|
196
|
+
const isPartial = options?.isPartial === true;
|
|
197
|
+
const expanded = options?.expanded ?? ctx.expanded;
|
|
198
|
+
const body = getTextContent(result);
|
|
199
|
+
|
|
200
|
+
if (ctx.isError || !body.trim()) {
|
|
201
|
+
text.setText(
|
|
202
|
+
`${BODY_PAD}${ctx.isError ? theme.fg("error", body || "Error") : theme.fg("muted", "(empty)")}`,
|
|
203
|
+
);
|
|
204
|
+
return isPartial ? text : frameToolResult(text, theme, ctx.isError);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// SAFETY: the renderer receives the tool's own details; the spec types them as D.
|
|
208
|
+
const d = (result.details ?? undefined) as D | undefined;
|
|
209
|
+
if (
|
|
210
|
+
!isPartial &&
|
|
211
|
+
d &&
|
|
212
|
+
tickCollapse(spec.tool, ctx.state as CollapseState, ctx.invalidate, expanded)
|
|
213
|
+
) {
|
|
214
|
+
text.setText(
|
|
215
|
+
renderRow(
|
|
216
|
+
theme,
|
|
217
|
+
spec.title ?? spec.tool,
|
|
218
|
+
spec.target?.(d) ?? "",
|
|
219
|
+
spec.meta?.(d) ?? "",
|
|
220
|
+
spec.status?.(d) ?? "success",
|
|
221
|
+
),
|
|
222
|
+
);
|
|
223
|
+
return text;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const failed = Boolean(d && spec.status?.(d) === "error");
|
|
227
|
+
if (spec.markdown && !failed && !isPartial)
|
|
228
|
+
return frameToolResult(markdownBody(body, theme, ctx, expanded), theme, false);
|
|
229
|
+
text.setText(dimBody(body, theme, ctx, expanded));
|
|
230
|
+
return isPartial ? text : frameToolResult(text, theme, failed);
|
|
231
|
+
};
|
|
232
|
+
}
|
package/src/tui.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tui.ts — the terminal UI surface for feature packages: pi-tui components and
|
|
3
|
+
* helpers plus Pi's UI types. Named re-exports only, so the host's classes keep
|
|
4
|
+
* their identity. Non-UI Pi API lives in `@xynogen/pix-runtime/host`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
ThemeColor,
|
|
9
|
+
ToolRenderers,
|
|
10
|
+
ToolRenderResultOptions,
|
|
11
|
+
} from "@earendil-works/pi-coding-agent";
|
|
12
|
+
export {
|
|
13
|
+
AssistantMessageComponent,
|
|
14
|
+
CustomEditor,
|
|
15
|
+
getMarkdownTheme,
|
|
16
|
+
Theme,
|
|
17
|
+
} from "@earendil-works/pi-coding-agent";
|
|
18
|
+
export type {
|
|
19
|
+
Component,
|
|
20
|
+
EditorTheme,
|
|
21
|
+
KeybindingsManager,
|
|
22
|
+
KeyId,
|
|
23
|
+
MarkdownTheme,
|
|
24
|
+
SelectItem,
|
|
25
|
+
TextStyle,
|
|
26
|
+
TUI,
|
|
27
|
+
} from "@earendil-works/pi-tui";
|
|
28
|
+
export {
|
|
29
|
+
Box,
|
|
30
|
+
Container,
|
|
31
|
+
decodeKittyPrintable,
|
|
32
|
+
Editor,
|
|
33
|
+
fuzzyFilter,
|
|
34
|
+
Input,
|
|
35
|
+
isKeyRelease,
|
|
36
|
+
isKeyRepeat,
|
|
37
|
+
isKittyProtocolActive,
|
|
38
|
+
Key,
|
|
39
|
+
Markdown,
|
|
40
|
+
matchesKey,
|
|
41
|
+
mixColors,
|
|
42
|
+
parseColor,
|
|
43
|
+
parseKey,
|
|
44
|
+
SelectList,
|
|
45
|
+
Spacer,
|
|
46
|
+
sliceByColumn,
|
|
47
|
+
stripTerminalSequences,
|
|
48
|
+
Text,
|
|
49
|
+
truncateToWidth,
|
|
50
|
+
visibleWidth,
|
|
51
|
+
wrapTextWithAnsi,
|
|
52
|
+
} from "@earendil-works/pi-tui";
|
package/src/types.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
ReadToolInput,
|
|
13
13
|
WriteToolInput,
|
|
14
14
|
} from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import type { Component } from "@earendil-works/pi-tui";
|
|
15
16
|
import type { FileFinder } from "@ff-labs/fff-node";
|
|
16
17
|
|
|
17
18
|
// We keep the original shiki-shaped types as plain string aliases so the
|
|
@@ -25,16 +26,18 @@ export type BundledTheme = string;
|
|
|
25
26
|
// ---------------------------------------------------------------------------
|
|
26
27
|
|
|
27
28
|
export type BgTheme = {
|
|
28
|
-
|
|
29
|
+
// Method syntax: Pi's Theme takes narrower ThemeBg keys, and method params are bivariant.
|
|
30
|
+
getBgAnsi?(key: string): string;
|
|
29
31
|
// Semantic background wrapper exposed by Pi's theme (e.g. modal fills). Optional
|
|
30
32
|
// so mock/partial themes remain assignable; real runtime themes provide it.
|
|
31
|
-
bg
|
|
33
|
+
bg?(key: string, text: string): string;
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
export type FgTheme = {
|
|
35
|
-
|
|
37
|
+
// Method syntax: Pi's Theme takes a narrower ThemeColor key, and method params are bivariant.
|
|
38
|
+
fg(key: string, text: string): string;
|
|
36
39
|
// Optional raw-ANSI accessor exposed by Pi's theme for semantic foregrounds.
|
|
37
|
-
getFgAnsi
|
|
40
|
+
getFgAnsi?(key: string): string;
|
|
38
41
|
};
|
|
39
42
|
|
|
40
43
|
export type ImageProtocol = "iterm2" | "kitty" | "none";
|
|
@@ -47,11 +50,9 @@ export type ToolContent = TextContent | ImageContent;
|
|
|
47
50
|
|
|
48
51
|
export type ToolResultLike<TDetails = unknown> = AgentToolResult<TDetails | undefined>;
|
|
49
52
|
|
|
50
|
-
export type TextComponentLike = {
|
|
53
|
+
export type TextComponentLike = Component & {
|
|
51
54
|
setText(value: string): void;
|
|
52
55
|
getText?: () => string;
|
|
53
|
-
render?: (width: number) => string[];
|
|
54
|
-
invalidate?: () => void;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
export type TextComponentCtor = new (text?: string, x?: number, y?: number) => TextComponentLike;
|
|
@@ -61,7 +62,7 @@ export type ThemeLike = BgTheme & FgTheme & { bold: (text: string) => string };
|
|
|
61
62
|
export type RenderContextLike<
|
|
62
63
|
TState extends Record<string, string | undefined> = Record<string, string | undefined>,
|
|
63
64
|
> = {
|
|
64
|
-
lastComponent?:
|
|
65
|
+
lastComponent?: Component;
|
|
65
66
|
state: TState;
|
|
66
67
|
expanded: boolean;
|
|
67
68
|
isError: boolean;
|
|
@@ -82,20 +83,19 @@ type SessionContextLike = ExtensionContext;
|
|
|
82
83
|
|
|
83
84
|
export type CommandContextLike = ExtensionCommandContext;
|
|
84
85
|
|
|
85
|
-
type ToolExecutor<TParams, TDetails = unknown> = (
|
|
86
|
-
toolCallId: string,
|
|
87
|
-
params: TParams,
|
|
88
|
-
signal?: AbortSignal,
|
|
89
|
-
onUpdate?: AgentToolUpdateCallback<TDetails | undefined>,
|
|
90
|
-
ctx?: ExtensionContext,
|
|
91
|
-
) => Promise<ToolResultLike<TDetails>>;
|
|
92
|
-
|
|
93
86
|
export type ToolFactory<TParams, TDetails = unknown> = (cwd: string) => {
|
|
94
87
|
name?: string;
|
|
95
88
|
description?: string;
|
|
96
89
|
label?: string;
|
|
97
90
|
parameters?: unknown;
|
|
98
|
-
|
|
91
|
+
// Method syntax: Pi's execute requires the narrower ExtensionToolContext; params stay bivariant.
|
|
92
|
+
execute(
|
|
93
|
+
toolCallId: string,
|
|
94
|
+
params: TParams,
|
|
95
|
+
signal?: AbortSignal,
|
|
96
|
+
onUpdate?: AgentToolUpdateCallback<TDetails | undefined>,
|
|
97
|
+
ctx?: ExtensionContext,
|
|
98
|
+
): Promise<ToolResultLike<TDetails>>;
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export type PiPrettySdk = {
|
|
@@ -116,19 +116,20 @@ export type PiPrettySdk = {
|
|
|
116
116
|
getAgentDir?: () => string;
|
|
117
117
|
};
|
|
118
118
|
|
|
119
|
+
// Method syntax keeps params bivariant, so Pi's generic/overloaded ExtensionAPI is assignable.
|
|
119
120
|
export type PiPrettyApi = {
|
|
120
|
-
registerTool
|
|
121
|
-
registerCommand
|
|
121
|
+
registerTool(tool: unknown): void;
|
|
122
|
+
registerCommand(
|
|
122
123
|
name: string,
|
|
123
124
|
command: {
|
|
124
125
|
description?: string;
|
|
125
126
|
handler: (args: string, ctx: CommandContextLike) => Promise<void> | void;
|
|
126
127
|
},
|
|
127
|
-
)
|
|
128
|
-
on
|
|
128
|
+
): void;
|
|
129
|
+
on(
|
|
129
130
|
event: string,
|
|
130
131
|
handler: (event: unknown, ctx: SessionContextLike) => Promise<void> | void,
|
|
131
|
-
)
|
|
132
|
+
): void;
|
|
132
133
|
};
|
|
133
134
|
|
|
134
135
|
export type OptionalFffModule = { FileFinder: typeof FileFinder };
|
package/src/utils.ts
CHANGED
|
@@ -865,6 +865,19 @@ export function unframeToolResult<T extends FramableComponent>(component: T): T
|
|
|
865
865
|
return (framed[RESULT_FRAME]?.component ?? component) as T;
|
|
866
866
|
}
|
|
867
867
|
|
|
868
|
+
function isTextComponent(component: Component): component is TextComponentLike {
|
|
869
|
+
return typeof (component as Partial<TextComponentLike>).setText === "function";
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/** The prior render's text component (unframed) when it has one, else a fresh one. */
|
|
873
|
+
export function reuseText(
|
|
874
|
+
last: Component | undefined,
|
|
875
|
+
TextComponent: TextComponentCtor = Text,
|
|
876
|
+
): TextComponentLike {
|
|
877
|
+
const prior = last && unframeToolResult(last);
|
|
878
|
+
return prior && isTextComponent(prior) ? prior : new TextComponent("", 0, 0);
|
|
879
|
+
}
|
|
880
|
+
|
|
868
881
|
/**
|
|
869
882
|
* Default completed-tool chrome: unchanged body, full-width solid close, then
|
|
870
883
|
* footer lines. Existing callers inherit this distro-wide presentation.
|
|
@@ -878,6 +891,31 @@ export function ruleFrame(
|
|
|
878
891
|
return [...bodyLines, rule(width ?? termW(), paint), ...footerLines];
|
|
879
892
|
}
|
|
880
893
|
|
|
894
|
+
/**
|
|
895
|
+
* Command-output body: the first MAX_PREVIEW_LINES rows (all when expanded) with a
|
|
896
|
+
* fading tail and an "… N more" footer. Completed output closes with a status rule;
|
|
897
|
+
* partial output stays unframed. Returns the rows; the caller fills the background.
|
|
898
|
+
*/
|
|
899
|
+
export function outputBodyRows(
|
|
900
|
+
lines: string[],
|
|
901
|
+
theme: StatusRuleTheme & MutedTheme & Parameters<typeof fadeRowsOf>[1],
|
|
902
|
+
ctx: ExpandHintCtx,
|
|
903
|
+
status: "success" | "error",
|
|
904
|
+
partial: boolean,
|
|
905
|
+
): string[] {
|
|
906
|
+
const maxShow = ctx.expanded ? lines.length : MAX_PREVIEW_LINES;
|
|
907
|
+
const footer = lines.length > maxShow ? [moreLines(lines.length - maxShow, theme, ctx)] : [];
|
|
908
|
+
// Fade the last preview rows instead of a hard cut before the "… N more" row.
|
|
909
|
+
const body = fadeRowsOf(
|
|
910
|
+
lines.slice(0, maxShow + 1).map((line) => bodyLine(line, theme)),
|
|
911
|
+
theme,
|
|
912
|
+
maxShow,
|
|
913
|
+
);
|
|
914
|
+
return partial
|
|
915
|
+
? [...body, ...footer]
|
|
916
|
+
: ruleFrame(body, footer, termW(), fadeRulePaint(theme, status));
|
|
917
|
+
}
|
|
918
|
+
|
|
881
919
|
/** Explicit solid top/bottom frame for sections that need stronger separation. */
|
|
882
920
|
export function sectionFrame(
|
|
883
921
|
bodyLines: string[],
|
|
@@ -948,6 +986,28 @@ export function makeTextResult<TDetails>(
|
|
|
948
986
|
};
|
|
949
987
|
}
|
|
950
988
|
|
|
989
|
+
/** Details of an action tool (download, proc): an outcome plus model-facing lines or an error. */
|
|
990
|
+
export interface ActionResultDetails {
|
|
991
|
+
action: string;
|
|
992
|
+
ok: boolean;
|
|
993
|
+
lines: string[];
|
|
994
|
+
error?: string;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/** Tool result for an action: the error, else the lines, else `<action> ok`. */
|
|
998
|
+
export function makeActionResult<TDetails extends ActionResultDetails>(details: TDetails) {
|
|
999
|
+
return {
|
|
1000
|
+
content: [
|
|
1001
|
+
{
|
|
1002
|
+
type: "text" as const,
|
|
1003
|
+
text: details.error ?? (details.lines.join("\n") || `${details.action} ok`),
|
|
1004
|
+
},
|
|
1005
|
+
],
|
|
1006
|
+
details,
|
|
1007
|
+
isError: !details.ok,
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
|
|
951
1011
|
export function appendNotices(text: string, notices: string[]): string {
|
|
952
1012
|
return notices.length ? `${text}\n\n[${notices.join(". ")}]` : text;
|
|
953
1013
|
}
|