@herbertgao/pi-extensions 2026.8.1 → 2026.8.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/README.md +5 -2
- package/node_modules/@czottmann/pi-automode/README.md +16 -2
- package/node_modules/@czottmann/pi-automode/docs/GLOSSARY.md +35 -0
- package/node_modules/@czottmann/pi-automode/docs/automode-classifier-flow.md +18 -9
- package/node_modules/@czottmann/pi-automode/docs/defaults.md +6 -2
- package/node_modules/@czottmann/pi-automode/examples/automode.local.json +6 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +11 -7
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +100 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +32 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/extension.ts +78 -3
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +16 -4
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/paths.ts +23 -1
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/permissions.ts +22 -1
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/types.ts +18 -2
- package/node_modules/@czottmann/pi-automode/package.json +4 -4
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-audit.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-debt.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-gain.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-help.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail-review.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/command/ponytail.md +5 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail-frontmatter.cjs +23 -0
- package/node_modules/@dietrichgebert/ponytail/.opencode/plugins/ponytail.mjs +99 -0
- package/node_modules/@dietrichgebert/ponytail/.qoder/rules/ponytail.md +30 -0
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +16 -0
- package/node_modules/@dietrichgebert/ponytail/AGENTS.md +32 -0
- package/node_modules/@dietrichgebert/ponytail/LICENSE +21 -0
- package/node_modules/@dietrichgebert/ponytail/README.es.md +298 -0
- package/node_modules/@dietrichgebert/ponytail/README.ko.md +315 -0
- package/node_modules/@dietrichgebert/ponytail/README.md +351 -0
- package/node_modules/@dietrichgebert/ponytail/assets/benchmark-3model.svg +21 -0
- package/node_modules/@dietrichgebert/ponytail/assets/benchmark-agentic.svg +62 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-dark.svg +115 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt-dark.svg +27 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo-greenpt.svg +27 -0
- package/node_modules/@dietrichgebert/ponytail/assets/logo.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/social-preview.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-es.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner-ko.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/assets/waitlist-banner.png +0 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +44 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +21 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +96 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-config.js +169 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-instructions.js +98 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-mode-tracker.js +130 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-runtime.js +85 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-statusline.ps1 +24 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-statusline.sh +18 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-subagent.js +77 -0
- package/node_modules/@dietrichgebert/ponytail/hooks/qoder-hooks.json +26 -0
- package/node_modules/@dietrichgebert/ponytail/package.json +47 -0
- package/node_modules/@dietrichgebert/ponytail/pi-extension/index.js +211 -0
- package/node_modules/@dietrichgebert/ponytail/pi-extension/package.json +8 -0
- package/node_modules/@dietrichgebert/ponytail/scripts/uninstall.js +60 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail/SKILL.md +120 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-audit/SKILL.md +41 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-debt/SKILL.md +44 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-gain/SKILL.md +50 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-help/SKILL.md +71 -0
- package/node_modules/@dietrichgebert/ponytail/skills/ponytail-review/SKILL.md +57 -0
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -3
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +10 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/agent-summary.ts +6 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +24 -83
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/markdown-enhance.ts +119 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +73 -9
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/index.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-hover.ts +130 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-interaction.ts +65 -542
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-layout.ts +160 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-packets.ts +143 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse-scroll.ts +184 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-diff/diff-renderer.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-grouping.ts +9 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/transcript-refresh.ts +91 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/utils/agent-summary.ts +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +1 -0
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +2 -2
- package/node_modules/@herbertgao/pi-stash/README.md +9 -9
- package/node_modules/@herbertgao/pi-stash/package.json +1 -1
- package/node_modules/@herbertgao/pi-stash/src/index.ts +2 -1
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +14 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +6 -2
- package/node_modules/@herbertgao/pi-subagents/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +85 -11
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +28 -4
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +12 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +2 -0
- package/node_modules/@narumitw/pi-btw/LICENSE +21 -0
- package/node_modules/@narumitw/pi-btw/README.md +210 -0
- package/node_modules/@narumitw/pi-btw/package.json +53 -0
- package/node_modules/@narumitw/pi-btw/src/bring-to-main.ts +632 -0
- package/node_modules/@narumitw/pi-btw/src/btw.ts +996 -0
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +339 -0
- package/node_modules/@narumitw/pi-btw/src/index.ts +1 -0
- package/node_modules/@narumitw/pi-btw/src/menu.ts +296 -0
- package/node_modules/@narumitw/pi-btw/src/settings.ts +237 -0
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +238 -0
- package/node_modules/@narumitw/pi-btw/src/text.ts +10 -0
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +620 -0
- package/node_modules/@pi-plugins/fast-mode/LICENSE +21 -0
- package/node_modules/@pi-plugins/fast-mode/README.md +92 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts +6 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.d.mts.map +1 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs +2026 -0
- package/node_modules/@pi-plugins/fast-mode/dist/index.mjs.map +1 -0
- package/node_modules/@pi-plugins/fast-mode/package.json +73 -0
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +59 -0
- package/node_modules/pi-mcp-adapter/README.md +62 -13
- package/node_modules/pi-mcp-adapter/agent-plugin-loader.ts +377 -0
- package/node_modules/pi-mcp-adapter/commands.ts +9 -7
- package/node_modules/pi-mcp-adapter/config.ts +110 -49
- package/node_modules/pi-mcp-adapter/direct-tools.ts +34 -19
- package/node_modules/pi-mcp-adapter/elicitation-handler.ts +37 -36
- package/node_modules/pi-mcp-adapter/errors.ts +21 -17
- package/node_modules/pi-mcp-adapter/host-html-template.ts +13 -7
- package/node_modules/pi-mcp-adapter/index.ts +37 -14
- package/node_modules/pi-mcp-adapter/init.ts +9 -7
- package/node_modules/pi-mcp-adapter/json-schema-validator.ts +2 -2
- package/node_modules/pi-mcp-adapter/lifecycle.ts +8 -8
- package/node_modules/pi-mcp-adapter/logger.ts +1 -1
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +36 -22
- package/node_modules/pi-mcp-adapter/mcp-auth.ts +120 -2
- package/node_modules/pi-mcp-adapter/mcp-code.ts +13 -11
- package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +19 -13
- package/node_modules/pi-mcp-adapter/mcp-output-guard.ts +15 -11
- package/node_modules/pi-mcp-adapter/mcp-panel.ts +34 -15
- package/node_modules/pi-mcp-adapter/mcp-probe.ts +131 -34
- package/node_modules/pi-mcp-adapter/mcp-script-worker.mjs +2 -2
- package/node_modules/pi-mcp-adapter/mcp-setup-panel.ts +7 -4
- package/node_modules/pi-mcp-adapter/mcp-trace.ts +59 -64
- package/node_modules/pi-mcp-adapter/metadata-cache.ts +34 -26
- package/node_modules/pi-mcp-adapter/npx-resolver.ts +6 -4
- package/node_modules/pi-mcp-adapter/oauth-handler.ts +1 -1
- package/node_modules/pi-mcp-adapter/onboarding-state.ts +19 -11
- package/node_modules/pi-mcp-adapter/package.json +13 -8
- package/node_modules/pi-mcp-adapter/panel-keys.ts +20 -4
- package/node_modules/pi-mcp-adapter/prompts.ts +2 -2
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +48 -11
- package/node_modules/pi-mcp-adapter/sampling-handler.ts +22 -15
- package/node_modules/pi-mcp-adapter/search-ranking.ts +2 -1
- package/node_modules/pi-mcp-adapter/server-manager.ts +165 -113
- package/node_modules/pi-mcp-adapter/session-recovery.ts +11 -12
- package/node_modules/pi-mcp-adapter/skills/mcp-scripting/SKILL.md +3 -3
- package/node_modules/pi-mcp-adapter/state.ts +3 -1
- package/node_modules/pi-mcp-adapter/tool-approval.ts +67 -4
- package/node_modules/pi-mcp-adapter/tool-metadata.ts +6 -5
- package/node_modules/pi-mcp-adapter/tool-result-renderer.ts +14 -2
- package/node_modules/pi-mcp-adapter/ts-shape.ts +9 -2
- package/node_modules/pi-mcp-adapter/types.ts +109 -22
- package/node_modules/pi-mcp-adapter/ui-app-bridge-helpers.ts +40 -0
- package/node_modules/pi-mcp-adapter/ui-resource-handler.ts +28 -19
- package/node_modules/pi-mcp-adapter/ui-server.ts +90 -58
- package/node_modules/pi-mcp-adapter/ui-session.ts +16 -14
- package/node_modules/pi-mcp-adapter/unix-socket-transport.ts +4 -4
- package/node_modules/pi-mcp-adapter/utils.ts +23 -9
- package/package.json +22 -7
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
2
|
+
import { isCompactAssistantComponent } from "./compact-mode.ts";
|
|
3
|
+
import { ToolGroupComponent } from "./tool-grouping.ts";
|
|
4
|
+
import {
|
|
5
|
+
isToolExecutionComponent,
|
|
6
|
+
stripTerminalSequencesPreservingLayout,
|
|
7
|
+
} from "./mouse-packets.ts";
|
|
8
|
+
import { scrollButtonWidget } from "./mouse-scroll.ts";
|
|
9
|
+
|
|
10
|
+
export type ComponentRowHit = {
|
|
11
|
+
component: any;
|
|
12
|
+
row: number;
|
|
13
|
+
/** 内部工具命中时所属的展开 group;普通卡点击仍折叠整个 group。 */
|
|
14
|
+
group?: ToolGroupComponent;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** 深度渲染组件树(容器 render 隐藏时回退 children)。 */
|
|
18
|
+
export function renderComponentTree(component: any, width: number): string[] {
|
|
19
|
+
if (!component || typeof component !== "object") return [];
|
|
20
|
+
try {
|
|
21
|
+
const lines = component.render?.(width);
|
|
22
|
+
if (Array.isArray(lines) && lines.length > 0) return lines;
|
|
23
|
+
} catch {
|
|
24
|
+
// Fall through to children for hidden container renderers.
|
|
25
|
+
}
|
|
26
|
+
if (!Array.isArray(component.children)) return [];
|
|
27
|
+
return component.children.flatMap((child: any) => renderComponentTree(child, width));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 行内 [click to show more] 提示的命中列区间(1-based,含两端)。 */
|
|
31
|
+
export function collapsedHintHitbox(line: string): { startCol: number; endCol: number } | null {
|
|
32
|
+
const plain = stripTerminalSequencesPreservingLayout(line);
|
|
33
|
+
const match = /(\([^()\n]* \/ click\)|click to show more|to show more)(?=\)?\s*$)/.exec(plain);
|
|
34
|
+
if (!match?.[1]) return null;
|
|
35
|
+
const startCol = visibleWidth(plain.slice(0, match.index)) + 1;
|
|
36
|
+
return { startCol, endCol: startCol + visibleWidth(match[1]) - 1 };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 布局树点查询:返回 (x,y) 处最深含行 leaf box(屏幕行 → 组件局部行)。 */
|
|
40
|
+
export function fullscreenLeafAt(
|
|
41
|
+
layout: any,
|
|
42
|
+
x: number,
|
|
43
|
+
y: number,
|
|
44
|
+
): { box: any; localRow: number } | null {
|
|
45
|
+
const root = layout?.root;
|
|
46
|
+
if (!root) return null;
|
|
47
|
+
let best: { box: any; localRow: number } | null = null;
|
|
48
|
+
let bestDepth = -1;
|
|
49
|
+
const visit = (box: any, depth: number) => {
|
|
50
|
+
if (!box) return;
|
|
51
|
+
const clip = box.clip;
|
|
52
|
+
if (!clip || x < clip.x || x >= clip.x + clip.width || y < clip.y || y >= clip.y + clip.height)
|
|
53
|
+
return;
|
|
54
|
+
const isLeaf = !Array.isArray(box.children) || box.children.length === 0;
|
|
55
|
+
if (
|
|
56
|
+
isLeaf &&
|
|
57
|
+
y >= box.rect.y &&
|
|
58
|
+
y < box.rect.y + Math.max(1, box.rect.height) &&
|
|
59
|
+
depth > bestDepth
|
|
60
|
+
) {
|
|
61
|
+
best = { box, localRow: Math.max(0, y - box.rect.y) };
|
|
62
|
+
bestDepth = depth;
|
|
63
|
+
}
|
|
64
|
+
for (const child of box.children ?? []) visit(child, depth + 1);
|
|
65
|
+
};
|
|
66
|
+
visit(root, 0);
|
|
67
|
+
return best;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** leaf 自身不带 scrollView;内容宽度由最近的 scroll 祖先决定。 */
|
|
71
|
+
export function fullscreenContentWidth(box: any, terminalWidth: number): number {
|
|
72
|
+
for (let current = box; current; current = current.parent) {
|
|
73
|
+
if (typeof current.scrollView?.getContentWidth === "function") {
|
|
74
|
+
return Math.max(1, current.scrollView.getContentWidth(terminalWidth));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return terminalWidth;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 点击列是否为官方滚动条列(放行官方拖动)。 */
|
|
81
|
+
export function isScrollbarColumnAt(layout: any, x: number): boolean {
|
|
82
|
+
let hit = false;
|
|
83
|
+
const visit = (box: any) => {
|
|
84
|
+
if (hit || !box) return;
|
|
85
|
+
if (box.scrollView?.isScrollbarVisible && x === box.rect.x + box.rect.width - 1) {
|
|
86
|
+
hit = true;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
for (const child of box.children ?? []) visit(child);
|
|
90
|
+
};
|
|
91
|
+
visit(layout?.root);
|
|
92
|
+
return hit;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 布局 leaf box 的组件通常是容器(documentContainer/dock 容器等),工具卡与
|
|
97
|
+
* widget 在其 children 内。按局部行遍历组件树,定位实际命中的子组件。
|
|
98
|
+
*/
|
|
99
|
+
export function componentAtLocalRow(
|
|
100
|
+
component: any,
|
|
101
|
+
localRow: number,
|
|
102
|
+
width: number,
|
|
103
|
+
): ComponentRowHit | null {
|
|
104
|
+
if (component instanceof ToolGroupComponent) {
|
|
105
|
+
// 展开的 group:头两行(空行 + 头行)归 group,其余行映射到内部工具。
|
|
106
|
+
const child = component.childAtRow(localRow, width);
|
|
107
|
+
return child ? { ...child, group: component } : { component, row: localRow };
|
|
108
|
+
}
|
|
109
|
+
if (isToolExecutionComponent(component)) {
|
|
110
|
+
return { component, row: localRow };
|
|
111
|
+
}
|
|
112
|
+
if (isCompactAssistantComponent(component)) {
|
|
113
|
+
// compact 摘要行整体作为可展开卡片(折叠摘要 / 展开内容)。
|
|
114
|
+
return { component, row: localRow };
|
|
115
|
+
}
|
|
116
|
+
if (component === scrollButtonWidget) {
|
|
117
|
+
return { component, row: localRow };
|
|
118
|
+
}
|
|
119
|
+
if (!Array.isArray(component.children)) return null;
|
|
120
|
+
let offset = 0;
|
|
121
|
+
for (const child of component.children) {
|
|
122
|
+
let lines: string[] = [];
|
|
123
|
+
try {
|
|
124
|
+
const rendered = child.render?.(width);
|
|
125
|
+
if (Array.isArray(rendered)) lines = rendered.map((line) => String(line));
|
|
126
|
+
} catch {
|
|
127
|
+
lines = [];
|
|
128
|
+
}
|
|
129
|
+
if (localRow < offset + lines.length) {
|
|
130
|
+
return (
|
|
131
|
+
componentAtLocalRow(child, localRow - offset, width) ?? {
|
|
132
|
+
component: child,
|
|
133
|
+
row: localRow - offset,
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
offset += lines.length;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** fullscreen single-expand:group 作为整体,不继续递归其内部工具。 */
|
|
143
|
+
export function collectFullscreenToolCards(
|
|
144
|
+
component: any,
|
|
145
|
+
out: any[],
|
|
146
|
+
seen = new Set<any>(),
|
|
147
|
+
): void {
|
|
148
|
+
if (!component || typeof component !== "object" || seen.has(component)) return;
|
|
149
|
+
seen.add(component);
|
|
150
|
+
if (
|
|
151
|
+
isToolExecutionComponent(component) ||
|
|
152
|
+
component instanceof ToolGroupComponent ||
|
|
153
|
+
isCompactAssistantComponent(component)
|
|
154
|
+
) {
|
|
155
|
+
out.push(component);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!Array.isArray(component.children)) return;
|
|
159
|
+
for (const child of component.children) collectFullscreenToolCards(child, out, seen);
|
|
160
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { ExpandedToolIoView, ToolIoSection } from "./tool-result.ts";
|
|
2
|
+
|
|
3
|
+
/** SGR 鼠标协议包(code;col;row + M/m 终结符)。 */
|
|
4
|
+
export type SgrMousePacket = {
|
|
5
|
+
code: number;
|
|
6
|
+
col: number;
|
|
7
|
+
row: number;
|
|
8
|
+
final: "M" | "m";
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/** Final painted placement of one outermost tool/group row after parent layout. */
|
|
12
|
+
export type FrameToolPlacement = {
|
|
13
|
+
component: any;
|
|
14
|
+
componentRow: number;
|
|
15
|
+
lineIndex: number;
|
|
16
|
+
/** Marker-stripped final line text as painted after parent layout. */
|
|
17
|
+
finalLine: string;
|
|
18
|
+
view?: ExpandedToolIoView;
|
|
19
|
+
section?: ToolIoSection;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Zero-width APC row marker (like pi CURSOR_MARKER); stripped before terminal output. */
|
|
23
|
+
const TOOL_FRAME_MARKER_RE = /\x1b_cc:t(\d+):(\d+)\x07/g;
|
|
24
|
+
const TOOL_VIEW_MARKER_RE = /\x1b_cc:v(\d+):([io])\x07/g;
|
|
25
|
+
export const toolFrameMarker = (id: number, row: number) => `\x1b_cc:t${id}:${row}\x07`;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 解析整段终端输入为 SGR 鼠标包序列;数据必须完全由连续 SGR 包组成
|
|
29
|
+
* (夹杂其他字节返回 null,交由常规输入链处理)。
|
|
30
|
+
*/
|
|
31
|
+
export function parseSgrMousePackets(data: string): SgrMousePacket[] | null {
|
|
32
|
+
const pattern = /\x1b\[<(\d+);(\d+);(\d+)([Mm])/g;
|
|
33
|
+
const packets: SgrMousePacket[] = [];
|
|
34
|
+
let offset = 0;
|
|
35
|
+
|
|
36
|
+
for (const match of data.matchAll(pattern)) {
|
|
37
|
+
if (match.index !== offset) return null;
|
|
38
|
+
offset = match.index + match[0].length;
|
|
39
|
+
packets.push({
|
|
40
|
+
code: Number(match[1]),
|
|
41
|
+
col: Number(match[2]),
|
|
42
|
+
row: Number(match[3]),
|
|
43
|
+
final: match[4] as "M" | "m",
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return packets.length > 0 && offset === data.length ? packets : null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 是否为左键按下(排除修饰键、32 表示 motion 事件)。 */
|
|
51
|
+
export function isSgrLeftPress(packet: SgrMousePacket): boolean {
|
|
52
|
+
const baseButton = packet.code & ~(4 | 8 | 16 | 32);
|
|
53
|
+
return packet.final === "M" && baseButton === 0 && (packet.code & 32) === 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 仅剥离终端序列、保留原布局(换行/空白不动),用于命中区间计算。 */
|
|
57
|
+
export function stripTerminalSequencesPreservingLayout(value: string): string {
|
|
58
|
+
return value
|
|
59
|
+
.replace(/\x1b\][^\x07]*(?:\x07|\x1b\\)/g, "")
|
|
60
|
+
.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, "");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 剥离终端序列并折叠空白(用于纯文本比较)。 */
|
|
64
|
+
export function stripTerminalSequences(value: string): string {
|
|
65
|
+
return stripTerminalSequencesPreservingLayout(value).replace(/\s+/g, " ").trim();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** 工具执行组件识别(toolCallId + setExpanded + render)。 */
|
|
69
|
+
export function isToolExecutionComponent(value: any): boolean {
|
|
70
|
+
return Boolean(
|
|
71
|
+
value &&
|
|
72
|
+
typeof value === "object" &&
|
|
73
|
+
typeof value.toolCallId === "string" &&
|
|
74
|
+
typeof value.setExpanded === "function" &&
|
|
75
|
+
typeof value.render === "function",
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** 深度收集组件树中的工具执行组件(含 getMountedRoots 分支)。 */
|
|
80
|
+
export function collectToolComponents(component: any, tools: any[], seen = new Set<any>()): void {
|
|
81
|
+
if (!component || typeof component !== "object" || seen.has(component)) return;
|
|
82
|
+
seen.add(component);
|
|
83
|
+
if (isToolExecutionComponent(component)) {
|
|
84
|
+
tools.push(component);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (Array.isArray(component.children)) {
|
|
88
|
+
for (const child of component.children) collectToolComponents(child, tools, seen);
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const mounted = component.getMountedRoots?.();
|
|
92
|
+
if (Array.isArray(mounted)) {
|
|
93
|
+
for (const root of mounted) collectToolComponents(root, tools, seen);
|
|
94
|
+
}
|
|
95
|
+
} catch {
|
|
96
|
+
// renderer 切换中的惰性 Proxy 可能暂时没有 mounted roots。
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 剥离一行中的零宽帧/视图 marker。 */
|
|
101
|
+
export function stripToolFrameMarkers(line: string): string {
|
|
102
|
+
return line.replace(TOOL_FRAME_MARKER_RE, "").replace(TOOL_VIEW_MARKER_RE, "");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 从渲染行中提取工具帧 placement(component/componentRow/lineIndex/finalLine
|
|
107
|
+
* 及其所属视图与 section),同时返回剥离 marker 后的行。
|
|
108
|
+
*/
|
|
109
|
+
export function extractToolFramePlacements(
|
|
110
|
+
lines: string[],
|
|
111
|
+
idToComponent: Map<number, any>,
|
|
112
|
+
idToView: Map<number, ExpandedToolIoView>,
|
|
113
|
+
): { lines: string[]; placements: FrameToolPlacement[] } {
|
|
114
|
+
const placements: FrameToolPlacement[] = [];
|
|
115
|
+
const cleaned = lines.map((line, lineIndex) => {
|
|
116
|
+
const toolMatches = [...line.matchAll(TOOL_FRAME_MARKER_RE)];
|
|
117
|
+
const viewMatches = [...line.matchAll(TOOL_VIEW_MARKER_RE)];
|
|
118
|
+
const finalLine = stripToolFrameMarkers(line);
|
|
119
|
+
let view: ExpandedToolIoView | undefined;
|
|
120
|
+
let section: ToolIoSection | undefined;
|
|
121
|
+
for (const match of viewMatches) {
|
|
122
|
+
const candidate = idToView.get(Number(match[1]));
|
|
123
|
+
if (!candidate) continue;
|
|
124
|
+
view = candidate;
|
|
125
|
+
section = match[2] === "i" ? "input" : "output";
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
for (const match of toolMatches) {
|
|
129
|
+
const component = idToComponent.get(Number(match[1]));
|
|
130
|
+
if (!component) continue;
|
|
131
|
+
placements.push({
|
|
132
|
+
component,
|
|
133
|
+
componentRow: Number(match[2]),
|
|
134
|
+
lineIndex,
|
|
135
|
+
finalLine,
|
|
136
|
+
view,
|
|
137
|
+
section,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return finalLine;
|
|
141
|
+
});
|
|
142
|
+
return { lines: cleaned, placements };
|
|
143
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getKeybindings,
|
|
3
|
+
matchesKey,
|
|
4
|
+
truncateToWidth,
|
|
5
|
+
visibleWidth,
|
|
6
|
+
type Keybinding,
|
|
7
|
+
} from "@earendil-works/pi-tui";
|
|
8
|
+
import { config } from "../config/config.ts";
|
|
9
|
+
import { isLazyProxyTui } from "../utils/fullscreen-detect.ts";
|
|
10
|
+
import { parseSgrMousePackets } from "./mouse-packets.ts";
|
|
11
|
+
|
|
12
|
+
const ZENTUI_PAGE_UP_INPUT = /^\x1b\[5;9(?::[12])?~$|^\x1b\[57421;9(?::[12])?u$|^\x1b\[1;6A$/;
|
|
13
|
+
const ZENTUI_PAGE_DOWN_INPUT = /^\x1b\[6;9(?::[12])?~$|^\x1b\[57422;9(?::[12])?u$|^\x1b\[1;6B$/;
|
|
14
|
+
const SCROLL_BOTTOM_SHORTCUT = "ctrl+end";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 当前安装的 tui 宿主。宿主放本模块(滚动按钮/调度依赖它),
|
|
18
|
+
* 由 mouse-interaction 经 setToolMouseTui 维护;跨模块一律经绑定/setter 访问。
|
|
19
|
+
*/
|
|
20
|
+
export let toolMouseTui: any = null;
|
|
21
|
+
export function setToolMouseTui(tui: any): void {
|
|
22
|
+
toolMouseTui = tui;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export let scrollButtonVisible = false;
|
|
26
|
+
export let scrollButtonHovered = false;
|
|
27
|
+
export let scrollButtonWidget: any = null;
|
|
28
|
+
let scrollButtonSyncScheduled = false;
|
|
29
|
+
|
|
30
|
+
export function setScrollButtonVisible(visible: boolean): void {
|
|
31
|
+
scrollButtonVisible = visible;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 返回是否发生变化(调用方据此决定是否需要重渲染)。 */
|
|
35
|
+
export function setScrollButtonHovered(hovered: boolean): boolean {
|
|
36
|
+
if (hovered === scrollButtonHovered) return false;
|
|
37
|
+
scrollButtonHovered = hovered;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function setScrollButtonWidget(widget: any): void {
|
|
42
|
+
scrollButtonWidget = widget;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** teardown 全量清零(visible/hovered/widget/sync 调度)。 */
|
|
46
|
+
export function resetScrollButtonState(): void {
|
|
47
|
+
scrollButtonVisible = false;
|
|
48
|
+
scrollButtonHovered = false;
|
|
49
|
+
scrollButtonWidget = null;
|
|
50
|
+
scrollButtonSyncScheduled = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function toolMouseInteractionActive(): boolean {
|
|
54
|
+
if (config.mode === "off") return false;
|
|
55
|
+
if (isLazyProxyTui(toolMouseTui)) return true;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** 惰性 Proxy 官方 fullscreen(TuiAltScreen)判定。 */
|
|
60
|
+
export function fullscreenLazyTui(tui: any): boolean {
|
|
61
|
+
return isLazyProxyTui(tui) && tui.mode === "fullscreen";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** 官方 fullscreen:是否已跟随 transcript 底部(按钮隐藏条件)。 */
|
|
65
|
+
export function isFullscreenAtBottom(tui: any): boolean {
|
|
66
|
+
const following = tui.isFollowingOutput ?? tui.getPrimaryScrollView?.()?.isFollowingEnd ?? true;
|
|
67
|
+
return Boolean(following);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function formatShortcut(shortcut: string): string {
|
|
71
|
+
return shortcut
|
|
72
|
+
.split("+")
|
|
73
|
+
.map((part) =>
|
|
74
|
+
part.length <= 1 ? part.toUpperCase() : `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`,
|
|
75
|
+
)
|
|
76
|
+
.join("+");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function isScrollBottomInput(data: string): boolean {
|
|
80
|
+
return matchesKey(data, SCROLL_BOTTOM_SHORTCUT);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function wheelDirection(data: string): "up" | "down" | null {
|
|
84
|
+
const packets = parseSgrMousePackets(data);
|
|
85
|
+
for (const packet of packets ?? []) {
|
|
86
|
+
if (packet.final !== "M") continue;
|
|
87
|
+
const baseButton = packet.code & ~(4 | 8 | 16 | 32);
|
|
88
|
+
if (baseButton === 64) return "up";
|
|
89
|
+
if (baseButton === 65) return "down";
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function isScrollNavigationInput(data: string): boolean {
|
|
95
|
+
if (
|
|
96
|
+
matchesKey(data, "pageUp") ||
|
|
97
|
+
matchesKey(data, "pageDown") ||
|
|
98
|
+
ZENTUI_PAGE_UP_INPUT.test(data) ||
|
|
99
|
+
ZENTUI_PAGE_DOWN_INPUT.test(data) ||
|
|
100
|
+
// 官方 fullscreen viewport 的可滚动键(half-page/prompt/top/bottom)。
|
|
101
|
+
[
|
|
102
|
+
"tui.altScreen.pageUp",
|
|
103
|
+
"tui.altScreen.pageDown",
|
|
104
|
+
"tui.altScreen.halfPageUp",
|
|
105
|
+
"tui.altScreen.halfPageDown",
|
|
106
|
+
"tui.altScreen.previousPrompt",
|
|
107
|
+
"tui.altScreen.nextPrompt",
|
|
108
|
+
"tui.altScreen.top",
|
|
109
|
+
"tui.altScreen.bottom",
|
|
110
|
+
].some((key) => getKeybindings().matches(data, key as Keybinding))
|
|
111
|
+
) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const packets = parseSgrMousePackets(data);
|
|
115
|
+
return Boolean(
|
|
116
|
+
packets?.some((packet) => {
|
|
117
|
+
const baseButton = packet.code & ~(4 | 8 | 16 | 32);
|
|
118
|
+
return packet.final === "M" && (baseButton === 64 || baseButton === 65);
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function isAtTranscriptBottom(tui: any): boolean {
|
|
124
|
+
// 惰性 Proxy fullscreen:官方 viewport 以 isFollowingOutput 判定是否在底部。
|
|
125
|
+
if (fullscreenLazyTui(tui)) return isFullscreenAtBottom(tui);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function hideScrollButton(tui: any): void {
|
|
130
|
+
const changed = scrollButtonVisible || scrollButtonHovered;
|
|
131
|
+
scrollButtonVisible = false;
|
|
132
|
+
scrollButtonHovered = false;
|
|
133
|
+
if (changed) tui.requestRender?.();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function scheduleScrollButtonSync(tui: any, data: string): void {
|
|
137
|
+
if (
|
|
138
|
+
!fullscreenLazyTui(tui) ||
|
|
139
|
+
!toolMouseInteractionActive() ||
|
|
140
|
+
!isScrollNavigationInput(data) ||
|
|
141
|
+
scrollButtonSyncScheduled
|
|
142
|
+
)
|
|
143
|
+
return;
|
|
144
|
+
scrollButtonSyncScheduled = true;
|
|
145
|
+
const previousLines = tui.previousLines;
|
|
146
|
+
const check = (attempt: number) => {
|
|
147
|
+
scrollButtonSyncScheduled = false;
|
|
148
|
+
if (toolMouseTui !== tui) return;
|
|
149
|
+
// Pi renders on its own frame timer. Inspect the resulting viewport before
|
|
150
|
+
// showing the button so empty or non-scrollable transcripts never flash it.
|
|
151
|
+
const rendered = tui.previousLines !== previousLines;
|
|
152
|
+
// fullscreen 下 isFollowingOutput 是即时状态,无需等待官方帧渲染。
|
|
153
|
+
if (!rendered && attempt < 4 && !fullscreenLazyTui(tui)) {
|
|
154
|
+
scrollButtonSyncScheduled = true;
|
|
155
|
+
const timer = setTimeout(() => check(attempt + 1), 16);
|
|
156
|
+
if (typeof timer === "object" && timer !== null && "unref" in timer) {
|
|
157
|
+
(timer as { unref: () => void }).unref();
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const nextVisible = !isAtTranscriptBottom(tui);
|
|
162
|
+
if (nextVisible !== scrollButtonVisible) {
|
|
163
|
+
scrollButtonVisible = nextVisible;
|
|
164
|
+
tui.requestRender?.();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
process.nextTick(() => check(0));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function updateScrollButtonFromInput(tui: any, data: string): void {
|
|
171
|
+
if (!fullscreenLazyTui(tui) || !toolMouseInteractionActive()) return;
|
|
172
|
+
if (matchesKey(data, "enter") || matchesKey(data, "return")) hideScrollButton(tui);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function renderScrollButton(width: number, theme: any): string[] {
|
|
176
|
+
if (!scrollButtonVisible || !fullscreenLazyTui(toolMouseTui)) return [];
|
|
177
|
+
const shortcut = formatShortcut(SCROLL_BOTTOM_SHORTCUT);
|
|
178
|
+
const label = theme.fg(
|
|
179
|
+
scrollButtonHovered ? "text" : "accent",
|
|
180
|
+
`[ ↓ Back to bottom · ${shortcut} ]`,
|
|
181
|
+
);
|
|
182
|
+
const leftPad = Math.max(0, Math.floor((width - visibleWidth(label)) / 2));
|
|
183
|
+
return [`${" ".repeat(leftPad)}${truncateToWidth(label, width, "…")}`];
|
|
184
|
+
}
|
package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool-diff/diff-renderer.ts
CHANGED
|
@@ -2653,7 +2653,7 @@ export function renderEditDiffResult(
|
|
|
2653
2653
|
return cache.set(safeWidth, options.expanded, mode, configKey, hovered, clampedLines);
|
|
2654
2654
|
},
|
|
2655
2655
|
invalidate: cache.invalidate,
|
|
2656
|
-
};
|
|
2656
|
+
} as Component;
|
|
2657
2657
|
}
|
|
2658
2658
|
|
|
2659
2659
|
function renderWriteHeader(
|
|
@@ -3079,5 +3079,5 @@ export function renderWriteDiffResult(
|
|
|
3079
3079
|
return cache.set(safeWidth, options.expanded, mode, configKey, hovered, finalLines);
|
|
3080
3080
|
},
|
|
3081
3081
|
invalidate: cache.invalidate,
|
|
3082
|
-
};
|
|
3082
|
+
} as Component;
|
|
3083
3083
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { AssistantMessageComponent, ToolExecutionComponent } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Container,
|
|
4
|
+
Spacer,
|
|
5
|
+
truncateToWidth,
|
|
6
|
+
visibleWidth,
|
|
7
|
+
type Component,
|
|
8
|
+
} from "@earendil-works/pi-tui";
|
|
3
9
|
import { TOOL_LOADING_INTERVAL_MS, toolLoadingIcon } from "../utils/tool-loading-icon.ts";
|
|
4
10
|
import { sanitizeToolResultText } from "../utils/tool-result-sanitize.ts";
|
|
5
11
|
import { showMoreHintText } from "./show-more-hint.ts";
|
|
@@ -285,7 +291,8 @@ export class ToolGroupComponent extends Container {
|
|
|
285
291
|
|
|
286
292
|
setExpanded(expanded: boolean): void {
|
|
287
293
|
this._expanded = expanded;
|
|
288
|
-
for (const tool of this.children)
|
|
294
|
+
for (const tool of this.children)
|
|
295
|
+
(tool as Component & { setExpanded?: (expanded: boolean) => void }).setExpanded?.(expanded);
|
|
289
296
|
}
|
|
290
297
|
|
|
291
298
|
setHintHovered(hovered: boolean): void {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
2
|
+
import { AssistantMessageComponent, ToolExecutionComponent } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
// pi-coding-agent 类型声明中 AssistantMessageComponent 仅能以 value 形式使用,
|
|
5
|
+
// updateContent/lastMessage 用结构化类型访问。
|
|
6
|
+
type TranscriptComponentInternals = {
|
|
7
|
+
lastMessage?: AssistantMessage;
|
|
8
|
+
updateContent(message: AssistantMessage): void;
|
|
9
|
+
invalidate?(): void;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 重绘单个已构造的组件:assistant 用最新消息重渲染(compact thinking),
|
|
14
|
+
* tool 强制 updateDisplay(其内容可能仍在旧 shell 容器中)。
|
|
15
|
+
* 不吞异常——由调用方决定如何处理失败。
|
|
16
|
+
*/
|
|
17
|
+
export function refreshTranscriptComponent(value: unknown): boolean {
|
|
18
|
+
if (!value || typeof value !== "object") return false;
|
|
19
|
+
if (value instanceof AssistantMessageComponent) {
|
|
20
|
+
const self = value as unknown as TranscriptComponentInternals;
|
|
21
|
+
if (self.lastMessage) self.updateContent(self.lastMessage);
|
|
22
|
+
else self.invalidate?.();
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (value instanceof ToolExecutionComponent) {
|
|
26
|
+
// updateDisplay 是私有方法,但它是 resume 后让内容回到正确
|
|
27
|
+
// shell 容器的唯一入口(原型链已含全局工具渲染补丁)。
|
|
28
|
+
(value as unknown as { updateDisplay(): void }).updateDisplay();
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 扫描挂载树,重绘所有已构造的 assistant/tool 组件。
|
|
36
|
+
* 用于 reload/resume/compaction 后"pi 用原始原型重建、补丁事后才装"的场景。
|
|
37
|
+
* 遍历 value.children 与 value.getMountedRoots?.()(seen 集合防环),
|
|
38
|
+
* 单个组件失败用 try/catch 隔离,不影响其余组件。
|
|
39
|
+
*/
|
|
40
|
+
// compact-mode 把补丁暴露在此 Symbol 上(见 compact-mode.ts),避免循环依赖。
|
|
41
|
+
const COMPACT_MODE_PATCH_KEY = Symbol.for("pi.ccstyle.compact-mode-patch");
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 补丁链序不变量:compact 模式下 compact-mode 必须位于 compact-thinking
|
|
45
|
+
* 外层(round 摘要才能聚合工具统计)。resume/reload 后若无新消息,
|
|
46
|
+
* message_update 触发的重新认领不会执行,这里在任何重绘前先断言一次。
|
|
47
|
+
* 断言幂等:链序已正确时无操作;mode=on 时也安全(外层走 pass-through)。
|
|
48
|
+
*/
|
|
49
|
+
function assertCompactModeOutermost(): void {
|
|
50
|
+
try {
|
|
51
|
+
const patch = (globalThis as any)[COMPACT_MODE_PATCH_KEY];
|
|
52
|
+
if (typeof patch?.assertAssistantOwnership === "function") {
|
|
53
|
+
patch.assertAssistantOwnership();
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// 无 compact-mode 补丁或断言失败时跳过,扫描仍会执行。
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function refreshMountedTranscript(tui?: unknown): void {
|
|
61
|
+
if (!tui || typeof (tui as any).getMountedRoots !== "function") return;
|
|
62
|
+
// 先修正链序再重绘:扫描触发 updateContent 时 compact-mode 已在外层。
|
|
63
|
+
assertCompactModeOutermost();
|
|
64
|
+
const seen = new Set<object>();
|
|
65
|
+
const visit = (value: any): void => {
|
|
66
|
+
if (!value || typeof value !== "object" || seen.has(value)) return;
|
|
67
|
+
seen.add(value);
|
|
68
|
+
if (Array.isArray(value)) {
|
|
69
|
+
for (const child of value) visit(child);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
refreshTranscriptComponent(value);
|
|
74
|
+
} catch {
|
|
75
|
+
// 单个组件失败不阻断其余组件;后续 session_tree/重绘再试。
|
|
76
|
+
}
|
|
77
|
+
const children = value.children;
|
|
78
|
+
if (Array.isArray(children)) {
|
|
79
|
+
for (const child of children) visit(child);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
const mounted = value.getMountedRoots?.();
|
|
83
|
+
if (Array.isArray(mounted)) {
|
|
84
|
+
for (const root of mounted) visit(root);
|
|
85
|
+
}
|
|
86
|
+
} catch {
|
|
87
|
+
// 惰性 Proxy / 未挂载容器没有 mounted roots。
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
visit(tui);
|
|
91
|
+
}
|
|
@@ -107,8 +107,8 @@ function summaryParts(data: AgentSummaryData): string[] {
|
|
|
107
107
|
const parts: string[] = [];
|
|
108
108
|
if (data.reads) parts.push(`read ${data.reads} file${plural(data.reads)}`);
|
|
109
109
|
if (data.edits) parts.push(`edited ${data.edits} file${plural(data.edits)}`);
|
|
110
|
-
if (data.commands) parts.push(`ran ${data.commands} command${plural(data.commands)}`);
|
|
111
110
|
if (data.others) parts.push(`${data.others} other tool${plural(data.others)}`);
|
|
111
|
+
if (data.commands) parts.push(`ran ${data.commands} command${plural(data.commands)}`);
|
|
112
112
|
if (data.failed) parts.push(`${data.failed} failed`);
|
|
113
113
|
return parts;
|
|
114
114
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/pi-cc-extensions",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.52",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "A Pi productivity suite with Claude Code-style UI, context inspection, and agent/session references",
|
|
6
6
|
"type": "module",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
},
|
|
70
70
|
"x-upstream": {
|
|
71
71
|
"package": "pi-cc-extensions",
|
|
72
|
-
"version": "0.8.
|
|
72
|
+
"version": "0.8.53",
|
|
73
73
|
"repository": "https://github.com/minuque/pi-cc-extensions",
|
|
74
|
-
"commit": "
|
|
74
|
+
"commit": "a7aaf6d4136af44a1ef7ac4993d5754fe084c921"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"toolTitle": "accentBright",
|
|
54
54
|
"toolOutput": "muted",
|
|
55
55
|
"mdHeading": "accentBright",
|
|
56
|
-
"mdLink": "
|
|
56
|
+
"mdLink": "cyan",
|
|
57
57
|
"mdLinkUrl": "muted",
|
|
58
|
-
"mdCode": "
|
|
58
|
+
"mdCode": "accentBright",
|
|
59
59
|
"mdCodeBlock": "text",
|
|
60
60
|
"mdCodeBlockBorder": "border",
|
|
61
61
|
"mdQuote": "muted",
|