memorydetective 1.0.1 → 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 +48 -1
- package/LICENSE +201 -21
- package/NOTICE +19 -0
- package/README.md +22 -23
- package/dist/cli.js +49 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -1
- package/dist/parsers/shortenClassName.d.ts +45 -0
- package/dist/parsers/shortenClassName.js +155 -0
- package/dist/parsers/shortenClassName.js.map +1 -0
- 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/analyzeMemgraph.d.ts +11 -2
- package/dist/tools/analyzeMemgraph.js +37 -9
- package/dist/tools/analyzeMemgraph.js.map +1 -1
- package/dist/tools/findCycles.d.ts +6 -2
- package/dist/tools/findCycles.js +11 -6
- package/dist/tools/findCycles.js.map +1 -1
- package/dist/tools/reachableFromCycle.d.ts +61 -0
- package/dist/tools/reachableFromCycle.js +116 -0
- package/dist/tools/reachableFromCycle.js.map +1 -0
- package/dist/tools/renderCycleGraph.d.ts +1 -1
- 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 +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,51 @@ 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
|
+
|
|
31
|
+
## [1.1.0] — 2026-05-01
|
|
32
|
+
|
|
33
|
+
Response-size + cycle-scoped queries + license switch + first-run engagement.
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- **`reachableFromCycle` tool** — cycle-scoped reachability + per-class counting. Pick a cycle by `cycleIndex` or `rootClassName` substring, get instance counts of every class reachable from that cycle root. Distinguishes the actual culprit (the cycle root) from its retained dependencies. API shape inspired by Meta's `memlab` predicate-based queries. Tool count: 19 → 20.
|
|
38
|
+
- **`verbosity` parameter** on `analyzeMemgraph`, `findCycles`, and `reachableFromCycle`. Three levels: `compact` (default — drops module prefixes, collapses nested SwiftUI `ModifiedContent` into `+N modifiers`, truncates deep generics with a hash placeholder), `normal` (lighter shortening, depth preserved), `full` (Swift demangled names verbatim).
|
|
39
|
+
- **`maxClassesInChain` parameter** on `analyzeMemgraph` (default 10). Caps the per-cycle `classesInChain` array to the top N unique classes ranked by occurrence count, with app-level types prioritized over SwiftUI internals. The full unique-class total is reported in a new `classesInChainTotal` field for context.
|
|
40
|
+
- **Class-name shortener** (`src/parsers/shortenClassName.ts`) — three layers (drop modules, collapse `ModifiedContent` chains, truncate deep generics) with deterministic hash placeholders so the same nested type produces the same short code across runs (useful for diffing two memgraphs).
|
|
41
|
+
- **First-run CLI banner** — first time `memorydetective` runs in non-JSON mode on a machine, prints a one-time message pointing at the GitHub repo, `USAGE.md`, and the sponsor link. Marker stored at `~/.config/memorydetective/seen` so it never re-prints.
|
|
42
|
+
- **Help / output footers** — `--help` and `analyze`/`classify` non-JSON output append a discreet `# ⭐ github.com/carloshpdoc/memorydetective` line. JSON output is untouched (won't break pipes / CI).
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- **License: MIT → Apache 2.0.** Permissions are unchanged for users (commercial use, modification, distribution all allowed). Apache 2.0 adds an explicit patent grant + a `NOTICE` file mechanism; the `NOTICE` file ships in the npm tarball and surfaces project attribution in downstream "About" / acknowledgements screens.
|
|
47
|
+
- `analyzeMemgraph` default response is now ~80% smaller for SwiftUI-heavy memgraphs (the per-cycle `classesInChain` no longer floods with hundreds of demangled SwiftUI generics; class names per node compress from 1000+ chars to ~200). Full-fidelity output is still available via `verbosity: "full"`.
|
|
48
|
+
- README: license badge updated to Apache 2.0; tool count updated 19 → 20.
|
|
49
|
+
|
|
50
|
+
### Notes
|
|
51
|
+
|
|
52
|
+
- No breaking changes — all new parameters have sensible defaults. Old callers continue to work; they just receive smaller, more readable responses.
|
|
53
|
+
|
|
9
54
|
## [1.0.1] — 2026-05-01
|
|
10
55
|
|
|
11
56
|
### Added
|
|
@@ -74,6 +119,8 @@ When called with no arguments it starts the MCP server over stdio.
|
|
|
74
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.
|
|
75
120
|
- **`detectLeaksInXCUITest`** is flagged experimental: orchestration logic is implemented but not yet validated against a wide set of production XCUITest runs.
|
|
76
121
|
|
|
77
|
-
[Unreleased]: https://github.com/carloshpdoc/memorydetective/compare/v1.0
|
|
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
|
|
124
|
+
[1.1.0]: https://github.com/carloshpdoc/memorydetective/compare/v1.0.1...v1.1.0
|
|
78
125
|
[1.0.1]: https://github.com/carloshpdoc/memorydetective/compare/v1.0.0...v1.0.1
|
|
79
126
|
[1.0.0]: https://github.com/carloshpdoc/memorydetective/releases/tag/v1.0.0
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Carlos Henrique
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
memorydetective
|
|
2
|
+
Copyright 2026 Carlos Henrique
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License").
|
|
5
|
+
A copy of the License is included in this distribution as `LICENSE`,
|
|
6
|
+
and is also available at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Project home:
|
|
11
|
+
https://github.com/carloshpdoc/memorydetective
|
|
12
|
+
|
|
13
|
+
This product includes software developed by Carlos Henrique
|
|
14
|
+
(https://github.com/carloshpdoc).
|
|
15
|
+
|
|
16
|
+
If `memorydetective` saves you time, please consider:
|
|
17
|
+
• Starring the repository: https://github.com/carloshpdoc/memorydetective
|
|
18
|
+
• Sponsoring development: https://github.com/sponsors/carloshpdoc
|
|
19
|
+
• Buying me a coffee: https://buymeacoffee.com/carloshperc
|
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/memorydetective)
|
|
6
6
|
[](https://github.com/carloshpdoc/memorydetective/actions/workflows/ci.yml)
|
|
7
|
-
[](./LICENSE)
|
|
8
|
+
[](https://github.com/carloshpdoc/memorydetective/stargazers)
|
|
8
9
|
[](#requirements)
|
|
9
10
|
[](#requirements)
|
|
10
11
|
|
|
@@ -176,9 +177,9 @@ Copilot's MCP integration moves fast — if this snippet is stale, see the [VS C
|
|
|
176
177
|
|
|
177
178
|
## API
|
|
178
179
|
|
|
179
|
-
|
|
180
|
+
25 MCP tools, grouped by purpose.
|
|
180
181
|
|
|
181
|
-
### Read & analyze (
|
|
182
|
+
### Read & analyze (13)
|
|
182
183
|
|
|
183
184
|
| Tool | What |
|
|
184
185
|
|---|---|
|
|
@@ -186,6 +187,7 @@ Copilot's MCP integration moves fast — if this snippet is stale, see the [VS C
|
|
|
186
187
|
| `findCycles` | Extract just the ROOT CYCLE blocks as flattened chains, with optional `className` substring filter. |
|
|
187
188
|
| `findRetainers` | "Who is keeping `<class>` alive?" — returns retain chain paths from a top-level node down to the match. |
|
|
188
189
|
| `countAlive` | Count instances by class. Provide `className` for one number, or omit for top-N most-leaked classes. |
|
|
190
|
+
| `reachableFromCycle` | Cycle-scoped reachability. "How many `<X>` instances are reachable from the cycle rooted at `<Y>`?" — distinguishes the actual culprit from its retained dependencies. |
|
|
189
191
|
| `diffMemgraphs` | Compare two `.memgraph` snapshots: total deltas + class-count changes + cycles new/gone/persisted. |
|
|
190
192
|
| `classifyCycle` | Match each ROOT CYCLE against a built-in catalog of 8 known patterns (TagIndexProjection, ForEachState, Combine sink, Task captures, NotificationCenter observer, etc.) with confidence + fix hint. |
|
|
191
193
|
| `analyzeHangs` | Parse `xctrace` `potential-hangs` schema; return Hang vs Microhang counts + top N longest. |
|
|
@@ -222,6 +224,20 @@ Copilot's MCP integration moves fast — if this snippet is stale, see the [VS C
|
|
|
222
224
|
|---|---|
|
|
223
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. |
|
|
224
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
|
+
|
|
225
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.
|
|
226
242
|
|
|
227
243
|
### CLI mode
|
|
@@ -273,17 +289,6 @@ Contributions are welcome — bug reports, feature requests, new cycle patterns,
|
|
|
273
289
|
|
|
274
290
|
In v0.2 the catalog moves to a separate repo so patterns can be added without modifying the server code.
|
|
275
291
|
|
|
276
|
-
### Working on the demo GIF
|
|
277
|
-
|
|
278
|
-
The demo GIF is generated deterministically from `examples/demo.tape` via [vhs](https://github.com/charmbracelet/vhs):
|
|
279
|
-
|
|
280
|
-
```bash
|
|
281
|
-
brew install vhs
|
|
282
|
-
vhs examples/demo.tape
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
The `.tape` file is committed; the `.gif` is regenerated from it. If you change the demo flow, please update both.
|
|
286
|
-
|
|
287
292
|
## Support this project
|
|
288
293
|
|
|
289
294
|
If `memorydetective` saves you time, you can support continued development:
|
|
@@ -293,17 +298,11 @@ If `memorydetective` saves you time, you can support continued development:
|
|
|
293
298
|
|
|
294
299
|
Every contribution helps keep this maintained and documented.
|
|
295
300
|
|
|
296
|
-
## Roadmap
|
|
297
|
-
|
|
298
|
-
- **v0.1.x** (current) — 12 MCP tools, 8 cycle patterns, CLI mode.
|
|
299
|
-
- **v0.2** — community-contributable cycle catalog, Claude Code plugin (`/plugin install memorydetective`), close the `analyzeTimeProfile` SIGSEGV gap. Design docs in [docs/](./docs/).
|
|
300
|
-
- **Phase 3** (gated) — GitHub Action + SaaS dashboard for PR-time leak detection.
|
|
301
|
-
|
|
302
|
-
See [docs/v0.2-roadmap.md](./docs/v0.2-roadmap.md) for the full plan.
|
|
303
|
-
|
|
304
301
|
## License
|
|
305
302
|
|
|
306
|
-
|
|
303
|
+
Apache 2.0 — see [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|
|
304
|
+
|
|
305
|
+
Permits commercial use, modification, distribution, patent use. Includes attribution clause via the `NOTICE` file.
|
|
307
306
|
|
|
308
307
|
## Why "memorydetective"?
|
|
309
308
|
|
package/dist/cli.js
CHANGED
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
* memorydetective --help
|
|
11
11
|
* memorydetective --version
|
|
12
12
|
*/
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
14
|
-
import {
|
|
13
|
+
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { resolve as resolvePath, join as joinPath } from "node:path";
|
|
15
16
|
import { analyzeMemgraph } from "./tools/analyzeMemgraph.js";
|
|
16
17
|
import { classifyCycle } from "./tools/classifyCycle.js";
|
|
17
18
|
const C = {
|
|
@@ -24,7 +25,7 @@ const C = {
|
|
|
24
25
|
cyan: "\x1b[36m",
|
|
25
26
|
gray: "\x1b[90m",
|
|
26
27
|
};
|
|
27
|
-
const VERSION = "1.0
|
|
28
|
+
const VERSION = "1.2.0";
|
|
28
29
|
const HELP = `${C.bold}memorydetective${C.reset} — iOS leak hunting from the CLI
|
|
29
30
|
|
|
30
31
|
${C.dim}Usage:${C.reset}
|
|
@@ -39,8 +40,38 @@ ${C.dim}Flags:${C.reset}
|
|
|
39
40
|
|
|
40
41
|
${C.dim}When called with no arguments, memorydetective starts as an MCP server${C.reset}
|
|
41
42
|
${C.dim}over stdio. See https://github.com/carloshpdoc/memorydetective#configure${C.reset}
|
|
42
|
-
${C.dim}for full Claude Code / Desktop / Cursor / Cline configuration.${C.reset}
|
|
43
|
+
${C.dim}for full Claude Code / Desktop / Cursor / Cline / Kiro configuration.${C.reset}
|
|
44
|
+
|
|
45
|
+
${C.dim}⭐ Star: ${C.reset}https://github.com/carloshpdoc/memorydetective
|
|
46
|
+
`;
|
|
47
|
+
const FIRST_RUN_BANNER = `
|
|
48
|
+
${C.bold}👋 First time using memorydetective?${C.reset}
|
|
49
|
+
|
|
50
|
+
${C.green}⭐ Star:${C.reset} https://github.com/carloshpdoc/memorydetective
|
|
51
|
+
${C.cyan}📖 Guide:${C.reset} https://github.com/carloshpdoc/memorydetective/blob/main/USAGE.md
|
|
52
|
+
${C.yellow}☕ Sponsor:${C.reset} https://buymeacoffee.com/carloshperc
|
|
53
|
+
|
|
54
|
+
${C.dim}This message shows once.${C.reset}
|
|
43
55
|
`;
|
|
56
|
+
const FIRST_RUN_MARKER = joinPath(homedir(), ".config", "memorydetective", "seen");
|
|
57
|
+
/** Show the first-time banner once per machine, then create a marker so it
|
|
58
|
+
* never shows again. Failures (e.g. read-only home) are silent — banner
|
|
59
|
+
* hygiene shouldn't break the user's actual work. */
|
|
60
|
+
function maybeShowFirstRunBanner() {
|
|
61
|
+
try {
|
|
62
|
+
if (existsSync(FIRST_RUN_MARKER))
|
|
63
|
+
return;
|
|
64
|
+
process.stderr.write(FIRST_RUN_BANNER + "\n");
|
|
65
|
+
mkdirSync(joinPath(homedir(), ".config", "memorydetective"), {
|
|
66
|
+
recursive: true,
|
|
67
|
+
});
|
|
68
|
+
writeFileSync(FIRST_RUN_MARKER, new Date().toISOString());
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// ignore — never fail because of the banner
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const DIAGNOSIS_FOOTER = `${C.dim}# Found this useful? ⭐ https://github.com/carloshpdoc/memorydetective${C.reset}`;
|
|
44
75
|
const KNOWN_COMMANDS = ["analyze", "classify", "--help", "-h", "help", "--version", "-v"];
|
|
45
76
|
function truncate(s, max) {
|
|
46
77
|
return s.length > max ? s.slice(0, max - 1) + "…" : s;
|
|
@@ -128,7 +159,12 @@ function suggestCommand(input) {
|
|
|
128
159
|
}
|
|
129
160
|
async function runAnalyze(memgraphPath, asJson) {
|
|
130
161
|
validateMemgraphPath(memgraphPath);
|
|
131
|
-
const result = await analyzeMemgraph({
|
|
162
|
+
const result = await analyzeMemgraph({
|
|
163
|
+
path: memgraphPath,
|
|
164
|
+
fullChains: false,
|
|
165
|
+
verbosity: "compact",
|
|
166
|
+
maxClassesInChain: 10,
|
|
167
|
+
});
|
|
132
168
|
if (asJson) {
|
|
133
169
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
134
170
|
return 0;
|
|
@@ -155,6 +191,7 @@ async function runAnalyze(memgraphPath, asJson) {
|
|
|
155
191
|
}
|
|
156
192
|
console.log(`\n ${C.bold}Diagnosis:${C.reset}`);
|
|
157
193
|
console.log(` ${C.green}${result.diagnosis}${C.reset}\n`);
|
|
194
|
+
console.log(DIAGNOSIS_FOOTER + "\n");
|
|
158
195
|
return 0;
|
|
159
196
|
}
|
|
160
197
|
async function runClassify(memgraphPath, asJson) {
|
|
@@ -190,9 +227,16 @@ async function runClassify(memgraphPath, asJson) {
|
|
|
190
227
|
}
|
|
191
228
|
}
|
|
192
229
|
console.log("");
|
|
230
|
+
console.log(DIAGNOSIS_FOOTER + "\n");
|
|
193
231
|
return 0;
|
|
194
232
|
}
|
|
195
233
|
export async function runCli(args) {
|
|
234
|
+
// Fire the first-run banner before dispatching anything heavy. JSON-mode
|
|
235
|
+
// callers shouldn't see it (might mess with their pipes), so we only show
|
|
236
|
+
// it for human-output commands.
|
|
237
|
+
const isJsonRun = args.includes("--json");
|
|
238
|
+
if (!isJsonRun)
|
|
239
|
+
maybeShowFirstRunBanner();
|
|
196
240
|
const [cmd, ...rest] = args;
|
|
197
241
|
try {
|
|
198
242
|
switch (cmd) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,WAA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IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,IAAI,GAAG,UAAU,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrF,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,KAAK,qBAAqB,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC;gBAC3E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC3B,OAAO,CAAC,CAAC;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,KAAK,IAAI,QAAQ,EAAE,CAAC,CAAC;QACtD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,8 @@ import { analyzeAppLaunch, analyzeAppLaunchSchema, } from "./tools/analyzeAppLau
|
|
|
19
19
|
import { renderCycleGraph, renderCycleGraphSchema, } from "./tools/renderCycleGraph.js";
|
|
20
20
|
import { logShow, logShowSchema, logStream, logStreamSchema, } from "./tools/logShow.js";
|
|
21
21
|
import { detectLeaksInXCUITest, detectLeaksInXCUITestSchema, } from "./tools/detectLeaksInXCUITest.js";
|
|
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";
|
|
22
24
|
const SERVER_NAME = "memorydetective";
|
|
23
25
|
const SERVER_VERSION = "0.1.0-dev";
|
|
24
26
|
const server = new McpServer({
|
|
@@ -211,6 +213,56 @@ server.registerTool("detectLeaksInXCUITest", {
|
|
|
211
213
|
const result = await detectLeaksInXCUITest(input);
|
|
212
214
|
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
213
215
|
});
|
|
216
|
+
server.registerTool("reachableFromCycle", {
|
|
217
|
+
title: "Count instances reachable from a specific cycle root",
|
|
218
|
+
description: "Cycle-scoped reachability + class counting. Answers questions like \"how many `NSURLSessionConfiguration` instances are reachable from the cycle rooted at `DetailViewModel`?\" — distinguishing the actual culprit (the cycle root) from its retained dependencies. Pick a cycle by zero-based `cycleIndex` or by `rootClassName` substring. Returns per-class counts ranked by occurrence, plus the total reachable node count.",
|
|
219
|
+
inputSchema: reachableFromCycleSchema.shape,
|
|
220
|
+
}, async (input) => {
|
|
221
|
+
const result = await reachableFromCycle(input);
|
|
222
|
+
return {
|
|
223
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
|
|
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
|
+
});
|
|
214
266
|
async function main() {
|
|
215
267
|
// CLI mode: when called with arguments, run the synchronous CLI wrapper.
|
|
216
268
|
// No arguments → start the MCP server over stdio (the default and the
|