pi-cc-extensions 0.7.9 → 0.7.10
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 +13 -2
- package/extensions/claude-code-style.ts +19 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
|
|
51
51
|
`extensions/claude-code-style.ts` 提供:
|
|
52
52
|
|
|
53
|
-
- Claude Code
|
|
53
|
+
- Claude Code 风格的工具调用行与结果摘要(默认覆盖普通工具 renderer)
|
|
54
54
|
- Pi 默认输入栏
|
|
55
|
-
-
|
|
55
|
+
- 通过 `excludeRenderers` 保留指定工具的原生或扩展 renderer
|
|
56
56
|
- 工具结果的折叠与展开
|
|
57
57
|
- 类 claude code 滚动到底部 button
|
|
58
58
|
|
|
@@ -65,6 +65,17 @@
|
|
|
65
65
|
/ccstyle status # 查看状态
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
需要保留指定工具的原生或扩展 renderer 时,编辑 `~/.pi/agent/claude-code-style.json`:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"enabled": true,
|
|
73
|
+
"excludeRenderers": ["edit", "write"]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
名单使用精确工具名;修改后执行 `/reload`。`Agent` 的专用 renderer 始终保留。
|
|
78
|
+
|
|
68
79
|
### 上下文窗口查看
|
|
69
80
|
|
|
70
81
|
`extensions/context.ts` 注册 `/context`,展示当前上下文窗口的使用分布,并可进一步预览:
|
|
@@ -12,8 +12,8 @@ import { join } from "node:path";
|
|
|
12
12
|
/**
|
|
13
13
|
* Claude Code Style for pi
|
|
14
14
|
*
|
|
15
|
-
* Tool calls and results use a compact fallback renderer.
|
|
16
|
-
*
|
|
15
|
+
* Tool calls and results use a compact fallback renderer by default. Renderers
|
|
16
|
+
* listed in excludeRenderers remain untouched. A collapsed tool result can be
|
|
17
17
|
* clicked on its Ctrl+O hint to expand only that tool.
|
|
18
18
|
*
|
|
19
19
|
* Dynamic commands:
|
|
@@ -28,6 +28,7 @@ import { join } from "node:path";
|
|
|
28
28
|
|
|
29
29
|
type Config = {
|
|
30
30
|
enabled: boolean;
|
|
31
|
+
excludeRenderers: string[];
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
const CONFIG_PATH = join(homedir(), ".pi", "agent", "claude-code-style.json");
|
|
@@ -38,14 +39,18 @@ function loadConfig(): Config {
|
|
|
38
39
|
try {
|
|
39
40
|
if (existsSync(CONFIG_PATH)) {
|
|
40
41
|
const parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf8")) as Partial<Config>;
|
|
42
|
+
const excludeRenderers = Array.isArray(parsed.excludeRenderers)
|
|
43
|
+
? [...new Set(parsed.excludeRenderers.filter((name): name is string => typeof name === "string" && name.length > 0))]
|
|
44
|
+
: [];
|
|
41
45
|
return {
|
|
42
46
|
enabled: parsed.enabled ?? true,
|
|
47
|
+
excludeRenderers,
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
} catch {
|
|
46
51
|
// Ignore bad config and fall back to defaults.
|
|
47
52
|
}
|
|
48
|
-
return { enabled: true };
|
|
53
|
+
return { enabled: true, excludeRenderers: [] };
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
function saveConfig() {
|
|
@@ -1069,10 +1074,9 @@ function createCcstyleTool(originalTool: any): any {
|
|
|
1069
1074
|
|
|
1070
1075
|
/**
|
|
1071
1076
|
* This extension does not register tools. ToolExecutionComponent is shared by
|
|
1072
|
-
* the TUI and exported by pi; patch its renderer lookup once so
|
|
1073
|
-
*
|
|
1074
|
-
*
|
|
1075
|
-
* fallback; subagents and extension-owned renderers keep their own output.
|
|
1077
|
+
* the TUI and exported by pi; patch its renderer lookup once so tools use the
|
|
1078
|
+
* same compact fallback shell by default. Tools named in excludeRenderers keep
|
|
1079
|
+
* their original renderer; subagent rendering remains protected.
|
|
1076
1080
|
*/
|
|
1077
1081
|
const GLOBAL_TOOL_RENDER_PATCH = Symbol.for("pi.ccstyle.global-tool-render-patch");
|
|
1078
1082
|
const COMPONENT_TOOL_RENDER_MODE = Symbol.for("pi.ccstyle.component-tool-render-mode");
|
|
@@ -1098,21 +1102,20 @@ function isMcpToolDefinition(definition: any, toolName: string): boolean {
|
|
|
1098
1102
|
return toolName === "mcp" || label === "MCP" || label.startsWith("MCP: ");
|
|
1099
1103
|
}
|
|
1100
1104
|
|
|
1101
|
-
/**
|
|
1102
|
-
* ToolExecutionComponent keeps extension-supplied and native definitions in
|
|
1103
|
-
* separate fields. Native renderers are eligible for ccstyle's fallback, while
|
|
1104
|
-
* an extension-owned dedicated renderer must remain untouched.
|
|
1105
|
-
*/
|
|
1105
|
+
/** Return true when this tool must keep its original renderer. */
|
|
1106
1106
|
export function preservesOriginalRenderer(
|
|
1107
1107
|
extensionDefinition: any,
|
|
1108
1108
|
toolName: string,
|
|
1109
1109
|
builtInToolDefinition?: any,
|
|
1110
|
+
excludeRenderers: readonly string[] = config.excludeRenderers,
|
|
1110
1111
|
): boolean {
|
|
1111
1112
|
if (SUBAGENT_TOOL_NAMES.has(toolName)) return true;
|
|
1112
|
-
if (!
|
|
1113
|
-
return extensionDefinition.
|
|
1114
|
-
|
|
1115
|
-
|| typeof
|
|
1113
|
+
if (!excludeRenderers.includes(toolName)) return false;
|
|
1114
|
+
return [extensionDefinition, builtInToolDefinition].some((definition) =>
|
|
1115
|
+
definition?.renderShell === "self"
|
|
1116
|
+
|| typeof definition?.renderCall === "function"
|
|
1117
|
+
|| typeof definition?.renderResult === "function",
|
|
1118
|
+
);
|
|
1116
1119
|
}
|
|
1117
1120
|
|
|
1118
1121
|
function shouldGloballyStyleTool(component: any, patch: GlobalToolRenderPatch): boolean {
|