pi-context-map 0.6.0 → 0.6.1
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/CHANGELOG.md +5 -0
- package/extensions/analyzer.ts +3 -9
- package/extensions/index.ts +1 -6
- package/extensions/live-server.ts +9 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.1] - 2026-06-15
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
- **Fixed libuv assertion on Windows**: Removed `process.on('exit')` handler and `process.exit(0)` calls that left server handles open. Server now closes synchronously via `closeAllConnections()`.
|
|
6
|
+
- **Synchronous stop()**: `isRunning` returns `false` immediately after `stop()` instead of after async callback.
|
|
7
|
+
|
|
3
8
|
## [0.6.0] - 2026-06-15
|
|
4
9
|
### Bug Fixes
|
|
5
10
|
- **Fixed composition analysis**: Changed `role === "tool"` to `role === "toolResult"` to match Pi's actual message format. Tools and files now show correct percentages instead of 0%.
|
package/extensions/analyzer.ts
CHANGED
|
@@ -81,8 +81,7 @@ export class ContextAnalyzer {
|
|
|
81
81
|
if (Array.isArray(msg.content)) {
|
|
82
82
|
for (const block of msg.content) {
|
|
83
83
|
if (block.type === "image" || block.type === "image_url") {
|
|
84
|
-
const p =
|
|
85
|
-
block.source?.url || block.image_url?.url || "[image]";
|
|
84
|
+
const p = block.source?.url || block.image_url?.url || "[image]";
|
|
86
85
|
const w = TokenCounter.count(JSON.stringify(block));
|
|
87
86
|
fileTokens += w;
|
|
88
87
|
if (!fileRegistry.has(p)) {
|
|
@@ -134,11 +133,7 @@ export class ContextAnalyzer {
|
|
|
134
133
|
const p = this.extractPath(block.name, input);
|
|
135
134
|
if (p) {
|
|
136
135
|
const opType = this.getOpType(block.name);
|
|
137
|
-
const result = this.findToolResult(
|
|
138
|
-
messages,
|
|
139
|
-
index,
|
|
140
|
-
block.id,
|
|
141
|
-
);
|
|
136
|
+
const result = this.findToolResult(messages, index, block.id);
|
|
142
137
|
const content = result?.content || "";
|
|
143
138
|
const w = TokenCounter.count(String(content));
|
|
144
139
|
fileTokens += w;
|
|
@@ -168,8 +163,7 @@ export class ContextAnalyzer {
|
|
|
168
163
|
|
|
169
164
|
const mk = (tokens: number): ContextSlice => ({
|
|
170
165
|
tokens: Math.ceil(tokens),
|
|
171
|
-
percent:
|
|
172
|
-
totalTokens > 0 ? Math.round((tokens / totalTokens) * 100) : 0,
|
|
166
|
+
percent: totalTokens > 0 ? Math.round((tokens / totalTokens) * 100) : 0,
|
|
173
167
|
});
|
|
174
168
|
|
|
175
169
|
const files_detail = Array.from(fileRegistry.values())
|
package/extensions/index.ts
CHANGED
|
@@ -25,9 +25,7 @@ function makeReportPath(sessionName?: string): string {
|
|
|
25
25
|
const now = new Date();
|
|
26
26
|
const date = now.toISOString().split("T")[0];
|
|
27
27
|
const time = now.toTimeString().split(" ")[0].replace(/:/g, "-");
|
|
28
|
-
const safe = (sessionName || "session")
|
|
29
|
-
.replace(/[^\w.-]/g, "_")
|
|
30
|
-
.slice(0, 40);
|
|
28
|
+
const safe = (sessionName || "session").replace(/[^\w.-]/g, "_").slice(0, 40);
|
|
31
29
|
const filename = `${date}_${time}_${safe}.html`;
|
|
32
30
|
return path.join(dir, filename);
|
|
33
31
|
}
|
|
@@ -211,13 +209,10 @@ export default async function piContextMap(pi: ExtensionAPI): Promise<void> {
|
|
|
211
209
|
liveServer.stop();
|
|
212
210
|
});
|
|
213
211
|
|
|
214
|
-
process.on("exit", () => liveServer.stop());
|
|
215
212
|
process.on("SIGINT", () => {
|
|
216
213
|
liveServer.stop();
|
|
217
|
-
process.exit(0);
|
|
218
214
|
});
|
|
219
215
|
process.on("SIGTERM", () => {
|
|
220
216
|
liveServer.stop();
|
|
221
|
-
process.exit(0);
|
|
222
217
|
});
|
|
223
218
|
}
|
|
@@ -94,18 +94,19 @@ export class LiveReportServer {
|
|
|
94
94
|
for (const client of this.clients) {
|
|
95
95
|
try {
|
|
96
96
|
client.end();
|
|
97
|
-
} catch
|
|
98
|
-
// Ignore
|
|
97
|
+
} catch {
|
|
98
|
+
// Ignore
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
this.clients.clear();
|
|
102
102
|
|
|
103
|
-
//
|
|
104
|
-
this.server.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
// Force-close all connections synchronously (Node 18.2+)
|
|
104
|
+
if (typeof this.server.closeAllConnections === "function") {
|
|
105
|
+
this.server.closeAllConnections();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Close server and reset state synchronously
|
|
109
|
+
this.server.close();
|
|
109
110
|
this.server = null;
|
|
110
111
|
this.port = 0;
|
|
111
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-context-map",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Professional context profiler for Pi that visualizes the session context window, token distribution, and integrates with Nexus packages for actionable insights.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|