memorydetective 1.1.0 → 1.2.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/CHANGELOG.md +24 -1
- package/README.md +15 -20
- package/dist/cli.js +1 -1
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/sourcekit/client.d.ts +37 -0
- package/dist/runtime/sourcekit/client.js +132 -0
- package/dist/runtime/sourcekit/client.js.map +1 -0
- package/dist/runtime/sourcekit/pool.d.ts +25 -0
- package/dist/runtime/sourcekit/pool.js +101 -0
- package/dist/runtime/sourcekit/pool.js.map +1 -0
- package/dist/runtime/sourcekit/protocol.d.ts +37 -0
- package/dist/runtime/sourcekit/protocol.js +161 -0
- package/dist/runtime/sourcekit/protocol.js.map +1 -0
- package/dist/tools/swift/_helpers.d.ts +29 -0
- package/dist/tools/swift/_helpers.js +64 -0
- package/dist/tools/swift/_helpers.js.map +1 -0
- package/dist/tools/swift/findSymbolReferences.d.ts +30 -0
- package/dist/tools/swift/findSymbolReferences.js +56 -0
- package/dist/tools/swift/findSymbolReferences.js.map +1 -0
- package/dist/tools/swift/getHoverInfo.d.ts +27 -0
- package/dist/tools/swift/getHoverInfo.js +40 -0
- package/dist/tools/swift/getHoverInfo.js.map +1 -0
- package/dist/tools/swift/getSymbolDefinition.d.ts +46 -0
- package/dist/tools/swift/getSymbolDefinition.js +68 -0
- package/dist/tools/swift/getSymbolDefinition.js.map +1 -0
- package/dist/tools/swift/getSymbolsOverview.d.ts +22 -0
- package/dist/tools/swift/getSymbolsOverview.js +33 -0
- package/dist/tools/swift/getSymbolsOverview.js.map +1 -0
- package/dist/tools/swift/index.d.ts +14 -0
- package/dist/tools/swift/index.js +15 -0
- package/dist/tools/swift/index.js.map +1 -0
- package/dist/tools/swift/searchPattern.d.ts +38 -0
- package/dist/tools/swift/searchPattern.js +71 -0
- package/dist/tools/swift/searchPattern.js.map +1 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.2.0] — 2026-05-01
|
|
10
|
+
|
|
11
|
+
Swift source-bridging. The agent can now go from "found a leak in the cycle" to "find the file/line in this project" without leaving chat. 20 → 25 tools.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **5 Swift source-bridging tools** backed by a `sourcekit-lsp` subprocess pool:
|
|
16
|
+
- `swiftGetSymbolDefinition` — locate a class/struct/enum/etc. declaration. Pre-scans candidate paths with a fast regex, then asks SourceKit-LSP for jump-to-definition.
|
|
17
|
+
- `swiftFindSymbolReferences` — every reference to a Swift symbol via `textDocument/references`. Includes a `needsIndex` hint when the IndexStoreDB is missing.
|
|
18
|
+
- `swiftGetSymbolsOverview` — top-level symbols in a file (cheap orientation when landing in a new file).
|
|
19
|
+
- `swiftGetHoverInfo` — type info / docs at a position. Useful to disambiguate class vs struct `self` captures.
|
|
20
|
+
- `swiftSearchPattern` — pure regex search over a Swift file (no LSP, no index). Catches closure capture lists and other patterns LSP can't see.
|
|
21
|
+
- **`src/runtime/sourcekit/` infrastructure**: `client.ts` (LSP subprocess + JSON-RPC stdio via `vscode-jsonrpc`), `pool.ts` (per-project-root client pool with 5-minute idle shutdown), `protocol.ts` (typed wrappers for the LSP methods we use, using `vscode-languageserver-protocol` types).
|
|
22
|
+
- New deps: `vscode-jsonrpc`, `vscode-languageserver-protocol`. Both MIT.
|
|
23
|
+
- 13 new unit tests for the Swift tools (mostly `searchPattern` + helper coverage; LSP-backed tools require a live SourceKit-LSP and are smoke-tested out-of-band).
|
|
24
|
+
|
|
25
|
+
### Notes
|
|
26
|
+
|
|
27
|
+
- The Swift tools require macOS + a full Xcode install (`xcrun sourcekit-lsp` must be available). Command Line Tools alone is not enough.
|
|
28
|
+
- For cross-file references, the project needs an `IndexStoreDB` at `<projectRoot>/.build/index/store`. Build it with `swift build -Xswiftc -index-store-path -Xswiftc <projectRoot>/.build/index/store`.
|
|
29
|
+
- `sourcekit-lsp` cold start is ~2s; the pool amortizes that across calls within a project.
|
|
30
|
+
|
|
9
31
|
## [1.1.0] — 2026-05-01
|
|
10
32
|
|
|
11
33
|
Response-size + cycle-scoped queries + license switch + first-run engagement.
|
|
@@ -97,7 +119,8 @@ When called with no arguments it starts the MCP server over stdio.
|
|
|
97
119
|
- **`captureMemgraph`** does not work on physical iOS devices — `leaks(1)` only attaches to processes on the local Mac (which includes iOS simulators). Memory Graph capture from a physical device still requires Xcode.
|
|
98
120
|
- **`detectLeaksInXCUITest`** is flagged experimental: orchestration logic is implemented but not yet validated against a wide set of production XCUITest runs.
|
|
99
121
|
|
|
100
|
-
[Unreleased]: https://github.com/carloshpdoc/memorydetective/compare/v1.
|
|
122
|
+
[Unreleased]: https://github.com/carloshpdoc/memorydetective/compare/v1.2.0...HEAD
|
|
123
|
+
[1.2.0]: https://github.com/carloshpdoc/memorydetective/compare/v1.1.0...v1.2.0
|
|
101
124
|
[1.1.0]: https://github.com/carloshpdoc/memorydetective/compare/v1.0.1...v1.1.0
|
|
102
125
|
[1.0.1]: https://github.com/carloshpdoc/memorydetective/compare/v1.0.0...v1.0.1
|
|
103
126
|
[1.0.0]: https://github.com/carloshpdoc/memorydetective/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -177,7 +177,7 @@ Copilot's MCP integration moves fast — if this snippet is stale, see the [VS C
|
|
|
177
177
|
|
|
178
178
|
## API
|
|
179
179
|
|
|
180
|
-
|
|
180
|
+
25 MCP tools, grouped by purpose.
|
|
181
181
|
|
|
182
182
|
### Read & analyze (13)
|
|
183
183
|
|
|
@@ -224,6 +224,20 @@ Copilot's MCP integration moves fast — if this snippet is stale, see the [VS C
|
|
|
224
224
|
|---|---|
|
|
225
225
|
| `detectLeaksInXCUITest` | **Experimental.** Build the workspace for testing, run the named XCUITest, capture `.memgraph` baseline + after, diff. Returns `passed: false` when new ROOT CYCLEs appear that aren't in the user's allowlist. CI-runnable. |
|
|
226
226
|
|
|
227
|
+
### Swift source bridging (5)
|
|
228
|
+
|
|
229
|
+
Pair the memory-graph diagnosis with source-code lookups via SourceKit-LSP. Closes the loop "found this leak in the cycle → find the file/line in your project".
|
|
230
|
+
|
|
231
|
+
| Tool | What |
|
|
232
|
+
|---|---|
|
|
233
|
+
| `swiftGetSymbolDefinition` | Locate the file:line where a Swift symbol is declared. Pre-scans `candidatePaths` (or `hint.filePath`) with a fast regex, then asks SourceKit-LSP for jump-to-definition. |
|
|
234
|
+
| `swiftFindSymbolReferences` | Find every reference to a Swift symbol via SourceKit-LSP `textDocument/references`. Requires an `IndexStoreDB` for cross-file results — the response carries a `needsIndex` hint when the index is missing. |
|
|
235
|
+
| `swiftGetSymbolsOverview` | List top-level symbols (classes, structs, enums, protocols, free functions) in a Swift file via `documentSymbol`. Cheap orientation when the agent lands in a new file. |
|
|
236
|
+
| `swiftGetHoverInfo` | Type info / docs at a (line, character) position. Disambiguates `self` captures: a class self in a closure can leak; a struct self can't. |
|
|
237
|
+
| `swiftSearchPattern` | Pure regex search over a Swift file (no LSP, no index). Catches what LSP misses: closure capture lists, `Task { ... self ... }` blocks, custom patterns from a leak chain. |
|
|
238
|
+
|
|
239
|
+
These tools require macOS + Xcode (full Xcode, not just Command Line Tools — `xcrun sourcekit-lsp` must be available). They start a `sourcekit-lsp` subprocess per project root and reuse it across calls; the subprocess shuts down after a 5-minute idle window.
|
|
240
|
+
|
|
227
241
|
> **Why `captureMemgraph` doesn't work on physical iOS devices**: `leaks(1)` only attaches to processes running on the local Mac (which includes iOS simulators). Memory Graph capture from a real device goes through Xcode's debugger over USB/lockdownd — different mechanism, no public CLI equivalent.
|
|
228
242
|
|
|
229
243
|
### CLI mode
|
|
@@ -275,17 +289,6 @@ Contributions are welcome — bug reports, feature requests, new cycle patterns,
|
|
|
275
289
|
|
|
276
290
|
In v0.2 the catalog moves to a separate repo so patterns can be added without modifying the server code.
|
|
277
291
|
|
|
278
|
-
### Working on the demo GIF
|
|
279
|
-
|
|
280
|
-
The demo GIF is generated deterministically from `examples/demo.tape` via [vhs](https://github.com/charmbracelet/vhs):
|
|
281
|
-
|
|
282
|
-
```bash
|
|
283
|
-
brew install vhs
|
|
284
|
-
vhs examples/demo.tape
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
The `.tape` file is committed; the `.gif` is regenerated from it. If you change the demo flow, please update both.
|
|
288
|
-
|
|
289
292
|
## Support this project
|
|
290
293
|
|
|
291
294
|
If `memorydetective` saves you time, you can support continued development:
|
|
@@ -301,14 +304,6 @@ Apache 2.0 — see [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
|
301
304
|
|
|
302
305
|
Permits commercial use, modification, distribution, patent use. Includes attribution clause via the `NOTICE` file.
|
|
303
306
|
|
|
304
|
-
## Companion MCPs
|
|
305
|
-
|
|
306
|
-
`memorydetective` focuses on memory-graph and trace artifacts. To bridge "found this leak in the cycle" with "find it in your codebase", pair it with a Swift source-aware MCP. Recommended:
|
|
307
|
-
|
|
308
|
-
- [SwiftLens](https://github.com/swiftlens/swiftlens) — wraps SourceKit-LSP for Swift symbol lookup, reference search, hover info. Different license model (non-commercial); read its terms before using in a paid product.
|
|
309
|
-
|
|
310
|
-
A future version of `memorydetective` may include a similar source-bridging surface natively under Apache 2.0; see the v1.2 roadmap notes in the design docs.
|
|
311
|
-
|
|
312
307
|
## Why "memorydetective"?
|
|
313
308
|
|
|
314
309
|
Hunting retain cycles in SwiftUI feels like detective work: you have a body (the leaked instance), a crime scene (the `.memgraph`), and a chain of suspects (the retain chain). The tool helps you read the evidence and name the killer. The brand follows the work.
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ import { renderCycleGraph, renderCycleGraphSchema, } from "./tools/renderCycleGr
|
|
|
20
20
|
import { logShow, logShowSchema, logStream, logStreamSchema, } from "./tools/logShow.js";
|
|
21
21
|
import { detectLeaksInXCUITest, detectLeaksInXCUITestSchema, } from "./tools/detectLeaksInXCUITest.js";
|
|
22
22
|
import { reachableFromCycle, reachableFromCycleSchema, } from "./tools/reachableFromCycle.js";
|
|
23
|
+
import { swiftGetSymbolDefinition, swiftGetSymbolDefinitionSchema, swiftFindSymbolReferences, swiftFindSymbolReferencesSchema, swiftGetSymbolsOverview, swiftGetSymbolsOverviewSchema, swiftGetHoverInfo, swiftGetHoverInfoSchema, swiftSearchPattern, swiftSearchPatternSchema, } from "./tools/swift/index.js";
|
|
23
24
|
const SERVER_NAME = "memorydetective";
|
|
24
25
|
const SERVER_VERSION = "0.1.0-dev";
|
|
25
26
|
const server = new McpServer({
|
|
@@ -222,6 +223,46 @@ server.registerTool("reachableFromCycle", {
|
|
|
222
223
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
223
224
|
};
|
|
224
225
|
});
|
|
226
|
+
server.registerTool("swiftGetSymbolDefinition", {
|
|
227
|
+
title: "Locate a Swift symbol's source declaration",
|
|
228
|
+
description: "Find the file:line where a Swift symbol (class, struct, enum, protocol, func, var, etc.) is declared. Pre-scans `candidatePaths` (or `hint.filePath`) with a fast regex first, then asks SourceKit-LSP for jump-to-definition. Returns the position even when LSP can't follow through. Use after `findRetainers` / `classifyCycle` surface a class name from a memgraph cycle to land in the actual source file.",
|
|
229
|
+
inputSchema: swiftGetSymbolDefinitionSchema.shape,
|
|
230
|
+
}, async (input) => {
|
|
231
|
+
const result = await swiftGetSymbolDefinition(input);
|
|
232
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
233
|
+
});
|
|
234
|
+
server.registerTool("swiftFindSymbolReferences", {
|
|
235
|
+
title: "Find every reference to a Swift symbol",
|
|
236
|
+
description: "Locates the symbol's declaration in `filePath`, then asks SourceKit-LSP for `textDocument/references`. Returns every callsite + capture across the project, with a snippet of each line. **Requires an IndexStoreDB** at `<projectRoot>/.build/index/store` for cross-file references — build it with `swift build -Xswiftc -index-store-path -Xswiftc <projectRoot>/.build/index/store`. The result includes a `needsIndex: true` hint when the index is missing.",
|
|
237
|
+
inputSchema: swiftFindSymbolReferencesSchema.shape,
|
|
238
|
+
}, async (input) => {
|
|
239
|
+
const result = await swiftFindSymbolReferences(input);
|
|
240
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
241
|
+
});
|
|
242
|
+
server.registerTool("swiftGetSymbolsOverview", {
|
|
243
|
+
title: "List top-level symbols in a Swift file",
|
|
244
|
+
description: "Cheap orientation: returns the top-level symbols (classes, structs, enums, protocols, free functions) declared in a Swift file via SourceKit-LSP's `documentSymbol`. Set `topLevelOnly: false` for nested children too. Useful right after `swiftGetSymbolDefinition` lands you in a new file.",
|
|
245
|
+
inputSchema: swiftGetSymbolsOverviewSchema.shape,
|
|
246
|
+
}, async (input) => {
|
|
247
|
+
const result = await swiftGetSymbolsOverview(input);
|
|
248
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
249
|
+
});
|
|
250
|
+
server.registerTool("swiftGetHoverInfo", {
|
|
251
|
+
title: "Get type info / docs at a Swift source position",
|
|
252
|
+
description: "SourceKit-LSP `textDocument/hover` at a (line, character) position. Returns the markdown / plaintext hover content plus a best-effort extracted declaration fragment. Use to disambiguate `self` captures: a class self in a closure can leak; a struct self can't.",
|
|
253
|
+
inputSchema: swiftGetHoverInfoSchema.shape,
|
|
254
|
+
}, async (input) => {
|
|
255
|
+
const result = await swiftGetHoverInfo(input);
|
|
256
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
257
|
+
});
|
|
258
|
+
server.registerTool("swiftSearchPattern", {
|
|
259
|
+
title: "Regex-search a Swift file (no LSP)",
|
|
260
|
+
description: "Pure regex search over a file's contents — no SourceKit-LSP, no IndexStoreDB. Catches what LSP misses: closure capture lists (`[weak self]`, `[unowned self]`), `Task { ... self ... }` blocks, and any other pattern the agent constructs from a leak chain. Returns matches with line/character positions and a trimmed snippet.",
|
|
261
|
+
inputSchema: swiftSearchPatternSchema.shape,
|
|
262
|
+
}, async (input) => {
|
|
263
|
+
const result = await swiftSearchPattern(input);
|
|
264
|
+
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
265
|
+
});
|
|
225
266
|
async function main() {
|
|
226
267
|
// CLI mode: when called with arguments, run the synchronous CLI wrapper.
|
|
227
268
|
// No arguments → start the MCP server over stdio (the default and the
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,eAAe,EACf,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,eAAe,EACf,oBAAoB,GACr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AAE,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent `sourcekit-lsp` subprocess client.
|
|
3
|
+
*
|
|
4
|
+
* One client per project root. Talks LSP over JSON-RPC stdio using
|
|
5
|
+
* `vscode-jsonrpc` for framing. Lifecycle:
|
|
6
|
+
*
|
|
7
|
+
* spawn -> initialize -> initialized -> [lots of requests] -> shutdown -> exit
|
|
8
|
+
*
|
|
9
|
+
* Used by the Swift source-bridging tools (`getSymbolDefinition`,
|
|
10
|
+
* `findSymbolReferences`, etc.). The pool (`./pool.ts`) keeps one client
|
|
11
|
+
* alive per project root and shuts it down after an idle window so we
|
|
12
|
+
* don't hold onto resources or stall builds.
|
|
13
|
+
*/
|
|
14
|
+
export interface SourceKitClientOptions {
|
|
15
|
+
projectRoot: string;
|
|
16
|
+
/** Override the binary path. Defaults to `xcrun sourcekit-lsp`. */
|
|
17
|
+
command?: string;
|
|
18
|
+
args?: string[];
|
|
19
|
+
/** Initialization timeout, ms. Default 30s. */
|
|
20
|
+
initTimeoutMs?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface InitializedClient {
|
|
23
|
+
projectRoot: string;
|
|
24
|
+
/** Send an arbitrary LSP request by method name. */
|
|
25
|
+
sendRequest<R = unknown>(method: string, params?: unknown): Promise<R>;
|
|
26
|
+
/** Send a notification (no response). */
|
|
27
|
+
sendNotification(method: string, params?: unknown): void;
|
|
28
|
+
/** Track a document as open with the server. Idempotent per uri. */
|
|
29
|
+
didOpen(filePath: string, languageId?: string): void;
|
|
30
|
+
/** Stop the server gracefully. Once called, the client cannot be reused. */
|
|
31
|
+
dispose(): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Spawn `sourcekit-lsp`, drive the LSP handshake, and return a client
|
|
35
|
+
* that exposes typed request/notification helpers.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createSourceKitClient(opts: SourceKitClientOptions): Promise<InitializedClient>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistent `sourcekit-lsp` subprocess client.
|
|
3
|
+
*
|
|
4
|
+
* One client per project root. Talks LSP over JSON-RPC stdio using
|
|
5
|
+
* `vscode-jsonrpc` for framing. Lifecycle:
|
|
6
|
+
*
|
|
7
|
+
* spawn -> initialize -> initialized -> [lots of requests] -> shutdown -> exit
|
|
8
|
+
*
|
|
9
|
+
* Used by the Swift source-bridging tools (`getSymbolDefinition`,
|
|
10
|
+
* `findSymbolReferences`, etc.). The pool (`./pool.ts`) keeps one client
|
|
11
|
+
* alive per project root and shuts it down after an idle window so we
|
|
12
|
+
* don't hold onto resources or stall builds.
|
|
13
|
+
*/
|
|
14
|
+
import { spawn } from "node:child_process";
|
|
15
|
+
import { resolve as resolvePath } from "node:path";
|
|
16
|
+
import { pathToFileURL } from "node:url";
|
|
17
|
+
import { createMessageConnection, StreamMessageReader, StreamMessageWriter, } from "vscode-jsonrpc/node.js";
|
|
18
|
+
const DEFAULT_INIT_TIMEOUT = 30_000;
|
|
19
|
+
/**
|
|
20
|
+
* Spawn `sourcekit-lsp`, drive the LSP handshake, and return a client
|
|
21
|
+
* that exposes typed request/notification helpers.
|
|
22
|
+
*/
|
|
23
|
+
export async function createSourceKitClient(opts) {
|
|
24
|
+
const command = opts.command ?? "xcrun";
|
|
25
|
+
const args = opts.args ?? ["sourcekit-lsp"];
|
|
26
|
+
const projectRoot = resolvePath(opts.projectRoot);
|
|
27
|
+
const child = spawn(command, args, {
|
|
28
|
+
cwd: projectRoot,
|
|
29
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
30
|
+
});
|
|
31
|
+
const connection = createMessageConnection(new StreamMessageReader(child.stdout), new StreamMessageWriter(child.stdin));
|
|
32
|
+
// Forward stderr to our stderr so SourceKit warnings/errors are visible.
|
|
33
|
+
child.stderr.on("data", (chunk) => {
|
|
34
|
+
process.stderr.write(`[sourcekit-lsp] ${chunk.toString("utf8")}`);
|
|
35
|
+
});
|
|
36
|
+
let exited = false;
|
|
37
|
+
child.on("exit", () => {
|
|
38
|
+
exited = true;
|
|
39
|
+
});
|
|
40
|
+
connection.listen();
|
|
41
|
+
const projectUri = pathToFileURL(projectRoot).href;
|
|
42
|
+
const initTimeoutMs = opts.initTimeoutMs ?? DEFAULT_INIT_TIMEOUT;
|
|
43
|
+
await withTimeout(connection.sendRequest("initialize", {
|
|
44
|
+
processId: process.pid,
|
|
45
|
+
rootUri: projectUri,
|
|
46
|
+
workspaceFolders: [{ uri: projectUri, name: projectRoot }],
|
|
47
|
+
capabilities: {
|
|
48
|
+
textDocument: {
|
|
49
|
+
definition: { linkSupport: true },
|
|
50
|
+
references: {},
|
|
51
|
+
hover: { contentFormat: ["plaintext", "markdown"] },
|
|
52
|
+
documentSymbol: { hierarchicalDocumentSymbolSupport: true },
|
|
53
|
+
},
|
|
54
|
+
workspace: { workspaceFolders: true },
|
|
55
|
+
},
|
|
56
|
+
initializationOptions: {
|
|
57
|
+
// sourcekit-lsp picks up .build/index/store automatically when present.
|
|
58
|
+
},
|
|
59
|
+
}), initTimeoutMs, "sourcekit-lsp initialize");
|
|
60
|
+
connection.sendNotification("initialized", {});
|
|
61
|
+
const openDocs = { set: new Set() };
|
|
62
|
+
const client = {
|
|
63
|
+
projectRoot,
|
|
64
|
+
async sendRequest(method, params) {
|
|
65
|
+
if (exited)
|
|
66
|
+
throw new Error("sourcekit-lsp client has exited");
|
|
67
|
+
return await connection.sendRequest(method, params);
|
|
68
|
+
},
|
|
69
|
+
sendNotification(method, params) {
|
|
70
|
+
if (exited)
|
|
71
|
+
throw new Error("sourcekit-lsp client has exited");
|
|
72
|
+
connection.sendNotification(method, params);
|
|
73
|
+
},
|
|
74
|
+
didOpen(filePath, languageId = "swift") {
|
|
75
|
+
const uri = pathToFileURL(resolvePath(filePath)).href;
|
|
76
|
+
if (openDocs.set.has(uri))
|
|
77
|
+
return;
|
|
78
|
+
openDocs.set.add(uri);
|
|
79
|
+
// We don't ship the file's text here — sourcekit-lsp reads from disk
|
|
80
|
+
// when version === 1. This works for read-only operations
|
|
81
|
+
// (definition, references, hover, documentSymbol).
|
|
82
|
+
connection.sendNotification("textDocument/didOpen", {
|
|
83
|
+
textDocument: {
|
|
84
|
+
uri,
|
|
85
|
+
languageId,
|
|
86
|
+
version: 1,
|
|
87
|
+
text: "",
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
async dispose() {
|
|
92
|
+
if (exited)
|
|
93
|
+
return;
|
|
94
|
+
try {
|
|
95
|
+
await withTimeout(connection.sendRequest("shutdown"), 5_000, "sourcekit-lsp shutdown");
|
|
96
|
+
connection.sendNotification("exit");
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// best effort — kill the process if shutdown didn't complete
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
connection.dispose();
|
|
103
|
+
}
|
|
104
|
+
catch { }
|
|
105
|
+
if (!exited) {
|
|
106
|
+
child.kill("SIGTERM");
|
|
107
|
+
// Give it a moment to die gracefully, then SIGKILL.
|
|
108
|
+
await new Promise((resolve) => {
|
|
109
|
+
const t = setTimeout(() => {
|
|
110
|
+
try {
|
|
111
|
+
child.kill("SIGKILL");
|
|
112
|
+
}
|
|
113
|
+
catch { }
|
|
114
|
+
resolve();
|
|
115
|
+
}, 2_000);
|
|
116
|
+
child.once("exit", () => {
|
|
117
|
+
clearTimeout(t);
|
|
118
|
+
resolve();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
return client;
|
|
125
|
+
}
|
|
126
|
+
async function withTimeout(p, ms, label) {
|
|
127
|
+
return await Promise.race([
|
|
128
|
+
Promise.resolve(p),
|
|
129
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms)),
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/runtime/sourcekit/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAuC,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,mBAAmB,GAEpB,MAAM,wBAAwB,CAAC;AAuBhC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAMpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC;IAC5C,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAElD,MAAM,KAAK,GAAmC,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE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AK,oBAAoB,EAAE,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAC5E;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pool of `sourcekit-lsp` clients, keyed by project root.
|
|
3
|
+
*
|
|
4
|
+
* Why a pool: starting `sourcekit-lsp` and waiting for it to be ready costs
|
|
5
|
+
* ~2 seconds. Doing that on every tool call would kill the agent loop.
|
|
6
|
+
* Instead we keep one client alive per project root and reuse it across
|
|
7
|
+
* tool invocations. After an idle window we shut it down so we're not
|
|
8
|
+
* blocking the user's build/test pipeline.
|
|
9
|
+
*/
|
|
10
|
+
import { type InitializedClient } from "./client.js";
|
|
11
|
+
/** Resolve a file path to its enclosing project root by walking up to the
|
|
12
|
+
* nearest `Package.swift`, `*.xcodeproj`, or `*.xcworkspace`. Falls back
|
|
13
|
+
* to the file's directory if nothing is found. */
|
|
14
|
+
export declare function projectRootFor(filePath: string): string;
|
|
15
|
+
export interface AcquireOptions {
|
|
16
|
+
/** Override idle shutdown window, ms. Default 5min. */
|
|
17
|
+
idleMs?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Acquire an LSP client for a project root. Reuses an existing one if
|
|
20
|
+
* warm, spawns + initializes one otherwise. */
|
|
21
|
+
export declare function acquireClient(projectRoot: string, opts?: AcquireOptions): Promise<InitializedClient>;
|
|
22
|
+
/** Manually shut down the client for a given project root. */
|
|
23
|
+
export declare function shutdownClient(projectRoot: string): Promise<void>;
|
|
24
|
+
/** Shut down all pooled clients. Useful in tests + on process exit. */
|
|
25
|
+
export declare function shutdownAll(): Promise<void>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pool of `sourcekit-lsp` clients, keyed by project root.
|
|
3
|
+
*
|
|
4
|
+
* Why a pool: starting `sourcekit-lsp` and waiting for it to be ready costs
|
|
5
|
+
* ~2 seconds. Doing that on every tool call would kill the agent loop.
|
|
6
|
+
* Instead we keep one client alive per project root and reuse it across
|
|
7
|
+
* tool invocations. After an idle window we shut it down so we're not
|
|
8
|
+
* blocking the user's build/test pipeline.
|
|
9
|
+
*/
|
|
10
|
+
import { existsSync, readdirSync, realpathSync } from "node:fs";
|
|
11
|
+
import { resolve as resolvePath } from "node:path";
|
|
12
|
+
import { createSourceKitClient, } from "./client.js";
|
|
13
|
+
const DEFAULT_IDLE_MS = 5 * 60_000; // 5 minutes
|
|
14
|
+
const pool = new Map();
|
|
15
|
+
/** Resolve a file path to its enclosing project root by walking up to the
|
|
16
|
+
* nearest `Package.swift`, `*.xcodeproj`, or `*.xcworkspace`. Falls back
|
|
17
|
+
* to the file's directory if nothing is found. */
|
|
18
|
+
export function projectRootFor(filePath) {
|
|
19
|
+
let dir = resolvePath(filePath);
|
|
20
|
+
try {
|
|
21
|
+
dir = realpathSync(dir);
|
|
22
|
+
}
|
|
23
|
+
catch { }
|
|
24
|
+
let prev = "";
|
|
25
|
+
while (dir !== prev) {
|
|
26
|
+
if (dirHas(dir, "Package.swift") ||
|
|
27
|
+
dirHasGlob(dir, ".xcodeproj") ||
|
|
28
|
+
dirHasGlob(dir, ".xcworkspace")) {
|
|
29
|
+
return dir;
|
|
30
|
+
}
|
|
31
|
+
prev = dir;
|
|
32
|
+
dir = resolvePath(dir, "..");
|
|
33
|
+
}
|
|
34
|
+
// No marker found — use the original directory.
|
|
35
|
+
return resolvePath(filePath, "..");
|
|
36
|
+
}
|
|
37
|
+
function dirHas(dir, name) {
|
|
38
|
+
try {
|
|
39
|
+
return existsSync(resolvePath(dir, name));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function dirHasGlob(dir, suffix) {
|
|
46
|
+
try {
|
|
47
|
+
return readdirSync(dir).some((entry) => entry.endsWith(suffix));
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Acquire an LSP client for a project root. Reuses an existing one if
|
|
54
|
+
* warm, spawns + initializes one otherwise. */
|
|
55
|
+
export async function acquireClient(projectRoot, opts = {}) {
|
|
56
|
+
const key = resolvePath(projectRoot);
|
|
57
|
+
const idleMs = opts.idleMs ?? DEFAULT_IDLE_MS;
|
|
58
|
+
let entry = pool.get(key);
|
|
59
|
+
if (!entry) {
|
|
60
|
+
const client = await createSourceKitClient({ projectRoot: key });
|
|
61
|
+
entry = { client, lastUsed: Date.now() };
|
|
62
|
+
pool.set(key, entry);
|
|
63
|
+
}
|
|
64
|
+
entry.lastUsed = Date.now();
|
|
65
|
+
if (entry.idleTimer)
|
|
66
|
+
clearTimeout(entry.idleTimer);
|
|
67
|
+
entry.idleTimer = setTimeout(() => {
|
|
68
|
+
void shutdownClient(key);
|
|
69
|
+
}, idleMs);
|
|
70
|
+
return entry.client;
|
|
71
|
+
}
|
|
72
|
+
/** Manually shut down the client for a given project root. */
|
|
73
|
+
export async function shutdownClient(projectRoot) {
|
|
74
|
+
const key = resolvePath(projectRoot);
|
|
75
|
+
const entry = pool.get(key);
|
|
76
|
+
if (!entry)
|
|
77
|
+
return;
|
|
78
|
+
pool.delete(key);
|
|
79
|
+
if (entry.idleTimer)
|
|
80
|
+
clearTimeout(entry.idleTimer);
|
|
81
|
+
await entry.client.dispose();
|
|
82
|
+
}
|
|
83
|
+
/** Shut down all pooled clients. Useful in tests + on process exit. */
|
|
84
|
+
export async function shutdownAll() {
|
|
85
|
+
const keys = Array.from(pool.keys());
|
|
86
|
+
for (const key of keys) {
|
|
87
|
+
await shutdownClient(key);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Best-effort cleanup on process exit.
|
|
91
|
+
process.once("exit", () => {
|
|
92
|
+
// Synchronous only — async cleanups won't run here, but the OS will
|
|
93
|
+
// reap the subprocess.
|
|
94
|
+
});
|
|
95
|
+
process.once("SIGINT", () => {
|
|
96
|
+
void shutdownAll().finally(() => process.exit(0));
|
|
97
|
+
});
|
|
98
|
+
process.once("SIGTERM", () => {
|
|
99
|
+
void shutdownAll().finally(() => process.exit(0));
|
|
100
|
+
});
|
|
101
|
+
//# sourceMappingURL=pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../../src/runtime/sourcekit/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,qBAAqB,GAEtB,MAAM,aAAa,CAAC;AAUrB,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,YAAY;AAChD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAqB,CAAC;AAE1C;;mDAEmD;AACnD,MAAM,UAAU,cAAc,CAAC,QAAgB;IAC7C,IAAI,GAAG,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAChC,IAAI,CAAC;QACH,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC;QACpB,IACE,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC;YAC5B,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC;YAC7B,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC,EAC/B,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QACD,IAAI,GAAG,GAAG,CAAC;QACX,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IACD,gDAAgD;IAChD,OAAO,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,MAAM,CAAC,GAA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CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed wrappers around the LSP methods we use.
|
|
3
|
+
*
|
|
4
|
+
* Imports types from `vscode-languageserver-protocol` and converts to/from
|
|
5
|
+
* the file:// URI format LSP servers expect. All paths in the public API
|
|
6
|
+
* are absolute filesystem paths; LSP URIs only show up internally.
|
|
7
|
+
*/
|
|
8
|
+
import type { InitializedClient } from "./client.js";
|
|
9
|
+
export interface SourceLocation {
|
|
10
|
+
filePath: string;
|
|
11
|
+
line: number;
|
|
12
|
+
character: number;
|
|
13
|
+
/** Optional end position when the LSP server returns a range. */
|
|
14
|
+
endLine?: number;
|
|
15
|
+
endCharacter?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolvedSymbol {
|
|
18
|
+
name: string;
|
|
19
|
+
kind: string;
|
|
20
|
+
filePath: string;
|
|
21
|
+
startLine: number;
|
|
22
|
+
startCharacter: number;
|
|
23
|
+
endLine: number;
|
|
24
|
+
endCharacter: number;
|
|
25
|
+
/** Children symbols (methods inside a class, properties, etc.) when hierarchical. */
|
|
26
|
+
children?: ResolvedSymbol[];
|
|
27
|
+
}
|
|
28
|
+
/** LSP `textDocument/definition` — returns 0+ source locations. */
|
|
29
|
+
export declare function lspDefinition(client: InitializedClient, filePath: string, line: number, character: number): Promise<SourceLocation[]>;
|
|
30
|
+
/** LSP `textDocument/references` — returns all references in indexed projects. */
|
|
31
|
+
export declare function lspReferences(client: InitializedClient, filePath: string, line: number, character: number, includeDeclaration?: boolean): Promise<SourceLocation[]>;
|
|
32
|
+
/** LSP `textDocument/hover` — returns type info / docs at a position. */
|
|
33
|
+
export declare function lspHover(client: InitializedClient, filePath: string, line: number, character: number): Promise<{
|
|
34
|
+
contents: string;
|
|
35
|
+
} | null>;
|
|
36
|
+
/** LSP `textDocument/documentSymbol` — returns top-level + nested symbols. */
|
|
37
|
+
export declare function lspDocumentSymbol(client: InitializedClient, filePath: string): Promise<ResolvedSymbol[]>;
|