@colbymchenry/codegraph-darwin-x64 0.9.3 → 0.9.5
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/lib/dist/bin/codegraph.d.ts +3 -0
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +250 -0
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/context/index.d.ts +13 -0
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +120 -1
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/db/index.d.ts +18 -0
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +31 -0
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/queries.d.ts +16 -0
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +80 -27
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +6 -0
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +31 -1
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +15 -2
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +170 -78
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/languages/index.d.ts.map +1 -1
- package/lib/dist/extraction/languages/index.js +2 -0
- package/lib/dist/extraction/languages/index.js.map +1 -1
- package/lib/dist/extraction/languages/objc.d.ts +3 -0
- package/lib/dist/extraction/languages/objc.d.ts.map +1 -0
- package/lib/dist/extraction/languages/objc.js +133 -0
- package/lib/dist/extraction/languages/objc.js.map +1 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts +4 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +155 -9
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/wasm-runtime-flags.d.ts +12 -0
- package/lib/dist/extraction/wasm-runtime-flags.d.ts.map +1 -1
- package/lib/dist/extraction/wasm-runtime-flags.js +14 -2
- package/lib/dist/extraction/wasm-runtime-flags.js.map +1 -1
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +71 -36
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/index.d.ts +21 -2
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +42 -0
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/instructions-template.d.ts +2 -2
- package/lib/dist/installer/instructions-template.d.ts.map +1 -1
- package/lib/dist/installer/instructions-template.js +3 -2
- package/lib/dist/installer/instructions-template.js.map +1 -1
- package/lib/dist/mcp/daemon-paths.d.ts +46 -0
- package/lib/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/lib/dist/mcp/daemon-paths.js +125 -0
- package/lib/dist/mcp/daemon-paths.js.map +1 -0
- package/lib/dist/mcp/daemon.d.ts +161 -0
- package/lib/dist/mcp/daemon.d.ts.map +1 -0
- package/lib/dist/mcp/daemon.js +403 -0
- package/lib/dist/mcp/daemon.js.map +1 -0
- package/lib/dist/mcp/engine.d.ts +100 -0
- package/lib/dist/mcp/engine.d.ts.map +1 -0
- package/lib/dist/mcp/engine.js +291 -0
- package/lib/dist/mcp/engine.js.map +1 -0
- package/lib/dist/mcp/index.d.ts +67 -52
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +347 -330
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/proxy.d.ts +46 -0
- package/lib/dist/mcp/proxy.d.ts.map +1 -0
- package/lib/dist/mcp/proxy.js +276 -0
- package/lib/dist/mcp/proxy.js.map +1 -0
- package/lib/dist/mcp/server-instructions.d.ts +1 -1
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +3 -1
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/session.d.ts +67 -0
- package/lib/dist/mcp/session.d.ts.map +1 -0
- package/lib/dist/mcp/session.js +276 -0
- package/lib/dist/mcp/session.js.map +1 -0
- package/lib/dist/mcp/tools.d.ts +130 -2
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +902 -37
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/transport.d.ts +111 -29
- package/lib/dist/mcp/transport.d.ts.map +1 -1
- package/lib/dist/mcp/transport.js +181 -71
- package/lib/dist/mcp/transport.js.map +1 -1
- package/lib/dist/mcp/version.d.ts +19 -0
- package/lib/dist/mcp/version.d.ts.map +1 -0
- package/lib/dist/mcp/version.js +71 -0
- package/lib/dist/mcp/version.js.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts +10 -0
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/lib/dist/resolution/callback-synthesizer.js +847 -0
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -0
- package/lib/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/csharp.js +36 -8
- package/lib/dist/resolution/frameworks/csharp.js.map +1 -1
- package/lib/dist/resolution/frameworks/drupal.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/drupal.js +44 -12
- package/lib/dist/resolution/frameworks/drupal.js.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/expo-modules.js +143 -0
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/lib/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/express.js +102 -19
- package/lib/dist/resolution/frameworks/express.js.map +1 -1
- package/lib/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/lib/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/fabric.js +354 -0
- package/lib/dist/resolution/frameworks/fabric.js.map +1 -0
- package/lib/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/go.js +6 -3
- package/lib/dist/resolution/frameworks/go.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +5 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +25 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +70 -12
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/laravel.js +17 -8
- package/lib/dist/resolution/frameworks/laravel.js.map +1 -1
- package/lib/dist/resolution/frameworks/play.d.ts +19 -0
- package/lib/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/play.js +111 -0
- package/lib/dist/resolution/frameworks/play.js.map +1 -0
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +134 -16
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/react-native.js +360 -0
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -0
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +96 -3
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/ruby.js +106 -2
- package/lib/dist/resolution/frameworks/ruby.js.map +1 -1
- package/lib/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/rust.js +102 -5
- package/lib/dist/resolution/frameworks/rust.js.map +1 -1
- package/lib/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/lib/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/swift-objc.js +252 -0
- package/lib/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/lib/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/swift.js +30 -6
- package/lib/dist/resolution/frameworks/swift.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +1 -0
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +61 -9
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/lru-cache.d.ts +24 -0
- package/lib/dist/resolution/lru-cache.d.ts.map +1 -0
- package/lib/dist/resolution/lru-cache.js +62 -0
- package/lib/dist/resolution/lru-cache.js.map +1 -0
- package/lib/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/lib/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/lib/dist/resolution/swift-objc-bridge.js +256 -0
- package/lib/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/lib/dist/resolution/types.d.ts +8 -0
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/sync/index.d.ts +3 -1
- package/lib/dist/sync/index.d.ts.map +1 -1
- package/lib/dist/sync/index.js +7 -1
- package/lib/dist/sync/index.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +109 -7
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +215 -33
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/sync/worktree.d.ts +54 -0
- package/lib/dist/sync/worktree.d.ts.map +1 -0
- package/lib/dist/sync/worktree.js +136 -0
- package/lib/dist/sync/worktree.js.map +1 -0
- package/lib/dist/types.d.ts +1 -1
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +1 -0
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/utils.js +1 -1
- package/lib/node_modules/.package-lock.json +29 -1
- package/lib/node_modules/chokidar/LICENSE +21 -0
- package/lib/node_modules/chokidar/README.md +305 -0
- package/lib/node_modules/chokidar/esm/handler.d.ts +90 -0
- package/lib/node_modules/chokidar/esm/handler.js +629 -0
- package/lib/node_modules/chokidar/esm/index.d.ts +215 -0
- package/lib/node_modules/chokidar/esm/index.js +798 -0
- package/lib/node_modules/chokidar/esm/package.json +1 -0
- package/lib/node_modules/chokidar/handler.d.ts +90 -0
- package/lib/node_modules/chokidar/handler.js +635 -0
- package/lib/node_modules/chokidar/index.d.ts +215 -0
- package/lib/node_modules/chokidar/index.js +804 -0
- package/lib/node_modules/chokidar/package.json +69 -0
- package/lib/node_modules/readdirp/LICENSE +21 -0
- package/lib/node_modules/readdirp/README.md +120 -0
- package/lib/node_modules/readdirp/esm/index.d.ts +108 -0
- package/lib/node_modules/readdirp/esm/index.js +257 -0
- package/lib/node_modules/readdirp/esm/package.json +1 -0
- package/lib/node_modules/readdirp/index.d.ts +108 -0
- package/lib/node_modules/readdirp/index.js +263 -0
- package/lib/node_modules/readdirp/package.json +70 -0
- package/lib/package.json +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP shared engine — the heavyweight, *shared* state for an MCP server:
|
|
4
|
+
* the project's {@link CodeGraph} instance, file watcher, and the
|
|
5
|
+
* {@link ToolHandler} cache for cross-project queries.
|
|
6
|
+
*
|
|
7
|
+
* One engine, many sessions:
|
|
8
|
+
* - direct mode (single stdio session) instantiates one engine + one session;
|
|
9
|
+
* - daemon mode instantiates one engine and a new session per socket
|
|
10
|
+
* connection. Every session reads from the same SQLite WAL and the same
|
|
11
|
+
* inotify watch set — that's the entire point of issue #411.
|
|
12
|
+
*/
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.MCPEngine = void 0;
|
|
48
|
+
exports.parseDebounceEnv = parseDebounceEnv;
|
|
49
|
+
const index_1 = __importStar(require("../index"));
|
|
50
|
+
const sync_1 = require("../sync");
|
|
51
|
+
const tools_1 = require("./tools");
|
|
52
|
+
/**
|
|
53
|
+
* Shared MCP engine. Thread-safe in the sense that multiple sessions can
|
|
54
|
+
* call its methods concurrently — internally it serializes initialization
|
|
55
|
+
* through a single promise so multiple sessions racing each other on first
|
|
56
|
+
* connect never double-open the SQLite file.
|
|
57
|
+
*/
|
|
58
|
+
class MCPEngine {
|
|
59
|
+
cg = null;
|
|
60
|
+
toolHandler;
|
|
61
|
+
// Project root we resolved to. Null until `ensureInitialized` succeeds
|
|
62
|
+
// (or null forever if no .codegraph/ ever turned up — that's a valid
|
|
63
|
+
// state for the engine, since cross-project queries still work).
|
|
64
|
+
projectPath = null;
|
|
65
|
+
// Set on first `ensureInitialized` so subsequent sessions don't redo work.
|
|
66
|
+
initPromise = null;
|
|
67
|
+
watcherStarted = false;
|
|
68
|
+
opts;
|
|
69
|
+
closed = false;
|
|
70
|
+
constructor(opts = {}) {
|
|
71
|
+
this.opts = { watch: opts.watch ?? true };
|
|
72
|
+
this.toolHandler = new tools_1.ToolHandler(null);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Convenience for {@link MCPServer} compatibility: pre-seed an explicit
|
|
76
|
+
* project path (from the `--path` CLI flag) without yet opening it. This
|
|
77
|
+
* keeps the synchronous constructor cheap; the actual open happens on the
|
|
78
|
+
* first `ensureInitialized` call.
|
|
79
|
+
*/
|
|
80
|
+
setProjectPathHint(projectPath) {
|
|
81
|
+
this.projectPath = projectPath;
|
|
82
|
+
this.toolHandler.setDefaultProjectHint(projectPath);
|
|
83
|
+
}
|
|
84
|
+
/** Project root that the engine resolved on first init (null if none). */
|
|
85
|
+
getProjectPath() {
|
|
86
|
+
return this.projectPath;
|
|
87
|
+
}
|
|
88
|
+
/** Shared ToolHandler — sessions delegate tool dispatch through this. */
|
|
89
|
+
getToolHandler() {
|
|
90
|
+
return this.toolHandler;
|
|
91
|
+
}
|
|
92
|
+
/** Whether the default project's CodeGraph is open. */
|
|
93
|
+
hasDefaultCodeGraph() {
|
|
94
|
+
return this.toolHandler.hasDefaultCodeGraph();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Walk up from `searchFrom` to find the nearest `.codegraph/` and open it.
|
|
98
|
+
* Idempotent: concurrent callers share one in-flight init; subsequent
|
|
99
|
+
* callers after success are no-ops.
|
|
100
|
+
*
|
|
101
|
+
* The original `MCPServer.tryInitializeDefault` carried the same retry-on-
|
|
102
|
+
* subsequent-tool-call semantics; we preserve them by NOT throwing when the
|
|
103
|
+
* search misses (just leaves `cg` null so the next call can retry).
|
|
104
|
+
*/
|
|
105
|
+
async ensureInitialized(searchFrom) {
|
|
106
|
+
if (this.closed)
|
|
107
|
+
return;
|
|
108
|
+
if (this.toolHandler.hasDefaultCodeGraph())
|
|
109
|
+
return;
|
|
110
|
+
if (this.initPromise) {
|
|
111
|
+
try {
|
|
112
|
+
await this.initPromise;
|
|
113
|
+
}
|
|
114
|
+
catch { /* let caller retry */ }
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
this.initPromise = this.doInitialize(searchFrom).finally(() => {
|
|
118
|
+
this.initPromise = null;
|
|
119
|
+
});
|
|
120
|
+
try {
|
|
121
|
+
await this.initPromise;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Init errors are logged inside `doInitialize`; falling through here
|
|
125
|
+
// matches MCPServer's previous "retry on next tool call" behavior.
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Synchronous last-resort init used by the per-session retry loop when the
|
|
130
|
+
* background `ensureInitialized` already finished (or failed) and we need
|
|
131
|
+
* to pick up a project that appeared *after* the engine started.
|
|
132
|
+
*/
|
|
133
|
+
retryInitializeSync(searchFrom) {
|
|
134
|
+
if (this.closed)
|
|
135
|
+
return;
|
|
136
|
+
if (this.toolHandler.hasDefaultCodeGraph())
|
|
137
|
+
return;
|
|
138
|
+
this.toolHandler.setDefaultProjectHint(searchFrom);
|
|
139
|
+
const resolvedRoot = (0, index_1.findNearestCodeGraphRoot)(searchFrom);
|
|
140
|
+
if (!resolvedRoot)
|
|
141
|
+
return;
|
|
142
|
+
try {
|
|
143
|
+
// Close any previously failed instance to avoid leaking resources.
|
|
144
|
+
if (this.cg) {
|
|
145
|
+
try {
|
|
146
|
+
this.cg.close();
|
|
147
|
+
}
|
|
148
|
+
catch { /* ignore */ }
|
|
149
|
+
this.cg = null;
|
|
150
|
+
}
|
|
151
|
+
this.cg = index_1.default.openSync(resolvedRoot);
|
|
152
|
+
this.projectPath = resolvedRoot;
|
|
153
|
+
this.toolHandler.setDefaultCodeGraph(this.cg);
|
|
154
|
+
this.startWatching();
|
|
155
|
+
this.catchUpSync();
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Still failing — caller will try again on the next tool call.
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Close everything. Used on graceful daemon shutdown (SIGTERM/idle timeout)
|
|
163
|
+
* and on direct-mode stop. Idempotent.
|
|
164
|
+
*/
|
|
165
|
+
stop() {
|
|
166
|
+
if (this.closed)
|
|
167
|
+
return;
|
|
168
|
+
this.closed = true;
|
|
169
|
+
this.toolHandler.closeAll();
|
|
170
|
+
if (this.cg) {
|
|
171
|
+
try {
|
|
172
|
+
this.cg.close();
|
|
173
|
+
}
|
|
174
|
+
catch { /* ignore */ }
|
|
175
|
+
this.cg = null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async doInitialize(searchFrom) {
|
|
179
|
+
this.toolHandler.setDefaultProjectHint(searchFrom);
|
|
180
|
+
const resolvedRoot = (0, index_1.findNearestCodeGraphRoot)(searchFrom);
|
|
181
|
+
if (!resolvedRoot) {
|
|
182
|
+
// No .codegraph/ above searchFrom — that's not an error, sessions may
|
|
183
|
+
// still discover one later via roots/list.
|
|
184
|
+
this.projectPath = searchFrom;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
this.projectPath = resolvedRoot;
|
|
188
|
+
try {
|
|
189
|
+
this.cg = await index_1.default.open(resolvedRoot);
|
|
190
|
+
this.toolHandler.setDefaultCodeGraph(this.cg);
|
|
191
|
+
this.startWatching();
|
|
192
|
+
this.catchUpSync();
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
196
|
+
process.stderr.write(`[CodeGraph MCP] Failed to open project at ${resolvedRoot}: ${msg}\n`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Start file watching on the active CodeGraph instance. Idempotent — the
|
|
201
|
+
* watcher is per-engine, not per-session, which is why the daemon path
|
|
202
|
+
* collapses N inotify sets to one. The wording of the disabled-reason log
|
|
203
|
+
* exactly matches the prior in-tree implementation so log-driven dashboards
|
|
204
|
+
* keep working.
|
|
205
|
+
*/
|
|
206
|
+
startWatching() {
|
|
207
|
+
if (!this.cg || this.watcherStarted || !this.opts.watch)
|
|
208
|
+
return;
|
|
209
|
+
const disabledReason = (0, sync_1.watchDisabledReason)(this.projectPath ?? process.cwd());
|
|
210
|
+
if (disabledReason) {
|
|
211
|
+
process.stderr.write(`[CodeGraph MCP] File watcher disabled — ${disabledReason}. ` +
|
|
212
|
+
`The graph will not auto-update; run \`codegraph sync\` (or install the git sync hooks via \`codegraph init\`) to refresh.\n`);
|
|
213
|
+
this.watcherStarted = true;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// Optional override for the debounce window via env var (issue #403).
|
|
217
|
+
// Useful for workspaces with bursty writes (formatter-on-save chains,
|
|
218
|
+
// large generated outputs) where the 2s default fires too often. Clamped
|
|
219
|
+
// to [100ms, 60s]; out-of-range / non-numeric values fall back to the
|
|
220
|
+
// FileWatcher default. We log the active value so it's discoverable.
|
|
221
|
+
const debounceMs = parseDebounceEnv(process.env.CODEGRAPH_WATCH_DEBOUNCE_MS);
|
|
222
|
+
if (debounceMs !== undefined) {
|
|
223
|
+
process.stderr.write(`[CodeGraph MCP] File watcher debounce: ${debounceMs}ms (CODEGRAPH_WATCH_DEBOUNCE_MS)\n`);
|
|
224
|
+
}
|
|
225
|
+
const started = this.cg.watch({
|
|
226
|
+
debounceMs,
|
|
227
|
+
onSyncComplete: (result) => {
|
|
228
|
+
if (result.filesChanged > 0) {
|
|
229
|
+
process.stderr.write(`[CodeGraph MCP] Auto-synced ${result.filesChanged} file(s) in ${result.durationMs}ms\n`);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
onSyncError: (err) => {
|
|
233
|
+
process.stderr.write(`[CodeGraph MCP] Auto-sync error: ${err.message}\n`);
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
this.watcherStarted = true;
|
|
237
|
+
if (started) {
|
|
238
|
+
process.stderr.write('[CodeGraph MCP] File watcher active — graph will auto-sync on changes\n');
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
process.stderr.write('[CodeGraph MCP] File watcher unavailable on this platform — run `codegraph sync` to refresh the graph after changes.\n');
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Reconcile the index with the current filesystem once, right after open —
|
|
246
|
+
* catches edits, adds, deletes, and `git pull`/`checkout` changes made while
|
|
247
|
+
* no watcher was running. Background, never awaited.
|
|
248
|
+
*/
|
|
249
|
+
catchUpSync() {
|
|
250
|
+
const cg = this.cg;
|
|
251
|
+
if (!cg)
|
|
252
|
+
return;
|
|
253
|
+
void cg
|
|
254
|
+
.sync()
|
|
255
|
+
.then((result) => {
|
|
256
|
+
const changed = result.filesAdded + result.filesModified + result.filesRemoved;
|
|
257
|
+
if (changed > 0) {
|
|
258
|
+
process.stderr.write(`[CodeGraph MCP] Caught up ${changed} file(s) changed since last run\n`);
|
|
259
|
+
}
|
|
260
|
+
})
|
|
261
|
+
.catch((err) => {
|
|
262
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
263
|
+
process.stderr.write(`[CodeGraph MCP] Catch-up sync failed: ${msg}\n`);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
exports.MCPEngine = MCPEngine;
|
|
268
|
+
/**
|
|
269
|
+
* Parse and clamp the CODEGRAPH_WATCH_DEBOUNCE_MS env override.
|
|
270
|
+
*
|
|
271
|
+
* Issue #403: workspaces with bursty writes (formatter-on-save, multi-file
|
|
272
|
+
* refactors) sometimes want a longer quiet window before sync. Returns
|
|
273
|
+
* `undefined` for unset / empty / non-numeric / out-of-range values so the
|
|
274
|
+
* FileWatcher default (2000ms) takes over — never throws.
|
|
275
|
+
*
|
|
276
|
+
* Clamp range: 100ms (faster would mean a sync per keystroke) to 60s (longer
|
|
277
|
+
* and the watcher feels broken). Out-of-range values are treated as "ignore
|
|
278
|
+
* this misconfiguration" rather than capped, since silently capping a 0 or
|
|
279
|
+
* a typoed value would mask a real config bug.
|
|
280
|
+
*/
|
|
281
|
+
function parseDebounceEnv(raw) {
|
|
282
|
+
if (!raw || !raw.trim())
|
|
283
|
+
return undefined;
|
|
284
|
+
const n = Number(raw);
|
|
285
|
+
if (!Number.isFinite(n) || !Number.isInteger(n))
|
|
286
|
+
return undefined;
|
|
287
|
+
if (n < 100 || n > 60000)
|
|
288
|
+
return undefined;
|
|
289
|
+
return n;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/mcp/engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuPH,4CAMC;AA3PD,kDAA+D;AAC/D,kCAA8C;AAC9C,mCAAsC;AAWtC;;;;;GAKG;AACH,MAAa,SAAS;IACZ,EAAE,GAAqB,IAAI,CAAC;IAC5B,WAAW,CAAc;IACjC,uEAAuE;IACvE,qEAAqE;IACrE,iEAAiE;IACzD,WAAW,GAAkB,IAAI,CAAC;IAC1C,2EAA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|
13
13
|
* const server = new MCPServer('/path/to/project');
|
|
14
14
|
* await server.start();
|
|
15
15
|
* ```
|
|
16
|
+
*
|
|
17
|
+
* Runtime modes (decided in {@link MCPServer.start}):
|
|
18
|
+
*
|
|
19
|
+
* - **Direct** — one process serves one MCP client over stdio. The pre-#411
|
|
20
|
+
* behavior; used when the user opts out (`CODEGRAPH_NO_DAEMON=1`), no
|
|
21
|
+
* `.codegraph/` is reachable, or the daemon machinery fails for any reason.
|
|
22
|
+
* - **Proxy** — what an MCP host actually talks to when sharing is on: a thin
|
|
23
|
+
* stdio↔socket pipe to the shared daemon. The proxy carries the #277 PPID
|
|
24
|
+
* watchdog, so a SIGKILL'd host reaps its proxy promptly. See {@link ./proxy.ts}.
|
|
25
|
+
* - **Daemon** — a *detached* background process (its own session/process
|
|
26
|
+
* group) that serves N proxies over a Unix-domain socket / named pipe,
|
|
27
|
+
* sharing one CodeGraph + watcher + SQLite handle. Spawned on demand; never a
|
|
28
|
+
* child of any host, so it survives individual sessions and is reaped by
|
|
29
|
+
* client-refcount + idle timeout. See {@link ./daemon.ts} and issue #411.
|
|
30
|
+
*
|
|
31
|
+
* The detached-daemon + always-proxy split is the fix for the review finding
|
|
32
|
+
* that the original in-process daemon (a) was the first host's child, so closing
|
|
33
|
+
* that terminal severed every other client, and (b) disabled the PPID watchdog,
|
|
34
|
+
* regressing #277 (orphaned daemons on host SIGKILL).
|
|
16
35
|
*/
|
|
17
36
|
/**
|
|
18
37
|
* MCP Server for CodeGraph
|
|
19
38
|
*
|
|
20
39
|
* Implements the Model Context Protocol to expose CodeGraph
|
|
21
40
|
* functionality as tools that can be called by AI assistants.
|
|
41
|
+
*
|
|
42
|
+
* Backwards-compatible constructor and `start()` signature with the
|
|
43
|
+
* pre-issue-#411 implementation: callers continue to do
|
|
44
|
+
* `new MCPServer(path).start()`. Internally we now pick from direct / proxy /
|
|
45
|
+
* daemon at start time.
|
|
22
46
|
*/
|
|
23
47
|
export declare class MCPServer {
|
|
24
|
-
private transport;
|
|
25
|
-
private cg;
|
|
26
|
-
private toolHandler;
|
|
27
48
|
private projectPath;
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
49
|
+
private session;
|
|
50
|
+
private engine;
|
|
51
|
+
private daemon;
|
|
52
|
+
private ppidWatchdog;
|
|
53
|
+
private originalPpid;
|
|
54
|
+
private hostPpid;
|
|
55
|
+
private stopped;
|
|
56
|
+
private mode;
|
|
31
57
|
constructor(projectPath?: string);
|
|
32
58
|
/**
|
|
33
|
-
* Start the MCP server
|
|
34
|
-
*
|
|
35
|
-
* Note: CodeGraph initialization is deferred until the initialize request
|
|
36
|
-
* is received, which includes the rootUri from the client.
|
|
37
|
-
*/
|
|
38
|
-
start(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Try to initialize CodeGraph for the default project.
|
|
59
|
+
* Start the MCP server.
|
|
41
60
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
61
|
+
* Decision order:
|
|
62
|
+
* 1. `CODEGRAPH_NO_DAEMON=1` → direct mode (unchanged pre-#411 behavior).
|
|
63
|
+
* 2. `CODEGRAPH_DAEMON_INTERNAL=1` → we ARE the detached daemon; listen.
|
|
64
|
+
* 3. No `.codegraph/` reachable → direct mode (the daemon's lockfile and
|
|
65
|
+
* socket both live under `.codegraph/`).
|
|
66
|
+
* 4. Otherwise connect to (or spawn) the shared daemon and proxy to it.
|
|
44
67
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* are still possible.
|
|
68
|
+
* On any unexpected failure in step 4 we transparently fall back to direct
|
|
69
|
+
* mode — a misbehaving daemon must never block a session from starting.
|
|
48
70
|
*/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Retry initialization of the default project if it previously failed.
|
|
52
|
-
* Called lazily on tool calls that need the default project.
|
|
53
|
-
* Re-walks parent directories each time so it picks up projects
|
|
54
|
-
* initialized after the MCP server started.
|
|
55
|
-
*
|
|
56
|
-
* Awaits any in-flight background init (kicked off by handleInitialize) so
|
|
57
|
-
* we never open the SQLite file twice concurrently.
|
|
58
|
-
*/
|
|
59
|
-
private retryInitIfNeeded;
|
|
60
|
-
/**
|
|
61
|
-
* Resolve the project root via the MCP `roots/list` request and initialize
|
|
62
|
-
* from the first root the client reports. Falls back to the process cwd if
|
|
63
|
-
* the client returns no usable root or doesn't answer in time. See issue #196.
|
|
64
|
-
*/
|
|
65
|
-
private initFromRoots;
|
|
66
|
-
/**
|
|
67
|
-
* Start file watching on the active CodeGraph instance.
|
|
68
|
-
* Logs sync activity to stderr for diagnostics.
|
|
69
|
-
*/
|
|
70
|
-
private startWatching;
|
|
71
|
+
start(): Promise<void>;
|
|
71
72
|
/**
|
|
72
|
-
* Stop the server
|
|
73
|
+
* Stop the server. In daemon mode this triggers graceful shutdown of every
|
|
74
|
+
* connected session; in direct mode it mirrors the pre-#411 behavior (close
|
|
75
|
+
* cg, exit). Proxy mode never routes through here — the proxy exits itself.
|
|
73
76
|
*/
|
|
74
77
|
stop(): void;
|
|
78
|
+
/** Single-process stdio MCP session — the pre-issue-#411 code path. */
|
|
79
|
+
private startDirect;
|
|
75
80
|
/**
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
+
* Run as the detached shared daemon (process spawned with
|
|
82
|
+
* `CODEGRAPH_DAEMON_INTERNAL=1`). Arbitrate the O_EXCL lock, then either
|
|
83
|
+
* become the daemon (bind the socket, serve forever) or — if a live daemon
|
|
84
|
+
* already holds the lock — exit so we don't leak a redundant process.
|
|
85
|
+
*
|
|
86
|
+
* No PPID watchdog and no stdin handlers: the daemon is detached on purpose
|
|
87
|
+
* and reaps itself via client-refcount + idle timeout (see {@link Daemon}).
|
|
81
88
|
*/
|
|
82
|
-
private
|
|
89
|
+
private startDaemonProcess;
|
|
83
90
|
/**
|
|
84
|
-
*
|
|
91
|
+
* Become a proxy to the shared daemon, spawning the daemon first if none is
|
|
92
|
+
* reachable. Returns 'proxy' once the proxied session has run to completion
|
|
93
|
+
* (the host disconnected), or 'fallback' if the caller should run in-process.
|
|
85
94
|
*/
|
|
86
|
-
private
|
|
95
|
+
private connectOrSpawnDaemon;
|
|
96
|
+
/** Standard SIGINT/SIGTERM handlers that route to our `stop()` (direct mode). */
|
|
97
|
+
private installSignalHandlers;
|
|
87
98
|
/**
|
|
88
|
-
*
|
|
99
|
+
* PPID watchdog (#277) — direct mode only. Daemon mode is detached on purpose
|
|
100
|
+
* and reaps via idle timeout; proxy mode installs its own watchdog inside
|
|
101
|
+
* {@link runProxy}. So this only ever runs for an in-process direct session.
|
|
89
102
|
*/
|
|
90
|
-
private
|
|
103
|
+
private installPpidWatchdog;
|
|
91
104
|
}
|
|
92
105
|
export { StdioTransport } from './transport';
|
|
93
106
|
export { tools, ToolHandler } from './tools';
|
|
107
|
+
export { Daemon } from './daemon';
|
|
108
|
+
export { CodeGraphPackageVersion } from './version';
|
|
94
109
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAiKH;;;;;;;;;;GAUG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,WAAW,CAAgB;IAGnC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,YAAY,CAA+C;IAGnE,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,QAAQ,CAA4D;IAE5E,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAA4D;gBAE5D,WAAW,CAAC,EAAE,MAAM;IAIhC;;;;;;;;;;;;OAYG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuC5B;;;;OAIG;IACH,IAAI,IAAI,IAAI;IAuBZ,uEAAuE;YACzD,WAAW;IA4BzB;;;;;;;;OAQG;YACW,kBAAkB;IAiChC;;;;OAIG;YACW,oBAAoB;IAwBlC,iFAAiF;IACjF,OAAO,CAAC,qBAAqB;IAK7B;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;CAoB5B;AAWD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC"}
|