pi-context-map 0.4.1 → 0.4.4

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.
@@ -194,10 +194,14 @@ export default async function piContextMap(pi: ExtensionAPI): Promise<void> {
194
194
  liveServer.stop();
195
195
  });
196
196
 
197
- if (serverUrl) {
198
- console.log(`[pi-context-map] Live server running at ${serverUrl}`);
199
- console.log(
200
- `[pi-context-map] Run /context-map to generate a report, or /context-map stop to terminate.`,
201
- );
202
- }
197
+ // Kill server when process exits
198
+ process.on("exit", () => liveServer.stop());
199
+ process.on("SIGINT", () => {
200
+ liveServer.stop();
201
+ process.exit(0);
202
+ });
203
+ process.on("SIGTERM", () => {
204
+ liveServer.stop();
205
+ process.exit(0);
206
+ });
203
207
  }
@@ -51,8 +51,9 @@ export class LiveReportServer {
51
51
  * Start the server. Returns a Promise that resolves to the URL, or null on failure.
52
52
  */
53
53
  public start(): Promise<string | null> {
54
+ // Kill any pre-existing server to ensure only one instance runs
54
55
  if (this.server) {
55
- return Promise.resolve(this.url);
56
+ this.stop();
56
57
  }
57
58
 
58
59
  return new Promise((resolve) => {
@@ -69,7 +70,6 @@ export class LiveReportServer {
69
70
  const addr = this.server?.address() as AddressInfo | null;
70
71
  if (addr) {
71
72
  this.port = addr.port;
72
- console.log(`[pi-context-map] Live server: ${this.url}`);
73
73
  resolve(this.url);
74
74
  } else {
75
75
  resolve(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-context-map",
3
- "version": "0.4.1",
3
+ "version": "0.4.4",
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",