@colbymchenry/codegraph 1.0.0 → 1.0.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/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  ## 🎉 1.0 Released!
6
6
 
7
+ Already installed? Run `codegraph upgrade` to update in place.
8
+
7
9
  Follow [@getcodegraph](https://x.com/getcodegraph) on X for updates.
8
10
 
9
11
  ### Supercharge Claude Code, Cursor, Codex, OpenCode, Hermes Agent, Gemini, Antigravity, and Kiro with Semantic Code Intelligence
@@ -53,7 +55,8 @@ curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install
53
55
  irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex
54
56
  ```
55
57
 
56
- Already have Node? Use npm instead (works on any version):
58
+ <details>
59
+ <summary><b>Already have Node? Use npm instead (works on any version)</b></summary>
57
60
 
58
61
  ```bash
59
62
  npm i -g @colbymchenry/codegraph
@@ -63,6 +66,8 @@ npm i -g @colbymchenry/codegraph
63
66
 
64
67
  <sub>**Upgrade any time** with `codegraph upgrade` — it detects how you installed (bundle, npm, or npx) and updates in place. Add `--check` to see if an update is available, or `codegraph upgrade <version>` to pin one.</sub>
65
68
 
69
+ </details>
70
+
66
71
  ### 2. Wire up your agent(s)
67
72
 
68
73
  In a **new terminal**, run the installer to connect CodeGraph to the agents you use:
@@ -77,10 +82,10 @@ codegraph install
77
82
 
78
83
  ```bash
79
84
  cd your-project
80
- codegraph init -i
85
+ codegraph init
81
86
  ```
82
87
 
83
- <sub>`codegraph init` just creates the local `.codegraph/` index directory; adding `-i` (`--index`) also builds the initial graph in the same step. Without `-i`, run `codegraph index` afterwards to populate it.</sub>
88
+ <sub>`codegraph init` creates the local `.codegraph/` directory and builds the full graph in the same step one command, done.</sub>
84
89
 
85
90
  <div align="center">
86
91
 
@@ -88,6 +93,10 @@ codegraph init -i
88
93
 
89
94
  </div>
90
95
 
96
+ ### 4. No more syncing!
97
+
98
+ Auto-sync is enabled by default. CodeGraph watches the project and updates the graph on every file change — while your agent edits code, or you add, modify, or delete files. **The index is never stale, and there is nothing to re-run.**
99
+
91
100
  ### Uninstall
92
101
 
93
102
  Changed your mind? One command removes CodeGraph from every agent it configured:
@@ -359,10 +368,10 @@ Restart your agent (Claude Code / Cursor / Codex CLI / opencode / Hermes Agent /
359
368
 
360
369
  ```bash
361
370
  cd your-project
362
- codegraph init -i
371
+ codegraph init
363
372
  ```
364
373
 
365
- Builds the per-project knowledge graph index. A single global `codegraph install` works in every project you open — no need to re-run the installer per project.
374
+ Builds the per-project knowledge graph index, which then auto-syncs on every file change. A single global `codegraph install` works in every project you open — no need to re-run the installer per project.
366
375
 
367
376
  That's it — your agent will use CodeGraph tools automatically when a `.codegraph/` directory exists.
368
377
 
@@ -467,6 +476,7 @@ codegraph uninit [path] # Remove CodeGraph from a project (--force to
467
476
  codegraph index [path] # Full index (--force to re-index, --quiet for less output)
468
477
  codegraph sync [path] # Incremental update
469
478
  codegraph status [path] # Show statistics
479
+ codegraph unlock [path] # Remove a stale lock file that's blocking indexing
470
480
  codegraph query <search> # Search symbols (--kind, --limit, --json)
471
481
  codegraph explore <query> # Relevant symbols' source + call paths in one shot (same output as the codegraph_explore MCP tool)
472
482
  codegraph node <symbol|file> # One symbol's source + callers, or read a file with line numbers (same output as codegraph_node)
@@ -475,8 +485,11 @@ codegraph callers <symbol> # Find what calls a function/method (--limit,
475
485
  codegraph callees <symbol> # Find what a function/method calls (--limit, --json)
476
486
  codegraph impact <symbol> # Analyze what code is affected by changing a symbol (--depth, --json)
477
487
  codegraph affected [files...] # Find test files affected by changes (see below)
478
- codegraph serve --mcp # Start MCP server
488
+ codegraph daemon # Manage background daemons — pick one to stop (alias: daemons)
489
+ codegraph telemetry [on|off] # Show or change anonymous usage telemetry
479
490
  codegraph upgrade [version] # Update to the latest release (--check, --force)
491
+ codegraph version # Print the installed version (also -v, --version)
492
+ codegraph help [command] # Show help, optionally for one command
480
493
  ```
481
494
 
482
495
  ### `codegraph affected`
@@ -709,7 +722,7 @@ Framework routing is validated the same way, on a canonical app per framework: E
709
722
  - **You're on an old (pre-0.9) install.** Reinstall to get the bundled runtime — `curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh` (macOS/Linux), `irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex` (Windows), or `npm i -g @colbymchenry/codegraph@latest`.
710
723
  - **`codegraph status` shows `Journal:` other than `wal`** — WAL couldn't be enabled on this filesystem (common on network shares and WSL2 `/mnt`), so reads can block on writes. Move the project (with its `.codegraph/` folder) onto a local disk.
711
724
 
712
- **MCP server not connecting** — Ensure the project is initialized/indexed, verify the path in your MCP config, and check that `codegraph serve --mcp` works from the command line.
725
+ **MCP server not connecting** — Your agent starts the server itself, so you don't launch it by hand. Make sure the project is initialized and indexed (`codegraph status`) and that the path in your MCP config is correct. If it still won't connect, re-run `codegraph install` to rewrite the config.
713
726
 
714
727
  **Missing symbols** — The MCP server auto-syncs on save (wait a couple seconds). Run `codegraph sync` manually if needed. Check that the file's language is supported and isn't inside a `.gitignore`d or default-excluded directory (e.g. `node_modules`, `dist`).
715
728
 
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Render an uncaught value for the last-resort log WITHOUT triggering stack
3
+ * formatting. Pure and total — never throws, never touches `.stack`.
4
+ */
5
+ export declare function describeFatal(value: unknown): string;
6
+ /** Injectable seams so the wiring is testable without registering real handlers. */
7
+ export interface FatalHandlerDeps {
8
+ /** Event target to attach to. Defaults to `process`. */
9
+ target?: NodeJS.EventEmitter;
10
+ /** How to terminate. Defaults to `process.exit`. */
11
+ exit?: (code: number) => void;
12
+ /** How to emit the bounded line. Defaults to a synchronous fd-2 write. */
13
+ write?: (line: string) => void;
14
+ }
15
+ /**
16
+ * Install the uncaught-exception / unhandled-rejection handlers. Both log a
17
+ * bounded line and then exit non-zero (Node's default fatal semantics).
18
+ */
19
+ export declare function installFatalHandlers(deps?: FatalHandlerDeps): void;
20
+ //# sourceMappingURL=fatal-handler.d.ts.map
@@ -57,6 +57,21 @@ export declare function isInitialized(projectRoot: string): boolean;
57
57
  * @param startPath - Directory to start searching from
58
58
  * @returns The project root containing .codegraph/, or null if not found
59
59
  */
60
+ /**
61
+ * Reason a directory is unsafe to use as an index ROOT, or null when it's fine.
62
+ *
63
+ * Indexing your home directory or a filesystem root drags in caches, `Library`,
64
+ * every other project, etc. — a multi-GB index, constant file-watcher churn, and
65
+ * (pre-1.0 on macOS) a file-descriptor blowup that exhausted `kern.maxfiles` and
66
+ * took unrelated apps / the whole machine down (#845). The classic trigger:
67
+ * running the installer or `codegraph init` from `$HOME`, which auto-indexes the
68
+ * current directory. These are never intended project roots, so the installer
69
+ * and `init`/`index` refuse them (overridable with `--force`).
70
+ *
71
+ * Pure-ish (reads only `os.homedir()` + realpath) so it's easy to unit-test.
72
+ * The returned string is a human phrase that slots into "… looks like {reason}".
73
+ */
74
+ export declare function unsafeIndexRootReason(projectRoot: string): string | null;
60
75
  export declare function findNearestCodeGraphRoot(startPath: string): string | null;
61
76
  /**
62
77
  * Create the .codegraph directory structure
@@ -0,0 +1,42 @@
1
+ import type { DaemonRecord, StopResult } from './daemon-registry';
2
+ /** Sentinel option values (not real roots, so they can't collide with a project path). */
3
+ export declare const STOP_ALL = "__stop_all__";
4
+ export declare const CANCEL = "__cancel__";
5
+ export interface PickItem {
6
+ value: string;
7
+ label: string;
8
+ hint?: string;
9
+ }
10
+ /** Compact uptime: `45s`, `12m`, `3h 5m`. */
11
+ export declare function formatUptime(ms: number): string;
12
+ /**
13
+ * Build the ordered, UI-ready option list: the current project's daemon first
14
+ * (so it's the auto-selected default), the rest newest-first, then "Stop all"
15
+ * (only when there's more than one) and "Cancel".
16
+ */
17
+ export declare function buildPickItems(daemons: DaemonRecord[], cwdRoot: string | null, now: number): PickItem[];
18
+ export interface PickerDeps {
19
+ list: () => DaemonRecord[];
20
+ stop: (root: string) => Promise<StopResult>;
21
+ stopAll: () => Promise<StopResult[]>;
22
+ /** Realpath'd root of the current project's daemon, or null. */
23
+ cwdRoot: string | null;
24
+ now: () => number;
25
+ /** Render the picker; returns the chosen value or a cancel sentinel. */
26
+ select: (opts: {
27
+ message: string;
28
+ options: PickItem[];
29
+ initialValue: string;
30
+ }) => Promise<unknown>;
31
+ isCancel: (v: unknown) => boolean;
32
+ /** Per-action note (e.g. "Stopped daemon …"). */
33
+ note: (msg: string) => void;
34
+ /** Final line + teardown (clack outro). */
35
+ done: (msg: string) => void;
36
+ }
37
+ /**
38
+ * Pick a daemon → stop it → re-prompt with what's left, until the user cancels
39
+ * (Esc / Ctrl-C / "Cancel"), picks "Stop all", or nothing remains.
40
+ */
41
+ export declare function runDaemonPicker(deps: PickerDeps): Promise<void>;
42
+ //# sourceMappingURL=daemon-manager.d.ts.map
@@ -0,0 +1,47 @@
1
+ export interface DaemonRecord {
2
+ /** Realpath'd project root the daemon serves. */
3
+ root: string;
4
+ pid: number;
5
+ version: string;
6
+ socketPath: string;
7
+ /** Epoch ms when the daemon bound its socket. */
8
+ startedAt: number;
9
+ }
10
+ /**
11
+ * `~/.codegraph/daemons` — GLOBAL, keyed off the home install dir. (The
12
+ * `CODEGRAPH_DIR` env var only renames the per-project index dir, not this.)
13
+ */
14
+ export declare function getRegistryDir(): string;
15
+ /**
16
+ * Is `pid` a live process? `kill(pid, 0)` sends no signal — it just probes:
17
+ * ESRCH ⇒ dead, EPERM ⇒ alive but not ours (still alive). Same liveness check
18
+ * the PPID watchdog (#277) and daemon lock arbitration use.
19
+ */
20
+ export declare function isProcessAlive(pid: number): boolean;
21
+ /** Best-effort: record this daemon so `list`/`stop --all` can find it. */
22
+ export declare function registerDaemon(rec: DaemonRecord): void;
23
+ /** Best-effort: drop this daemon's record on graceful shutdown. */
24
+ export declare function deregisterDaemon(root: string): void;
25
+ /**
26
+ * All registered daemons whose process is still alive, newest first. Dead/garbage
27
+ * records are deleted as a side effect (self-healing) unless `prune` is false.
28
+ */
29
+ export declare function listDaemons(opts?: {
30
+ prune?: boolean;
31
+ }): DaemonRecord[];
32
+ export interface StopResult {
33
+ root: string;
34
+ pid: number | null;
35
+ /** 'term' graceful, 'kill' force, 'not-running' stale lock, 'no-daemon' none found. */
36
+ outcome: 'term' | 'kill' | 'not-running' | 'no-daemon';
37
+ }
38
+ /**
39
+ * Stop the daemon serving `root`: SIGTERM, wait, then SIGKILL if it won't go,
40
+ * then sweep its artifacts. `root` must be realpath'd (match how the daemon
41
+ * keys its socket/lockfile). Resolves the pid from the authoritative lockfile,
42
+ * falling back to the registry.
43
+ */
44
+ export declare function stopDaemonAt(root: string): Promise<StopResult>;
45
+ /** Stop every registered, live daemon. */
46
+ export declare function stopAllDaemons(): Promise<StopResult[]>;
47
+ //# sourceMappingURL=daemon-registry.d.ts.map
@@ -50,6 +50,7 @@ export declare class MCPServer {
50
50
  private engine;
51
51
  private daemon;
52
52
  private ppidWatchdog;
53
+ private livenessWatchdog;
53
54
  private originalPpid;
54
55
  private hostPpid;
55
56
  private stopped;
@@ -0,0 +1,18 @@
1
+ /** Default: 60s — ~300× shorter than the 5h #850 wedge, far longer than any real main-thread block. */
2
+ export declare const DEFAULT_WATCHDOG_TIMEOUT_MS = 60000;
3
+ /** Parse the timeout env, falling back to the default for missing/invalid values. */
4
+ export declare function parseWatchdogTimeoutMs(raw: string | undefined, fallback?: number): number;
5
+ /** Derive a heartbeat cadence that emits several beats inside the timeout window. */
6
+ export declare function deriveCheckIntervalMs(timeoutMs: number): number;
7
+ export interface WatchdogHandle {
8
+ /** Stop heartbeating and shut the watchdog child down. Idempotent. */
9
+ stop(): void;
10
+ }
11
+ /**
12
+ * Install the main-thread liveness watchdog for a long-lived process. Returns a
13
+ * handle to stop it, or `null` when disabled or when the child can't be spawned
14
+ * (degraded, never throws — a missing watchdog must never keep a process from
15
+ * starting).
16
+ */
17
+ export declare function installMainThreadWatchdog(): WatchdogHandle | null;
18
+ //# sourceMappingURL=liveness-watchdog.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colbymchenry/codegraph",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Local-first code intelligence for AI agents (MCP). Self-contained — bundles its own runtime.",
5
5
  "bin": {
6
6
  "codegraph": "npm-shim.js"
@@ -15,12 +15,12 @@
15
15
  "./package.json": "./package.json"
16
16
  },
17
17
  "optionalDependencies": {
18
- "@colbymchenry/codegraph-darwin-arm64": "1.0.0",
19
- "@colbymchenry/codegraph-darwin-x64": "1.0.0",
20
- "@colbymchenry/codegraph-linux-arm64": "1.0.0",
21
- "@colbymchenry/codegraph-linux-x64": "1.0.0",
22
- "@colbymchenry/codegraph-win32-arm64": "1.0.0",
23
- "@colbymchenry/codegraph-win32-x64": "1.0.0"
18
+ "@colbymchenry/codegraph-darwin-arm64": "1.0.1",
19
+ "@colbymchenry/codegraph-darwin-x64": "1.0.1",
20
+ "@colbymchenry/codegraph-linux-arm64": "1.0.1",
21
+ "@colbymchenry/codegraph-linux-x64": "1.0.1",
22
+ "@colbymchenry/codegraph-win32-arm64": "1.0.1",
23
+ "@colbymchenry/codegraph-win32-x64": "1.0.1"
24
24
  },
25
25
  "files": [
26
26
  "npm-shim.js",