@aabadin/project-memory-context 0.2.11 → 0.2.12

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.
@@ -1,13 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from 'node:child_process';
3
- import { dirname, resolve } from 'node:path';
3
+ import { dirname, resolve, join } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
6
+ import { tmpdir } from 'node:os';
5
7
 
6
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
9
  const PACKAGE_ROOT = resolve(__dirname, '..');
8
10
 
9
11
  // graph-explorer lives INSIDE the package: tools/pmc-graph-explorer/
10
12
  const GRAPH_EXPLORER_PATH = resolve(PACKAGE_ROOT, 'tools/pmc-graph-explorer/server.mjs');
13
+ const PID_FILE = join(tmpdir(), 'pmc-graph-explorer.pid');
14
+
15
+ // Kill previous server instance if running
16
+ if (existsSync(PID_FILE)) {
17
+ try {
18
+ const pid = parseInt(readFileSync(PID_FILE, 'utf8').trim(), 10);
19
+ if (pid) process.kill(pid, 'SIGKILL');
20
+ } catch { /* already dead or invalid pid */ }
21
+ }
11
22
 
12
23
  const child = spawn(process.execPath, [GRAPH_EXPLORER_PATH], {
13
24
  env: { ...process.env, PMC_PROJECT_ROOT: process.cwd() },
@@ -16,4 +27,5 @@ const child = spawn(process.execPath, [GRAPH_EXPLORER_PATH], {
16
27
  shell: false,
17
28
  });
18
29
 
19
- child.unref();
30
+ writeFileSync(PID_FILE, String(child.pid), 'utf8');
31
+ child.unref();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aabadin/project-memory-context",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "Portable project memory context CLI — bootstraps semantic enrichment workflows for any AI coding agent.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",