@herbertgao/pi-extensions 2026.10.7 → 2026.10.9
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 +4 -5
- package/THIRD_PARTY_NOTICES.md +2 -28
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +28 -27
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +6 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +16 -27
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +49 -48
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +2 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +0 -60
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +2 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer-layout.ts +105 -23
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +59 -43
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +96 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +36 -34
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +7 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +23 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +24 -12
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +121 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-palette.ts +39 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-presentation.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/message-display.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +49 -49
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +24 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-state.ts +51 -2
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +71 -70
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +71 -70
- package/node_modules/@tifan/pi-inline-skills/package.json +5 -1
- package/node_modules/@tifan/pi-inline-skills/src/index.ts +5 -2
- package/node_modules/pi-provider-qoder/dist/index.js +136 -31
- package/node_modules/pi-provider-qoder/package.json +1 -1
- package/node_modules/pi-typesafe/README.md +3 -3
- package/node_modules/pi-typesafe/dist/backends.d.ts +7 -2
- package/node_modules/pi-typesafe/dist/backends.js +42 -0
- package/node_modules/pi-typesafe/dist/batch.d.ts +10 -6
- package/node_modules/pi-typesafe/dist/batch.js +20 -9
- package/node_modules/pi-typesafe/dist/client.d.ts +4 -1
- package/node_modules/pi-typesafe/dist/client.js +5 -4
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/schema.d.ts +18 -3
- package/node_modules/pi-typesafe/dist/schema.js +29 -3
- package/node_modules/pi-typesafe/package.json +1 -1
- package/node_modules/pi-web-access/CHANGELOG.md +16 -0
- package/node_modules/pi-web-access/README.md +5 -2
- package/node_modules/pi-web-access/dist/index.js +13 -2
- package/node_modules/pi-web-access/dist/mcp-cli.js +14 -3
- package/node_modules/pi-web-access/extract.ts +4 -2
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/searxng.ts +2 -1
- package/node_modules/pi-web-access/ssrf-protection.ts +11 -0
- package/package.json +6 -11
- package/node_modules/pi-multi-account/CHANGELOG.md +0 -1264
- package/node_modules/pi-multi-account/CONTRIBUTING.md +0 -61
- package/node_modules/pi-multi-account/LICENSE +0 -21
- package/node_modules/pi-multi-account/README.md +0 -277
- package/node_modules/pi-multi-account/SECURITY.md +0 -27
- package/node_modules/pi-multi-account/auth-file-transaction.ts +0 -56
- package/node_modules/pi-multi-account/child-usability.ts +0 -233
- package/node_modules/pi-multi-account/compaction-summary.ts +0 -32
- package/node_modules/pi-multi-account/completion-route-planner.ts +0 -224
- package/node_modules/pi-multi-account/config-file-transaction.ts +0 -42
- package/node_modules/pi-multi-account/context-guard.ts +0 -420
- package/node_modules/pi-multi-account/cursor/LICENSE +0 -21
- package/node_modules/pi-multi-account/cursor/NOTICE +0 -2
- package/node_modules/pi-multi-account/cursor/auth.ts +0 -165
- package/node_modules/pi-multi-account/cursor/bridge-handle.ts +0 -155
- package/node_modules/pi-multi-account/cursor/conversation-registry.ts +0 -104
- package/node_modules/pi-multi-account/cursor/cursor-models-raw.json +0 -611
- package/node_modules/pi-multi-account/cursor/cursor-shared.ts +0 -192
- package/node_modules/pi-multi-account/cursor/h2-bridge.mjs +0 -175
- package/node_modules/pi-multi-account/cursor/index.ts +0 -572
- package/node_modules/pi-multi-account/cursor/message-parsing.ts +0 -323
- package/node_modules/pi-multi-account/cursor/prompt-usage.ts +0 -53
- package/node_modules/pi-multi-account/cursor/proto/agent_pb.ts +0 -15294
- package/node_modules/pi-multi-account/cursor/proxy.ts +0 -2510
- package/node_modules/pi-multi-account/cursor/session-lifecycle.ts +0 -40
- package/node_modules/pi-multi-account/cursor/sse-keepalive.ts +0 -24
- package/node_modules/pi-multi-account/cursor/stream-lifecycle.ts +0 -193
- package/node_modules/pi-multi-account/cursor/upstream-watchdog.ts +0 -88
- package/node_modules/pi-multi-account/cursor-bridge.ts +0 -240
- package/node_modules/pi-multi-account/cursor-model-name.ts +0 -12
- package/node_modules/pi-multi-account/index.ts +0 -12340
- package/node_modules/pi-multi-account/model-catalog.ts +0 -354
- package/node_modules/pi-multi-account/model-pins.ts +0 -36
- package/node_modules/pi-multi-account/package.json +0 -104
- package/node_modules/pi-multi-account/pi-contract.ts +0 -281
- package/node_modules/pi-multi-account/provider-payload-stream.ts +0 -52
- package/node_modules/pi-multi-account/provider-priority.ts +0 -189
- package/node_modules/pi-multi-account/slot-proxy-auth.ts +0 -177
- package/node_modules/pi-multi-account/slot-proxy.ts +0 -366
- package/node_modules/pi-multi-account/state-file-transaction.ts +0 -67
- package/node_modules/pi-multi-account/usage.ts +0 -1128
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Compact mode:每条含 toolCall 的 assistant message 折叠为一条逐步累加的摘要行
|
|
3
3
|
* (`Ran for 8s, bash×2, read×2`),edit/write 独立标题行(`✓ write <path> (+25 -0)`),
|
|
4
4
|
* 普通工具折叠时不显示独立行;展开(Ctrl+O / fullscreen 点击)时助手文本按原生渲染,
|
|
5
|
-
* thinking
|
|
5
|
+
* thinking 与工具卡装进按状态着色的面板(卡内恢复 compact-thinking/Pi 原生或专用
|
|
6
6
|
* renderer)。edit/write 复用 mode=on 的 rich diff
|
|
7
7
|
* 与 `editDiffCollapsedLines` / `writeDiffCollapsedLines` / `expandedPreviewMaxLines`。
|
|
8
8
|
* Agent/Task 族:调用只进摘要计数,tool 卡始终折叠(避免 pending→完成高度闪动)。
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
} from "@earendil-works/pi-coding-agent";
|
|
38
38
|
import { truncateToWidth, visibleWidth, Box, Spacer } from "@earendil-works/pi-tui";
|
|
39
39
|
import { config, getToolDisplayConfig } from "../config/config.ts";
|
|
40
|
+
import { aggregateToolCardBgSlot, toolCardBgSlot } from "./tool/tool-state.ts";
|
|
40
41
|
import { ASK_USER_QUESTION_TOOL_NAME } from "./tool/ask-user-question.ts";
|
|
41
42
|
import { toolLoadingIcon } from "../utils/tool-loading-icon.ts";
|
|
42
43
|
import { sanitizeToolResultText } from "../utils/tool-result-sanitize.ts";
|
|
@@ -53,7 +54,7 @@ import { displayConfigCacheKey } from "./tool/diff/diff-component.ts";
|
|
|
53
54
|
import type { WriteExecutionMetadataStore } from "./tool/diff/write-execution.ts";
|
|
54
55
|
import { isToolCallHovered } from "./mouse/hover.ts";
|
|
55
56
|
import { getToolMouseTui } from "./mouse/scroll.ts";
|
|
56
|
-
import { insetComponent } from "./tool/result.ts";
|
|
57
|
+
import { expandedBodyComponent, insetComponent } from "./tool/result.ts";
|
|
57
58
|
import { isLiveToolCall, scheduleAnimation } from "./tool/tool-state.ts";
|
|
58
59
|
import { renderExpandedToolResult } from "./tool/tool-io.ts";
|
|
59
60
|
import { paddedBackgroundRow } from "./tool/grouping.ts";
|
|
@@ -114,8 +115,7 @@ export function styleCompactThinkingText(
|
|
|
114
115
|
bold = false,
|
|
115
116
|
): string {
|
|
116
117
|
if (!theme) return text;
|
|
117
|
-
const
|
|
118
|
-
const colored = typeof theme.fg === "function" ? theme.fg(color, text) : text;
|
|
118
|
+
const colored = typeof theme.fg === "function" ? theme.fg("dim", text) : text;
|
|
119
119
|
const weighted = bold && typeof theme.bold === "function" ? theme.bold(colored) : colored;
|
|
120
120
|
return typeof theme.italic === "function" ? theme.italic(weighted) : weighted;
|
|
121
121
|
}
|
|
@@ -333,7 +333,7 @@ function darkenBgAnsi(theme: any, slot: string): string {
|
|
|
333
333
|
return `\x1b[48;2;${r};${g};${b}m`;
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
/**
|
|
336
|
+
/** 工具卡深色行:左右各缩 1 格(含工具卡自身 padding),背景只到内容区,
|
|
337
337
|
* 修复行尾 reset 截断。 */
|
|
338
338
|
function toolCardBgRow(
|
|
339
339
|
theme: any,
|
|
@@ -342,8 +342,8 @@ function toolCardBgRow(
|
|
|
342
342
|
line: string,
|
|
343
343
|
width: number,
|
|
344
344
|
): string {
|
|
345
|
-
const leftInset =
|
|
346
|
-
const rightInset =
|
|
345
|
+
const leftInset = 1;
|
|
346
|
+
const rightInset = 1;
|
|
347
347
|
const contentWidth = Math.max(0, width - leftInset - rightInset);
|
|
348
348
|
// 深色块内左右各 1 格内部 padding;去掉行首原有空格后重新对齐
|
|
349
349
|
const text = stripBackgroundAnsi(line).replace(/^ +/, "");
|
|
@@ -356,14 +356,13 @@ function toolCardBgRow(
|
|
|
356
356
|
const inset = (n: number) => (outerBg ? `${outerBg}${" ".repeat(n)}\x1b[49m` : " ".repeat(n));
|
|
357
357
|
return `${inset(leftInset)}${bgAnsi}${stable}\x1b[49m${inset(rightInset)}`;
|
|
358
358
|
}
|
|
359
|
-
/** edit/write
|
|
360
|
-
function editWriteExpandedCard(theme: any): any {
|
|
359
|
+
/** edit/write 展开卡:按这张工具卡自己的状态取底色,不应用工具卡深色/间距改动。 */
|
|
360
|
+
function editWriteExpandedCard(theme: any, component: any): any {
|
|
361
|
+
const slot = toolCardBgSlot(component);
|
|
361
362
|
return new Box(
|
|
362
363
|
1,
|
|
363
364
|
1,
|
|
364
|
-
typeof theme.bg === "function"
|
|
365
|
-
? (text: string) => theme.bg(config.expandedCardBackground, text)
|
|
366
|
-
: undefined,
|
|
365
|
+
typeof theme.bg === "function" ? (text: string) => theme.bg(slot, text) : undefined,
|
|
367
366
|
);
|
|
368
367
|
}
|
|
369
368
|
|
|
@@ -384,7 +383,7 @@ function layoutExpandedToolCard(
|
|
|
384
383
|
toolHits = false,
|
|
385
384
|
live = false,
|
|
386
385
|
): { lines: string[]; hits: Array<{ child: any; start: number; end: number }> } {
|
|
387
|
-
const slot =
|
|
386
|
+
const slot = aggregateToolCardBgSlot(children.map((child) => child?.__ccTool).filter(Boolean));
|
|
388
387
|
const toolBgAnsi = darkenBgAnsi(theme, slot);
|
|
389
388
|
/** live 每行前面的标记宽度(首行 `↳ `,其余对齐空格)。 */
|
|
390
389
|
const markerWidth = live ? 2 : 0;
|
|
@@ -397,7 +396,10 @@ function layoutExpandedToolCard(
|
|
|
397
396
|
let liveLead = 0;
|
|
398
397
|
const pushRow = (raw: string) => {
|
|
399
398
|
if (!live) {
|
|
400
|
-
|
|
399
|
+
// 面板 pad 1 是唯一左边距:剥掉子行 collapsed 态自带的 1 格 lead,
|
|
400
|
+
// 否则标题行偏到 2、↳ 行偏到 4,左右不再对称。
|
|
401
|
+
const line = raw.replace(/^((?:\x1b\[[0-?]*[ -/]*[@-~])*) /, "$1");
|
|
402
|
+
lines.push(paddedBackgroundRow(theme, slot, line, width));
|
|
401
403
|
return;
|
|
402
404
|
}
|
|
403
405
|
// 槽位里不重复展开入口(见 SLOT_HINT_PATTERNS)。
|
|
@@ -500,7 +502,9 @@ function compactRoundCard(
|
|
|
500
502
|
| undefined;
|
|
501
503
|
const layout = (width: number) => {
|
|
502
504
|
const theme = themeOf();
|
|
503
|
-
const bgSlot =
|
|
505
|
+
const bgSlot = aggregateToolCardBgSlot(
|
|
506
|
+
children.map((child) => child?.__ccTool).filter(Boolean),
|
|
507
|
+
);
|
|
504
508
|
const innerWidth = contentWidth(width);
|
|
505
509
|
const paints = children.map((child) => {
|
|
506
510
|
const lines = child.render?.(innerWidth);
|
|
@@ -706,7 +710,7 @@ function compactEditWriteLine(
|
|
|
706
710
|
const isError = component.result?.isError === true;
|
|
707
711
|
const isPending = !component.result || component.isPartial === true;
|
|
708
712
|
const icon = isError ? "✗" : isPending ? toolLoadingIcon() : "✓";
|
|
709
|
-
const iconColor = isError ? "error" : isPending ? "
|
|
713
|
+
const iconColor = isError ? "error" : isPending ? "dim" : "success";
|
|
710
714
|
let statsText = "";
|
|
711
715
|
let statsStyled = "";
|
|
712
716
|
// 统计只显示一处:正文自带 +A -D 时标题不再重复(showStats=false)。
|
|
@@ -749,7 +753,7 @@ function compactEditWriteLine(
|
|
|
749
753
|
const hintPart = clickable
|
|
750
754
|
? `${theme.fg("dim", " · ")}${theme.fg(isToolCallHovered(component.toolCallId) ? "text" : "dim", clickText)}`
|
|
751
755
|
: "";
|
|
752
|
-
const line = `${iconPart}${namePart}${theme.fg("
|
|
756
|
+
const line = `${iconPart}${namePart}${theme.fg("muted", pathPart)}${statsStyled}${hintPart}`;
|
|
753
757
|
return ["", truncateToWidth(line, width, "")];
|
|
754
758
|
}
|
|
755
759
|
|
|
@@ -809,7 +813,7 @@ function compactEditWriteLines(
|
|
|
809
813
|
hit &&
|
|
810
814
|
hit.width === width &&
|
|
811
815
|
hit.theme === theme &&
|
|
812
|
-
hit.bgSlot ===
|
|
816
|
+
hit.bgSlot === toolCardBgSlot(component) &&
|
|
813
817
|
hit.diffConfigKey === diffConfigKey &&
|
|
814
818
|
hit.expanded === expanded &&
|
|
815
819
|
hit.result === component.result &&
|
|
@@ -826,7 +830,7 @@ function compactEditWriteLines(
|
|
|
826
830
|
compactEditPaintCache.set(component, {
|
|
827
831
|
width,
|
|
828
832
|
theme,
|
|
829
|
-
bgSlot:
|
|
833
|
+
bgSlot: toolCardBgSlot(component),
|
|
830
834
|
diffConfigKey,
|
|
831
835
|
expanded,
|
|
832
836
|
result: component.result,
|
|
@@ -894,7 +898,7 @@ function paintCompactEditWrite(
|
|
|
894
898
|
|
|
895
899
|
let detail: any;
|
|
896
900
|
if (hasRich) {
|
|
897
|
-
detail = expanded ? candidate : insetComponent(candidate as any);
|
|
901
|
+
detail = expanded ? expandedBodyComponent(candidate) : insetComponent(candidate as any);
|
|
898
902
|
} else {
|
|
899
903
|
const outputText = sanitizeToolResultText(
|
|
900
904
|
Array.isArray(result?.content)
|
|
@@ -921,7 +925,7 @@ function paintCompactEditWrite(
|
|
|
921
925
|
return [...title, ...detail.render(width)];
|
|
922
926
|
}
|
|
923
927
|
|
|
924
|
-
const box = editWriteExpandedCard(theme);
|
|
928
|
+
const box = editWriteExpandedCard(theme, component);
|
|
925
929
|
box.addChild({
|
|
926
930
|
render(innerWidth: number): string[] {
|
|
927
931
|
return compactEditWriteLine(component, innerWidth, writeMetadata, {
|
|
@@ -985,8 +989,7 @@ function compactAssistantLineComponent(
|
|
|
985
989
|
return paint.lines;
|
|
986
990
|
}
|
|
987
991
|
const plainText = truncateToWidth(resolved, summaryWidth, "…");
|
|
988
|
-
|
|
989
|
-
const plain = (value: string) => theme.fg(config.dimThinkingText ? "dim" : "muted", value);
|
|
992
|
+
const plain = (value: string) => theme.fg("dim", value);
|
|
990
993
|
let text = plain(plainText);
|
|
991
994
|
if (runningActive || plainText.startsWith("Ran for ")) {
|
|
992
995
|
const separator = plainText.indexOf(", ");
|
|
@@ -2065,7 +2068,11 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
2065
2068
|
const sweepOrphanTails = (): void => {
|
|
2066
2069
|
for (const tail of [...mountedTails]) {
|
|
2067
2070
|
const round = tail.round as CompactRound | undefined;
|
|
2068
|
-
|
|
2071
|
+
// 回合还在本 pass 名单里、且没有同 anchor 的更新 tail 顶位时保留。
|
|
2072
|
+
if (round && liveRounds.has(round)) {
|
|
2073
|
+
const anchor = round.anchor;
|
|
2074
|
+
if (!anchor || tailByAnchor.get(anchor) === tail) continue;
|
|
2075
|
+
}
|
|
2069
2076
|
removeTailHost(tail);
|
|
2070
2077
|
mountedTails.delete(tail);
|
|
2071
2078
|
if (round?.anchor && tailByAnchor.get(round.anchor) === tail) {
|
|
@@ -2143,16 +2150,11 @@ export function installCompactMode(deps: CompactModeInstallDeps): CompactModeHoo
|
|
|
2143
2150
|
|
|
2144
2151
|
if (hasToolCalls) {
|
|
2145
2152
|
let round = roundByComponent.get(this);
|
|
2146
|
-
if (
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
if (activeRound) finishRound(activeRound, message.timestamp);
|
|
2152
|
-
round = createRound(this, message);
|
|
2153
|
-
roundByComponent.set(this, round);
|
|
2154
|
-
} else if (!round) {
|
|
2155
|
-
// 中间隔着用户消息就另起一回合,不并进上一个回合。
|
|
2153
|
+
if (!round) {
|
|
2154
|
+
// 本条消息是否带 text 不是回合边界:pi 流式协议里同一条
|
|
2155
|
+
// assistant 消息会以 text+toolCall、toolCall-only 反复到达。
|
|
2156
|
+
// 只在「组件未挂进任何回合」时并入 activeRound;被用户消息
|
|
2157
|
+
// 隔开(steer/上回合没正文)时由 joinOrCreateRound 收尾另起。
|
|
2156
2158
|
round = joinOrCreateRound(this, message);
|
|
2157
2159
|
roundByComponent.set(this, round);
|
|
2158
2160
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
TOOL_EXPANDED_BACKGROUND_PATCH,
|
|
15
15
|
} from "../utils/patch-keys.ts";
|
|
16
16
|
import { isToolCallHovered } from "./mouse/hover.ts";
|
|
17
|
-
import { isLiveToolCall } from "./tool/tool-state.ts";
|
|
17
|
+
import { isLiveToolCall, toolCardBgSlot } from "./tool/tool-state.ts";
|
|
18
18
|
import { getMessageDisplayTheme } from "./tool/message-display.ts";
|
|
19
19
|
import { createCcstyleTool } from "./tool/ccstyle-tool.ts";
|
|
20
20
|
import type { WriteExecutionMetadataStore } from "./tool/diff/index.ts";
|
|
@@ -373,7 +373,9 @@ function deactivateGlobalToolRendering(patch: GlobalToolRenderPatch): void {
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
-
/**
|
|
376
|
+
/** 展开面板背景按工具状态取槽位;折叠行保持原生状态色。
|
|
377
|
+
* compact 下 ask_user_question 等普通工具的展开也走原生 contentBox,
|
|
378
|
+
* 这里按同一套状态覆盖它的底色。
|
|
377
379
|
* 必须在 compact-mode 之后安装,shutdown 时先于 compact-mode 释放。 */
|
|
378
380
|
export function installToolExpandedBackground(): () => void {
|
|
379
381
|
const previous = patchRegistry.get<ToolExpandedBackgroundPatch>(TOOL_EXPANDED_BACKGROUND_PATCH);
|
|
@@ -385,7 +387,7 @@ export function installToolExpandedBackground(): () => void {
|
|
|
385
387
|
prototype,
|
|
386
388
|
installed: function (this: any) {
|
|
387
389
|
original.call(this);
|
|
388
|
-
if (!patch.active || config.mode
|
|
390
|
+
if (!patch.active || config.mode === "off" || !this.expanded) return;
|
|
389
391
|
const theme = getMessageDisplayTheme();
|
|
390
392
|
if (!theme?.bg) return;
|
|
391
393
|
const box = this.contentBox;
|
|
@@ -394,7 +396,8 @@ export function installToolExpandedBackground(): () => void {
|
|
|
394
396
|
box.paddingX = 1;
|
|
395
397
|
box.paddingY = 1;
|
|
396
398
|
if (box.setBgFn) {
|
|
397
|
-
|
|
399
|
+
const slot = toolCardBgSlot(this);
|
|
400
|
+
box.setBgFn((text: string) => theme.bg(slot, text));
|
|
398
401
|
}
|
|
399
402
|
}
|
|
400
403
|
},
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
import {
|
|
49
49
|
fullscreenLazyTui,
|
|
50
50
|
hideScrollButton,
|
|
51
|
+
dockScrollButtonActive,
|
|
51
52
|
restoreOfficialScrollToEnd,
|
|
52
53
|
syncOfficialScrollToEnd,
|
|
53
54
|
isScrollBottomInput,
|
|
@@ -503,8 +504,8 @@ function keepViewportOnExpand(tui: any): void {
|
|
|
503
504
|
const view = tui.getPrimaryScrollView?.();
|
|
504
505
|
if (typeof view?.scrollTo !== "function" || typeof view.scrollTop !== "number") return;
|
|
505
506
|
view.scrollTo(view.scrollTop, { disableFollow: true });
|
|
506
|
-
//
|
|
507
|
-
if (view.isFollowingEnd === false) setScrollButtonVisible(true);
|
|
507
|
+
// 已脱离底部跟随:dock 模式亮出回到底部按钮,新输出到来时仍有入口。
|
|
508
|
+
if (view.isFollowingEnd === false && dockScrollButtonActive()) setScrollButtonVisible(true);
|
|
508
509
|
}
|
|
509
510
|
|
|
510
511
|
/**
|
|
@@ -68,7 +68,7 @@ export function setScrollButtonVisible(visible: boolean): void {
|
|
|
68
68
|
export function noteNewTranscriptItem(): void {
|
|
69
69
|
const state = scrollButtonState();
|
|
70
70
|
const tui = getToolMouseTui();
|
|
71
|
-
if (!state.visible || !tui) return;
|
|
71
|
+
if (!dockScrollButtonActive() || !state.visible || !tui) return;
|
|
72
72
|
// 提交新消息时官方可能直接跳回底部(不经过滚动输入):先按实时跟随状态校正,
|
|
73
73
|
// 否则跟随期间的内容会被当成“离开底部时的新消息”计入。
|
|
74
74
|
if (isAtTranscriptBottom(tui)) {
|
|
@@ -107,6 +107,11 @@ export function toolMouseInteractionActive(): boolean {
|
|
|
107
107
|
return config.mode !== "off";
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
/** dock 模式才用扩展的独占行;native 或 ccstyle off 时交还 Pi 原生浮层。 */
|
|
111
|
+
export function dockScrollButtonActive(): boolean {
|
|
112
|
+
return toolMouseInteractionActive() && config.scrollButtonMode === "dock";
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
/** 惰性 Proxy 官方 fullscreen(TuiAltScreen)判定。 */
|
|
111
116
|
export function fullscreenLazyTui(tui: any): boolean {
|
|
112
117
|
return isLazyProxyTui(tui) && tui.mode === "fullscreen";
|
|
@@ -132,10 +137,15 @@ export function restoreOfficialScrollToEnd(tui: any): void {
|
|
|
132
137
|
tui[OFFICIAL_SCROLL_TO_END_KEY] = undefined;
|
|
133
138
|
}
|
|
134
139
|
|
|
135
|
-
/**
|
|
140
|
+
/** dock 模式替换官方浮层;native 或 ccstyle off 时保留 Pi 原生 Jump to latest。 */
|
|
136
141
|
export function syncOfficialScrollToEnd(tui: any): void {
|
|
137
|
-
if (
|
|
138
|
-
|
|
142
|
+
if (dockScrollButtonActive()) {
|
|
143
|
+
disableOfficialScrollToEnd(tui);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
restoreOfficialScrollToEnd(tui);
|
|
147
|
+
setScrollButtonVisible(false);
|
|
148
|
+
setScrollButtonHovered(false);
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
/** 官方 fullscreen:是否已跟随 transcript 底部(按钮隐藏条件)。 */
|
|
@@ -202,7 +212,7 @@ export function hideScrollButton(tui: any): void {
|
|
|
202
212
|
export function scheduleScrollButtonSync(tui: any, data: string): void {
|
|
203
213
|
if (
|
|
204
214
|
!fullscreenLazyTui(tui) ||
|
|
205
|
-
!
|
|
215
|
+
!dockScrollButtonActive() ||
|
|
206
216
|
!isScrollNavigationInput(data) ||
|
|
207
217
|
scrollButtonSyncScheduled
|
|
208
218
|
)
|
|
@@ -211,7 +221,7 @@ export function scheduleScrollButtonSync(tui: any, data: string): void {
|
|
|
211
221
|
const previousLines = tui.previousLines;
|
|
212
222
|
const check = (attempt: number) => {
|
|
213
223
|
scrollButtonSyncScheduled = false;
|
|
214
|
-
if (getToolMouseTui() !== tui) return;
|
|
224
|
+
if (getToolMouseTui() !== tui || !dockScrollButtonActive()) return;
|
|
215
225
|
// Pi renders on its own frame timer. Inspect the resulting viewport before
|
|
216
226
|
// showing the button so empty or non-scrollable transcripts never flash it.
|
|
217
227
|
const rendered = tui.previousLines !== previousLines;
|
|
@@ -234,7 +244,7 @@ export function scheduleScrollButtonSync(tui: any, data: string): void {
|
|
|
234
244
|
}
|
|
235
245
|
|
|
236
246
|
export function updateScrollButtonFromInput(tui: any, data: string): void {
|
|
237
|
-
if (!fullscreenLazyTui(tui) || !
|
|
247
|
+
if (!fullscreenLazyTui(tui) || !dockScrollButtonActive()) return;
|
|
238
248
|
if (matchesKey(data, "enter") || matchesKey(data, "return")) hideScrollButton(tui);
|
|
239
249
|
}
|
|
240
250
|
|
|
@@ -247,7 +257,12 @@ function scrollButtonText(): string {
|
|
|
247
257
|
}
|
|
248
258
|
|
|
249
259
|
export function renderScrollButton(width: number, theme: any): string[] {
|
|
250
|
-
if (
|
|
260
|
+
if (
|
|
261
|
+
!dockScrollButtonActive() ||
|
|
262
|
+
!getScrollButtonVisible() ||
|
|
263
|
+
!fullscreenLazyTui(getToolMouseTui())
|
|
264
|
+
)
|
|
265
|
+
return [];
|
|
251
266
|
const label = theme.fg(
|
|
252
267
|
getScrollButtonHovered() ? "text" : "accent",
|
|
253
268
|
`[ ↓ ${scrollButtonText()} ]`,
|
package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "../../utils/patch-keys.ts";
|
|
28
28
|
import { isToolTuiFullscreen } from "../tool/names.ts";
|
|
29
29
|
import type { SgrMousePacket } from "./packets.ts";
|
|
30
|
-
import { setScrollButtonVisible } from "./scroll.ts";
|
|
30
|
+
import { dockScrollButtonActive, setScrollButtonVisible } from "./scroll.ts";
|
|
31
31
|
|
|
32
32
|
/** 消息正文首行/末行的零宽 APC 标记;终端忽略,合成前剥离。 */
|
|
33
33
|
const MESSAGE_START = "\x1b_cc:p\x07";
|
|
@@ -338,7 +338,7 @@ export function handleStickyPromptClick(tui: any, packet: SgrMousePacket): boole
|
|
|
338
338
|
const view = tui.getPrimaryScrollView?.();
|
|
339
339
|
if (typeof view?.scrollTo === "function") {
|
|
340
340
|
view.scrollTo(state.jumpRow, { disableFollow: true });
|
|
341
|
-
if (view.isFollowingEnd === false) setScrollButtonVisible(true);
|
|
341
|
+
if (view.isFollowingEnd === false && dockScrollButtonActive()) setScrollButtonVisible(true);
|
|
342
342
|
}
|
|
343
343
|
// 落点已到消息头,这一帧的粘性行立即失效;等下一帧按新位置重算。
|
|
344
344
|
state.visible = false;
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
} from "./names.ts";
|
|
28
28
|
import {
|
|
29
29
|
collapsedResultSummary,
|
|
30
|
+
expandedBodyComponent,
|
|
30
31
|
formatToolDuration,
|
|
31
32
|
insetComponent,
|
|
32
33
|
renderCollapsedToolResultToWidth,
|
|
@@ -154,6 +155,23 @@ function renderExpandedTaskResult(
|
|
|
154
155
|
return formatted ? new Text(`↳ ${formatted}`, 0, 0) : undefined;
|
|
155
156
|
}
|
|
156
157
|
|
|
158
|
+
/**
|
|
159
|
+
* 工具耗时(毫秒)。结束时优先用 pi 记在结果上的 durationMs(单调,restore 出来的行也带得到);
|
|
160
|
+
* 运行中 pi 不给(partial 期间渲染上下文里恒为 undefined),退回 renderCall 记下的时钟。
|
|
161
|
+
* 拿不到返回 undefined。时钟回拨时钳到 0。
|
|
162
|
+
*/
|
|
163
|
+
function toolElapsedMs(context: any, isPartial: boolean): number | undefined {
|
|
164
|
+
const recorded = context?.durationMs;
|
|
165
|
+
if (!isPartial && typeof recorded === "number" && Number.isFinite(recorded) && recorded >= 0) {
|
|
166
|
+
return recorded;
|
|
167
|
+
}
|
|
168
|
+
const startedAt = context?.state?.ccstyleShellStartedAt;
|
|
169
|
+
if (typeof startedAt !== "number") return undefined;
|
|
170
|
+
const endedAt = context?.state?.ccstyleShellEndedAt;
|
|
171
|
+
const end = typeof endedAt === "number" ? endedAt : Date.now();
|
|
172
|
+
return Math.max(0, end - startedAt);
|
|
173
|
+
}
|
|
174
|
+
|
|
157
175
|
/**
|
|
158
176
|
* shell 的耗时文本。Pi 原生 shell 渲染器会在结果底部报一行,ccstyle 的通用折叠行把它盖掉了。
|
|
159
177
|
*
|
|
@@ -163,16 +181,8 @@ function renderExpandedTaskResult(
|
|
|
163
181
|
*/
|
|
164
182
|
function shellDurationText(toolName: string, context: any, isPartial: boolean): string {
|
|
165
183
|
if (!SHELL_TOOL_NAMES.has(toolName)) return "";
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
return formatToolDuration(recorded);
|
|
169
|
-
}
|
|
170
|
-
const startedAt = context?.state?.ccstyleShellStartedAt;
|
|
171
|
-
if (typeof startedAt !== "number") return "";
|
|
172
|
-
const endedAt = context?.state?.ccstyleShellEndedAt;
|
|
173
|
-
const end = typeof endedAt === "number" ? endedAt : Date.now();
|
|
174
|
-
// 时钟回拨时别吐负数;快照固定时钟也会走到这。
|
|
175
|
-
return formatToolDuration(Math.max(0, end - startedAt));
|
|
184
|
+
const elapsed = toolElapsedMs(context, isPartial);
|
|
185
|
+
return elapsed === undefined ? "" : formatToolDuration(elapsed);
|
|
176
186
|
}
|
|
177
187
|
|
|
178
188
|
/** 用 ccstyle call/result 包装任意工具定义。 */
|
|
@@ -328,6 +338,7 @@ export function createCcstyleTool(
|
|
|
328
338
|
running: Boolean(options?.isPartial),
|
|
329
339
|
isError,
|
|
330
340
|
isHovered: () => isToolCallHovered(toolCallId),
|
|
341
|
+
code: context?.args?.code,
|
|
331
342
|
});
|
|
332
343
|
}
|
|
333
344
|
// ask_user_question:折叠态摊成问答树,展开态按问题逐条列出选择。
|
|
@@ -405,8 +416,9 @@ export function createCcstyleTool(
|
|
|
405
416
|
writeExecutionMetadata,
|
|
406
417
|
getToolDisplayConfig,
|
|
407
418
|
);
|
|
408
|
-
// 展开态由 Box(1,1)
|
|
409
|
-
if (richResult)
|
|
419
|
+
// 展开态由 Box(1,1) 提供内边距,首行再缩 2 格与标题文字列对齐;折叠态 inset 一级缩进
|
|
420
|
+
if (richResult)
|
|
421
|
+
return expanded ? expandedBodyComponent(richResult) : insetComponent(richResult);
|
|
410
422
|
}
|
|
411
423
|
|
|
412
424
|
const text = textFromResult(result, expanded);
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* - 输出以 "Script completed\nWall time …\nOutput:\n" 开头(pi 原生也切掉),行数统计与展开正文都得去掉它,
|
|
9
9
|
* 否则折叠摘要会多算 3 行。
|
|
10
10
|
*/
|
|
11
|
+
import { highlightCode } from "@earendil-works/pi-coding-agent";
|
|
11
12
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
13
|
+
import { config } from "../../config/config.ts";
|
|
12
14
|
import { stripAnsi } from "../../utils/ansi-text.ts";
|
|
15
|
+
import { oneLine } from "../../utils/format.ts";
|
|
13
16
|
import { toolLoadingIcon } from "../../utils/tool-loading-icon.ts";
|
|
14
17
|
import { sanitizeToolResultText } from "../../utils/tool-result-sanitize.ts";
|
|
15
18
|
import { mcpToolTitle } from "./mcp-title.ts";
|
|
@@ -94,6 +97,105 @@ function fitSummaryParts(parts: readonly string[], width: number): string {
|
|
|
94
97
|
return visibleWidth(text) <= width ? text : headTruncateToWidth(text, width);
|
|
95
98
|
}
|
|
96
99
|
|
|
100
|
+
/**
|
|
101
|
+
* 摘要行的打分:调用最能说明脚本在干什么,字符串次之,行长只在前两者相同时决胜。
|
|
102
|
+
* 调用权重必须大于「字符串分 + 行长上限」,否则长赋值会压过短调用。
|
|
103
|
+
*/
|
|
104
|
+
const CODE_SUMMARY_CALL_SCORE = 4;
|
|
105
|
+
const CODE_SUMMARY_STRING_SCORE = 2;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 无子调用时的脚本摘要:取信息量最大的一行语句,压成单行。
|
|
109
|
+
*
|
|
110
|
+
* 要的是一段真实的 JavaScript 片段,折叠行才能用 highlightCode 着色;
|
|
111
|
+
* 标识符链(`a → b → c`)着色器认不出,染不上。跳过注释、空行和 `// @options`。
|
|
112
|
+
* 只是折叠行的提示,不求还原语义;看代码还是展开 Input。
|
|
113
|
+
*/
|
|
114
|
+
export function codemodeCodeSummary(code: unknown): string | undefined {
|
|
115
|
+
if (typeof code !== "string" || !code.trim()) return undefined;
|
|
116
|
+
let best: { text: string; score: number } | undefined;
|
|
117
|
+
let skippingBlock = false;
|
|
118
|
+
for (const raw of code.split("\n")) {
|
|
119
|
+
const line = raw.trim();
|
|
120
|
+
if (skippingBlock) {
|
|
121
|
+
if (line.includes("*/")) skippingBlock = false;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (line.startsWith("/*")) {
|
|
125
|
+
if (!line.includes("*/")) skippingBlock = true;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!line || line.startsWith("//") || line.startsWith("*")) continue;
|
|
129
|
+
const text = oneLine(line);
|
|
130
|
+
if (!text) continue;
|
|
131
|
+
const score =
|
|
132
|
+
(text.includes("(") ? CODE_SUMMARY_CALL_SCORE : 0) +
|
|
133
|
+
(/["'`]/.test(text) ? CODE_SUMMARY_STRING_SCORE : 0) +
|
|
134
|
+
Math.min(text.length, 100) / 100;
|
|
135
|
+
if (!best || score > best.score) best = { text, score };
|
|
136
|
+
}
|
|
137
|
+
return best?.text;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 没有子调用时的脚本行:语句逐行用 │ 树线列出,行数跟 expandedInputMaxLines。
|
|
142
|
+
* 超出的收成一行 `… N more lines`。注释、空行和 `// @options` 不占行。
|
|
143
|
+
*/
|
|
144
|
+
export function codemodeCodeLines(
|
|
145
|
+
code: unknown,
|
|
146
|
+
fg: (color: string, text: string) => string,
|
|
147
|
+
rowWidth: number,
|
|
148
|
+
): string[] {
|
|
149
|
+
if (typeof code !== "string" || !code.trim()) return [];
|
|
150
|
+
const statements: string[] = [];
|
|
151
|
+
let skippingBlock = false;
|
|
152
|
+
for (const raw of code.split("\n")) {
|
|
153
|
+
const line = raw.trim();
|
|
154
|
+
if (skippingBlock) {
|
|
155
|
+
if (line.includes("*/")) skippingBlock = false;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (line.startsWith("/*")) {
|
|
159
|
+
if (!line.includes("*/")) skippingBlock = true;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (!line || line.startsWith("//") || line.startsWith("*")) continue;
|
|
163
|
+
const text = oneLine(line);
|
|
164
|
+
if (text) statements.push(text);
|
|
165
|
+
}
|
|
166
|
+
if (statements.length === 0) return [];
|
|
167
|
+
const limit = Math.max(1, config.expandedInputMaxLines);
|
|
168
|
+
const visible = statements.slice(0, limit);
|
|
169
|
+
const rail = `${INDENT}${fg("dim", "│")} `;
|
|
170
|
+
const lines = visible.map((statement) =>
|
|
171
|
+
truncateToWidth(`${rail}${highlightCodeSummary(statement)}`, rowWidth, ""),
|
|
172
|
+
);
|
|
173
|
+
const hidden = statements.length - visible.length;
|
|
174
|
+
if (hidden > 0) {
|
|
175
|
+
lines.push(
|
|
176
|
+
truncateToWidth(
|
|
177
|
+
`${rail}${fg("dim", `… ${hidden} more ${hidden === 1 ? "line" : "lines"}`)}`,
|
|
178
|
+
rowWidth,
|
|
179
|
+
"",
|
|
180
|
+
),
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return lines;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* 所以包一层 `() => { … }` 再取中间那一行。失败或没着色时退回原文。
|
|
188
|
+
*/
|
|
189
|
+
export function highlightCodeSummary(summary: string): string {
|
|
190
|
+
try {
|
|
191
|
+
const lines = highlightCode(`() => { ${summary} }`, "javascript");
|
|
192
|
+
const colored = lines[0]?.replace(/^\(\) => \{ /, "").replace(/ \}$/, "");
|
|
193
|
+
return colored && stripAnsi(colored) === summary ? colored : summary;
|
|
194
|
+
} catch {
|
|
195
|
+
return summary;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
97
199
|
/** 与 pi 原生一致:不到 1 分显示两位有效数字。 */
|
|
98
200
|
function formatCost(cost: number): string {
|
|
99
201
|
return `$${cost >= 0.01 ? cost.toFixed(2) : cost.toPrecision(2)}`;
|
|
@@ -159,9 +261,12 @@ function callSummary(call: CodemodeNestedCall): ToolCallSummary {
|
|
|
159
261
|
const parsed = parseCallArgs(raw);
|
|
160
262
|
if (parsed) {
|
|
161
263
|
const summary = toolCallSummary(name, parsed.args, { title, variant: "default" });
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
|
|
264
|
+
// 截断串只恢复出部分字段:字段链认出来了才用(payload 是字段链挑出的值,
|
|
265
|
+
// path/main 的兜底标题不算);认不出仍旧贴原文,免得把不完整的 JSON 当成完整入参摊开。
|
|
266
|
+
const recognized = summary.payload !== undefined || summary.path !== undefined;
|
|
267
|
+
// 完全还原的入参:标题与载荷分色后的 summary 直接用;恢复了字段的也用结构化
|
|
268
|
+
// 结果(字段链认出的值比截断原文更可读)。认不出的才退回贴原文。
|
|
269
|
+
if (parsed.complete || recognized) return summary;
|
|
165
270
|
}
|
|
166
271
|
return { main: title, detail: "", payload: raw };
|
|
167
272
|
}
|
|
@@ -176,7 +281,7 @@ function statusIcon(status: unknown, theme: any): string {
|
|
|
176
281
|
return theme.fg("muted", "⊘");
|
|
177
282
|
default:
|
|
178
283
|
// 运行中:帧在 render() 内取,动画定时器只负责 requestRender
|
|
179
|
-
return theme.fg("
|
|
284
|
+
return theme.fg("dim", toolLoadingIcon());
|
|
180
285
|
}
|
|
181
286
|
}
|
|
182
287
|
|
|
@@ -209,6 +314,8 @@ export function codemodeCollapsedLines(options: {
|
|
|
209
314
|
width: number;
|
|
210
315
|
/** 鼠标悬停整卡时展开提示用 text 色,与其它折叠卡一致。 */
|
|
211
316
|
hovered?: boolean;
|
|
317
|
+
/** 脚本源码;没有子调用时用来补一行 `code:` 摘要。 */
|
|
318
|
+
code?: unknown;
|
|
212
319
|
}): string[] {
|
|
213
320
|
const { result, theme, running, isError } = options;
|
|
214
321
|
const fg = theme.fg.bind(theme);
|
|
@@ -216,6 +323,11 @@ export function codemodeCollapsedLines(options: {
|
|
|
216
323
|
const rowWidth = toolViewportWidth(options.width);
|
|
217
324
|
const shown = calls.slice(-COLLAPSED_CALL_LIMIT);
|
|
218
325
|
const lines: string[] = [];
|
|
326
|
+
// 没有子调用时脚本本身是唯一线索:逐行用 │ 树线列出,行数跟 expandedInputMaxLines,
|
|
327
|
+
// 汇总行仍用 └ 收尾。
|
|
328
|
+
if (shown.length === 0) {
|
|
329
|
+
lines.push(...codemodeCodeLines(options.code, fg, rowWidth));
|
|
330
|
+
}
|
|
219
331
|
if (shown.length < calls.length) {
|
|
220
332
|
const hidden = calls.length - shown.length;
|
|
221
333
|
lines.push(
|
|
@@ -229,8 +341,8 @@ export function codemodeCollapsedLines(options: {
|
|
|
229
341
|
for (const call of shown) lines.push(callRow(call, theme, rowWidth));
|
|
230
342
|
|
|
231
343
|
const summary = codemodeSummaryParts(calls, codemodeOutputLineCount(result), running);
|
|
232
|
-
//
|
|
233
|
-
const prefix =
|
|
344
|
+
// 上面已有行(子调用或代码摘要)时用 └ 收尾,否则不画衔接符
|
|
345
|
+
const prefix = lines.length > 0 ? `${INDENT}${fg("dim", "└")} ` : INDENT;
|
|
234
346
|
// 圆点保持 dim;hover 只高亮可点击文字。
|
|
235
347
|
const hint = running
|
|
236
348
|
? ""
|
|
@@ -281,6 +393,8 @@ export function createCodemodeResultComponent(options: {
|
|
|
281
393
|
isError: boolean;
|
|
282
394
|
/** 折叠态 hover 查询,与 diff 卡同一套(mouse/hover)。 */
|
|
283
395
|
isHovered?: () => boolean;
|
|
396
|
+
/** 脚本源码;没有子调用时用来补一行 `code:` 摘要。 */
|
|
397
|
+
code?: unknown;
|
|
284
398
|
}): any {
|
|
285
399
|
const { result, theme, running, isError } = options;
|
|
286
400
|
return {
|
|
@@ -292,6 +406,7 @@ export function createCodemodeResultComponent(options: {
|
|
|
292
406
|
isError,
|
|
293
407
|
width,
|
|
294
408
|
hovered: options.isHovered?.() ?? false,
|
|
409
|
+
code: options.code,
|
|
295
410
|
});
|
|
296
411
|
},
|
|
297
412
|
invalidate(): void {},
|
package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts
CHANGED
|
@@ -135,10 +135,11 @@ export function applyLineLimit(
|
|
|
135
135
|
const clickLabel = showMoreHintText();
|
|
136
136
|
const clickIndex = hintText.lastIndexOf(clickLabel);
|
|
137
137
|
// 展开态不会再截断,剩下的分支必是折叠态提示。
|
|
138
|
+
// 提示文本与其余折叠卡一致用 dim,hover 时 clickLabel 提到 text。
|
|
138
139
|
const styledHint =
|
|
139
|
-
|
|
140
|
+
clickIndex >= 0
|
|
140
141
|
? theme.fg("muted", hintText.slice(0, clickIndex)) +
|
|
141
|
-
theme.fg("text", clickLabel) +
|
|
142
|
+
theme.fg(hovered ? "text" : "dim", clickLabel) +
|
|
142
143
|
theme.fg("muted", hintText.slice(clickIndex + clickLabel.length))
|
|
143
144
|
: theme.fg("muted", hintText);
|
|
144
145
|
return {
|