@henryqw/pi-codegraph 0.2.1 → 0.2.2

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
@@ -17,6 +17,7 @@ Requires the `codegraph` CLI on `PATH` and [pi-mcp-adapter](https://github.com/n
17
17
  | Package | Relationship | Purpose |
18
18
  | --- | --- | --- |
19
19
  | [`@colbymchenry/codegraph`](https://github.com/colbymchenry/codegraph) | Required | Builds the indexes and serves CodeGraph tools over MCP. |
20
+ | [`@henryqw/pi-footer`](https://pi.henry.wang/extensions/pi-footer) | Improves | Shows a compact CodeGraph index badge and direct tool activity when loaded. |
20
21
  | [`pi-mcp-adapter`](https://github.com/nicobailon/pi-mcp-adapter) | Required | Connects the MCP server to Pi. |
21
22
 
22
23
  ## Use
@@ -43,17 +44,22 @@ The adapter discovers tools lazily.
43
44
  - Initialization happens when Pi launches, not when Git creates the worktree.
44
45
  - Each linked worktree keeps its own `.codegraph`; databases are never copied or shared between branches.
45
46
  - Non-Git directories and repositories without a primary index are not initialized.
46
- - When loaded, the extension reports whether the local index is `indexed`, `missing`, or `indexing…` through Pi's status channel. The `pi-footer` extension places a compact `CG` badge first on its third line and temporarily shows `● CG` during direct CodeGraph tool calls.
47
+ - The extension reports `checking index…` and `indexing…` during setup, `indexed` when a database file exists, `missing` when no index was built, `prerequisites missing` when setup was skipped, and `setup failed` on an error. `indexed` does not guarantee database health.
48
+ - If `pi-footer` is also loaded, it places a compact `CG` badge first on its third line: `✓ CG` indexed, `○ CG` missing, `◐ CG` checking or indexing, `! CG` setup problem, or `? CG` unknown state. It temporarily shows `● CG` only during direct `codegraph_explore` calls or `codegraph_*` calls through this package's MCP server, not for every MCP call.
47
49
 
48
50
  ## State and storage
49
51
 
50
- The extension relies on CodeGraph's own state — each worktree maintains its own `.codegraph/codegraph.db`. The extension never copies, shares, or modifies this database. Existing indexes are left alone; CodeGraph owns synchronization when its MCP server runs.
52
+ The extension relies on CodeGraph's own state — each worktree maintains its own `.codegraph/codegraph.db`. The extension never copies or shares the database and does not write it directly: it delegates creation to `codegraph init --yes <worktree-root>`. Existing indexes are left alone; CodeGraph owns synchronization when its MCP server runs.
51
53
 
52
54
  ## Limits and recovery
53
55
 
54
56
  At startup, the extension checks for a loaded adapter and runs `codegraph --version`. If either prerequisite is unavailable, Pi warns, reports `prerequisites missing`, and skips setup. Restart Pi or run `/reload` after fixing prerequisites.
55
57
 
56
- Initialization uses an exclusive `pi-codegraph-init.lock` in the worktree's Git metadata. Failed or interrupted initialization keeps the lock so a partial database is not accepted. To recover: remove the lock directory with `rmdir` only after `codegraph index` succeeds, then run `/reload`.
58
+ Initialization uses an exclusive `pi-codegraph-init.lock` in the worktree's Git metadata. Failed or interrupted initialization keeps the lock so a partial database is not accepted. To recover, first confirm no initializer is running, then run `codegraph index` **from the affected worktree root** (not the primary checkout or a nested directory). Only after it succeeds, remove the lock directory with `rmdir` using the path in the error message, then run `/reload`:
59
+
60
+ ```bash
61
+ cd /path/to/affected-worktree-root && codegraph index && rmdir /path/to/pi-codegraph-init.lock
62
+ ```
57
63
 
58
64
  The package never installs prerequisites automatically. The `codegraph` executable must be available to both Pi and its MCP child process. Only Git worktree-root indexes using the default `.codegraph` directory are supported; nested monorepo indexes are not initialized automatically. The primary checkout must remain indexed for automatic opt-in detection.
59
65
 
@@ -74,7 +74,6 @@ async function initialize(pi: ExtensionAPI, ctx: ExtensionContext): Promise<void
74
74
  }
75
75
  }
76
76
  let attempted = false;
77
- let succeeded = false;
78
77
  try {
79
78
  if (await hasIndex(root)) {
80
79
  indexed = true;
@@ -91,7 +90,6 @@ async function initialize(pi: ExtensionAPI, ctx: ExtensionContext): Promise<void
91
90
  if (result.code !== 0 || result.killed || !(await hasIndex(root))) {
92
91
  throw new Error(`CodeGraph init failed (${result.killed ? "timed out or killed" : `exit ${result.code}`}): ${(result.stderr || result.stdout).trim().slice(-2000)}`);
93
92
  }
94
- succeeded = true;
95
93
  indexed = true;
96
94
  if (ctx.hasUI) {
97
95
  ctx.ui.setWidget(WIDGET_KEY, ["pi-codegraph: index ready"]);
@@ -104,7 +102,7 @@ async function initialize(pi: ExtensionAPI, ctx: ExtensionContext): Promise<void
104
102
  throw error;
105
103
  } finally {
106
104
  // A failed or interrupted init stays locked; never accept its partial DB on reload.
107
- if (!attempted || succeeded) await rmdir(lock);
105
+ if (!attempted || indexed) await rmdir(lock);
108
106
  }
109
107
  } finally {
110
108
  ctx.ui.setStatus("pi-codegraph", indexed ? "pi-codegraph: indexed" : "pi-codegraph: missing");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-codegraph",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Initialize CodeGraph indexes in opted-in Git worktrees and expose CodeGraph through pi-mcp-adapter.",
5
5
  "keywords": [
6
6
  "pi-package",