memtrace 0.8.9 → 0.8.11
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/installer/dist/commands/doctor.js +24 -1
- package/installer/dist/commands/install.js +10 -4
- package/installer/dist/index.js +1 -1
- package/installer/dist/transformers/index.d.ts +2 -1
- package/installer/dist/transformers/index.js +3 -1
- package/installer/dist/transformers/pi.d.ts +5 -0
- package/installer/dist/transformers/pi.js +152 -0
- package/installer/dist/transformers/types.d.ts +1 -1
- package/installer/package.json +1 -1
- package/lib/install-consent.js +1 -1
- package/package.json +9 -8
- package/pi-package/LICENSE +21 -0
- package/pi-package/README.md +51 -0
- package/pi-package/extension/config.ts +96 -0
- package/pi-package/extension/index.ts +764 -0
- package/pi-package/extension/mcp-client.ts +259 -0
- package/pi-package/extension/schema.ts +293 -0
- package/pi-package/package.json +25 -0
- package/pi-package/skills/memtrace-codebase-exploration/SKILL.md +132 -0
- package/pi-package/skills/memtrace-evolution/SKILL.md +158 -0
- package/pi-package/skills/memtrace-first/SKILL.md +213 -0
- package/pi-package/skills/memtrace-impact/SKILL.md +108 -0
- package/pi-package/skills/references/mcp-parameters.md +358 -0
- package/pi-package/tsconfig.json +17 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-codebase-exploration
|
|
3
|
+
description: Map an indexed source-code repo into a structured overview — scale, communities, central symbols, execution flows, API surface, recent activity. Use when the user wants to explore, understand, onboard to, map, or get an overview of an indexed source-code repo, architecture, modules, or major flows. Do not use find, grep, or manual file browsing as the first exploration path; Memtrace provides structured graph briefing. Do NOT use for change history / what-changed questions — use memtrace-evolution.
|
|
4
|
+
allowed-tools: memtrace_index_directory memtrace_check_job_status memtrace_list_indexed_repositories memtrace_get_repository_stats memtrace_list_communities memtrace_list_processes memtrace_find_central_symbols memtrace_find_bridge_symbols memtrace_find_api_endpoints memtrace_get_api_topology memtrace_get_evolution memtrace_find_most_complex_functions
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
author: "Memtrace <support@syncable.dev>"
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
category: development
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Full codebase exploration workflow — from indexing through architectural understanding. Chains indexing, graph algorithms, community detection, and temporal analysis into a structured onboarding experience. Use this when someone is new to a codebase and needs to build a mental model.
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
### 1. Index the codebase
|
|
19
|
+
|
|
20
|
+
Call `memtrace_list_indexed_repositories` first. If the repo is already indexed, skip to step 2.
|
|
21
|
+
|
|
22
|
+
Otherwise, call `memtrace_index_directory` with the project path (or run `/memtrace:index`), then poll `memtrace_check_job_status` until completion.
|
|
23
|
+
|
|
24
|
+
**Success criteria:** Repo appears in `memtrace_list_indexed_repositories` with non-zero node/edge counts.
|
|
25
|
+
|
|
26
|
+
### 2. Get the lay of the land
|
|
27
|
+
|
|
28
|
+
Call `memtrace_get_repository_stats` to understand scale:
|
|
29
|
+
- How many functions, classes, methods, interfaces?
|
|
30
|
+
- How many relationships (calls, imports, extends)?
|
|
31
|
+
- How many communities and processes were detected?
|
|
32
|
+
|
|
33
|
+
Report these numbers to the user — they set expectations for the codebase's size and complexity.
|
|
34
|
+
|
|
35
|
+
### 3. Map the architecture (communities)
|
|
36
|
+
|
|
37
|
+
Call `memtrace_list_communities` to see how the codebase naturally clusters into logical modules.
|
|
38
|
+
|
|
39
|
+
**Decision:** If >10 communities, summarize the top 5–7 by size and let the user ask about specific ones.
|
|
40
|
+
|
|
41
|
+
Each community represents a cohesive module — these are the "areas" of the codebase.
|
|
42
|
+
|
|
43
|
+
### 4. Find the most important symbols
|
|
44
|
+
|
|
45
|
+
Call `memtrace_find_central_symbols` — PageRank over CALLS/REFERENCES edges (no `method` param):
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{ "repo_id": "<repo>", "limit": 15 }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
These are the symbols that the rest of the codebase depends on most heavily. They form the "skeleton" of the architecture.
|
|
52
|
+
|
|
53
|
+
### 5. Find architectural bottlenecks
|
|
54
|
+
|
|
55
|
+
Call `memtrace_find_bridge_symbols` to identify chokepoints — symbols that connect otherwise-separate parts of the codebase.
|
|
56
|
+
|
|
57
|
+
**Decision:** If bridge symbols overlap heavily with central symbols, flag them as critical infrastructure — high importance AND single point of failure.
|
|
58
|
+
|
|
59
|
+
### 6. Map execution flows
|
|
60
|
+
|
|
61
|
+
Call `memtrace_list_processes` to discover entry points:
|
|
62
|
+
- HTTP handlers (API endpoints)
|
|
63
|
+
- Background jobs
|
|
64
|
+
- CLI commands
|
|
65
|
+
- Event handlers
|
|
66
|
+
|
|
67
|
+
This shows HOW the code is actually used at runtime, not just how it's structured.
|
|
68
|
+
|
|
69
|
+
### 7. Map the API surface (if applicable)
|
|
70
|
+
|
|
71
|
+
Call `memtrace_find_api_endpoints` to list all HTTP routes.
|
|
72
|
+
|
|
73
|
+
**Decision:** If multiple repos are indexed, also call `memtrace_get_api_topology` to map service-to-service dependencies.
|
|
74
|
+
|
|
75
|
+
### 8. Recent activity
|
|
76
|
+
|
|
77
|
+
Call `memtrace_get_evolution` to see recent activity:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{ "repo_id": "<repo>", "from": "30d ago", "mode": "overview" }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Check `totals.episode_count` and episode boundaries. For file/symbol hotspots, switch to `compound`:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{ "repo_id": "<repo>", "from": "30d ago", "mode": "compound" }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Review `top_changed_files` and `top_touched_symbols`.
|
|
90
|
+
|
|
91
|
+
### 9. Complexity hotspots
|
|
92
|
+
|
|
93
|
+
Call `memtrace_find_most_complex_functions`:
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{ "repo_id": "<repo>", "top_n": 10 }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Full parameter spec for every Memtrace tool: [`../references/mcp-parameters.md`](../references/mcp-parameters.md).
|
|
100
|
+
|
|
101
|
+
## Report synthesis
|
|
102
|
+
|
|
103
|
+
Synthesize findings into a structured overview:
|
|
104
|
+
|
|
105
|
+
1. **Scale** — languages, total symbols, total relationships
|
|
106
|
+
2. **Architecture** — main communities/modules and what they do
|
|
107
|
+
3. **Critical Infrastructure** — central symbols and bridge points
|
|
108
|
+
4. **Execution Flows** — how the code is entered and used
|
|
109
|
+
5. **API Surface** — endpoints and service dependencies
|
|
110
|
+
6. **Recent Activity** — what's been changing in the last 30 days
|
|
111
|
+
7. **Technical Debt** — complexity hotspots and potential dead code
|
|
112
|
+
|
|
113
|
+
## Output
|
|
114
|
+
|
|
115
|
+
The deliverable is the 7-part overview above. Skeleton (one headline per part):
|
|
116
|
+
|
|
117
|
+
1. Scale — 2 languages, 4,812 symbols, 19,344 relationships
|
|
118
|
+
2. Architecture — 12 communities; top 5: auth, indexing, api, ui, billing
|
|
119
|
+
3. Critical Infrastructure — `EngineHandle::open` (central AND bridge — flag it)
|
|
120
|
+
4. Execution Flows — 14 processes: 9 HTTP handlers, 3 CLI commands, 2 jobs
|
|
121
|
+
5. API Surface — 42 endpoints; 2 cross-repo service dependencies
|
|
122
|
+
6. Recent Activity — 31 episodes in 30d; hottest file per `top_changed_files`
|
|
123
|
+
7. Technical Debt — top-10 complex functions, highest complexity first
|
|
124
|
+
|
|
125
|
+
## Common mistakes
|
|
126
|
+
|
|
127
|
+
| Mistake | Reality |
|
|
128
|
+
|---------|---------|
|
|
129
|
+
| Skipping indexing and using file-based grep | The knowledge graph provides structural understanding that grep cannot — callers, callees, communities, processes |
|
|
130
|
+
| Reporting raw numbers without interpretation | "450 functions across 12 communities" means nothing; describe what each community does |
|
|
131
|
+
| Only looking at code structure | Execution flows (processes) show how the code is actually used — always include them |
|
|
132
|
+
| Ignoring temporal context | Recent evolution shows where active development is happening — this is where the user will likely need to work |
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-evolution
|
|
3
|
+
description: Trace source-code change history from Memtrace's symbol-level temporal memory. Use when the user asks about change history, recent modifications, what changed since a date, symbol timeline, evolution, unexpected changes, or incident timelines. Do not use git log, git diff, grep, or manual file search to reconstruct history. Do NOT use for current-state architecture overviews (use memtrace-codebase-exploration) or for replaying one commit/save's graph diff (use memtrace-impact for blast radius instead).
|
|
4
|
+
allowed-tools: memtrace_get_evolution memtrace_get_timeline memtrace_detect_changes memtrace_list_indexed_repositories memtrace_get_changes_since memtrace_get_impact memtrace_get_cochange_context
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
author: "Memtrace <support@syncable.dev>"
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
category: development
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Temporal analysis for "what changed in this repo between two points in time?" Works on both git commits and uncommitted working-tree saves.
|
|
15
|
+
|
|
16
|
+
## Required parameters — read before calling
|
|
17
|
+
|
|
18
|
+
`memtrace_get_evolution` **always** requires `repo_id` and `from`. There is no `days` parameter.
|
|
19
|
+
|
|
20
|
+
| Parameter | Required | Type | Example |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| `repo_id` | yes | string | `"my-repo"` |
|
|
23
|
+
| `from` | yes | string | `"90d ago"`, `"2026-04-01T00:00:00Z"`, `"yesterday"` |
|
|
24
|
+
| `to` | no | string | defaults to now; set to incident time when investigating |
|
|
25
|
+
| `mode` | no | string | `"recent"` (default), `"compound"`, `"summary"`, `"overview"` |
|
|
26
|
+
| `target` | no | string | symbol name or file path substring to scope results |
|
|
27
|
+
| `branch` | no | string | branch filter |
|
|
28
|
+
|
|
29
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`limit`, `cursor`, etc.) must be JSON numbers — not strings. Use `limit: 100`, never `limit: "100"`.
|
|
30
|
+
|
|
31
|
+
### Time-window parameters — do not confuse these tools
|
|
32
|
+
|
|
33
|
+
| Tool | Time param | Example | Notes |
|
|
34
|
+
|---|---|---|---|
|
|
35
|
+
| `memtrace_get_evolution` | **`from`** (required) | `"90d ago"` | optional `to`; **never** pass `days` |
|
|
36
|
+
| `memtrace_get_changes_since` | **`since`** (required) | `"2026-04-13T10:43:00Z"` | optional `until` |
|
|
37
|
+
|
|
38
|
+
Common failure: `MCP error -32602: missing field 'from'` — you omitted `from` or passed `days` instead.
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
// CORRECT — 90-day overview
|
|
42
|
+
{ "repo_id": "my-repo", "from": "90d ago", "mode": "overview" }
|
|
43
|
+
|
|
44
|
+
// WRONG — days is not a memtrace_get_evolution parameter
|
|
45
|
+
{ "repo_id": "my-repo", "days": 90, "mode": "overview" }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Query modes — only these four exist
|
|
49
|
+
|
|
50
|
+
| Mode | What you get | Best for |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `recent` | Per-episode list with nodes/edges added/removed; paginate with `limit` + `cursor` | Incident timelines, walking commit-by-commit |
|
|
53
|
+
| `compound` | Totals plus `top_changed_files` and `top_touched_symbols` | "What changed?" when you need hotspots |
|
|
54
|
+
| `summary` | Totals plus `first_episode` / `last_episode` metadata | Cheapest window check |
|
|
55
|
+
| `overview` | Alias for `summary` | Same as `summary` |
|
|
56
|
+
|
|
57
|
+
Modes **`impact`**, **`novel`**, and **`directional`** are **not implemented** — calling them returns `unknown mode`.
|
|
58
|
+
|
|
59
|
+
### `recent` mode filters (ignored by `compound` / `summary`)
|
|
60
|
+
|
|
61
|
+
| Param | Purpose |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `file_path` | substring match against episode `touched_files` |
|
|
64
|
+
| `kind` | `"git_commit"` or `"working_tree"` |
|
|
65
|
+
| `limit` | page size (default 100 episodes) |
|
|
66
|
+
| `cursor` | pagination offset; follow `next_cursor` in response |
|
|
67
|
+
|
|
68
|
+
Full parameter spec for every Memtrace tool: [`../references/mcp-parameters.md`](../references/mcp-parameters.md).
|
|
69
|
+
|
|
70
|
+
## Steps
|
|
71
|
+
|
|
72
|
+
### 1. Get `repo_id`
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
memtrace_list_indexed_repositories()
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 2. Choose the time window
|
|
79
|
+
|
|
80
|
+
- `from` — start (required). Relative strings work: `"7d ago"`, `"24 hours ago"`.
|
|
81
|
+
- `to` — end (optional, defaults to now). Set to the incident timestamp when investigating regressions.
|
|
82
|
+
|
|
83
|
+
If resuming a session and you have a stored timestamp from last time, prefer `memtrace_get_changes_since(since=...)`.
|
|
84
|
+
|
|
85
|
+
### 3. Choose the mode
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
User wants...
|
|
89
|
+
├── per-commit / per-save changelog → recent
|
|
90
|
+
├── top changed files + symbols → compound
|
|
91
|
+
├── quick totals only → summary or overview
|
|
92
|
+
└── one symbol's full history → memtrace_get_timeline (not memtrace_get_evolution)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 4. Execute
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
// General "what changed lately?"
|
|
99
|
+
{ "repo_id": "my-repo", "from": "30d ago", "mode": "compound" }
|
|
100
|
+
|
|
101
|
+
// Changes in one file last week
|
|
102
|
+
{ "repo_id": "my-repo", "from": "7d ago", "mode": "recent", "file_path": "auth.ts", "limit": 50 }
|
|
103
|
+
|
|
104
|
+
// Incident: 24h before failure until failure time
|
|
105
|
+
{ "repo_id": "my-repo", "from": "2026-04-16T13:00:00Z", "to": "2026-04-17T13:00:00Z", "mode": "recent" }
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 5. Interpret results
|
|
109
|
+
|
|
110
|
+
**`recent` mode** — each entry in `episodes[]`:
|
|
111
|
+
- `episode` — metadata (`source_type`, `reference_time`, `touched_files`, …)
|
|
112
|
+
- `nodes_added`, `nodes_removed`, `edges_added`, `edges_removed`
|
|
113
|
+
|
|
114
|
+
**`compound` mode:**
|
|
115
|
+
- `totals` — aggregate counts
|
|
116
|
+
- `top_changed_files` — files with most activity
|
|
117
|
+
- `top_touched_symbols` — symbols with most activity
|
|
118
|
+
|
|
119
|
+
**`summary` / `overview` mode:**
|
|
120
|
+
- `totals` — episode and node/edge counts
|
|
121
|
+
- `first_episode`, `last_episode` — window boundaries
|
|
122
|
+
|
|
123
|
+
### 6. Drill deeper
|
|
124
|
+
|
|
125
|
+
| Need | Tool |
|
|
126
|
+
|---|---|
|
|
127
|
+
| Full history of one symbol | `memtrace_get_timeline(repo_id, scope_path, file_path)` |
|
|
128
|
+
| Blast radius of a suspect symbol | `memtrace_get_impact(repo_id, target)` — see `memtrace-impact` |
|
|
129
|
+
| What a diff would affect | `memtrace_detect_changes(repo_id, diff=...)` |
|
|
130
|
+
| Behavioral coupling | `memtrace_get_cochange_context(repo_id, target=<symbol>)` |
|
|
131
|
+
|
|
132
|
+
## Output
|
|
133
|
+
|
|
134
|
+
Sample `compound` payload (per-mode field lists: step 5 above):
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"totals": { "episodes": 42, "nodes_added": 310, "nodes_removed": 95,
|
|
139
|
+
"edges_added": 541, "edges_removed": 120 },
|
|
140
|
+
"top_changed_files": [ /* files ranked by activity */ ],
|
|
141
|
+
"top_touched_symbols": [ /* symbols ranked by activity */ ]
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`recent` returns `episodes[]` + `totals` + `page.next_cursor`; `summary`/`overview` return `totals` + `first_episode`/`last_episode`.
|
|
146
|
+
|
|
147
|
+
## Common mistakes
|
|
148
|
+
|
|
149
|
+
| Mistake | Reality |
|
|
150
|
+
|---|---|
|
|
151
|
+
| Passing `days: 90` | Use `from: "90d ago"` |
|
|
152
|
+
| Omitting `from` | Required — call fails with `-32602` before any query runs |
|
|
153
|
+
| Using `mode: "novel"` / `"impact"` / `"directional"` | Not implemented — use `compound` + `memtrace_get_impact` + `memtrace_get_cochange_context` instead |
|
|
154
|
+
| Expecting `by_module[]` or significance scores | Not in current response shape — use `top_changed_files` from `compound` |
|
|
155
|
+
| Using `overview` when you need file/symbol detail | `overview`/`summary` are totals only — switch to `compound` or `recent` |
|
|
156
|
+
| Using `memtrace_get_evolution` for one symbol's history | Use `memtrace_get_timeline` |
|
|
157
|
+
| Guessing timestamps when resuming work | Use `memtrace_get_changes_since(since=<stored time>)` |
|
|
158
|
+
| Applying `file_path` filter in `compound` mode | Filters are ignored in roll-up modes — use `recent` with `file_path` instead |
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-first
|
|
3
|
+
description: Route code discovery, debugging, flow tracing, and how-code-works questions in indexed source-code repos to Memtrace graph tools. Use first — before searching files, reading code for discovery, debugging, tracing flows, finding implementations, understanding behavior, or answering how code works. Do not use grep, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results, missing languages, or partial-looking stats are not permission to grep; diagnose/reindex with Memtrace.
|
|
4
|
+
allowed-tools: memtrace_list_indexed_repositories memtrace_index_directory memtrace_find_symbol memtrace_find_code memtrace_get_symbol_context memtrace_get_impact memtrace_analyze_relationships memtrace_get_process_flow memtrace_list_communities memtrace_find_central_symbols memtrace_find_api_endpoints memtrace_find_api_calls memtrace_get_service_diagram memtrace_get_api_topology memtrace_find_dependency_path memtrace_get_cochange_context memtrace_get_evolution memtrace_get_changes_since memtrace_get_style_fingerprint memtrace_find_most_complex_functions memtrace_get_source_window memtrace_status read grep find
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
author: "Memtrace <support@syncable.dev>"
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
category: development
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Memtrace First
|
|
13
|
+
|
|
14
|
+
## The Iron Law
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
IF THE REPO IS INDEXED IN MEMTRACE → USE memtrace_* TOOLS FIRST.
|
|
18
|
+
After a search hit, route to GRAPH tools (memtrace_get_symbol_context,
|
|
19
|
+
memtrace_get_impact, memtrace_analyze_relationships) — that's what Memtrace
|
|
20
|
+
uniquely provides. Read source ONLY when you're about to edit or quote, and
|
|
21
|
+
read only the bounded span Memtrace returned (start_line .. end_line + small
|
|
22
|
+
context). Do not grep/find to "locate" anything already in the graph, and do
|
|
23
|
+
not read the whole file when Memtrace has given you exact lines.
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Memtrace is the **memory layer** of the codebase, not a search engine that returns code. It has the full knowledge graph — every symbol, call, import, community, process, and API — with a time dimension. The point is to navigate that graph: who calls this, what's the blast radius, when did this change, what community is it part of. `read`/`grep`/`find` are blind to all of that.
|
|
27
|
+
|
|
28
|
+
**No exceptions for what's in the graph.**
|
|
29
|
+
|
|
30
|
+
## Before you start: check Memtrace is available
|
|
31
|
+
|
|
32
|
+
Call `memtrace_status` once per session if you are unsure whether Memtrace is connected. It reports whether the `memtrace` binary is installed, whether the MCP server is connected, and which repos are indexed (with their `repo_id` values you need for every other `memtrace_*` call). If it reports `installed: false`, tell the user to run `npm install -g memtrace`, then `memtrace start`.
|
|
33
|
+
|
|
34
|
+
## What Memtrace actually indexes
|
|
35
|
+
|
|
36
|
+
Memtrace's hybrid search = **BM25 over symbol metadata** (name, signature, file_path, kind) **+ semantic vector search over embedded code bodies** (first ~1500 chars of every Function / Method / Class / Struct / Interface body), fused via Reciprocal Rank Fusion.
|
|
37
|
+
|
|
38
|
+
The semantic side means **string literals, error messages, magic constants, log strings, and any text inside an indexed symbol's body are findable through `memtrace_find_code`**. The body got embedded; the embedding catches it. You do NOT need `grep` to hunt for `STRIPE_KEY_FOO_BAR` if it lives inside a function in your indexed codebase.
|
|
39
|
+
|
|
40
|
+
## Zero results are not a grep license
|
|
41
|
+
|
|
42
|
+
If Memtrace returns 0 results, or repository stats look incomplete, do **not** infer that a source subdirectory is outside the index. Diagnose through Memtrace:
|
|
43
|
+
|
|
44
|
+
1. Call `memtrace_list_indexed_repositories` and identify the repo root/repo_id.
|
|
45
|
+
2. If the path is under that indexed repo root, keep using Memtrace.
|
|
46
|
+
3. Retry with broader `memtrace_find_code` terms and, when available, `file_path` filters such as `ui/`, `src/`, or the framework directory.
|
|
47
|
+
4. If the language/path still appears missing, run `memtrace_index_directory` on the repo root with `incremental: true` (or ask before `clear_existing: true`).
|
|
48
|
+
5. Report the indexing coverage problem instead of silently switching to grep.
|
|
49
|
+
|
|
50
|
+
**Never say "the index only covers X, so grep is right" when the target path is inside the indexed repository.** That is an indexing freshness/coverage issue, not permission to abandon Memtrace.
|
|
51
|
+
|
|
52
|
+
## The narrow exceptions where grep/find are still right
|
|
53
|
+
|
|
54
|
+
These are the ONLY cases where file tools beat Memtrace:
|
|
55
|
+
|
|
56
|
+
- **Files outside every indexed repo root.** Confirm this with `memtrace_list_indexed_repositories`; 0 search results or missing language stats do not prove it. Vendored deps, system headers, and excluded dirs (`.git`, `node_modules`, `target`, `dist`) are examples Memtrace cannot see.
|
|
57
|
+
- **Non-source artifacts.** `.env`, `package.json`, build scripts, top-level `README.md`, raw config files. Memtrace indexes parseable code, not configuration text.
|
|
58
|
+
- **Pure file-inventory questions.** "How many `*.test.ts` files exist", "list every Markdown file in `docs/`". You're asking for a file count, not a symbol search.
|
|
59
|
+
- **Reading at a known path outside Memtrace.** For configs, docs, or non-source artifacts that Memtrace cannot index, `read` is fine. For source-code spans returned by Memtrace, read the precise line range with `read(file, offset, limit)` or `memtrace_get_source_window`. Do not whole-file read when you have a span.
|
|
60
|
+
|
|
61
|
+
For everything else inside the indexed repo, Memtrace is the right tool.
|
|
62
|
+
|
|
63
|
+
## The decision rule
|
|
64
|
+
|
|
65
|
+
| Question you're asking | Right tool |
|
|
66
|
+
|---|---|
|
|
67
|
+
| "Where is symbol `foo` defined?" | `memtrace_find_symbol(name="foo")` → then `memtrace_get_symbol_context` for callers/callees/community, NOT a source read unless you're editing. |
|
|
68
|
+
| "What calls `foo`?" | `memtrace_get_symbol_context(repo_id, symbol="foo")` → callers with file:line. |
|
|
69
|
+
| "How does authentication work?" | `memtrace_find_code(query="authentication")` → `memtrace_get_symbol_context` on the top hit, NOT a source read. |
|
|
70
|
+
| "Find behavior X" with multi-word phrase (3+ words) | `memtrace_find_code(verbatim)` first; if low confidence, fan out with identifier-shaped reshapes (camelCase / snake_case). |
|
|
71
|
+
| "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `memtrace_find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
|
|
72
|
+
| "Where's that error message `'connection refused for tenant'`?" | `memtrace_find_code(query="connection refused for tenant")` → semantic catches it. |
|
|
73
|
+
| "What breaks if I change `foo`?" | `memtrace_get_impact(repo_id, target="foo")` → blast radius. |
|
|
74
|
+
| "What changed in `auth.ts` last week?" | `memtrace_get_evolution(repo_id, from="7d ago", mode="recent", file_path="auth.ts")`. |
|
|
75
|
+
| "List all `*.test.ts` files." | `find` (file inventory, not symbol search). |
|
|
76
|
+
| "Find this string in my `.env`." | `grep` (non-source artifact). |
|
|
77
|
+
| "I'm about to edit `foo` — show me its source." | Bounded `read(file, offset=start_line, limit=end_line-start_line+8)`, or `memtrace_get_source_window`. Never whole-file. |
|
|
78
|
+
| "Read config/doc file I already have the path of." | `read` (non-source artifact, path is known). |
|
|
79
|
+
|
|
80
|
+
## Parameter types — read this before calling any tool
|
|
81
|
+
|
|
82
|
+
All `memtrace_*` tools are **strictly typed**. Pass JSON numbers (not strings) for integer parameters.
|
|
83
|
+
|
|
84
|
+
| Parameter | Correct | WRONG (fails with MCP error -32602) |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `limit`, `min_size`, `depth`, `max_depth`, `last_n` | `limit: 20` | `limit: "20"` |
|
|
87
|
+
| `repo_id`, `branch`, `name`, `symbol_name`, `query` | `repo_id: "my-repo"` | `repo_id: my-repo` (unquoted) |
|
|
88
|
+
| `fuzzy`, `include_tests`, `invalidate` | `fuzzy: true` | `fuzzy: "true"` |
|
|
89
|
+
| `memtrace_get_evolution.from` | `from: "90d ago"` | `days: 90` (wrong param — use `from`, not `days`) |
|
|
90
|
+
| `memtrace_get_changes_since.since` | `since: "2026-04-13T10:43:00Z"` | `last_episode_id: "..."` (wrong param) |
|
|
91
|
+
| `memtrace_get_impact.target` / `memtrace_get_symbol_context.symbol` | `target: "foo"` / `symbol: "foo"` | `symbol_id: "..."` (wrong — use name) |
|
|
92
|
+
| `memtrace_find_most_complex_functions` | `top_n: 10` | `limit: 10` (wrong param name) |
|
|
93
|
+
| `memtrace_get_cochange_context` | `target: "execute"` | `symbol: "execute"` (wrong param name) |
|
|
94
|
+
|
|
95
|
+
If you see `failed to deserialize parameters: invalid type: string "N", expected usize`, remove the quotes from the number and retry.
|
|
96
|
+
|
|
97
|
+
If you see `missing field 'from'`, you called `memtrace_get_evolution` without `from` — pass e.g. `"90d ago"`, never `days`.
|
|
98
|
+
|
|
99
|
+
Full parameter spec for every Memtrace tool: [`../references/mcp-parameters.md`](../references/mcp-parameters.md).
|
|
100
|
+
|
|
101
|
+
## Check indexing first (once per session)
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
memtrace_list_indexed_repositories
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
If the current repo appears → Memtrace is active. Follow this skill for ALL code tasks.
|
|
108
|
+
If not indexed → offer to index with `memtrace_index_directory`, then follow this skill. (Or use `/memtrace:index`.)
|
|
109
|
+
|
|
110
|
+
## Task → tool map
|
|
111
|
+
|
|
112
|
+
| What you need | Use instead of grep/find/read |
|
|
113
|
+
|---|---|
|
|
114
|
+
| Find a function / class / symbol | `memtrace_find_symbol` or `memtrace_find_code` |
|
|
115
|
+
| Understand how something works | `memtrace_get_symbol_context` (the default next step) |
|
|
116
|
+
| Find all callers of a function | `memtrace_get_symbol_context` (callers field) |
|
|
117
|
+
| Find all callees / dependencies | `memtrace_get_symbol_context` (callees field) |
|
|
118
|
+
| Trace a request / execution path | `memtrace_get_process_flow` |
|
|
119
|
+
| Understand module structure | `memtrace_list_communities` |
|
|
120
|
+
| Find the most important symbols | `memtrace_find_central_symbols` |
|
|
121
|
+
| Find API endpoints | `memtrace_find_api_endpoints` |
|
|
122
|
+
| Find where an API is called | `memtrace_find_api_calls` |
|
|
123
|
+
| Debug a problem | `memtrace_get_symbol_context` → `memtrace_get_impact` → `memtrace_get_evolution` |
|
|
124
|
+
| What changed recently? | `memtrace_get_changes_since` or `memtrace_get_evolution` |
|
|
125
|
+
| What breaks if I change X? | `memtrace_get_impact` |
|
|
126
|
+
| Cross-service / cross-repo calls | `memtrace_get_service_diagram` or `memtrace_get_api_topology` |
|
|
127
|
+
| Dependency between two symbols | `memtrace_find_dependency_path` |
|
|
128
|
+
| What files change together? | `memtrace_get_cochange_context` |
|
|
129
|
+
| Architecture overview | `memtrace_list_communities` + `memtrace_find_central_symbols` (see `memtrace-codebase-exploration`) |
|
|
130
|
+
| About to edit / quote — need exact lines | Bounded `read(file, offset=start_line, limit=N)` (preferred), or `memtrace_get_source_window` |
|
|
131
|
+
| About to choose between competing idioms (ternary vs if-else, arrow vs fn-decl, const vs let, await vs `.then`) | `memtrace_get_style_fingerprint(repo_id, file_path)` — empirical codebase norm |
|
|
132
|
+
|
|
133
|
+
## Standard workflows
|
|
134
|
+
|
|
135
|
+
### "How does X work?" / "Explain X"
|
|
136
|
+
1. `memtrace_find_symbol` or `memtrace_find_code` → locate the symbol
|
|
137
|
+
2. `memtrace_get_symbol_context` → callers, callees, community, processes (this usually answers "how it works")
|
|
138
|
+
3. `memtrace_get_process_flow` (if it's a process/request path)
|
|
139
|
+
4. Only if you need to quote source: bounded `read` at start_line..end_line, or `memtrace_get_source_window`
|
|
140
|
+
|
|
141
|
+
### Debugging "X is broken"
|
|
142
|
+
1. `memtrace_find_symbol` → locate the broken thing
|
|
143
|
+
2. `memtrace_get_symbol_context` → understand its role
|
|
144
|
+
3. `memtrace_get_impact` → blast radius (what else breaks)
|
|
145
|
+
4. `memtrace_get_evolution(from=<lookback>, mode: recent)` → per-episode changelog near the incident
|
|
146
|
+
5. `memtrace_get_changes_since(since=<anchor>)` → catch-up since last session (requires stored `since` timestamp)
|
|
147
|
+
|
|
148
|
+
### "Where is X defined / called?"
|
|
149
|
+
1. `memtrace_find_symbol` with `fuzzy: true`
|
|
150
|
+
2. `memtrace_get_symbol_context` for full caller/callee map
|
|
151
|
+
3. Only if you need source text: bounded `read` at start_line..end_line, or `memtrace_get_source_window`
|
|
152
|
+
|
|
153
|
+
### Before any code modification
|
|
154
|
+
1. `memtrace_find_symbol` → confirm you have the right target
|
|
155
|
+
2. `memtrace_get_symbol_context` → understand full context
|
|
156
|
+
3. `memtrace_get_impact` → know blast radius before touching anything
|
|
157
|
+
4. `memtrace_get_style_fingerprint(repo_id, file_path=<file>)` → match the codebase's empirical idiom
|
|
158
|
+
|
|
159
|
+
## Red flags — STOP, use Memtrace instead
|
|
160
|
+
|
|
161
|
+
You are violating this skill if you think:
|
|
162
|
+
|
|
163
|
+
| Thought | Reality |
|
|
164
|
+
|---|---|
|
|
165
|
+
| "Let me grep for this" | `memtrace_find_code` or `memtrace_find_symbol` is faster and structurally aware |
|
|
166
|
+
| "Let me find the file by name" | `memtrace_find_symbol` returns exact location with context |
|
|
167
|
+
| "Let me read the whole file" | `memtrace_get_symbol_context` for the WHY (callers/callees/community); a bounded source read at start_line..end_line for the WHAT |
|
|
168
|
+
| "It's just a quick search" | grep has no understanding of call graphs, communities, or time |
|
|
169
|
+
| "I don't know if it's indexed" | Check with `memtrace_status` or `memtrace_list_indexed_repositories` first — takes 1 second |
|
|
170
|
+
| "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
|
|
171
|
+
| "Stats only show one language, but I need another directory" | That is a coverage diagnostic. Reindex the repo root; do not grep source code. |
|
|
172
|
+
| "The user didn't say to use Memtrace" | User asked about the code. Repo is indexed. Use Memtrace. |
|
|
173
|
+
| "This is a simple question" | Simple questions benefit most — one `memtrace_find_symbol` vs 20 file reads |
|
|
174
|
+
|
|
175
|
+
## When file tools are still correct
|
|
176
|
+
|
|
177
|
+
Use `grep`/`find`/`read` ONLY for:
|
|
178
|
+
- Non-source files or paths outside every indexed source repo
|
|
179
|
+
- Files that are config, data, or docs (not source code symbols)
|
|
180
|
+
- Repos or paths confirmed outside every Memtrace indexed root
|
|
181
|
+
|
|
182
|
+
For source-code spans already located by Memtrace, use a **bounded** `read(file, offset, limit)` with the returned `start_line`/`end_line`, or `memtrace_get_source_window`. Do not read the whole file.
|
|
183
|
+
|
|
184
|
+
Never use file tools as a **discovery** mechanism when Memtrace is available.
|
|
185
|
+
|
|
186
|
+
## Skill priority
|
|
187
|
+
|
|
188
|
+
This skill is a **process skill** — it runs BEFORE any implementation or search task.
|
|
189
|
+
|
|
190
|
+
When this skill applies, it overrides default file-search behavior. Companion skills installed alongside this one by `memtrace install`:
|
|
191
|
+
|
|
192
|
+
- Architecture overview → `memtrace-codebase-exploration`
|
|
193
|
+
- Temporal / change analysis → `memtrace-evolution`
|
|
194
|
+
- Impact analysis → `memtrace-impact`
|
|
195
|
+
- Search, quality, refactoring, decision memory, fleet coordination, etc. → other `memtrace-*` skills in `~/.pi/agent/skills/`
|
|
196
|
+
|
|
197
|
+
## Output
|
|
198
|
+
|
|
199
|
+
`memtrace_find_symbol` / `memtrace_find_code` return ranked symbol entries (`score` only with `include_diagnostics: true`):
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{ "name": "handleAuth", "kind": "Function", "file_path": "src/auth.ts",
|
|
203
|
+
"start_line": 42, "end_line": 87 }
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
`memtrace_get_symbol_context` returns the graph neighborhood: `symbol`, `callers`, `callees`, `type_references`, `community`, `processes`, `api_callers_cross_repo`. Feed `start_line`/`end_line` into a bounded `read` or `memtrace_get_source_window` — never a whole-file read.
|
|
207
|
+
|
|
208
|
+
## Success criteria
|
|
209
|
+
|
|
210
|
+
- The answer is grounded in Memtrace graph results (search hit → `memtrace_get_symbol_context` / `memtrace_get_impact`), not file-tool discovery.
|
|
211
|
+
- `grep`/`find`/`read` appear only via the documented narrow exceptions (non-source artifacts, paths outside every indexed root, file inventory, bounded span reads).
|
|
212
|
+
- Zero-result queries were diagnosed (`memtrace_list_indexed_repositories` → broaden → reindex), not bypassed to grep.
|
|
213
|
+
- Any source read was bounded to the span Memtrace returned.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-impact
|
|
3
|
+
description: Compute the blast radius of modifying a symbol through transitive graph impact. Use when the user asks about blast radius, impact, what breaks, risk, upstream callers, downstream dependencies, or consequences of modifying a symbol, before or during source-code changes. Do not use grep or manual reference search; Memtrace computes transitive graph impact.
|
|
4
|
+
allowed-tools: memtrace_get_impact memtrace_detect_changes memtrace_find_symbol memtrace_find_code
|
|
5
|
+
license: MIT
|
|
6
|
+
metadata:
|
|
7
|
+
author: "Memtrace <support@syncable.dev>"
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
category: development
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Compute the blast radius of changing a specific symbol. Traces upstream (what depends on this) and downstream (what this depends on) through the knowledge graph to quantify risk before making modifications.
|
|
15
|
+
|
|
16
|
+
## Quick reference
|
|
17
|
+
|
|
18
|
+
| Tool | Purpose |
|
|
19
|
+
|------|---------|
|
|
20
|
+
| `memtrace_get_impact` | Blast radius from a symbol **name** (`target`) |
|
|
21
|
+
| `memtrace_detect_changes` | Scope symbols affected by a diff/patch |
|
|
22
|
+
|
|
23
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`depth`, `limit`, etc.) must be JSON numbers — not strings.
|
|
24
|
+
|
|
25
|
+
## Required parameters — `memtrace_get_impact`
|
|
26
|
+
|
|
27
|
+
| Parameter | Required | Default | Notes |
|
|
28
|
+
|---|---|---|---|
|
|
29
|
+
| `repo_id` | yes | — | |
|
|
30
|
+
| `target` | yes | — | Symbol name (e.g. `"validateToken"`) — **not** `symbol_id` |
|
|
31
|
+
| `direction` | no | `"both"` | `"upstream"` \| `"downstream"` \| `"both"` |
|
|
32
|
+
| `depth` | no | `5` | BFS depth (max 15) |
|
|
33
|
+
| `as_of` | no | now | ISO-8601 for time-travel |
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{ "repo_id": "my-repo", "target": "validateToken", "direction": "both", "depth": 5 }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Full parameter spec for every Memtrace tool: [`../references/mcp-parameters.md`](../references/mcp-parameters.md).
|
|
40
|
+
|
|
41
|
+
## Steps
|
|
42
|
+
|
|
43
|
+
### 1. Identify the symbol name
|
|
44
|
+
|
|
45
|
+
If you don't know the exact name:
|
|
46
|
+
- `memtrace_find_symbol(name="...")` for exact identifiers
|
|
47
|
+
- `memtrace_find_code(query="...")` for natural-language queries
|
|
48
|
+
|
|
49
|
+
Use the returned **`name`** (and optional `file_path` hint) — graph tools resolve by name, not internal IDs.
|
|
50
|
+
|
|
51
|
+
### 2. Run impact analysis
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"repo_id": "my-repo",
|
|
56
|
+
"target": "validateToken",
|
|
57
|
+
"direction": "upstream",
|
|
58
|
+
"depth": 5
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 3. Interpret the risk rating
|
|
63
|
+
|
|
64
|
+
| Risk | Meaning | Action |
|
|
65
|
+
|------|---------|--------|
|
|
66
|
+
| **Low** | Few dependents, leaf node | Safe to modify; minimal testing needed |
|
|
67
|
+
| **Medium** | Moderate dependents | Test direct callers; review interface contracts |
|
|
68
|
+
| **High** | Many dependents across modules | Coordinate changes; comprehensive test coverage |
|
|
69
|
+
| **Critical** | Core infrastructure, many transitive dependents | Plan migration strategy; backward-compatible changes |
|
|
70
|
+
|
|
71
|
+
### 4. For diff-based analysis
|
|
72
|
+
|
|
73
|
+
When you have an actual code diff, use `memtrace_detect_changes`:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{ "repo_id": "my-repo", "diff": "<unified git diff text>" }
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or pass `changed_files: ["path/a.rs", "path/b.ts"]` when no diff text is available.
|
|
80
|
+
|
|
81
|
+
## Decision points
|
|
82
|
+
|
|
83
|
+
| Situation | Action |
|
|
84
|
+
|-----------|--------|
|
|
85
|
+
| Changing a single function | `memtrace_get_impact` with `direction: "both"` |
|
|
86
|
+
| Reviewing a PR or diff | `memtrace_detect_changes` with the diff content |
|
|
87
|
+
| Renaming/removing a public API | `memtrace_get_impact` with `direction: "upstream"`, higher `depth` |
|
|
88
|
+
| Refactoring internals | `memtrace_get_impact` with `direction: "downstream"` |
|
|
89
|
+
|
|
90
|
+
## Output
|
|
91
|
+
|
|
92
|
+
`memtrace_get_impact` returns the blast radius for the target symbol:
|
|
93
|
+
|
|
94
|
+
| Field | Example / meaning |
|
|
95
|
+
|---|---|
|
|
96
|
+
| Risk rating | `High` — one of `Low` / `Medium` / `High` / `Critical` (interpret via step 3) |
|
|
97
|
+
| Upstream | Transitive dependents (callers/importers) within `depth` hops — what breaks if the target changes |
|
|
98
|
+
| Downstream | Transitive dependencies — what the target relies on |
|
|
99
|
+
|
|
100
|
+
`memtrace_detect_changes` returns the set of symbols affected by the supplied `diff` / `changed_files`, plus the affected processes (execution flows).
|
|
101
|
+
|
|
102
|
+
## Common mistakes
|
|
103
|
+
|
|
104
|
+
| Mistake | Reality |
|
|
105
|
+
|---------|---------|
|
|
106
|
+
| Passing `symbol_id` or `name` | Required param is **`target`** |
|
|
107
|
+
| Omitting `repo_id` | Both `repo_id` and `target` are required |
|
|
108
|
+
| Defaulting `depth` to 3 | API default is **5** |
|