@hheei/pi-ext-ui 0.4.0 → 0.4.2
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/diff-view.js +5 -2
- package/dist/message-view.js +9 -2
- package/dist/nested-calls-view.js +14 -8
- package/dist/renderer.js +19 -6
- package/dist/tool-view.js +22 -5
- package/package.json +1 -1
package/dist/diff-view.js
CHANGED
|
@@ -153,9 +153,12 @@ export class DiffView {
|
|
|
153
153
|
if (!this.#parsed.ok)
|
|
154
154
|
rows.push(this.#theme.fg("warning", `! ${this.#parsed.diagnostic}`));
|
|
155
155
|
for (const raw of (this.#rawText ?? "").split(/\r?\n/)) {
|
|
156
|
-
|
|
156
|
+
const wrapped = wrapTextWithAnsi(raw, width);
|
|
157
|
+
for (const line of wrapped.length > 0 ? wrapped : [""]) {
|
|
158
|
+
rows.push(this.#theme.fg("dim", line));
|
|
159
|
+
}
|
|
157
160
|
}
|
|
158
|
-
return rows
|
|
161
|
+
return rows;
|
|
159
162
|
}
|
|
160
163
|
#renderDiff(width, hunks) {
|
|
161
164
|
const numberCol = numberWidth(hunks);
|
package/dist/message-view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { truncateToWidth, } from "@earendil-works/pi-tui";
|
|
1
|
+
import { truncateToWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
2
2
|
import { toContentRows, toSingleRow } from "./tool-view.js";
|
|
3
3
|
/**
|
|
4
4
|
* A transcript notice, not a tool execution.
|
|
@@ -38,7 +38,14 @@ function layRows(source, width) {
|
|
|
38
38
|
const raw = isComponent(source)
|
|
39
39
|
? source.render(inner).flatMap((line) => toContentRows(line))
|
|
40
40
|
: (typeof source === "string" ? [source] : source).flatMap((line) => toContentRows(line));
|
|
41
|
-
|
|
41
|
+
const rows = [];
|
|
42
|
+
for (const line of raw) {
|
|
43
|
+
const wrapped = wrapTextWithAnsi(line, inner);
|
|
44
|
+
for (const chunk of wrapped.length > 0 ? wrapped : [""]) {
|
|
45
|
+
rows.push(truncate(` ${chunk}`, width));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return rows;
|
|
42
49
|
}
|
|
43
50
|
function invalidateRows(source) {
|
|
44
51
|
if (source !== undefined && isComponent(source))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { copyToClipboard as copyToSystemClipboard, getLanguageFromPath, highlightCode, } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { stripTerminalSequences, truncateToWidth, visibleWidth, } from "@earendil-works/pi-tui";
|
|
2
|
+
import { stripTerminalSequences, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
3
3
|
import { inlinePresentation } from "./renderer.js";
|
|
4
4
|
import { formatToolHeaderText, ToolView, toContentRows, transitionFoldLevel, } from "./tool-view.js";
|
|
5
5
|
function truncate(text, width) {
|
|
@@ -167,6 +167,7 @@ export class NestedCallsView {
|
|
|
167
167
|
: context.toolCallId;
|
|
168
168
|
return {
|
|
169
169
|
...context,
|
|
170
|
+
lastComponent: undefined,
|
|
170
171
|
args: "args" in call ? call.args : undefined,
|
|
171
172
|
toolCallId,
|
|
172
173
|
durationMs: call.durationMs,
|
|
@@ -268,15 +269,20 @@ export class NestedCallsView {
|
|
|
268
269
|
copyRegion: { startX: width - copySlotWidth - 1, endX: width },
|
|
269
270
|
};
|
|
270
271
|
if (isExpanded) {
|
|
271
|
-
const
|
|
272
|
+
const childWidth = Math.max(1, width - 2);
|
|
273
|
+
const bodyLines = this.#renderChildBody(call, childWidth, expansionLevel);
|
|
272
274
|
for (const rawLine of bodyLines) {
|
|
273
275
|
for (const bodyLine of toContentRows(rawLine)) {
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
const wrapped = wrapTextWithAnsi(bodyLine, childWidth);
|
|
277
|
+
const chunks = wrapped.length > 0 ? wrapped : [""];
|
|
278
|
+
for (const chunk of chunks) {
|
|
279
|
+
const bodyLineIdx = lines.length;
|
|
280
|
+
lines.push(truncate(` ${chunk}`, width));
|
|
281
|
+
this.#lineMapping[bodyLineIdx] = {
|
|
282
|
+
callIndex: i,
|
|
283
|
+
isHeader: false,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
280
286
|
}
|
|
281
287
|
}
|
|
282
288
|
}
|
package/dist/renderer.js
CHANGED
|
@@ -53,7 +53,8 @@ function resolveToolCallSummary(params) {
|
|
|
53
53
|
// Tier 1: Host Native RenderCall Delegation
|
|
54
54
|
if (originalRenderCall !== undefined) {
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
56
|
+
const upstreamContext = { ...context, lastComponent: undefined };
|
|
57
|
+
const upstreamLines = originalRenderCall(args, theme, upstreamContext).render(120);
|
|
57
58
|
const firstNonEmpty = upstreamLines
|
|
58
59
|
.map((line) => stripTerminalSequences(line).trim())
|
|
59
60
|
.find((line) => line !== "");
|
|
@@ -143,9 +144,6 @@ export function isMcpTool(toolName) {
|
|
|
143
144
|
toolName === "list_mcp_resource_templates");
|
|
144
145
|
}
|
|
145
146
|
function shouldInterceptTool(toolName, options) {
|
|
146
|
-
if (options?.catchAll === true) {
|
|
147
|
-
return options.match !== undefined ? options.match(toolName) : true;
|
|
148
|
-
}
|
|
149
147
|
if (options?.match?.(toolName)) {
|
|
150
148
|
return true;
|
|
151
149
|
}
|
|
@@ -153,7 +151,10 @@ function shouldInterceptTool(toolName, options) {
|
|
|
153
151
|
if (toolList !== undefined) {
|
|
154
152
|
return toolList.includes(toolName);
|
|
155
153
|
}
|
|
156
|
-
|
|
154
|
+
if (options?.catchAll === false) {
|
|
155
|
+
return SPECIALIZED_TOOL_SET.has(toolName) || isMcpTool(toolName);
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
157
158
|
}
|
|
158
159
|
function renderGenericResult(params) {
|
|
159
160
|
const { toolName, theme, context, result, renderOptions, defaultLevel, originalRenderCall, originalRenderResult, resolvePresentation, resolveNativeRenderer, options, } = params;
|
|
@@ -305,9 +306,21 @@ function renderGenericResult(params) {
|
|
|
305
306
|
...renderOptions,
|
|
306
307
|
expanded: effectiveExpanded,
|
|
307
308
|
};
|
|
309
|
+
let lastUpstreamComponent;
|
|
308
310
|
const lazyUpstreamComponent = {
|
|
309
311
|
render(w) {
|
|
310
|
-
|
|
312
|
+
try {
|
|
313
|
+
const upstreamContext = {
|
|
314
|
+
...context,
|
|
315
|
+
lastComponent: lastUpstreamComponent,
|
|
316
|
+
};
|
|
317
|
+
const comp = originalRenderResult(result, effectiveOptions, theme, upstreamContext);
|
|
318
|
+
lastUpstreamComponent = comp;
|
|
319
|
+
return comp.render(w);
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
return rawOutput !== "" ? rawOutput.split("\n") : [];
|
|
323
|
+
}
|
|
311
324
|
},
|
|
312
325
|
invalidate() { },
|
|
313
326
|
};
|
package/dist/tool-view.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { copyToClipboard as copyToSystemClipboard, } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { truncateToWidth, visibleWidth, } from "@earendil-works/pi-tui";
|
|
3
|
+
import { truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@earendil-works/pi-tui";
|
|
4
4
|
export function isCollapsible(value) {
|
|
5
5
|
return (typeof value === "object" &&
|
|
6
6
|
value !== null &&
|
|
@@ -384,10 +384,27 @@ export class ToolView {
|
|
|
384
384
|
const rail = noRail ? "" : `${theme.fg(section.railToken, "▎")} `;
|
|
385
385
|
const { rows: rawLines, isByteTruncated, totalBytes, } = resolveRows(section.content, innerWidth, toContentRows);
|
|
386
386
|
const cap = level === 1 ? (section.maxLines ?? DEFAULT_MAX_SECTION_LINES) : MAX_LEVEL2_SECTION_LINES;
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
for (const line of
|
|
390
|
-
|
|
387
|
+
const sectionRows = [];
|
|
388
|
+
let logicalLinesCount = 0;
|
|
389
|
+
for (const line of rawLines) {
|
|
390
|
+
const wrapped = wrapTextWithAnsi(line, innerWidth);
|
|
391
|
+
const chunks = wrapped.length > 0 ? wrapped : [""];
|
|
392
|
+
if (Number.isFinite(cap) && sectionRows.length + chunks.length > cap) {
|
|
393
|
+
const canTake = Math.max(0, cap - sectionRows.length);
|
|
394
|
+
for (let i = 0; i < canTake; i++) {
|
|
395
|
+
const chunk = chunks[i];
|
|
396
|
+
if (chunk !== undefined) {
|
|
397
|
+
sectionRows.push(chunk);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
sectionRows.push(...chunks);
|
|
403
|
+
logicalLinesCount++;
|
|
404
|
+
}
|
|
405
|
+
const omittedCount = rawLines.length - logicalLinesCount;
|
|
406
|
+
for (const row of sectionRows) {
|
|
407
|
+
output.push(truncate(rail + row, safeWidth));
|
|
391
408
|
}
|
|
392
409
|
if (omittedCount > 0 || isByteTruncated) {
|
|
393
410
|
const hint = isByteTruncated
|