xtrm-tools 0.5.35 → 0.5.36
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/.claude-plugin/plugin.json +1 -1
- package/cli/dist/index.cjs +36 -1
- package/cli/dist/index.cjs.map +1 -1
- package/cli/package.json +1 -1
- package/config/pi/extensions/pi-serena-compact/index.ts +121 -0
- package/config/pi/extensions/pi-serena-compact/package.json +16 -0
- package/package.json +1 -1
- package/plugins/xtrm-tools/.claude-plugin/plugin.json +1 -1
package/cli/package.json
CHANGED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { ExtensionAPI, ToolResultEvent } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
|
|
3
|
+
// Serena/GitNexus MCP tool names that produce verbose output
|
|
4
|
+
const COMPACT_TOOLS = new Set([
|
|
5
|
+
// Serena symbol operations
|
|
6
|
+
"find_symbol",
|
|
7
|
+
"find_referencing_symbols",
|
|
8
|
+
"get_symbols_overview",
|
|
9
|
+
"jet_brains_find_symbol",
|
|
10
|
+
"jet_brains_find_referencing_symbols",
|
|
11
|
+
"jet_brains_get_symbols_overview",
|
|
12
|
+
"jet_brains_type_hierarchy",
|
|
13
|
+
|
|
14
|
+
// Serena file operations
|
|
15
|
+
"read_file",
|
|
16
|
+
"create_text_file",
|
|
17
|
+
"replace_content",
|
|
18
|
+
"replace_lines",
|
|
19
|
+
"delete_lines",
|
|
20
|
+
"insert_at_line",
|
|
21
|
+
|
|
22
|
+
// Serena search/navigation
|
|
23
|
+
"search_for_pattern",
|
|
24
|
+
"list_dir",
|
|
25
|
+
"find_file",
|
|
26
|
+
|
|
27
|
+
// Serena symbol editing
|
|
28
|
+
"replace_symbol_body",
|
|
29
|
+
"insert_after_symbol",
|
|
30
|
+
"insert_before_symbol",
|
|
31
|
+
"rename_symbol",
|
|
32
|
+
|
|
33
|
+
// GitNexus
|
|
34
|
+
"gitnexus_query",
|
|
35
|
+
"gitnexus_context",
|
|
36
|
+
"gitnexus_impact",
|
|
37
|
+
"gitnexus_detect_changes",
|
|
38
|
+
"gitnexus_list_repos",
|
|
39
|
+
|
|
40
|
+
// Serena memory
|
|
41
|
+
"read_memory",
|
|
42
|
+
"write_memory",
|
|
43
|
+
"list_memories",
|
|
44
|
+
|
|
45
|
+
// Other verbose tools
|
|
46
|
+
"execute_shell_command",
|
|
47
|
+
"structured_return",
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
// Tools that should show more output even when compacted
|
|
51
|
+
const PRESERVE_OUTPUT_TOOLS = new Set([
|
|
52
|
+
"read_file",
|
|
53
|
+
"read_memory",
|
|
54
|
+
"execute_shell_command",
|
|
55
|
+
"structured_return",
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
function isSerenaTool(toolName: string): boolean {
|
|
59
|
+
return COMPACT_TOOLS.has(toolName);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getTextContent(content: Array<{ type: string; text?: string }>): string {
|
|
63
|
+
const item = content.find((c) => c.type === "text");
|
|
64
|
+
return item?.text ?? "";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function truncateLines(text: string, maxLines: number, maxLineLen = 180): string {
|
|
68
|
+
const lines = text.split("\n");
|
|
69
|
+
const truncated = lines.map(line =>
|
|
70
|
+
line.length > maxLineLen ? line.slice(0, maxLineLen) + "…" : line
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (truncated.length <= maxLines) return truncated.join("\n");
|
|
74
|
+
return truncated.slice(0, maxLines).join("\n") + `\n… +${truncated.length - maxLines} more lines`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function compactResult(
|
|
78
|
+
toolName: string,
|
|
79
|
+
content: Array<{ type: string; text?: string }>,
|
|
80
|
+
maxLines: number = 6,
|
|
81
|
+
): Array<{ type: string; text: string }> {
|
|
82
|
+
const textContent = getTextContent(content);
|
|
83
|
+
|
|
84
|
+
if (!textContent) {
|
|
85
|
+
return [{ type: "text", text: "✓ No output" }];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// For certain tools, show more output
|
|
89
|
+
const effectiveMaxLines = PRESERVE_OUTPUT_TOOLS.has(toolName) ? 12 : maxLines;
|
|
90
|
+
|
|
91
|
+
const compacted = truncateLines(textContent, effectiveMaxLines, 180);
|
|
92
|
+
|
|
93
|
+
return [{ type: "text", text: compacted }];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default function serenaCompactExtension(pi: ExtensionAPI): void {
|
|
97
|
+
let toolsExpanded = false;
|
|
98
|
+
|
|
99
|
+
// Track tools expanded state
|
|
100
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
101
|
+
toolsExpanded = ctx.ui.getToolsExpanded();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
pi.on("session_switch", async (_event, ctx) => {
|
|
105
|
+
toolsExpanded = ctx.ui.getToolsExpanded();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Compact Serena tool results
|
|
109
|
+
pi.on("tool_result", async (event: ToolResultEvent) => {
|
|
110
|
+
// Only handle Serena/MCP tools
|
|
111
|
+
if (!isSerenaTool(event.toolName)) return undefined;
|
|
112
|
+
|
|
113
|
+
// If tools are expanded, don't compact
|
|
114
|
+
if (toolsExpanded) return undefined;
|
|
115
|
+
|
|
116
|
+
// Compact the content
|
|
117
|
+
const compacted = compactResult(event.toolName, event.content, 6);
|
|
118
|
+
|
|
119
|
+
return { content: compacted };
|
|
120
|
+
});
|
|
121
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-serena-compact",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Compact output for Serena MCP tools in Pi",
|
|
5
|
+
"keywords": ["pi", "pi-extension", "serena", "mcp"],
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.ts",
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"@mariozechner/pi-coding-agent": "^0.56.0",
|
|
11
|
+
"@mariozechner/pi-tui": "^0.56.0"
|
|
12
|
+
},
|
|
13
|
+
"pi": {
|
|
14
|
+
"extensions": ["./index.ts"]
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED