memtrace-skills 1.2.7 → 1.2.8
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/dist/skills.js +2 -1
- package/dist/tool-names.d.ts +1 -0
- package/dist/tool-names.js +101 -0
- package/dist/transformers/pi.d.ts +8 -0
- package/dist/transformers/pi.js +36 -6
- package/package.json +1 -1
- package/plugin-assets/index.d.ts +1 -1
- package/plugin-assets/index.js +5 -1
- package/plugins/memtrace-skills/references/mcp-parameters.md +10 -1
- package/plugins/memtrace-skills/skills/memtrace-first/SKILL.md +149 -269
- package/plugins/memtrace-skills/skills/memtrace-search/SKILL.md +31 -7
- package/skills/commands/memtrace-search.md +33 -7
- package/skills/workflows/memtrace-first.md +149 -269
|
@@ -1,41 +1,88 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-first
|
|
3
|
-
description: "Route code discovery, debugging, flow tracing, how-code-works questions, and pre-edit rationale checks in indexed source-code repos to Memtrace graph plus Cortex decision tools. Use first before searching/reading code, and before editing, refactoring, deleting, or re-picking an approach that may have a recorded decision, ban, convention, or contract. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results are not permission to grep
|
|
3
|
+
description: "Route code discovery, debugging, flow tracing, how-code-works questions, and pre-edit rationale checks in indexed source-code repos to Memtrace graph plus Cortex decision tools. Use first before searching/reading code, and before editing, refactoring, deleting, or re-picking an approach that may have a recorded decision, ban, convention, or contract. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results are not permission to grep: diagnose the miss first, then allow one targeted reformulation and bounded source verification or fallback, and reindex only on evidence of stale or incomplete coverage — never in a loop. A `repo_not_in_store` refusal means a different store holds the repository: route to that store, never grep and never re-index here."
|
|
4
4
|
---
|
|
5
|
-
|
|
6
5
|
# Memtrace First
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
IF THE REPO IS INDEXED IN MEMTRACE → USE MEMTRACE TOOLS FIRST.
|
|
12
|
-
After a search hit, route to GRAPH tools (get_symbol_context, get_impact,
|
|
13
|
-
analyze_relationships) — that's what Memtrace uniquely provides. Read source
|
|
14
|
-
ONLY when you're about to edit or quote, and read only the bounded span
|
|
15
|
-
returned by Memtrace (start_line .. end_line + small context). Do not
|
|
16
|
-
Grep/Glob/Find to "locate" anything already in the graph, and do not read
|
|
17
|
-
the whole file when Memtrace has given you exact lines.
|
|
18
|
-
|
|
19
|
-
BEFORE you edit/refactor/delete existing code or choose/re-pick a pattern,
|
|
20
|
-
call Cortex decision memory: recall_decision for the symbol/subsystem/approach,
|
|
21
|
-
and use provenance/contracts when a symbol_id is available. Use Memtrace's graph
|
|
22
|
-
tools for structure and blast radius; use Cortex for rationale, bans, and
|
|
23
|
-
contracts.
|
|
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. File tools are blind to all of that.
|
|
7
|
+
Use Memtrace first for code discovery in indexed repositories. Use its graph to
|
|
8
|
+
understand relationships, processes and impact; verify source when exact behavior
|
|
9
|
+
matters. Retrieval is evidence, not a guarantee of complete coverage.
|
|
27
10
|
|
|
28
|
-
|
|
11
|
+
## Establish scope
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
Call `list_indexed_repositories` once per session. Select the actual repository
|
|
14
|
+
and branch; pass `repo_id` explicitly when possible. It lists this session's
|
|
15
|
+
store only, so a repository missing from it may still be indexed and live in
|
|
16
|
+
another store. Do not index a parent containing unrelated repositories. For a
|
|
17
|
+
deliberately shared workspace, verify its workspace marker and scope before
|
|
18
|
+
indexing. If tools are unavailable, state that limitation and use bounded source
|
|
19
|
+
inspection rather than blocking the task.
|
|
31
20
|
|
|
32
|
-
|
|
21
|
+
### Workspace boundary check
|
|
33
22
|
|
|
34
|
-
|
|
23
|
+
Before indexing or reindexing, make sure the target path is the repo the user
|
|
24
|
+
asked about. If the current folder is only a parent that contains multiple
|
|
25
|
+
independent git repos, do **not** index the parent just because it is the open
|
|
26
|
+
editor folder. That creates or reuses a shared `.memdb` and can make agents
|
|
27
|
+
answer from stale repos.
|
|
35
28
|
|
|
36
|
-
|
|
29
|
+
- For separate repos: use the actual git repo root as the `index_directory`
|
|
30
|
+
path, or ask the user to open/run the agent from that repo root.
|
|
31
|
+
- For an intentional shared workspace: a portable manifest is the durable
|
|
32
|
+
form — `memtrace start --workspace-file <manifest>` declares the members and
|
|
33
|
+
records the manifest as the owner of the store's membership. The Folder
|
|
34
|
+
Group flow still works and the CLI now calls it legacy: the user blesses the
|
|
35
|
+
parent with `memtrace start --bless-workspace`, then verifies it with
|
|
36
|
+
`memtrace workspace status <path>`; the workspace marker should be present.
|
|
37
|
+
- A store whose membership is already owned by a manifest or a Named Workspace
|
|
38
|
+
cannot be widened by a plain `memtrace start` from a parent folder. That
|
|
39
|
+
start is refused with "a folder-walked start cannot widen it. Run
|
|
40
|
+
`<command>`", and the refusal names the exact command to run instead. Run
|
|
41
|
+
it. Do not route around the refusal by indexing elsewhere. A folder-sourced
|
|
42
|
+
store has no owning definition, so that refusal does not apply to it. A
|
|
43
|
+
`memtrace mcp` session can never widen an existing store under any flag,
|
|
44
|
+
including `--workspace-file`: adding a repository is always a `memtrace
|
|
45
|
+
start` for that store, carrying the manifest or the workspace name when one
|
|
46
|
+
owns its members.
|
|
47
|
+
- If `list_indexed_repositories` returns empty or its metadata says the MCP
|
|
48
|
+
child resolved a data dir from cwd because no workspace marker/git root was
|
|
49
|
+
found, surface the workspace mismatch. Do not "fix" it by indexing the broad
|
|
50
|
+
parent folder.
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
## Search, then investigate
|
|
53
|
+
|
|
54
|
+
- Exact symbol: `find_symbol(name=..., repo_id=...)`.
|
|
55
|
+
- Behavior or concept: `find_code(query=..., repo_id=...)`.
|
|
56
|
+
- Relationships: `get_symbol_context` or `analyze_relationships` on the useful hit.
|
|
57
|
+
- Change impact: `get_impact`; confirm relevant callers against source.
|
|
58
|
+
- Execution path: `get_process_flow`; follow its `next_offset` for further steps.
|
|
59
|
+
- Architecture: `list_communities`, `find_central_symbols` and process tools.
|
|
60
|
+
- Historical coupling or changes: `get_cochange_context`, `get_evolution`,
|
|
61
|
+
`get_changes_since` or `get_episode_replay` as appropriate.
|
|
62
|
+
|
|
63
|
+
Inspect `find_code.context` first: concept queries include query-matched processes,
|
|
64
|
+
communities and selected callers/callees, referencing primary results by one-based
|
|
65
|
+
number. Set `include_context: true` for identifier searches or `false` for flat
|
|
66
|
+
results. Expand a graph tool only when this context does not answer the question.
|
|
67
|
+
Treat partial context, truncation and unavailable overlay context as incomplete
|
|
68
|
+
evidence; selected static flows are not complete runtime traces.
|
|
69
|
+
|
|
70
|
+
`context.next_calls` provides scoped follow-up arguments for the useful symbol
|
|
71
|
+
and process. Before changing shared behavior, inspect relevant callers and
|
|
72
|
+
callees to identify contracts the patch must preserve. Use process IDs for
|
|
73
|
+
flow navigation. No sampled flow is not proof that no call path exists.
|
|
74
|
+
|
|
75
|
+
Turn the requested behavior into observable tests, including failure and
|
|
76
|
+
boundary cases. Check that tests exercise the failure condition itself;
|
|
77
|
+
manual cleanup must not make a broken asynchronous operation appear correct.
|
|
78
|
+
Run related existing tests to detect regressions before claiming completion.
|
|
79
|
+
|
|
80
|
+
Read the bounded source span when verifying behavior, editing or quoting. Do not
|
|
81
|
+
fetch whole files or entire process traces when a local span answers the question.
|
|
82
|
+
`get_symbol_context` omits source bodies by default; use `include_content: true`
|
|
83
|
+
for explicit expansion, and `limit`/`offset` for relationship pages. An omitted
|
|
84
|
+
risk diagnostic means unknown, not zero callers or low risk. Check truncation and
|
|
85
|
+
pagination metadata before describing a neighborhood as complete.
|
|
39
86
|
|
|
40
87
|
## Read the envelope before you diagnose anything
|
|
41
88
|
|
|
@@ -105,249 +152,82 @@ A forwarded read can also come back as a bounded `busy` answer with
|
|
|
105
152
|
the graph lane and for how long. That is a wait, not an absence — retry, or
|
|
106
153
|
narrow the call.
|
|
107
154
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
headers, and excluded dirs (`.git`, `node_modules`, `target`, `dist`) are
|
|
173
|
-
examples Memtrace cannot see.
|
|
174
|
-
- **Non-source artifacts.** `.env`, `package.json`, build scripts, top-level `README.md`, raw config files. Memtrace indexes parseable code, not configuration text.
|
|
175
|
-
- **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.
|
|
176
|
-
- **Reading at a known path outside Memtrace.** For configs, docs, or non-source artifacts that Memtrace cannot index, file `Read` is fine. For source-code spans returned by Memtrace, read the precise line range (your harness's `Read` with offset/limit, or `get_source_window` if your harness lacks bounded reads). Do not whole-file Read when you have a span.
|
|
177
|
-
|
|
178
|
-
For everything else inside the indexed repo, memtrace is the right tool.
|
|
179
|
-
|
|
180
|
-
## The decision rule
|
|
181
|
-
|
|
182
|
-
| Question Claude is asking | Right tool |
|
|
183
|
-
|---|---|
|
|
184
|
-
| "Where is symbol `foo` defined?" | `find_symbol(name="foo")` → then `get_symbol_context` for callers/callees/community, NOT a source read unless you're editing. |
|
|
185
|
-
| "What calls `foo`?" | `get_symbol_context(repo_id, symbol="foo")` → callers with file:line. |
|
|
186
|
-
| "How does authentication work?" | `find_code(query="authentication")` → `get_symbol_context` on the top hit, NOT a source read. |
|
|
187
|
-
| "Find behavior X" with multi-word phrase (3+ words) | `find_code(verbatim)` first; if low confidence, fan out with identifier-shaped reshapes (camelCase / snake_case). |
|
|
188
|
-
| "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
|
|
189
|
-
| "Where's that error message `'connection refused for tenant'`?" | `find_code(query="connection refused for tenant")` → semantic catches it. |
|
|
190
|
-
| "What breaks if I change `foo`?" | `get_impact(repo_id, target="foo")` → blast radius. |
|
|
191
|
-
| "Should I change/delete/refactor `foo`?" | `find_symbol`/`get_symbol_context` → `recall_decision("foo / subsystem / approach")`; if a symbol id is available, `why_is_this_here` + `governing_contracts`; then `get_impact`. |
|
|
192
|
-
| "Can I use/switch to pattern or library X?" | `recall_decision("X")` FIRST; bans and conventions are decisions. Verify a matching decision with `verify_intent(decision_id)` before relying on it. |
|
|
193
|
-
| "What changed in `auth.ts` last week?" | `get_evolution(repo_id, from="7d ago", mode="recent", file_path="auth.ts")`. |
|
|
194
|
-
| The answer carries `error_code: "repo_not_in_store"` | Read `diagnostic.reason`. On `ambiguous_repo_id`, pass the exact id. Otherwise read `diagnostic.repo_lives_in` and route the question to the session attached to that store. Never grep, never `index_directory`. |
|
|
195
|
-
| A `repo_id` tool answered zero with no `repo_in_store` key | It never checked membership. Re-ask through `find_code` or `find_symbol` before treating the zero as an absence. |
|
|
196
|
-
| "List all `*.test.ts` files." | `Glob` (file inventory, not symbol search). |
|
|
197
|
-
| "Find this string in my `.env`." | `Grep` (non-source artifact). |
|
|
198
|
-
| "I'm about to edit `foo` — show me its source." | Bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`, or `get_source_window` if your harness lacks bounded reads. Never whole-file. |
|
|
199
|
-
| "Read config/doc file I already have the path of." | `Read` (non-source artifact, path is known). |
|
|
200
|
-
|
|
201
|
-
## Parameter Types — Read This Before Calling Any Tool
|
|
202
|
-
|
|
203
|
-
All memtrace MCP tools are **strictly typed**. Pass JSON numbers (not strings) for integer parameters.
|
|
204
|
-
|
|
205
|
-
| Parameter | Correct | WRONG (fails with MCP error -32602) |
|
|
206
|
-
|---|---|---|
|
|
207
|
-
| `limit`, `min_size`, `depth`, `max_depth`, `last_n` | `limit: 20` | `limit: "20"` |
|
|
208
|
-
| `repo_id`, `branch`, `name`, `symbol_name`, `query` | `repo_id: "my-repo"` | `repo_id: my-repo` (unquoted) |
|
|
209
|
-
| `fuzzy`, `include_tests`, `invalidate` | `fuzzy: true` | `fuzzy: "true"` |
|
|
210
|
-
| `get_evolution.from` | `from: "90d ago"` | `days: 90` (wrong param — use `from`, not `days`) |
|
|
211
|
-
| `get_changes_since.since` | `since: "2026-04-13T10:43:00Z"` | `last_episode_id: "..."` (wrong param) |
|
|
212
|
-
| `get_impact.target` / `get_symbol_context.symbol` | `target: "foo"` / `symbol: "foo"` | `symbol_id: "..."` (wrong — use name) |
|
|
213
|
-
| `find_most_complex_functions` | `top_n: 10` | `limit: 10` (wrong param name) |
|
|
214
|
-
| `get_cochange_context` | `target: "execute"` | `symbol: "execute"` (wrong param name) |
|
|
215
|
-
|
|
216
|
-
If you see `failed to deserialize parameters: invalid type: string "N", expected usize`, remove the quotes from the number and retry.
|
|
217
|
-
|
|
218
|
-
If you see `missing field 'from'`, you called `get_evolution` without `from` — pass e.g. `"90d ago"`, never `days`.
|
|
219
|
-
|
|
220
|
-
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
221
|
-
|
|
222
|
-
## Check Indexing First (Once Per Session)
|
|
223
|
-
|
|
224
|
-
```
|
|
225
|
-
mcp__memtrace__list_indexed_repositories
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
If the current repo appears → Memtrace is active. Follow this skill for ALL code tasks.
|
|
229
|
-
If not indexed → offer to index with `mcp__memtrace__index_directory`, then follow this skill.
|
|
230
|
-
|
|
231
|
-
## Task → Tool Map
|
|
232
|
-
|
|
233
|
-
| What you need | Use instead of Grep/Glob/Read |
|
|
234
|
-
|---|---|
|
|
235
|
-
| Find a function / class / symbol | `find_symbol` or `find_code` |
|
|
236
|
-
| Understand how something works | `get_symbol_context` (the default next step) |
|
|
237
|
-
| Find all callers of a function | `get_symbol_context` (callers field) |
|
|
238
|
-
| Find all callees / dependencies | `get_symbol_context` (callees field) |
|
|
239
|
-
| Trace a request / execution path | `get_process_flow` |
|
|
240
|
-
| Understand module structure | `list_communities` |
|
|
241
|
-
| Find the most important symbols | `find_central_symbols` |
|
|
242
|
-
| Find API endpoints | `find_api_endpoints` |
|
|
243
|
-
| Find where an API is called | `find_api_calls` |
|
|
244
|
-
| Debug a problem | `get_symbol_context` → `get_impact` → `get_evolution` |
|
|
245
|
-
| What changed recently? | `get_changes_since` or `get_evolution` |
|
|
246
|
-
| What breaks if I change X? | `get_impact` |
|
|
247
|
-
| Cross-service / cross-repo calls | `get_service_diagram` or `get_api_topology` |
|
|
248
|
-
| Dependency between two symbols | `find_dependency_path` |
|
|
249
|
-
| What files change together? | `get_cochange_context` |
|
|
250
|
-
| Architecture overview | `list_communities` + `find_central_symbols` |
|
|
251
|
-
| About to edit / quote — need exact lines | Bounded `Read(file, offset=start_line, limit=N)` (preferred), or `get_source_window` for path-resolution parity |
|
|
252
|
-
| About to edit/refactor/delete existing code | `recall_decision` for the intent + `why_is_this_here`/`governing_contracts` when a symbol id is available, then `get_impact` |
|
|
253
|
-
| About to choose or replace a library/pattern/architecture | `recall_decision` first; use `verify_intent` on any matching decision before contradicting it |
|
|
254
|
-
| About to choose between competing idioms (ternary vs if-else, arrow vs fn-decl, const vs let, await vs `.then`) | `get_style_fingerprint(repo_id, file_path)` — empirical codebase norm; see `memtrace-style-fingerprint` workflow |
|
|
255
|
-
|
|
256
|
-
## Standard Workflows
|
|
257
|
-
|
|
258
|
-
### "How does X work?" / "Explain X"
|
|
259
|
-
1. `find_symbol` or `find_code` → locate the symbol
|
|
260
|
-
2. `get_symbol_context` → callers, callees, community, processes (this usually answers "how it works")
|
|
261
|
-
3. `get_process_flow` (if it's a process/request path)
|
|
262
|
-
4. Only if you need to quote source: bounded `Read` at start_line..end_line, or `get_source_window`
|
|
263
|
-
|
|
264
|
-
### Debugging "X is broken"
|
|
265
|
-
1. `find_symbol` → locate the broken thing
|
|
266
|
-
2. `get_symbol_context` → understand its role
|
|
267
|
-
3. `get_impact` → blast radius (what else breaks)
|
|
268
|
-
4. `get_evolution(from=<lookback>, mode: recent)` → per-episode changelog near the incident
|
|
269
|
-
5. `get_changes_since(since=<anchor>)` → catch-up since last session (requires stored `since` timestamp)
|
|
270
|
-
|
|
271
|
-
### "Where is X defined / called?"
|
|
272
|
-
1. `find_symbol` with `fuzzy: true`
|
|
273
|
-
2. `get_symbol_context` for full caller/callee map
|
|
274
|
-
3. Only if you need source text: bounded `Read` at start_line..end_line, or `get_source_window`
|
|
275
|
-
|
|
276
|
-
### Before any code modification
|
|
277
|
-
1. `find_symbol` → confirm you have the right target
|
|
278
|
-
2. `get_symbol_context` → understand full context
|
|
279
|
-
3. `recall_decision("<symbol/subsystem/approach>")` → surface recorded choices, bans, and conventions before deciding what to do
|
|
280
|
-
4. If a `symbol_id` is available, `why_is_this_here(symbol_id)` + `governing_contracts(symbol_id)` before deleting, rewriting, or "cleaning up" odd code
|
|
281
|
-
5. `get_impact` → know blast radius before touching anything
|
|
282
|
-
6. `get_style_fingerprint(repo_id, file_path=<file>)` → match the codebase's empirical idiom (ternary vs if-else, arrow vs fn-decl, etc.) — see `memtrace-style-fingerprint` workflow for the full decision rule
|
|
283
|
-
|
|
284
|
-
## Red Flags — STOP, Use Memtrace Instead
|
|
285
|
-
|
|
286
|
-
You are violating this skill if you think:
|
|
287
|
-
|
|
288
|
-
| Thought | Reality |
|
|
289
|
-
|---|---|
|
|
290
|
-
| "Let me grep for this" | `find_code` or `find_symbol` is faster and structurally aware |
|
|
291
|
-
| "Let me glob for the file" | `find_symbol` returns exact location with context |
|
|
292
|
-
| "Let me read the whole file" | `get_symbol_context` for the WHY (callers/callees/community); a bounded source read at start_line..end_line for the WHAT |
|
|
293
|
-
| "I know why this is written this way" | Check Cortex first. Use `recall_decision`; use `why_is_this_here`/`governing_contracts` when you have a symbol id. |
|
|
294
|
-
| "This looks unused/weird; I'll remove it" | `why_is_this_here` + `governing_contracts` first, then blast radius. CannotProve is unknown, not permission. |
|
|
295
|
-
| "I'll just switch to library/pattern X" | `recall_decision("X")` first — you may be reintroducing a banned approach. |
|
|
296
|
-
| "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
|
|
297
|
-
| "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
|
|
298
|
-
| "Memtrace returned 0 results" | Check `repo_in_store` first. If it is true, broaden the query, check repo_id/path coverage, then reindex if needed |
|
|
299
|
-
| "The zero had no `repo_in_store`, so the repo is not indexed" | Only ten tools set that key. A zero from the others says nothing about membership — re-ask through `find_code` or `find_symbol` |
|
|
300
|
-
| "It said `repo_not_in_store`, so I'll index it here" | The repository is already indexed in the store `diagnostic.repo_lives_in` names. Indexing here makes a second copy in the wrong store |
|
|
301
|
-
| "Stats only show Rust, but I need `ui/` or `memtrace-ui/`" | That is a coverage diagnostic. Reindex the repo root; do not grep source code. |
|
|
302
|
-
| "The user didn't say to use Memtrace" | User asked about the code. Repo is indexed. Use Memtrace. |
|
|
303
|
-
| "This is a simple question" | Simple questions benefit most — one `find_symbol` vs 20 file reads |
|
|
304
|
-
|
|
305
|
-
## When File Tools Are Still Correct
|
|
306
|
-
|
|
307
|
-
Use Grep/Glob/Read ONLY for:
|
|
308
|
-
- Non-source files or paths outside every indexed source repo
|
|
309
|
-
- Files that are config, data, or docs (not source code symbols)
|
|
310
|
-
- Repos or paths confirmed outside every Memtrace indexed root
|
|
311
|
-
- **Official Memtrace product documentation** — use `memtrace-docs` (`ask_docs` / `search_docs` / `read_doc`), not file tools or web search
|
|
312
|
-
|
|
313
|
-
For source-code spans already located by Memtrace, use a **bounded** read —
|
|
314
|
-
your harness's `Read(file, offset, limit)` with the returned `start_line` /
|
|
315
|
-
`end_line`, or `get_source_window` if your harness lacks bounded reads. Do
|
|
316
|
-
not read the whole file.
|
|
317
|
-
|
|
318
|
-
Never use file tools as a **discovery** mechanism when Memtrace is available.
|
|
319
|
-
|
|
320
|
-
## Skill Priority
|
|
321
|
-
|
|
322
|
-
This skill is a **process skill** — it runs BEFORE any implementation or search skill.
|
|
323
|
-
|
|
324
|
-
When this skill applies, it overrides default file-search behavior. Use the specific Memtrace sub-skills for deep detail on each tool:
|
|
325
|
-
|
|
326
|
-
- Discovery → `memtrace-search`
|
|
327
|
-
- Impact analysis → `memtrace-impact`
|
|
328
|
-
- Temporal / change analysis → `memtrace-evolution`
|
|
329
|
-
- Rationale / prior decisions / bans / contracts → `memtrace-decision-memory`
|
|
330
|
-
- Incident investigation → `memtrace-incident-investigation`
|
|
331
|
-
- Architecture overview → `memtrace-codebase-exploration`
|
|
332
|
-
- Refactoring → `memtrace-refactoring-guide`
|
|
333
|
-
- Memtrace **product docs** (install, CLI, MCP, enterprise) → `memtrace-docs`
|
|
334
|
-
|
|
335
|
-
## Output
|
|
336
|
-
|
|
337
|
-
`find_symbol` / `find_code` return ranked symbol entries (`score` only with `include_diagnostics: true`):
|
|
338
|
-
|
|
339
|
-
```json
|
|
340
|
-
{ "name": "handleAuth", "kind": "Function", "file_path": "src/auth.ts",
|
|
341
|
-
"start_line": 42, "end_line": 87 }
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
`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 `get_source_window` — never a whole-file read.
|
|
155
|
+
A `repo_not_in_store` refusal is also not evidence that a path lies outside
|
|
156
|
+
every indexed root: `list_indexed_repositories` covers this session's store
|
|
157
|
+
only, and the refusal's `diagnostic.repo_lives_in` names the store that does
|
|
158
|
+
hold the repository.
|
|
159
|
+
|
|
160
|
+
## Handle misses without loops
|
|
161
|
+
|
|
162
|
+
This ladder applies to a genuine zero — an empty or irrelevant result from a
|
|
163
|
+
tool that reported `repo_in_store: true`. A refusal, or a zero from a tool
|
|
164
|
+
that sets no `repo_in_store` key, is handled in the section above, not here.
|
|
165
|
+
|
|
166
|
+
1. Distinguish a tool error, a refusal (`repo_in_store: false`), a zero from a
|
|
167
|
+
tool that sets no `repo_in_store` key, missing scope, wrong branch, pending
|
|
168
|
+
index/embedding job, stale index and a valid empty result. Do not treat an
|
|
169
|
+
error as a clean miss, and do not treat a refusal or a keyless zero as one
|
|
170
|
+
either — re-ask through `find_code` or `find_symbol` before reading
|
|
171
|
+
anything into a keyless zero.
|
|
172
|
+
2. For an ambiguous query, make at most one targeted reformulation, using an
|
|
173
|
+
identifier or path hint where available, and a `file_path` filter such as
|
|
174
|
+
`ui/`, `memtrace-ui/`, `src/` or the framework directory when one applies.
|
|
175
|
+
3. If the result remains empty or irrelevant, use a bounded filesystem search
|
|
176
|
+
(`rg`, Grep or Glob) and verify the matching source. A returned hit that does
|
|
177
|
+
not answer the question is also a retrieval miss. Do **not** infer from a
|
|
178
|
+
zero that a source subdirectory is outside the index.
|
|
179
|
+
4. Record the original miss and fallback in diagnostic/benchmark evidence. Do
|
|
180
|
+
not count filesystem recovery as successful Memtrace retrieval, and report
|
|
181
|
+
the indexing coverage problem rather than silently switching to grep.
|
|
182
|
+
5. Reindex only when there is evidence of stale or incomplete coverage, at the
|
|
183
|
+
correct repository root, and only once steps 1 and 2 show the repository is
|
|
184
|
+
a member of this store. Prefer incremental repair (`index_directory` with
|
|
185
|
+
`incremental: true`; ask before `clear_existing: true`). Never repeat
|
|
186
|
+
indexing merely because a semantic query did not retrieve a target, and
|
|
187
|
+
never reindex in response to a `repo_not_in_store` refusal.
|
|
188
|
+
|
|
189
|
+
Memtrace combines full-text retrieval, vectors and graph expansion. Embedding
|
|
190
|
+
eligibility, language support, source limits and ranking affect recall. Literal
|
|
191
|
+
strings, short helpers and arbitrary body text are not guaranteed to appear in
|
|
192
|
+
semantic results. Use source search to establish exhaustive literal occurrences.
|
|
193
|
+
Configuration files, documentation, file inventories and excluded dependencies
|
|
194
|
+
are also appropriate uses of file tools.
|
|
195
|
+
|
|
196
|
+
## Check rationale before changing code
|
|
197
|
+
|
|
198
|
+
BEFORE you edit/refactor/delete existing code or choose another pattern, call
|
|
199
|
+
Cortex `recall_decision("<symbol/subsystem/approach>")` when available. If a symbol
|
|
200
|
+
ID is available, consult `why_is_this_here(symbol_id)` and
|
|
201
|
+
`governing_contracts(symbol_id)`. Verify a
|
|
202
|
+
matching decision with `verify_intent` before relying on it. Unknown rationale
|
|
203
|
+
is not evidence that there is no contract. Use graph impact for structure and
|
|
204
|
+
Cortex for recorded choices, conventions and bans. Use `get_style_fingerprint`
|
|
205
|
+
when choosing among competing local idioms.
|
|
206
|
+
|
|
207
|
+
## Tool arguments
|
|
208
|
+
|
|
209
|
+
Use JSON numbers for limits/depths and booleans for switches. Use symbol names
|
|
210
|
+
for `get_symbol_context.symbol`, `get_impact.target` and relationship targets;
|
|
211
|
+
use IDs only where the specific schema asks for one. Prefer the live schema over
|
|
212
|
+
remembered parameters. `find_code` has no `kind` filter; use `find_symbol` for it.
|
|
213
|
+
Search without an explicit repository uses safe scope inference, not an implicit
|
|
214
|
+
search of every repository. `get_evolution` uses `from`, not `days`.
|
|
215
|
+
|
|
216
|
+
For product setup or usage documentation, use `memtrace-docs`. Full tool parameter
|
|
217
|
+
references are bundled with the skills package. Do not print routine tool usage
|
|
218
|
+
receipts; preserve evidence internally and report meaningful findings and limits.
|
|
345
219
|
|
|
346
220
|
## Success criteria
|
|
347
221
|
|
|
348
|
-
- The
|
|
349
|
-
-
|
|
350
|
-
|
|
351
|
-
-
|
|
352
|
-
|
|
222
|
+
- The right repository and branch were used.
|
|
223
|
+
- Graph claims are supported by retrieved edges, with missing/truncated data
|
|
224
|
+
made explicit, and exact behavioral claims are checked against source.
|
|
225
|
+
- A `repo_not_in_store` refusal was routed on `diagnostic.repo_lives_in`, not
|
|
226
|
+
answered by grep and not answered by indexing the repository into this store.
|
|
227
|
+
- A zero from a tool that sets no `repo_in_store` key was re-checked through a
|
|
228
|
+
membership-checking tool before it was called an absence.
|
|
229
|
+
- Failed retrieval on a genuine zero (`repo_in_store: true`) is diagnosed and
|
|
230
|
+
bounded; it does not trigger query or reindex loops, and fallbacks remain
|
|
231
|
+
distinguishable from retrieval successes.
|
|
353
232
|
- Any source read was bounded to the span Memtrace returned.
|
|
233
|
+
- Existing rationale and contracts were checked when the tools were available.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-search
|
|
3
|
-
description: "Find source code with Memtrace hybrid BM25+semantic search: symbols, functions, classes, types, constants, definitions, implementations, logic, or error strings inside code. Use when the user wants to find, search, locate, or look up code or asks where code lives.
|
|
3
|
+
description: "Find source code with Memtrace hybrid BM25+semantic search: symbols, functions, classes, types, constants, definitions, implementations, logic, or error strings inside code. Use when the user wants to find, search, locate, or look up code or asks where code lives. Use Memtrace first; after a diagnosed miss and one targeted retry, allow bounded source verification or fallback. Reindex only for evidence of stale or incomplete coverage."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
@@ -22,11 +22,13 @@ Find code using hybrid BM25 + semantic search (RRF). Primary discovery tool —
|
|
|
22
22
|
| Param | Required | Default | Notes |
|
|
23
23
|
|---|---|---|---|
|
|
24
24
|
| `query` | yes | — | Natural language or symbol text |
|
|
25
|
-
| `repo_id` | no | this store's members |
|
|
25
|
+
| `repo_id` | no | this store's members | Safe scope inference: omitted, an unambiguous session resolves to its own repository; a multi-repo store fans out across its discovered members |
|
|
26
26
|
| `limit` | no | 20 | Max 100 |
|
|
27
27
|
| `file_path` | no | — | Path/directory substring filter |
|
|
28
28
|
| `as_of` | no | now | ISO-8601 time-travel |
|
|
29
29
|
| `include_diagnostics` | no | false | Set true for `id`, `score` in results |
|
|
30
|
+
| `include_dependency_checks` | no | true | With diagnostics, set false for scores without pre-edit risk checks |
|
|
31
|
+
| `include_context` | no | auto | Query-matched processes, communities and selected callers/callees; auto on for concept queries, off for identifiers |
|
|
30
32
|
|
|
31
33
|
**No `kind` param on `find_code`** — use `find_symbol(kind=...)` to filter by symbol type.
|
|
32
34
|
|
|
@@ -39,7 +41,7 @@ Find code using hybrid BM25 + semantic search (RRF). Primary discovery tool —
|
|
|
39
41
|
| Param | Required | Default | Notes |
|
|
40
42
|
|---|---|---|---|
|
|
41
43
|
| `name` | yes | — | Symbol name to search |
|
|
42
|
-
| `repo_id` | no | inferred |
|
|
44
|
+
| `repo_id` | no | inferred | Safe scope inference: one repository is inferred only when that is unambiguous; otherwise the call returns `repo_scope_required` |
|
|
43
45
|
| `fuzzy` | no | false | API field exists; currently exact-match in backend |
|
|
44
46
|
| `edit_distance` | no | 2 | Only when fuzzy enabled |
|
|
45
47
|
| `kind` | no | — | `Function`, `Class`, `Method`, etc. |
|
|
@@ -64,9 +66,27 @@ Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bun
|
|
|
64
66
|
|
|
65
67
|
Result shape: see [Output](#output) below.
|
|
66
68
|
|
|
67
|
-
### 3.
|
|
69
|
+
### 3. Inspect query context, then expand if needed
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
Concept searches include a bounded `context` object. Its process matches and
|
|
72
|
+
community members reference the primary `results` by one-based number. Inspect
|
|
73
|
+
these and the selected callers/callees before making another graph call.
|
|
74
|
+
Use `include_context: true` for identifier context, or `false` for flat results.
|
|
75
|
+
Check `status`, `incomplete_reasons`, `coverage` and `payload_truncated`: omitted
|
|
76
|
+
relationships are not proof of absence. The context contains selected matches,
|
|
77
|
+
not a complete process trace. Worktree overlays report context unavailable until
|
|
78
|
+
their graph is refreshed.
|
|
79
|
+
|
|
80
|
+
For a code change, inspect the relevant caller/callee contracts before editing.
|
|
81
|
+
`context.next_calls` supplies valid tool names and arguments for the selected
|
|
82
|
+
symbol and flow; use these directly when they address the investigation.
|
|
83
|
+
They preserve repository, branch and file disambiguation. Process navigation
|
|
84
|
+
uses the returned process UUID. Symbol navigation uses name plus file path.
|
|
85
|
+
Expand only the evidence needed; an empty sampled process list does not mean
|
|
86
|
+
the symbol has no callers or callees.
|
|
87
|
+
|
|
88
|
+
For symbol navigation, save **`name`**, **`scope_path`**, and **`file_path`**.
|
|
89
|
+
For process navigation, retain its **process `id`**:
|
|
70
90
|
|
|
71
91
|
```json
|
|
72
92
|
{ "repo_id": "memdb", "symbol": "validateToken" }
|
|
@@ -74,12 +94,12 @@ Save **`name`**, **`scope_path`**, and **`file_path`** — **not** internal IDs:
|
|
|
74
94
|
{ "repo_id": "memdb", "target": "validateToken", "query_type": "find_callers" }
|
|
75
95
|
```
|
|
76
96
|
|
|
77
|
-
Read source
|
|
97
|
+
Read source when verifying behavior, editing or quoting — bounded `Read(offset, limit)` at returned lines.
|
|
78
98
|
|
|
79
99
|
### Multi-word queries
|
|
80
100
|
|
|
81
101
|
1. Try verbatim `find_code` query.
|
|
82
|
-
2. If weak,
|
|
102
|
+
2. If weak, make one targeted reformulation with an identifier or path hint.
|
|
83
103
|
3. Dedupe top hits by `file_path:start_line`.
|
|
84
104
|
|
|
85
105
|
## Output
|
|
@@ -124,3 +144,7 @@ names.
|
|
|
124
144
|
| Assuming `fuzzy: true` always works | Backend is exact-match today — try spelling variants |
|
|
125
145
|
| Skipping `list_indexed_repositories` | Verify repo is indexed first — it lists this session's store only |
|
|
126
146
|
| Reading `repo_not_in_store` as an empty index | Nothing was searched; the repository lives in the store `diagnostic.repo_lives_in` names |
|
|
147
|
+
|
|
148
|
+
## Retrieval limits and fallback
|
|
149
|
+
|
|
150
|
+
A valid empty or irrelevant result is not a guarantee that the code is absent. Check scope, branch and indexing/embedding readiness; retry once with a targeted query. Then permit bounded source search and verification. Record the original miss and do not count fallback recovery as Memtrace retrieval success. Reindex only for demonstrated stale or incomplete coverage. Embeddings cannot guarantee literal-string or short-symbol recall. A `repo_not_in_store` refusal is not such a miss: nothing was searched, so route it to the store `diagnostic.repo_lives_in` names rather than falling back to source search or reindexing here.
|