@isac322/pi-codegraph 0.2.0 → 0.3.0
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/.mcp.json +1 -2
- package/CONTRIBUTING.md +63 -0
- package/README.md +35 -2
- package/dist/bin/codegraph-mcp.d.ts +3 -0
- package/dist/bin/codegraph-mcp.d.ts.map +1 -0
- package/dist/bin/codegraph-mcp.js +199 -0
- package/dist/bin/codegraph-mcp.js.map +1 -0
- package/dist/extensions/omp.d.ts +14 -0
- package/dist/extensions/omp.d.ts.map +1 -0
- package/dist/extensions/omp.js +19 -0
- package/dist/extensions/omp.js.map +1 -0
- package/dist/extensions/pi.d.ts +3 -0
- package/dist/extensions/pi.d.ts.map +1 -0
- package/dist/extensions/pi.js +162 -0
- package/dist/extensions/pi.js.map +1 -0
- package/dist/lib/codegraph.d.ts +65 -0
- package/dist/lib/codegraph.d.ts.map +1 -0
- package/dist/lib/codegraph.js +546 -0
- package/dist/lib/codegraph.js.map +1 -0
- package/dist/lib/config.d.ts +5 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +131 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/jsonrpc.d.ts +19 -0
- package/dist/lib/jsonrpc.d.ts.map +1 -0
- package/dist/lib/jsonrpc.js +116 -0
- package/dist/lib/jsonrpc.js.map +1 -0
- package/dist/lib/pi-mcp-client.d.ts +15 -0
- package/dist/lib/pi-mcp-client.d.ts.map +1 -0
- package/dist/lib/pi-mcp-client.js +84 -0
- package/dist/lib/pi-mcp-client.js.map +1 -0
- package/dist/lib/prompt.d.ts +7 -0
- package/dist/lib/prompt.d.ts.map +1 -0
- package/dist/lib/prompt.js +16 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/tool-metadata.d.ts +10 -0
- package/dist/lib/tool-metadata.d.ts.map +1 -0
- package/dist/lib/tool-metadata.js +163 -0
- package/dist/lib/tool-metadata.js.map +1 -0
- package/dist/lib/types.d.ts +69 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/worker-pool.d.ts +19 -0
- package/dist/lib/worker-pool.d.ts.map +1 -0
- package/dist/lib/worker-pool.js +221 -0
- package/dist/lib/worker-pool.js.map +1 -0
- package/package.json +29 -9
- package/bin/codegraph-mcp.mjs +0 -146
- package/extensions/omp.mjs +0 -14
- package/extensions/pi.mjs +0 -127
- package/lib/codegraph.mjs +0 -415
- package/lib/config.mjs +0 -103
- package/lib/jsonrpc.mjs +0 -90
- package/lib/pi-mcp-client.mjs +0 -68
- package/lib/prompt.mjs +0 -15
- package/lib/tool-metadata.mjs +0 -97
- package/lib/worker-pool.mjs +0 -107
package/.mcp.json
CHANGED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Commit format
|
|
4
|
+
|
|
5
|
+
This repository uses Conventional Commits. Release Please reads commits on `main` and determines the next package version from them.
|
|
6
|
+
|
|
7
|
+
Use one of these forms for user-facing changes:
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
fix: correct stale worktree index cleanup
|
|
11
|
+
feat: add a CodeGraph query command
|
|
12
|
+
feat!: change the project routing contract
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Scopes are optional:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
fix(mcp): cancel timed-out worker requests
|
|
19
|
+
feat(pi): render compact CodeGraph results
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Version rules
|
|
23
|
+
|
|
24
|
+
| Commit | Version change | Example |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `fix:` | Patch | `0.2.0` to `0.2.1` |
|
|
27
|
+
| `feat:` | Minor | `0.2.0` to `0.3.0` |
|
|
28
|
+
| `type!:` | Major | `0.2.0` to `1.0.0` |
|
|
29
|
+
| `BREAKING CHANGE:` footer | Major | `0.2.0` to `1.0.0` |
|
|
30
|
+
|
|
31
|
+
`docs:`, `test:`, `ci:`, `chore:`, and other maintenance-only commits do not create a release by themselves. A breaking-change marker still takes precedence when a maintenance commit intentionally changes the public contract.
|
|
32
|
+
|
|
33
|
+
Do not manually change the version in `package.json` for a normal contribution. Do not manually edit generated release notes in `CHANGELOG.md` outside the release PR.
|
|
34
|
+
|
|
35
|
+
## Breaking changes
|
|
36
|
+
|
|
37
|
+
Use either `!` after the commit type or a `BREAKING CHANGE:` footer. The footer should explain the incompatible behavior and the required migration.
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
feat(mcp)!: require trusted project roots
|
|
41
|
+
|
|
42
|
+
BREAKING CHANGE: projectPath values outside the configured workspace are now rejected. Add shared roots to allowedProjectRoots before upgrading.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Release flow
|
|
46
|
+
|
|
47
|
+
1. Merge Conventional Commits into `main`.
|
|
48
|
+
2. Release Please creates or updates a release PR.
|
|
49
|
+
3. Review and merge the release PR.
|
|
50
|
+
4. The workflow updates `package.json` and `CHANGELOG.md` and creates a version tag and GitHub Release.
|
|
51
|
+
5. The same workflow publishes `@isac322/pi-codegraph` to npm through OIDC trusted publishing.
|
|
52
|
+
6. The Pi package gallery discovers the published npm version.
|
|
53
|
+
|
|
54
|
+
The release PR is the approval gate. Do not run `npm publish`, create release tags, or create GitHub Releases manually for normal releases.
|
|
55
|
+
|
|
56
|
+
## Release configuration
|
|
57
|
+
|
|
58
|
+
- Release workflow: `.github/workflows/publish.yml`
|
|
59
|
+
- Release Please configuration: `release-please-config.json`
|
|
60
|
+
- Current released version manifest: `.release-please-manifest.json`
|
|
61
|
+
- npm package: `@isac322/pi-codegraph`
|
|
62
|
+
|
|
63
|
+
The npm trusted publisher must remain bound to GitHub owner `isac322`, repository `pi-codegraph`, workflow filename `publish.yml`, and the `npm publish` action.
|
package/README.md
CHANGED
|
@@ -8,13 +8,28 @@ The extension exposes CodeGraph's structural tools with native Pi metadata and r
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
+
### Pi
|
|
12
|
+
|
|
11
13
|
```sh
|
|
12
14
|
pi install npm:@isac322/pi-codegraph
|
|
13
15
|
```
|
|
14
16
|
|
|
17
|
+
### OMP
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
omp install @isac322/pi-codegraph
|
|
21
|
+
omp plugin list
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Restart OMP or run `/reload-plugins` after installation. `omp install` uses the user scope by default.
|
|
25
|
+
|
|
15
26
|
OMP loads the package-local `.mcp.json` and `omp.extensions` entry. Pi loads `pi.extensions` and starts the internal MCP facade at session start, never during extension discovery.
|
|
16
27
|
|
|
17
|
-
The package installs `@colbymchenry/codegraph` as an optional dependency and falls back to a `codegraph` executable on `PATH`.
|
|
28
|
+
The package installs `@colbymchenry/codegraph@1.4.1` as an optional dependency and falls back to a `codegraph` executable on `PATH`.
|
|
29
|
+
|
|
30
|
+
Node.js 22.19 through Node 24 is required. OMP itself may run under Bun, but it starts this package's compiled MCP facade with the `node` command declared in `.mcp.json`; MCP child processes do not inherit or need to match the host agent's runtime.
|
|
31
|
+
|
|
32
|
+
The repository contains TypeScript source only. Release builds compile it into `dist`, and the npm tarball includes the compiled JavaScript, declarations, and source maps rather than the TypeScript runtime source.
|
|
18
33
|
|
|
19
34
|
## Tools
|
|
20
35
|
|
|
@@ -80,6 +95,16 @@ Environment overrides:
|
|
|
80
95
|
- `codegraph_files` accepts absolute in-project paths and `~`, normalizing them to repo-relative POSIX prefixes.
|
|
81
96
|
- Large results are bounded and retain both their beginning and end with an explicit truncation marker.
|
|
82
97
|
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm ci
|
|
102
|
+
npm run typecheck
|
|
103
|
+
npm run build
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`npm pack` and local `npm publish` run the build through `prepack`. The release workflow installs locked dependencies, typechecks, builds `dist`, and publishes that distribution through npm OIDC.
|
|
107
|
+
|
|
83
108
|
## Security
|
|
84
109
|
|
|
85
110
|
Pi checks project trust before initialization or tool execution. The MCP facade resolves real paths and restricts access to the active workspace, sibling worktrees of the same repository, and explicitly configured roots.
|
|
@@ -88,7 +113,15 @@ Pi checks project trust before initialization or tool execution. The MCP facade
|
|
|
88
113
|
|
|
89
114
|
The npm package declares the `pi-package` keyword and an explicit `pi.extensions` manifest. After npm publication, Pi's package gallery can index it at [pi.dev/packages](https://pi.dev/packages).
|
|
90
115
|
|
|
91
|
-
Releases
|
|
116
|
+
Releases are managed by Release Please. Conventional commits on `main` update a release PR. Merging that PR updates `package.json` and `CHANGELOG.md`, creates the version tag and GitHub Release, and publishes the package through npm trusted publishing in the same workflow. See [CONTRIBUTING.md](CONTRIBUTING.md) for the version rules and release process.
|
|
117
|
+
|
|
118
|
+
Use `fix:` for patch releases, `feat:` for minor releases, and a `!` or `BREAKING CHANGE:` footer for major releases. Configure the npm trusted publisher with GitHub owner `isac322`, repository `pi-codegraph`, workflow filename `publish.yml`, no environment, and the `npm publish` action.
|
|
119
|
+
|
|
120
|
+
### Shared daemon lifecycle
|
|
121
|
+
|
|
122
|
+
All Pi and OMP sessions that use the same `indexStore` attach to one CodeGraph daemon. Each tool request forwards its canonical `projectPath`, so the daemon can serve multiple repositories and Git worktrees without merging their indexes.
|
|
123
|
+
|
|
124
|
+
`maxWorkers` controls the shared daemon's query worker count. `workerIdleTimeoutMs` controls how long the daemon remains alive after the last Pi or OMP client disconnects; the default is five minutes. Set the same `indexStore` for every session that should share a daemon.
|
|
92
125
|
|
|
93
126
|
## License
|
|
94
127
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegraph-mcp.d.ts","sourceRoot":"","sources":["../../bin/codegraph-mcp.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { annotateFilesResult, normalizeFilesPath, ProjectGuard, publicSettings, sanitizeDiagnostic, truncateText, WorkspaceManager, } from "../lib/codegraph.js";
|
|
3
|
+
import { loadSettings } from "../lib/config.js";
|
|
4
|
+
import { codegraphToolNames, codegraphTools } from "../lib/tool-metadata.js";
|
|
5
|
+
import { CodeGraphWorkerPool } from "../lib/worker-pool.js";
|
|
6
|
+
const settings = await loadSettings();
|
|
7
|
+
const baseRoot = process.env.PI_CODEGRAPH_BASE_ROOT || process.cwd();
|
|
8
|
+
const guard = await ProjectGuard.create(baseRoot, settings);
|
|
9
|
+
const manager = new WorkspaceManager(settings);
|
|
10
|
+
const pool = new CodeGraphWorkerPool(settings);
|
|
11
|
+
const controllers = new Map();
|
|
12
|
+
let buffer = "";
|
|
13
|
+
let gcTimer;
|
|
14
|
+
function errorMessage(error) {
|
|
15
|
+
return error instanceof Error ? error.message : String(error);
|
|
16
|
+
}
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === "object" && value !== null;
|
|
19
|
+
}
|
|
20
|
+
function write(message) {
|
|
21
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
22
|
+
}
|
|
23
|
+
function response(id, result) {
|
|
24
|
+
write({ jsonrpc: "2.0", id, result });
|
|
25
|
+
}
|
|
26
|
+
function errorResponse(id, error, code = -32603) {
|
|
27
|
+
write({
|
|
28
|
+
jsonrpc: "2.0",
|
|
29
|
+
id,
|
|
30
|
+
error: { code, message: sanitizeDiagnostic(errorMessage(error)) },
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async function resolveIdentity(params = {}) {
|
|
34
|
+
return guard.resolve(typeof params.projectPath === "string" ? params.projectPath : baseRoot);
|
|
35
|
+
}
|
|
36
|
+
function extractText(result) {
|
|
37
|
+
return ((result?.content || [])
|
|
38
|
+
.filter((part) => part?.type === "text")
|
|
39
|
+
.map((part) => part.text ?? "")
|
|
40
|
+
.join("\n") || JSON.stringify(result));
|
|
41
|
+
}
|
|
42
|
+
async function callTool(params, signal) {
|
|
43
|
+
const name = params?.name;
|
|
44
|
+
if (typeof name !== "string" || !codegraphToolNames.includes(name))
|
|
45
|
+
throw new Error(`Unknown CodeGraph tool: ${name}`);
|
|
46
|
+
const supplied = isRecord(params.arguments) ? { ...params.arguments } : {};
|
|
47
|
+
const identity = await resolveIdentity(supplied);
|
|
48
|
+
await manager.prepare(identity, { signal });
|
|
49
|
+
supplied.projectPath = identity.sourcePath;
|
|
50
|
+
const originalFilesPath = name === "codegraph_files" && typeof supplied.path === "string"
|
|
51
|
+
? supplied.path
|
|
52
|
+
: undefined;
|
|
53
|
+
if (name === "codegraph_files") {
|
|
54
|
+
const normalized = normalizeFilesPath(originalFilesPath, identity.sourcePath);
|
|
55
|
+
if (normalized === undefined)
|
|
56
|
+
delete supplied.path;
|
|
57
|
+
else
|
|
58
|
+
supplied.path = normalized;
|
|
59
|
+
}
|
|
60
|
+
const result = await pool.call(identity.sourcePath, name, supplied, signal);
|
|
61
|
+
if (result?.isError)
|
|
62
|
+
return result;
|
|
63
|
+
let text = extractText(result);
|
|
64
|
+
if (name === "codegraph_files")
|
|
65
|
+
text = annotateFilesResult(text, originalFilesPath);
|
|
66
|
+
const limited = truncateText(text, settings.maxOutputChars);
|
|
67
|
+
return {
|
|
68
|
+
...result,
|
|
69
|
+
content: [{ type: "text", text: limited.text }],
|
|
70
|
+
_meta: { projectPath: identity.sourcePath, truncated: limited.truncated },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async function handleRequest(message, signal) {
|
|
74
|
+
switch (message.method) {
|
|
75
|
+
case "initialize":
|
|
76
|
+
return {
|
|
77
|
+
protocolVersion: "2024-11-05",
|
|
78
|
+
capabilities: { tools: { listChanged: false } },
|
|
79
|
+
serverInfo: { name: "pi-codegraph", version: "0.2.0" },
|
|
80
|
+
};
|
|
81
|
+
case "tools/list":
|
|
82
|
+
return {
|
|
83
|
+
tools: codegraphTools.map((tool) => ({
|
|
84
|
+
name: tool.name,
|
|
85
|
+
description: tool.description,
|
|
86
|
+
inputSchema: tool.inputSchema,
|
|
87
|
+
})),
|
|
88
|
+
};
|
|
89
|
+
case "tools/call":
|
|
90
|
+
return callTool(message.params ?? {}, signal);
|
|
91
|
+
case "codegraph/workspace/prepare": {
|
|
92
|
+
const identity = await resolveIdentity(message.params ?? {});
|
|
93
|
+
const result = await manager.prepare(identity, { signal });
|
|
94
|
+
await manager.gc(pool.activeProjects());
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
case "codegraph/workspace/status": {
|
|
98
|
+
const identity = await resolveIdentity(message.params ?? {});
|
|
99
|
+
return manager.status(identity);
|
|
100
|
+
}
|
|
101
|
+
case "codegraph/workspace/sync": {
|
|
102
|
+
const identity = await resolveIdentity(message.params ?? {});
|
|
103
|
+
return manager.prepare(identity, { signal, forceSync: true });
|
|
104
|
+
}
|
|
105
|
+
case "codegraph/workspace/doctor": {
|
|
106
|
+
const identity = await resolveIdentity(message.params ?? {});
|
|
107
|
+
return manager.doctor(identity);
|
|
108
|
+
}
|
|
109
|
+
case "codegraph/workspace/gc":
|
|
110
|
+
return manager.gc(pool.activeProjects(), Boolean(message.params?.force));
|
|
111
|
+
case "codegraph/settings":
|
|
112
|
+
return publicSettings(settings);
|
|
113
|
+
case "shutdown":
|
|
114
|
+
return null;
|
|
115
|
+
default:
|
|
116
|
+
throw Object.assign(new Error(`Method not found: ${message.method}`), {
|
|
117
|
+
rpcCode: -32601,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function receive(message) {
|
|
122
|
+
if (message.method === "notifications/cancelled") {
|
|
123
|
+
const requestId = message.params?.requestId;
|
|
124
|
+
if (typeof requestId === "number" ||
|
|
125
|
+
typeof requestId === "string" ||
|
|
126
|
+
requestId === null) {
|
|
127
|
+
controllers.get(requestId)?.abort();
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (message.id === undefined)
|
|
132
|
+
return;
|
|
133
|
+
const controller = new AbortController();
|
|
134
|
+
controllers.set(message.id, controller);
|
|
135
|
+
try {
|
|
136
|
+
response(message.id, await handleRequest(message, controller.signal));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (message.method === "tools/call") {
|
|
140
|
+
response(message.id, {
|
|
141
|
+
content: [
|
|
142
|
+
{ type: "text", text: sanitizeDiagnostic(errorMessage(error)) },
|
|
143
|
+
],
|
|
144
|
+
isError: true,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const rpcCode = error instanceof Error &&
|
|
149
|
+
"rpcCode" in error &&
|
|
150
|
+
typeof error.rpcCode === "number"
|
|
151
|
+
? error.rpcCode
|
|
152
|
+
: undefined;
|
|
153
|
+
errorResponse(message.id, error, rpcCode);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
controllers.delete(message.id);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
process.stdin.on("data", (chunk) => {
|
|
161
|
+
buffer += chunk.toString("utf8");
|
|
162
|
+
let newline = buffer.indexOf("\n");
|
|
163
|
+
while (newline !== -1) {
|
|
164
|
+
const line = buffer.slice(0, newline).trim();
|
|
165
|
+
buffer = buffer.slice(newline + 1);
|
|
166
|
+
if (!line)
|
|
167
|
+
continue;
|
|
168
|
+
try {
|
|
169
|
+
void receive(JSON.parse(line));
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
errorResponse(null, new Error("Invalid JSON"), -32700);
|
|
173
|
+
}
|
|
174
|
+
newline = buffer.indexOf("\n");
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
async function shutdown() {
|
|
178
|
+
if (gcTimer)
|
|
179
|
+
clearInterval(gcTimer);
|
|
180
|
+
for (const controller of controllers.values())
|
|
181
|
+
controller.abort();
|
|
182
|
+
await pool.close();
|
|
183
|
+
}
|
|
184
|
+
if (settings.autoGc) {
|
|
185
|
+
gcTimer = setInterval(() => {
|
|
186
|
+
void manager.gc(pool.activeProjects());
|
|
187
|
+
}, 60 * 60_000);
|
|
188
|
+
gcTimer.unref?.();
|
|
189
|
+
}
|
|
190
|
+
process.on("SIGTERM", () => {
|
|
191
|
+
void shutdown().finally(() => process.exit(0));
|
|
192
|
+
});
|
|
193
|
+
process.on("SIGINT", () => {
|
|
194
|
+
void shutdown().finally(() => process.exit(0));
|
|
195
|
+
});
|
|
196
|
+
process.stdin.on("end", () => {
|
|
197
|
+
void shutdown().finally(() => process.exit(0));
|
|
198
|
+
});
|
|
199
|
+
//# sourceMappingURL=codegraph-mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codegraph-mcp.js","sourceRoot":"","sources":["../../bin/codegraph-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC;AACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;AACrE,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5D,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AAC/C,MAAM,IAAI,GAAG,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,IAAI,GAAG,EAA2C,CAAC;AACvE,IAAI,MAAM,GAAG,EAAE,CAAC;AAChB,IA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K,EAAE,CAAC;AACrB,CAAC;AAED,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpB,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;QACzB,KAAK,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IACzC,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,CAAC;IAChB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AACpB,CAAC;AACD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,KAAK,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,KAAK,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;IAC3B,KAAK,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface OmpBeforeAgentStartEvent {
|
|
2
|
+
systemPrompt?: string;
|
|
3
|
+
}
|
|
4
|
+
interface OmpExtensionContext {
|
|
5
|
+
cwd?: string;
|
|
6
|
+
}
|
|
7
|
+
interface OmpExtensionApi {
|
|
8
|
+
on: (event: "before_agent_start", handler: (event: OmpBeforeAgentStartEvent, context: OmpExtensionContext) => Promise<{
|
|
9
|
+
systemPrompt: string;
|
|
10
|
+
}>) => void;
|
|
11
|
+
}
|
|
12
|
+
export default function ompCodeGraphExtension(omp: OmpExtensionApi): Promise<void>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=omp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omp.d.ts","sourceRoot":"","sources":["../../extensions/omp.ts"],"names":[],"mappings":"AAIA,UAAU,wBAAwB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,UAAU,eAAe;IACvB,EAAE,EAAE,CACF,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,CACP,KAAK,EAAE,wBAAwB,EAC/B,OAAO,EAAE,mBAAmB,KACzB,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,KACnC,IAAI,CAAC;CACX;AAED,wBAA8B,qBAAqB,CACjD,GAAG,EAAE,eAAe,GACnB,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { workspaceSummary } from "../lib/codegraph.js";
|
|
2
|
+
import { loadSettings } from "../lib/config.js";
|
|
3
|
+
import { buildCodeGraphPrompt } from "../lib/prompt.js";
|
|
4
|
+
export default async function ompCodeGraphExtension(omp) {
|
|
5
|
+
const settings = await loadSettings();
|
|
6
|
+
if (!settings.promptInjection || typeof omp?.on !== "function")
|
|
7
|
+
return;
|
|
8
|
+
omp.on("before_agent_start", async (event, ctx) => {
|
|
9
|
+
const cwd = ctx?.cwd || process.cwd();
|
|
10
|
+
const status = await workspaceSummary(cwd);
|
|
11
|
+
const guidance = buildCodeGraphPrompt({ runtime: "omp", cwd, status });
|
|
12
|
+
return {
|
|
13
|
+
systemPrompt: event.systemPrompt
|
|
14
|
+
? `${event.systemPrompt}\n\n${guidance}`
|
|
15
|
+
: guidance,
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=omp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omp.js","sourceRoot":"","sources":["../../extensions/omp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAoBxD,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,qBAAqB,CACjD,GAAoB;IAEpB,MAAM,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC;IACtC,IAAI,CAAC,QAAQ,CAAC,eAAe,IAAI,OAAO,GAAG,EAAE,EAAE,KAAK,UAAU;QAAE,OAAO;IACvE,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QAChD,MAAM,GAAG,GAAG,GAAG,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,oBAAoB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;QACvE,OAAO;YACL,YAAY,EAAE,KAAK,CAAC,YAAY;gBAC9B,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,OAAO,QAAQ,EAAE;gBACxC,CAAC,CAAC,QAAQ;SACb,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.d.ts","sourceRoot":"","sources":["../../extensions/pi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,iCAAiC,CAAC;AAoCzC,wBAA8B,oBAAoB,CAChD,EAAE,EAAE,YAAY,GACf,OAAO,CAAC,IAAI,CAAC,CAkKf"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
2
|
+
import { workspaceSummary } from "../lib/codegraph.js";
|
|
3
|
+
import { loadSettings } from "../lib/config.js";
|
|
4
|
+
import { PiCodeGraphClient } from "../lib/pi-mcp-client.js";
|
|
5
|
+
import { buildCodeGraphPrompt } from "../lib/prompt.js";
|
|
6
|
+
import { codegraphTools, summarizeToolText, toolCallLabel, } from "../lib/tool-metadata.js";
|
|
7
|
+
function errorMessage(error) {
|
|
8
|
+
return error instanceof Error ? error.message : String(error);
|
|
9
|
+
}
|
|
10
|
+
function textContent(result) {
|
|
11
|
+
return (result?.content || [])
|
|
12
|
+
.filter((item) => item?.type === "text")
|
|
13
|
+
.map((item) => item.text ?? "")
|
|
14
|
+
.join("\n");
|
|
15
|
+
}
|
|
16
|
+
async function trusted(ctx) {
|
|
17
|
+
if (typeof ctx?.isProjectTrusted !== "function")
|
|
18
|
+
return true;
|
|
19
|
+
return Boolean(await ctx.isProjectTrusted());
|
|
20
|
+
}
|
|
21
|
+
export default async function piCodeGraphExtension(pi) {
|
|
22
|
+
const settings = await loadSettings();
|
|
23
|
+
let sessionCwd = process.cwd();
|
|
24
|
+
let client;
|
|
25
|
+
const getClient = async (cwd, ctx) => {
|
|
26
|
+
if (!(await trusted(ctx)))
|
|
27
|
+
throw new Error("CodeGraph is disabled until this project is trusted.");
|
|
28
|
+
if (!client || sessionCwd !== cwd) {
|
|
29
|
+
await client?.close();
|
|
30
|
+
sessionCwd = cwd;
|
|
31
|
+
client = new PiCodeGraphClient(settings, cwd);
|
|
32
|
+
}
|
|
33
|
+
return client;
|
|
34
|
+
};
|
|
35
|
+
for (const tool of codegraphTools) {
|
|
36
|
+
const definition = {
|
|
37
|
+
name: tool.name,
|
|
38
|
+
label: tool.label,
|
|
39
|
+
description: tool.description,
|
|
40
|
+
promptSnippet: tool.promptSnippet,
|
|
41
|
+
promptGuidelines: tool.promptGuidelines,
|
|
42
|
+
parameters: tool.inputSchema,
|
|
43
|
+
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
|
44
|
+
const cwd = ctx?.cwd || sessionCwd || process.cwd();
|
|
45
|
+
const activeClient = await getClient(cwd, ctx);
|
|
46
|
+
const args = {
|
|
47
|
+
...(params || {}),
|
|
48
|
+
projectPath: params?.projectPath || cwd,
|
|
49
|
+
};
|
|
50
|
+
const result = await activeClient.callTool(tool.name, args, signal);
|
|
51
|
+
const text = textContent(result);
|
|
52
|
+
if (result?.isError)
|
|
53
|
+
throw new Error(text || `${tool.label} failed`);
|
|
54
|
+
const summary = summarizeToolText(text);
|
|
55
|
+
return {
|
|
56
|
+
content: result?.content?.length
|
|
57
|
+
? result.content
|
|
58
|
+
: [{ type: "text", text: JSON.stringify(result) }],
|
|
59
|
+
details: {
|
|
60
|
+
toolName: tool.name,
|
|
61
|
+
projectPath: args.projectPath,
|
|
62
|
+
...summary,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
renderCall(args, theme) {
|
|
67
|
+
return new Text(theme.fg("toolTitle", theme.bold(`${tool.label} `)) +
|
|
68
|
+
theme.fg("muted", toolCallLabel(tool.name, args)), 0, 0);
|
|
69
|
+
},
|
|
70
|
+
renderResult(result, { expanded }, theme) {
|
|
71
|
+
const details = result.details || {};
|
|
72
|
+
const text = textContent(result);
|
|
73
|
+
if (!text)
|
|
74
|
+
return new Text(theme.fg("dim", "No output"), 0, 0);
|
|
75
|
+
if (expanded)
|
|
76
|
+
return new Text(text, 0, 0);
|
|
77
|
+
const lines = text.split("\n");
|
|
78
|
+
const preview = lines.slice(0, 6).join("\n");
|
|
79
|
+
const suffix = lines.length > 6
|
|
80
|
+
? `\n${theme.fg("dim", `... ${lines.length - 6} more lines`)}`
|
|
81
|
+
: "";
|
|
82
|
+
const marker = details.truncated
|
|
83
|
+
? theme.fg("warning", " [truncated]")
|
|
84
|
+
: "";
|
|
85
|
+
return new Text(`${preview}${suffix}${marker}`, 0, 0);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
pi.registerTool(definition);
|
|
89
|
+
}
|
|
90
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
91
|
+
sessionCwd = ctx.cwd || process.cwd();
|
|
92
|
+
if (!(await trusted(ctx)))
|
|
93
|
+
return;
|
|
94
|
+
ctx.ui?.setStatus?.("codegraph", "CodeGraph indexing");
|
|
95
|
+
try {
|
|
96
|
+
const activeClient = await getClient(sessionCwd, ctx);
|
|
97
|
+
await activeClient.request("codegraph/workspace/prepare", {
|
|
98
|
+
projectPath: sessionCwd,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
ctx.ui?.notify?.(`CodeGraph initialization failed: ${errorMessage(error)}`, "warning");
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
ctx.ui?.setStatus?.("codegraph", undefined);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
109
|
+
if (!settings.promptInjection || !(await trusted(ctx)))
|
|
110
|
+
return;
|
|
111
|
+
const cwd = ctx.cwd || sessionCwd || process.cwd();
|
|
112
|
+
const status = await workspaceSummary(cwd);
|
|
113
|
+
const guidance = buildCodeGraphPrompt({ runtime: "pi", cwd, status });
|
|
114
|
+
return {
|
|
115
|
+
systemPrompt: event.systemPrompt
|
|
116
|
+
? `${event.systemPrompt}\n\n${guidance}`
|
|
117
|
+
: guidance,
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
pi.on("session_shutdown", async () => {
|
|
121
|
+
await client?.close();
|
|
122
|
+
client = undefined;
|
|
123
|
+
});
|
|
124
|
+
pi.registerCommand("codegraph", {
|
|
125
|
+
description: "CodeGraph status, sync, doctor, or gc",
|
|
126
|
+
handler: async (input, ctx) => {
|
|
127
|
+
if (!(await trusted(ctx))) {
|
|
128
|
+
ctx.ui?.notify?.("Trust this project before using CodeGraph.", "error");
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const action = String(input || "status")
|
|
132
|
+
.trim()
|
|
133
|
+
.split(/\s+/)[0] || "status";
|
|
134
|
+
const methods = {
|
|
135
|
+
status: "codegraph/workspace/status",
|
|
136
|
+
sync: "codegraph/workspace/sync",
|
|
137
|
+
doctor: "codegraph/workspace/doctor",
|
|
138
|
+
gc: "codegraph/workspace/gc",
|
|
139
|
+
};
|
|
140
|
+
if (!methods[action]) {
|
|
141
|
+
ctx.ui?.notify?.("Usage: /codegraph [status|sync|doctor|gc]", "error");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
ctx.ui?.setStatus?.("codegraph", `CodeGraph ${action}`);
|
|
145
|
+
try {
|
|
146
|
+
const activeClient = await getClient(ctx.cwd || sessionCwd, ctx);
|
|
147
|
+
const result = await activeClient.request(methods[action], {
|
|
148
|
+
projectPath: ctx.cwd || sessionCwd,
|
|
149
|
+
force: action === "gc",
|
|
150
|
+
});
|
|
151
|
+
ctx.ui?.notify?.(JSON.stringify(result, null, 2), "info");
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
ctx.ui?.notify?.(`CodeGraph ${action} failed: ${errorMessage(error)}`, "error");
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
ctx.ui?.setStatus?.("codegraph", undefined);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=pi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pi.js","sourceRoot":"","sources":["../../extensions/pi.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kB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|
|
1
|
+
import type { CodeGraphSettings, WorkspaceIdentity, WorkspaceStatus } from "./types.js";
|
|
2
|
+
interface CodeGraphRunOptions {
|
|
3
|
+
signal?: AbortSignal;
|
|
4
|
+
timeoutMs?: number;
|
|
5
|
+
forceSync?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface CodeGraphRunResult {
|
|
8
|
+
stdout: string;
|
|
9
|
+
stderr: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function sanitizeDiagnostic(value: unknown, maxLength?: number): string;
|
|
12
|
+
export declare function truncateText(value: unknown, maxChars: number): {
|
|
13
|
+
text: string;
|
|
14
|
+
truncated: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function normalizeFilesPath(inputPath: unknown, projectCwd?: string): string | undefined;
|
|
17
|
+
export declare function annotateFilesResult(text: string, originalPath?: string): string;
|
|
18
|
+
export declare function gitIdentity(input: string): Promise<WorkspaceIdentity>;
|
|
19
|
+
export declare class ProjectGuard {
|
|
20
|
+
readonly base: WorkspaceIdentity;
|
|
21
|
+
readonly allowedRoots: string[];
|
|
22
|
+
static create(baseRoot: string, settings: CodeGraphSettings): Promise<ProjectGuard>;
|
|
23
|
+
constructor(base: WorkspaceIdentity, allowedRoots: string[]);
|
|
24
|
+
resolve(requestedPath?: string): Promise<WorkspaceIdentity>;
|
|
25
|
+
}
|
|
26
|
+
export declare function resolveCodeGraphLaunch(settings: CodeGraphSettings, args?: string[]): Promise<{
|
|
27
|
+
command: string;
|
|
28
|
+
args: string[];
|
|
29
|
+
}>;
|
|
30
|
+
export declare function runCodeGraph(settings: CodeGraphSettings, cwd: string, args: string[], options?: CodeGraphRunOptions): Promise<CodeGraphRunResult>;
|
|
31
|
+
export declare class WorkspaceManager {
|
|
32
|
+
#private;
|
|
33
|
+
readonly settings: CodeGraphSettings;
|
|
34
|
+
readonly lastSync: Map<string, number>;
|
|
35
|
+
private lastGc;
|
|
36
|
+
constructor(settings: CodeGraphSettings);
|
|
37
|
+
prepare(identity: WorkspaceIdentity, options?: CodeGraphRunOptions): Promise<{
|
|
38
|
+
schemaVersion: number;
|
|
39
|
+
sourcePath: string;
|
|
40
|
+
repoIdentity: string;
|
|
41
|
+
worktreeIdentity: string;
|
|
42
|
+
managed: boolean;
|
|
43
|
+
lastPreparedAt: string;
|
|
44
|
+
lastSyncAt: number | null;
|
|
45
|
+
indexPath: string;
|
|
46
|
+
state: string;
|
|
47
|
+
}>;
|
|
48
|
+
status(identity: WorkspaceIdentity): Promise<WorkspaceStatus>;
|
|
49
|
+
doctor(identity: WorkspaceIdentity): Promise<{
|
|
50
|
+
executable: string;
|
|
51
|
+
workspace: WorkspaceStatus;
|
|
52
|
+
settings: Omit<CodeGraphSettings, "codegraphExecutable"> & {
|
|
53
|
+
codegraphExecutable: string;
|
|
54
|
+
};
|
|
55
|
+
}>;
|
|
56
|
+
gc(activeProjects?: ReadonlySet<string>, force?: boolean): Promise<{
|
|
57
|
+
removed: string[];
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export declare function workspaceSummary(cwd: string): Promise<WorkspaceStatus>;
|
|
61
|
+
export declare function publicSettings(settings: CodeGraphSettings): Omit<CodeGraphSettings, "codegraphExecutable"> & {
|
|
62
|
+
codegraphExecutable: string;
|
|
63
|
+
};
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=codegraph.d.ts.map
|