memtrace 0.1.2-2.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/README.md +242 -0
- package/bin/memtrace.js +25 -0
- package/install.js +236 -0
- package/package.json +39 -0
- package/skills/commands/memtrace-api-topology.md +62 -0
- package/skills/commands/memtrace-evolution.md +119 -0
- package/skills/commands/memtrace-graph.md +67 -0
- package/skills/commands/memtrace-impact.md +61 -0
- package/skills/commands/memtrace-index.md +63 -0
- package/skills/commands/memtrace-quality.md +66 -0
- package/skills/commands/memtrace-relationships.md +70 -0
- package/skills/commands/memtrace-search.md +62 -0
- package/skills/workflows/memtrace-change-impact-analysis.md +85 -0
- package/skills/workflows/memtrace-codebase-exploration.md +108 -0
- package/skills/workflows/memtrace-incident-investigation.md +104 -0
- package/skills/workflows/memtrace-refactoring-guide.md +116 -0
package/README.md
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/syncable-dev/memtrace-public/main/assets/logo.svg" alt="Memtrace" width="120" height="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Memtrace</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Code intelligence graph for AI agents</strong><br/>
|
|
9
|
+
Structural search · Relationship analysis · Temporal evolution · Architectural understanding
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/memtrace"><img src="https://img.shields.io/npm/v/memtrace?style=flat-square&color=00D4B8&label=npm" alt="npm version" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/memtrace"><img src="https://img.shields.io/npm/dm/memtrace?style=flat-square&color=0A1628&label=downloads" alt="npm downloads" /></a>
|
|
15
|
+
<a href="https://github.com/syncable-dev/memtrace-public/stargazers"><img src="https://img.shields.io/github/stars/syncable-dev/memtrace-public?style=flat-square&color=00D4B8" alt="GitHub stars" /></a>
|
|
16
|
+
<a href="https://github.com/syncable-dev/memtrace-public/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Proprietary%20EULA-0A1628?style=flat-square" alt="license" /></a>
|
|
17
|
+
<a href="https://memtrace.dev"><img src="https://img.shields.io/badge/docs-memtrace.dev-00D4B8?style=flat-square" alt="docs" /></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="#quick-start">Quick Start</a> ·
|
|
22
|
+
<a href="#skills">Skills</a> ·
|
|
23
|
+
<a href="#mcp-tools">MCP Tools</a> ·
|
|
24
|
+
<a href="#evolution-engine">Evolution Engine</a> ·
|
|
25
|
+
<a href="#claude-code-setup">Claude Code</a> ·
|
|
26
|
+
<a href="#claude-desktop-setup">Claude Desktop</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
Memtrace is an MCP server that builds a **persistent knowledge graph** from your codebase. It parses source files, resolves cross-file relationships, detects API endpoints, runs community detection, and embeds all symbols for semantic search — then exposes 25+ tools via the [Model Context Protocol](https://modelcontextprotocol.io) so AI agents can explore, analyze, and reason about your code structurally.
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Install (binary + skills + MCP server — all in one)
|
|
37
|
+
npm install -g memtrace
|
|
38
|
+
|
|
39
|
+
# Start the graph database
|
|
40
|
+
memtrace start
|
|
41
|
+
|
|
42
|
+
# Index your project
|
|
43
|
+
memtrace index /path/to/your/project
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
That's it. The installer handles everything:
|
|
47
|
+
|
|
48
|
+
| Step | What happens |
|
|
49
|
+
|------|-------------|
|
|
50
|
+
| **Binary** | Platform-specific native binary installed via npm |
|
|
51
|
+
| **Skills** | 12 AI agent skills written to `~/.claude/skills/` and plugin cache |
|
|
52
|
+
| **Plugin** | `memtrace-skills@memtrace` enabled in `~/.claude/settings.json` |
|
|
53
|
+
| **Marketplace** | GitHub marketplace registered for auto-updates |
|
|
54
|
+
| **MCP Server** | `memtrace mcp` registered in `mcpServers` |
|
|
55
|
+
|
|
56
|
+
> **Zero configuration required** — just install and start exploring your codebase with Claude.
|
|
57
|
+
|
|
58
|
+
## Skills
|
|
59
|
+
|
|
60
|
+
Memtrace ships with **12 skills** that teach Claude _how_ to use the knowledge graph. Skills fire automatically based on what you ask.
|
|
61
|
+
|
|
62
|
+
### Command Skills
|
|
63
|
+
|
|
64
|
+
| Skill | Triggers when you say... |
|
|
65
|
+
|:------|:------------------------|
|
|
66
|
+
| `memtrace-index` | _"index this project"_, _"set up code intelligence"_, _"parse this codebase"_ |
|
|
67
|
+
| `memtrace-search` | _"find this function"_, _"where is X defined"_, _"search for authentication logic"_ |
|
|
68
|
+
| `memtrace-relationships` | _"who calls this"_, _"what does this function call"_, _"show class hierarchy"_ |
|
|
69
|
+
| `memtrace-evolution` | _"what changed this week"_, _"how did this evolve"_, _"what's different since Monday"_ |
|
|
70
|
+
| `memtrace-impact` | _"what will break if I change this"_, _"blast radius"_, _"risk assessment"_ |
|
|
71
|
+
| `memtrace-quality` | _"find dead code"_, _"complexity hotspots"_, _"code smells"_ |
|
|
72
|
+
| `memtrace-graph` | _"show me the architecture"_, _"find bottlenecks"_, _"most important functions"_ |
|
|
73
|
+
| `memtrace-api-topology` | _"list API endpoints"_, _"service dependencies"_, _"who calls this API"_ |
|
|
74
|
+
|
|
75
|
+
### Workflow Skills
|
|
76
|
+
|
|
77
|
+
Multi-step orchestrations that chain tools together with decision logic:
|
|
78
|
+
|
|
79
|
+
| Skill | Triggers when you say... |
|
|
80
|
+
|:------|:------------------------|
|
|
81
|
+
| `memtrace-codebase-exploration` | _"explore this codebase"_, _"I'm new to this project"_, _"give me an overview"_ |
|
|
82
|
+
| `memtrace-change-impact-analysis` | _"what will break if I refactor this"_, _"pre-change risk assessment"_ |
|
|
83
|
+
| `memtrace-incident-investigation` | _"something broke"_, _"root cause analysis"_, _"what went wrong"_ |
|
|
84
|
+
| `memtrace-refactoring-guide` | _"help me refactor"_, _"reduce complexity"_, _"clean up tech debt"_ |
|
|
85
|
+
|
|
86
|
+
## MCP Tools
|
|
87
|
+
|
|
88
|
+
25+ tools exposed via the Model Context Protocol:
|
|
89
|
+
|
|
90
|
+
<table>
|
|
91
|
+
<tr>
|
|
92
|
+
<td width="50%" valign="top">
|
|
93
|
+
|
|
94
|
+
**Search & Discovery**
|
|
95
|
+
- `find_code` — hybrid BM25 + semantic search with RRF
|
|
96
|
+
- `find_symbol` — exact/fuzzy name match with Levenshtein
|
|
97
|
+
|
|
98
|
+
**Relationships**
|
|
99
|
+
- `analyze_relationships` — callers, callees, hierarchy, imports
|
|
100
|
+
- `get_symbol_context` — 360° view in one call
|
|
101
|
+
|
|
102
|
+
**Impact Analysis**
|
|
103
|
+
- `get_impact` — blast radius with risk rating
|
|
104
|
+
- `detect_changes` — diff-to-symbols scope mapping
|
|
105
|
+
|
|
106
|
+
**Code Quality**
|
|
107
|
+
- `find_dead_code` — zero-caller detection
|
|
108
|
+
- `find_most_complex_functions` — complexity hotspots
|
|
109
|
+
- `calculate_cyclomatic_complexity` — per-symbol scoring
|
|
110
|
+
- `get_repository_stats` — repo-wide metrics
|
|
111
|
+
|
|
112
|
+
</td>
|
|
113
|
+
<td width="50%" valign="top">
|
|
114
|
+
|
|
115
|
+
**Temporal Analysis**
|
|
116
|
+
- `get_evolution` — 6 scoring modes (see below)
|
|
117
|
+
- `get_timeline` — full symbol version history
|
|
118
|
+
- `detect_changes` — diff-based impact scope
|
|
119
|
+
|
|
120
|
+
**Graph Algorithms**
|
|
121
|
+
- `find_bridge_symbols` — betweenness centrality
|
|
122
|
+
- `find_central_symbols` — PageRank / degree
|
|
123
|
+
- `list_communities` — Louvain module detection
|
|
124
|
+
- `list_processes` / `get_process_flow` — execution tracing
|
|
125
|
+
|
|
126
|
+
**API Topology**
|
|
127
|
+
- `get_api_topology` — cross-repo HTTP call graph
|
|
128
|
+
- `find_api_endpoints` — all exposed routes
|
|
129
|
+
- `find_api_calls` — all outbound HTTP calls
|
|
130
|
+
|
|
131
|
+
**Indexing & Watch**
|
|
132
|
+
- `index_directory` — parse, resolve, embed
|
|
133
|
+
- `watch_directory` — live incremental re-indexing
|
|
134
|
+
- `execute_cypher` — direct graph queries
|
|
135
|
+
|
|
136
|
+
</td>
|
|
137
|
+
</tr>
|
|
138
|
+
</table>
|
|
139
|
+
|
|
140
|
+
## Evolution Engine
|
|
141
|
+
|
|
142
|
+
The temporal analysis engine implements **six distinct scoring algorithms** — choose the right one for the question you're asking:
|
|
143
|
+
|
|
144
|
+
| Mode | Formula | Best for |
|
|
145
|
+
|:-----|:--------|:---------|
|
|
146
|
+
| **`compound`** | `0.50 × rank(impact) + 0.35 × rank(novel) + 0.15 × rank(recent)` | General-purpose _"what changed?"_ |
|
|
147
|
+
| **`impact`** | `sig(n) = in_degree^0.7 × (1 + out_degree)^0.3` | _"What broke?"_ — largest blast radius |
|
|
148
|
+
| **`novel`** | `surprise(n) = (1 + in_degree) / (1 + change_freq_90d)` | _"What's unexpected?"_ — anomaly detection |
|
|
149
|
+
| **`recent`** | `impact × exp(−0.5 × Δhours)` | _"What changed near the incident?"_ |
|
|
150
|
+
| **`directional`** | Asymmetric: added → out_degree, removed → in_degree | _"What was added vs removed?"_ |
|
|
151
|
+
| **`overview`** | Module-level rollup only | Quick summary, no per-symbol scoring |
|
|
152
|
+
|
|
153
|
+
Uses **Structural Significance Budgeting (SSB)** to select the minimum set of changes covering ≥80% of total significance — surfaces what matters without drowning you in noise.
|
|
154
|
+
|
|
155
|
+
## Claude Code Setup
|
|
156
|
+
|
|
157
|
+
`npm install -g memtrace` handles everything. For manual setup:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# 1. Register the marketplace
|
|
161
|
+
claude plugin marketplace add syncable-dev/memtrace
|
|
162
|
+
|
|
163
|
+
# 2. Install the skills plugin
|
|
164
|
+
claude plugin install memtrace-skills@memtrace --scope user
|
|
165
|
+
|
|
166
|
+
# 3. Register the MCP server
|
|
167
|
+
claude mcp add memtrace -- memtrace mcp -e MEMGRAPH_URL=bolt://localhost:7687
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
<details>
|
|
171
|
+
<summary><strong>What this writes to <code>~/.claude/settings.json</code></strong></summary>
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{
|
|
175
|
+
"mcpServers": {
|
|
176
|
+
"memtrace": {
|
|
177
|
+
"command": "memtrace",
|
|
178
|
+
"args": ["mcp"],
|
|
179
|
+
"env": { "MEMGRAPH_URL": "bolt://localhost:7687" }
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"enabledPlugins": {
|
|
183
|
+
"memtrace-skills@memtrace": true
|
|
184
|
+
},
|
|
185
|
+
"extraKnownMarketplaces": {
|
|
186
|
+
"memtrace": {
|
|
187
|
+
"source": { "source": "github", "repo": "syncable-dev/memtrace" }
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
</details>
|
|
194
|
+
|
|
195
|
+
### Installing skills separately
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npx memtrace-skills install # install skills + register MCP
|
|
199
|
+
npx memtrace-skills uninstall # remove everything
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Claude Desktop Setup
|
|
203
|
+
|
|
204
|
+
Skills are installed to `~/.claude/skills/` which is shared between Claude Code and Claude Desktop — both pick up skills automatically after `npm install -g memtrace`.
|
|
205
|
+
|
|
206
|
+
Add the MCP server to your `claude_desktop_config.json`:
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"mcpServers": {
|
|
211
|
+
"memtrace": {
|
|
212
|
+
"command": "memtrace",
|
|
213
|
+
"args": ["mcp"],
|
|
214
|
+
"env": { "MEMGRAPH_URL": "bolt://localhost:7687" }
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Supported Languages
|
|
221
|
+
|
|
222
|
+
Rust · Go · TypeScript · JavaScript · Python · Java · C · C++ · C# · Swift · Kotlin · Ruby · PHP · Dart · Scala · Perl — and more via Tree-sitter.
|
|
223
|
+
|
|
224
|
+
## Requirements
|
|
225
|
+
|
|
226
|
+
| Dependency | Purpose |
|
|
227
|
+
|:-----------|:--------|
|
|
228
|
+
| **Memgraph** | Knowledge graph backend — auto-managed via `memtrace start` |
|
|
229
|
+
| **Node.js ≥ 18** | npm installation |
|
|
230
|
+
| **Git** | Temporal analysis (commit history) |
|
|
231
|
+
|
|
232
|
+
## Links
|
|
233
|
+
|
|
234
|
+
- [Documentation](https://memtrace.dev)
|
|
235
|
+
- [npm Package](https://www.npmjs.com/package/memtrace)
|
|
236
|
+
- [Report an Issue](https://github.com/syncable-dev/memtrace-public/issues)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
<p align="center">
|
|
241
|
+
<sub>Built by <a href="https://syncable.dev">Syncable</a> · <a href="LICENSE">Proprietary EULA</a> · Free to use</sub>
|
|
242
|
+
</p>
|
package/bin/memtrace.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require("child_process");
|
|
5
|
+
const { getBinaryPath } = require("../install.js");
|
|
6
|
+
|
|
7
|
+
let binaryPath;
|
|
8
|
+
try {
|
|
9
|
+
binaryPath = getBinaryPath();
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.error(`Error: ${e.message}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), {
|
|
16
|
+
stdio: "inherit",
|
|
17
|
+
env: process.env,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (result.error) {
|
|
21
|
+
console.error(`Failed to run memtrace: ${result.error.message}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
process.exit(result.status ?? 0);
|
package/install.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const os = require("os");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const { execSync } = require("child_process");
|
|
8
|
+
|
|
9
|
+
// ── Constants ─────────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
const PLUGIN_NAME = "memtrace-skills";
|
|
12
|
+
const MARKETPLACE_NAME = "memtrace";
|
|
13
|
+
const MARKETPLACE_REPO = "syncable-dev/memtrace-public";
|
|
14
|
+
|
|
15
|
+
const PLATFORM_MAP = {
|
|
16
|
+
"darwin-arm64": "@memtrace/darwin-arm64",
|
|
17
|
+
"darwin-x64": "@memtrace/darwin-x64",
|
|
18
|
+
"linux-x64": "@memtrace/linux-x64",
|
|
19
|
+
"linux-arm64": "@memtrace/linux-arm64",
|
|
20
|
+
"win32-x64": "@memtrace/win32-x64",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// ── Binary helpers ────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
function getPlatformKey() {
|
|
26
|
+
return `${os.platform()}-${os.arch()}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getBinaryPath() {
|
|
30
|
+
const key = getPlatformKey();
|
|
31
|
+
const pkg = PLATFORM_MAP[key];
|
|
32
|
+
|
|
33
|
+
if (!pkg) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`Memtrace does not support platform: ${key}\n` +
|
|
36
|
+
`Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const ext = os.platform() === "win32" ? ".exe" : "";
|
|
41
|
+
const binaryName = `memtrace${ext}`;
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
return require.resolve(`${pkg}/bin/${binaryName}`);
|
|
45
|
+
} catch {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`Could not find memtrace binary for ${key}.\n` +
|
|
48
|
+
`Try reinstalling: npm install -g memtrace`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── Skill installation ───────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
function installSkills() {
|
|
56
|
+
const skillsSrc = path.join(__dirname, "skills");
|
|
57
|
+
if (!fs.existsSync(skillsSrc)) {
|
|
58
|
+
console.warn("memtrace: skills directory not found, skipping skill installation");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const claudeSkillsDir = path.join(os.homedir(), ".claude", "skills");
|
|
63
|
+
|
|
64
|
+
// Collect all .md skill files from commands/ and workflows/
|
|
65
|
+
const skillDirs = ["commands", "workflows"];
|
|
66
|
+
let installed = 0;
|
|
67
|
+
|
|
68
|
+
for (const dir of skillDirs) {
|
|
69
|
+
const srcDir = path.join(skillsSrc, dir);
|
|
70
|
+
if (!fs.existsSync(srcDir)) continue;
|
|
71
|
+
|
|
72
|
+
const files = fs.readdirSync(srcDir).filter(f => f.endsWith(".md"));
|
|
73
|
+
for (const file of files) {
|
|
74
|
+
const skillName = file.replace(/\.md$/, "");
|
|
75
|
+
const destDir = path.join(claudeSkillsDir, skillName);
|
|
76
|
+
const srcFile = path.join(srcDir, file);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
80
|
+
fs.copyFileSync(srcFile, path.join(destDir, "SKILL.md"));
|
|
81
|
+
installed++;
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.warn(`memtrace: failed to install skill ${skillName}: ${e.message}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (installed > 0) {
|
|
89
|
+
console.log(`memtrace: installed ${installed} skills to ${claudeSkillsDir}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ── Settings.json helpers ────────────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
function readSettings() {
|
|
96
|
+
const settingsFile = path.join(os.homedir(), ".claude", "settings.json");
|
|
97
|
+
if (fs.existsSync(settingsFile)) {
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(fs.readFileSync(settingsFile, "utf-8"));
|
|
100
|
+
} catch {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return {};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function writeSettings(settings) {
|
|
108
|
+
const settingsFile = path.join(os.homedir(), ".claude", "settings.json");
|
|
109
|
+
fs.mkdirSync(path.dirname(settingsFile), { recursive: true });
|
|
110
|
+
fs.writeFileSync(settingsFile, JSON.stringify(settings, null, 2) + "\n");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ── MCP server registration ─────────────────────────────────────────────────
|
|
114
|
+
|
|
115
|
+
function registerMcpServer(binaryPath) {
|
|
116
|
+
const settings = readSettings();
|
|
117
|
+
|
|
118
|
+
if (!settings.mcpServers || typeof settings.mcpServers !== "object") {
|
|
119
|
+
settings.mcpServers = {};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
settings.mcpServers.memtrace = {
|
|
123
|
+
command: binaryPath,
|
|
124
|
+
args: ["mcp"],
|
|
125
|
+
env: {
|
|
126
|
+
MEMGRAPH_URL: "bolt://localhost:7687",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
writeSettings(settings);
|
|
131
|
+
console.log("memtrace: registered MCP server in ~/.claude/settings.json");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ── Plugin + marketplace registration ────────────────────────────────────────
|
|
135
|
+
|
|
136
|
+
function enablePlugin() {
|
|
137
|
+
const settings = readSettings();
|
|
138
|
+
|
|
139
|
+
// Enable plugin
|
|
140
|
+
if (!settings.enabledPlugins || typeof settings.enabledPlugins !== "object") {
|
|
141
|
+
settings.enabledPlugins = {};
|
|
142
|
+
}
|
|
143
|
+
const pluginKey = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
|
|
144
|
+
settings.enabledPlugins[pluginKey] = true;
|
|
145
|
+
|
|
146
|
+
// Register marketplace
|
|
147
|
+
if (!settings.extraKnownMarketplaces || typeof settings.extraKnownMarketplaces !== "object") {
|
|
148
|
+
settings.extraKnownMarketplaces = {};
|
|
149
|
+
}
|
|
150
|
+
settings.extraKnownMarketplaces[MARKETPLACE_NAME] = {
|
|
151
|
+
source: {
|
|
152
|
+
source: "github",
|
|
153
|
+
repo: MARKETPLACE_REPO,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
writeSettings(settings);
|
|
158
|
+
console.log(`memtrace: enabled plugin ${pluginKey}`);
|
|
159
|
+
console.log(`memtrace: registered marketplace ${MARKETPLACE_NAME}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ── Try Claude CLI install first ─────────────────────────────────────────────
|
|
163
|
+
|
|
164
|
+
function commandExists(cmd) {
|
|
165
|
+
try {
|
|
166
|
+
execSync(`which ${cmd}`, { stdio: "ignore" });
|
|
167
|
+
return true;
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function tryClaudeCliInstall() {
|
|
174
|
+
if (!commandExists("claude")) return false;
|
|
175
|
+
|
|
176
|
+
try {
|
|
177
|
+
execSync(`claude plugin marketplace add ${MARKETPLACE_REPO}`, {
|
|
178
|
+
stdio: "ignore",
|
|
179
|
+
timeout: 15000,
|
|
180
|
+
});
|
|
181
|
+
execSync(`claude plugin install ${PLUGIN_NAME}@${MARKETPLACE_NAME} --scope user`, {
|
|
182
|
+
stdio: "ignore",
|
|
183
|
+
timeout: 15000,
|
|
184
|
+
});
|
|
185
|
+
console.log("memtrace: installed skills via Claude CLI");
|
|
186
|
+
return true;
|
|
187
|
+
} catch {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// ── Main postinstall ─────────────────────────────────────────────────────────
|
|
193
|
+
|
|
194
|
+
if (require.main === module) {
|
|
195
|
+
// 1. Verify binary
|
|
196
|
+
let binaryPath = null;
|
|
197
|
+
try {
|
|
198
|
+
binaryPath = getBinaryPath();
|
|
199
|
+
if (!fs.existsSync(binaryPath)) {
|
|
200
|
+
throw new Error(`Binary not found at: ${binaryPath}`);
|
|
201
|
+
}
|
|
202
|
+
if (os.platform() !== "win32") {
|
|
203
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
204
|
+
}
|
|
205
|
+
console.log(`memtrace: binary installed at ${binaryPath}`);
|
|
206
|
+
} catch (e) {
|
|
207
|
+
console.warn(`memtrace: ${e.message}`);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// 2. Install skills to ~/.claude/skills/
|
|
211
|
+
try {
|
|
212
|
+
installSkills();
|
|
213
|
+
} catch (e) {
|
|
214
|
+
console.warn(`memtrace: skill installation failed: ${e.message}`);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 3. Try Claude CLI first, fall back to manual settings
|
|
218
|
+
try {
|
|
219
|
+
if (!tryClaudeCliInstall()) {
|
|
220
|
+
enablePlugin();
|
|
221
|
+
}
|
|
222
|
+
} catch (e) {
|
|
223
|
+
console.warn(`memtrace: plugin registration failed: ${e.message}`);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// 4. Register MCP server
|
|
227
|
+
if (binaryPath) {
|
|
228
|
+
try {
|
|
229
|
+
registerMcpServer(binaryPath);
|
|
230
|
+
} catch (e) {
|
|
231
|
+
console.warn(`memtrace: MCP server registration failed: ${e.message}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
module.exports = { getBinaryPath };
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "memtrace",
|
|
3
|
+
"version": "0.1.22.5",
|
|
4
|
+
"description": "Code intelligence graph — MCP server + AI agent skills + visualization UI",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"code-intelligence",
|
|
8
|
+
"ai",
|
|
9
|
+
"memgraph",
|
|
10
|
+
"graph",
|
|
11
|
+
"skills",
|
|
12
|
+
"claude-code"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://memtrace.dev",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/syncable-dev/memtrace-public"
|
|
18
|
+
},
|
|
19
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
20
|
+
"bin": {
|
|
21
|
+
"memtrace": "bin/memtrace.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"bin/",
|
|
25
|
+
"skills/",
|
|
26
|
+
"install.js"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"postinstall": "node install.js"
|
|
30
|
+
},
|
|
31
|
+
"optionalDependencies": {
|
|
32
|
+
"@memtrace/darwin-arm64": "0.1.22.5",
|
|
33
|
+
"@memtrace/linux-x64": "0.1.22.5",
|
|
34
|
+
"@memtrace/win32-x64": "0.1.22.5"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-api-topology
|
|
3
|
+
description: "Use when the user asks about API endpoints, HTTP routes, service-to-service calls, microservice dependencies, API topology, which services call which, cross-repo dependencies, or wants to understand the API surface of a codebase"
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__get_api_topology
|
|
6
|
+
- mcp__memtrace__find_api_endpoints
|
|
7
|
+
- mcp__memtrace__find_api_calls
|
|
8
|
+
- mcp__memtrace__get_symbol_context
|
|
9
|
+
- mcp__memtrace__link_repositories
|
|
10
|
+
user-invocable: true
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Map the HTTP API surface of a codebase — exposed endpoints, outbound HTTP calls, and cross-repo service-to-service dependency graphs. Supports auto-detection for Express, Encore, NestJS, Axum, FastAPI, Flask, Gin, Spring Boot, and more.
|
|
16
|
+
|
|
17
|
+
## Quick Reference
|
|
18
|
+
|
|
19
|
+
| Tool | Purpose |
|
|
20
|
+
|------|---------|
|
|
21
|
+
| `find_api_endpoints` | All exposed HTTP endpoints (GET /users, POST /orders, etc.) |
|
|
22
|
+
| `find_api_calls` | All outbound HTTP calls (fetch, axios, reqwest, etc.) |
|
|
23
|
+
| `get_api_topology` | Cross-repo call graph: which service calls which endpoint |
|
|
24
|
+
| `link_repositories` | Manually link repos for cross-repo edge detection |
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
### 1. Discover endpoints
|
|
29
|
+
|
|
30
|
+
Use `find_api_endpoints`:
|
|
31
|
+
- `repo_id` — required
|
|
32
|
+
- Returns: method, path, handler function, framework detected
|
|
33
|
+
|
|
34
|
+
### 2. Discover outbound calls
|
|
35
|
+
|
|
36
|
+
Use `find_api_calls`:
|
|
37
|
+
- `repo_id` — required
|
|
38
|
+
- Returns: target URL/path, HTTP method, calling function, library used (fetch, axios, reqwest, etc.)
|
|
39
|
+
|
|
40
|
+
### 3. Map service topology
|
|
41
|
+
|
|
42
|
+
Use `get_api_topology` to see the cross-repo HTTP call graph:
|
|
43
|
+
- Which services call which endpoints
|
|
44
|
+
- Confidence scores for each detected link
|
|
45
|
+
- Service-to-service dependency direction
|
|
46
|
+
|
|
47
|
+
**Prerequisite:** Multiple repos must be indexed. If cross-repo links aren't appearing, use `link_repositories` to explicitly connect them.
|
|
48
|
+
|
|
49
|
+
### 4. Deep-dive into an endpoint
|
|
50
|
+
|
|
51
|
+
For any specific endpoint, use `get_symbol_context` with the endpoint's symbol ID to see:
|
|
52
|
+
- Which internal functions handle the request
|
|
53
|
+
- Which processes (execution flows) include this endpoint
|
|
54
|
+
- Which external services call this endpoint
|
|
55
|
+
|
|
56
|
+
## Common Mistakes
|
|
57
|
+
|
|
58
|
+
| Mistake | Reality |
|
|
59
|
+
|---------|---------|
|
|
60
|
+
| Expecting cross-repo links with only one repo indexed | Index ALL related services first; cross-repo HTTP edges are linked automatically after indexing |
|
|
61
|
+
| Missing endpoints from custom frameworks | Memtrace auto-detects major frameworks; for custom routers, the endpoints may appear as regular functions |
|
|
62
|
+
| Not using `link_repositories` | If auto-linking missed a connection, use this to manually establish cross-repo edges |
|