@vndv/pi-codegraph 0.1.8 → 0.1.9
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 +3 -3
- package/extensions/codegraph.ts +42 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ An extension for [pi](https://pi.dev) that gives the agent access to [CodeGraph]
|
|
|
18
18
|
npm install -g @colbymchenry/codegraph
|
|
19
19
|
cd /path/to/project
|
|
20
20
|
codegraph init -i
|
|
21
|
-
pi install npm:@vndv/pi-codegraph@0.1.
|
|
21
|
+
pi install npm:@vndv/pi-codegraph@0.1.9
|
|
22
22
|
pi
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -52,7 +52,7 @@ Extension tools only. There is no MCP setup for pi users to maintain.
|
|
|
52
52
|
From npm:
|
|
53
53
|
|
|
54
54
|
```bash
|
|
55
|
-
pi install npm:@vndv/pi-codegraph@0.1.
|
|
55
|
+
pi install npm:@vndv/pi-codegraph@0.1.9
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
From GitHub:
|
|
@@ -159,7 +159,7 @@ That means another developer only needs the npm package, the `codegraph` CLI, an
|
|
|
159
159
|
Remove the package using the same source shown by `pi list`:
|
|
160
160
|
|
|
161
161
|
```bash
|
|
162
|
-
pi remove npm:@vndv/pi-codegraph@0.1.
|
|
162
|
+
pi remove npm:@vndv/pi-codegraph@0.1.9
|
|
163
163
|
```
|
|
164
164
|
|
|
165
165
|
If you installed from GitHub or a local path, remove that exact entry instead:
|
package/extensions/codegraph.ts
CHANGED
|
@@ -120,7 +120,8 @@ type PendingJsonRpcRequests = Map<number, {
|
|
|
120
120
|
reject: (error: Error) => void;
|
|
121
121
|
}>;
|
|
122
122
|
|
|
123
|
-
const MaxDiagnosticLength = 1000;
|
|
123
|
+
export const MaxDiagnosticLength = 1000;
|
|
124
|
+
export const SessionTimeoutMs = 20_000;
|
|
124
125
|
|
|
125
126
|
export const codegraphToolNames = ToolDefinitions.map((tool) => tool.name);
|
|
126
127
|
|
|
@@ -136,11 +137,49 @@ export async function withCodeGraphMcp<T>(
|
|
|
136
137
|
stdio: ["pipe", "pipe", "pipe"],
|
|
137
138
|
});
|
|
138
139
|
|
|
139
|
-
|
|
140
|
+
const session = runJsonRpcSession(child, cwd, signal, fn);
|
|
141
|
+
|
|
142
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
143
|
+
const onAbortClearTimer = () => clearTimeout(timer);
|
|
144
|
+
const timeout = new Promise<never>((_, reject) => {
|
|
145
|
+
timer = setTimeout(() => {
|
|
146
|
+
if (!child.killed) child.kill();
|
|
147
|
+
reject(new Error(
|
|
148
|
+
"CodeGraph MCP session timed out after " + SessionTimeoutMs + "ms. " +
|
|
149
|
+
'Try running "codegraph unlock" in the project directory, then restart pi.'
|
|
150
|
+
));
|
|
151
|
+
}, SessionTimeoutMs);
|
|
152
|
+
signal?.addEventListener("abort", onAbortClearTimer, { once: true });
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
session.catch(() => {});
|
|
156
|
+
timeout.catch(() => {});
|
|
157
|
+
return Promise.race([session, timeout]).finally(() => {
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
signal?.removeEventListener("abort", onAbortClearTimer);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function normalizeWindowsPath(inputPath: string): string {
|
|
164
|
+
let normalized = inputPath.trim();
|
|
165
|
+
|
|
166
|
+
if (process.platform !== "win32") return normalized;
|
|
167
|
+
|
|
168
|
+
const wslMatch = normalized.match(/^\/mnt\/([a-zA-Z])\/(.*)$/);
|
|
169
|
+
if (wslMatch) {
|
|
170
|
+
normalized = wslMatch[1].toUpperCase() + ":\\" + wslMatch[2].replace(/\//g, "\\");
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const gitBashMatch = normalized.match(/^\/([a-zA-Z])\/(.*)$/);
|
|
174
|
+
if (gitBashMatch) {
|
|
175
|
+
normalized = gitBashMatch[1].toUpperCase() + ":\\" + gitBashMatch[2].replace(/\//g, "\\");
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return normalized;
|
|
140
179
|
}
|
|
141
180
|
|
|
142
181
|
export async function resolveProjectCwd(projectPath: string | undefined): Promise<string> {
|
|
143
|
-
const cwd = projectPath || process.cwd();
|
|
182
|
+
const cwd = normalizeWindowsPath(projectPath || process.cwd());
|
|
144
183
|
|
|
145
184
|
if (!path.isAbsolute(cwd)) {
|
|
146
185
|
throw new Error("CodeGraph projectPath must be an absolute path.");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vndv/pi-codegraph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "CodeGraph tools for Pi Agent.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@changesets/cli": "^2.31.0",
|
|
62
|
-
"@colbymchenry/codegraph": "^0.
|
|
63
|
-
"@earendil-works/pi-coding-agent": "^0.
|
|
64
|
-
"@types/node": "^
|
|
62
|
+
"@colbymchenry/codegraph": "^1.0.1",
|
|
63
|
+
"@earendil-works/pi-coding-agent": "^0.79.6",
|
|
64
|
+
"@types/node": "^26.0.0",
|
|
65
65
|
"typescript": "^6.0.3",
|
|
66
66
|
"vitest": "^4.1.7"
|
|
67
67
|
}
|