memtrace-skills 0.7.10
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/commands/doctor.d.ts +16 -0
- package/dist/commands/doctor.js +199 -0
- package/dist/commands/enterprise-install.d.ts +7 -0
- package/dist/commands/enterprise-install.js +129 -0
- package/dist/commands/install.d.ts +9 -0
- package/dist/commands/install.js +104 -0
- package/dist/commands/picker.d.ts +6 -0
- package/dist/commands/picker.js +22 -0
- package/dist/commands/rail-install.d.ts +7 -0
- package/dist/commands/rail-install.js +37 -0
- package/dist/fs-safe.d.ts +21 -0
- package/dist/fs-safe.js +35 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +87 -0
- package/dist/rail-install.d.ts +20 -0
- package/dist/rail-install.js +183 -0
- package/dist/skills.d.ts +17 -0
- package/dist/skills.js +64 -0
- package/dist/transformers/claude.d.ts +71 -0
- package/dist/transformers/claude.js +702 -0
- package/dist/transformers/codex.d.ts +8 -0
- package/dist/transformers/codex.js +294 -0
- package/dist/transformers/cursor.d.ts +7 -0
- package/dist/transformers/cursor.js +124 -0
- package/dist/transformers/gemini.d.ts +3 -0
- package/dist/transformers/gemini.js +78 -0
- package/dist/transformers/hermes.d.ts +5 -0
- package/dist/transformers/hermes.js +136 -0
- package/dist/transformers/index.d.ts +14 -0
- package/dist/transformers/index.js +24 -0
- package/dist/transformers/kiro.d.ts +2 -0
- package/dist/transformers/kiro.js +69 -0
- package/dist/transformers/opencode.d.ts +2 -0
- package/dist/transformers/opencode.js +77 -0
- package/dist/transformers/rail-hooks.d.ts +56 -0
- package/dist/transformers/rail-hooks.js +303 -0
- package/dist/transformers/shared.d.ts +18 -0
- package/dist/transformers/shared.js +129 -0
- package/dist/transformers/types.d.ts +40 -0
- package/dist/transformers/types.js +1 -0
- package/dist/transformers/vscode.d.ts +3 -0
- package/dist/transformers/vscode.js +53 -0
- package/dist/transformers/windsurf.d.ts +3 -0
- package/dist/transformers/windsurf.js +43 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +22 -0
- package/package.json +50 -0
- package/plugins/memtrace-skills/.claude-plugin/plugin.json +23 -0
- package/plugins/memtrace-skills/references/mcp-parameters.md +302 -0
- package/plugins/memtrace-skills/skills/memtrace-api-topology/SKILL.md +58 -0
- package/plugins/memtrace-skills/skills/memtrace-change-impact-analysis/SKILL.md +75 -0
- package/plugins/memtrace-skills/skills/memtrace-cochange/SKILL.md +71 -0
- package/plugins/memtrace-skills/skills/memtrace-code-review/SKILL.md +41 -0
- package/plugins/memtrace-skills/skills/memtrace-codebase-exploration/SKILL.md +94 -0
- package/plugins/memtrace-skills/skills/memtrace-continuous-memory/SKILL.md +96 -0
- package/plugins/memtrace-skills/skills/memtrace-episode-replay/SKILL.md +94 -0
- package/plugins/memtrace-skills/skills/memtrace-evolution/SKILL.md +128 -0
- package/plugins/memtrace-skills/skills/memtrace-first/SKILL.md +194 -0
- package/plugins/memtrace-skills/skills/memtrace-fleet-coordination/SKILL.md +80 -0
- package/plugins/memtrace-skills/skills/memtrace-fleet-first/SKILL.md +125 -0
- package/plugins/memtrace-skills/skills/memtrace-fleet-publish-intent/SKILL.md +48 -0
- package/plugins/memtrace-skills/skills/memtrace-fleet-record-episode/SKILL.md +44 -0
- package/plugins/memtrace-skills/skills/memtrace-fleet-resolve/SKILL.md +54 -0
- package/plugins/memtrace-skills/skills/memtrace-graph/SKILL.md +67 -0
- package/plugins/memtrace-skills/skills/memtrace-impact/SKILL.md +58 -0
- package/plugins/memtrace-skills/skills/memtrace-incident-investigation/SKILL.md +112 -0
- package/plugins/memtrace-skills/skills/memtrace-index/SKILL.md +65 -0
- package/plugins/memtrace-skills/skills/memtrace-quality/SKILL.md +63 -0
- package/plugins/memtrace-skills/skills/memtrace-refactoring-guide/SKILL.md +103 -0
- package/plugins/memtrace-skills/skills/memtrace-relationships/SKILL.md +67 -0
- package/plugins/memtrace-skills/skills/memtrace-search/SKILL.md +93 -0
- package/plugins/memtrace-skills/skills/memtrace-session-continuity/SKILL.md +93 -0
- package/plugins/memtrace-skills/skills/memtrace-style-fingerprint/SKILL.md +105 -0
- package/skills/commands/memtrace-api-topology.md +65 -0
- package/skills/commands/memtrace-cochange.md +76 -0
- package/skills/commands/memtrace-evolution.md +135 -0
- package/skills/commands/memtrace-fleet-publish-intent.md +51 -0
- package/skills/commands/memtrace-fleet-record-episode.md +48 -0
- package/skills/commands/memtrace-fleet-resolve.md +59 -0
- package/skills/commands/memtrace-graph.md +75 -0
- package/skills/commands/memtrace-impact.md +64 -0
- package/skills/commands/memtrace-index.md +71 -0
- package/skills/commands/memtrace-quality.md +69 -0
- package/skills/commands/memtrace-relationships.md +73 -0
- package/skills/commands/memtrace-search.md +93 -0
- package/skills/workflows/memtrace-change-impact-analysis.md +85 -0
- package/skills/workflows/memtrace-code-review.md +48 -0
- package/skills/workflows/memtrace-codebase-exploration.md +108 -0
- package/skills/workflows/memtrace-continuous-memory.md +104 -0
- package/skills/workflows/memtrace-episode-replay.md +100 -0
- package/skills/workflows/memtrace-first.md +194 -0
- package/skills/workflows/memtrace-fleet-coordination.md +87 -0
- package/skills/workflows/memtrace-fleet-first.md +132 -0
- package/skills/workflows/memtrace-incident-investigation.md +125 -0
- package/skills/workflows/memtrace-refactoring-guide.md +116 -0
- package/skills/workflows/memtrace-session-continuity.md +98 -0
- package/skills/workflows/memtrace-style-fingerprint.md +111 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-impact
|
|
3
|
+
description: "Always use before or during source-code changes when the user asks about blast radius, impact, what breaks, risk, upstream callers, downstream dependencies, or consequences of modifying a symbol. Do not use Grep or manual reference search; Memtrace computes transitive graph impact."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__get_impact
|
|
6
|
+
- mcp__memtrace__detect_changes
|
|
7
|
+
- mcp__memtrace__find_symbol
|
|
8
|
+
- mcp__memtrace__find_code
|
|
9
|
+
user-invocable: true
|
|
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
|
+
| `get_impact` | Blast radius from a specific symbol (by ID) |
|
|
21
|
+
| `detect_changes` | Scope symbols affected by a diff/patch |
|
|
22
|
+
|
|
23
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`limit`, `depth`, `min_size`, `last_n`, etc.) must be JSON numbers — not strings. Use `limit: 20`, never `limit: "20"`. Passing a string yields `MCP error -32602: invalid type: string, expected usize`.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
### 1. Identify the symbol
|
|
29
|
+
|
|
30
|
+
If you have a symbol name but not its ID:
|
|
31
|
+
- Use `find_symbol` for exact names
|
|
32
|
+
- Use `find_code` for natural-language queries
|
|
33
|
+
|
|
34
|
+
### 2. Run impact analysis
|
|
35
|
+
|
|
36
|
+
Use the `get_impact` MCP tool:
|
|
37
|
+
- `symbol_id` — the symbol you plan to change (required)
|
|
38
|
+
- `direction` — `upstream` (what depends on me), `downstream` (what I depend on), or `both` (default)
|
|
39
|
+
- `depth` — traversal hops (default 3)
|
|
40
|
+
|
|
41
|
+
### 3. Interpret the risk rating
|
|
42
|
+
|
|
43
|
+
| Risk | Meaning | Action |
|
|
44
|
+
|------|---------|--------|
|
|
45
|
+
| **Low** | Few dependents, leaf node | Safe to modify; minimal testing needed |
|
|
46
|
+
| **Medium** | Moderate dependents | Test direct callers; review interface contracts |
|
|
47
|
+
| **High** | Many dependents across modules | Coordinate changes; comprehensive test coverage |
|
|
48
|
+
| **Critical** | Core infrastructure, many transitive dependents | Plan migration strategy; consider backward-compatible changes |
|
|
49
|
+
|
|
50
|
+
### 4. For diff-based analysis
|
|
51
|
+
|
|
52
|
+
When you have an actual code diff (not just a symbol), use `detect_changes`:
|
|
53
|
+
- Scopes all symbols affected by the diff
|
|
54
|
+
- Returns blast radius AND affected processes (execution flows)
|
|
55
|
+
- Useful for PR reviews or pre-commit checks
|
|
56
|
+
|
|
57
|
+
## Decision Points
|
|
58
|
+
|
|
59
|
+
| Situation | Action |
|
|
60
|
+
|-----------|--------|
|
|
61
|
+
| Changing a single function | `get_impact` with `direction: both` |
|
|
62
|
+
| Reviewing a PR or diff | `detect_changes` with the diff content |
|
|
63
|
+
| Renaming/removing a public API | `get_impact` with `direction: upstream`, high depth |
|
|
64
|
+
| Refactoring internals | `get_impact` with `direction: downstream` to check what you depend on |
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-index
|
|
3
|
+
description: "Always use when the user asks to index, parse, ingest, reindex, watch, or prepare a source-code repo for Memtrace analysis, when code exploration needs an index, or when searches return 0/partial results for source paths under an indexed root. Use this before Grep, Glob, rg, find, or manual code search whenever the repo can be indexed."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__index_directory
|
|
6
|
+
- mcp__memtrace__check_job_status
|
|
7
|
+
- mcp__memtrace__list_jobs
|
|
8
|
+
- mcp__memtrace__list_indexed_repositories
|
|
9
|
+
user-invocable: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Index a local codebase into the persistent code knowledge graph. This is always the first step — it parses every source file, resolves cross-file relationships, detects API endpoints/calls, runs community detection and process tracing, and embeds all symbols for semantic search.
|
|
15
|
+
|
|
16
|
+
## Quick Reference
|
|
17
|
+
|
|
18
|
+
| Parameter | Purpose |
|
|
19
|
+
|-----------|---------|
|
|
20
|
+
| `path` | Absolute path to the directory to index |
|
|
21
|
+
| `incremental` | Only re-parse changed files (use for subsequent runs) |
|
|
22
|
+
| `clear_existing` | Wipe and rebuild from scratch |
|
|
23
|
+
|
|
24
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`limit`, `depth`, `min_size`, `last_n`, etc.) must be JSON numbers — not strings. Use `limit: 20`, never `limit: "20"`. Passing a string yields `MCP error -32602: invalid type: string, expected usize`.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Steps
|
|
28
|
+
|
|
29
|
+
### 1. Check if already indexed
|
|
30
|
+
|
|
31
|
+
Use the `list_indexed_repositories` MCP tool first. If the repo is already indexed and recent, skip to step 4.
|
|
32
|
+
|
|
33
|
+
**Success criteria:** You have a list of repo_ids and their last-indexed timestamps.
|
|
34
|
+
|
|
35
|
+
If a repo is present but searches miss a source subdirectory under that repo
|
|
36
|
+
root (for example `ui/`, `memtrace-ui/`, `web/`, `frontend/`, or `src/`), treat
|
|
37
|
+
that as a stale/partial index. Do not use grep as a workaround. Run incremental
|
|
38
|
+
indexing on the repo root, then retry the Memtrace query.
|
|
39
|
+
|
|
40
|
+
### 2. Index the directory
|
|
41
|
+
|
|
42
|
+
Use the `index_directory` MCP tool:
|
|
43
|
+
|
|
44
|
+
- Set `path` to the project root (absolute path)
|
|
45
|
+
- Set `incremental: true` if re-indexing after changes
|
|
46
|
+
- Set `clear_existing: true` only if a full rebuild is needed
|
|
47
|
+
|
|
48
|
+
**Success criteria:** You receive a `job_id` immediately.
|
|
49
|
+
|
|
50
|
+
### 3. Poll for completion
|
|
51
|
+
|
|
52
|
+
Use `check_job_status` with the `job_id` every 2–3 seconds.
|
|
53
|
+
|
|
54
|
+
Pipeline stages in order: **scan → parse → resolve → communities → processes → persist → embeddings → api_detect → done**
|
|
55
|
+
|
|
56
|
+
Wait until `status = "completed"`. If `status = "failed"`, report the error message to the user.
|
|
57
|
+
|
|
58
|
+
### 4. Report to user
|
|
59
|
+
|
|
60
|
+
After indexing completes, call `list_indexed_repositories` to confirm the repo appears with correct node/edge counts. Report: repo_id, languages detected, total symbols, total relationships.
|
|
61
|
+
|
|
62
|
+
**Save the `repo_id`** — most other memtrace tools require it.
|
|
63
|
+
|
|
64
|
+
## Error Handling
|
|
65
|
+
|
|
66
|
+
| Error | Action |
|
|
67
|
+
|-------|--------|
|
|
68
|
+
| Path does not exist | Ask user to verify the absolute path |
|
|
69
|
+
| Job status "failed" | Report the error message; suggest `clear_existing: true` for a fresh rebuild |
|
|
70
|
+
| Timeout (job running > 5 min) | Large repos are normal; keep polling. For monorepos, index subdirectories separately |
|
|
71
|
+
| Already indexed | Use `incremental: true` to update, or skip indexing entirely |
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-quality
|
|
3
|
+
description: "Always use for source-code quality, dead code, unused functions, zero callers, complexity, cyclomatic complexity, hotspots, refactoring candidates, or code smell questions. Do not use Grep, Glob, rg, or manual reference search for unused code; Memtrace uses graph reachability and complexity metrics."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__find_dead_code
|
|
6
|
+
- mcp__memtrace__calculate_cyclomatic_complexity
|
|
7
|
+
- mcp__memtrace__find_most_complex_functions
|
|
8
|
+
- mcp__memtrace__get_repository_stats
|
|
9
|
+
user-invocable: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Identify code quality issues using structural graph analysis — dead code (zero callers), complexity hotspots (high out-degree), and repository-wide statistics.
|
|
15
|
+
|
|
16
|
+
## Quick Reference
|
|
17
|
+
|
|
18
|
+
| Tool | Purpose |
|
|
19
|
+
|------|---------|
|
|
20
|
+
| `find_dead_code` | Symbols with zero callers (potentially unused) |
|
|
21
|
+
| `calculate_cyclomatic_complexity` | Complexity score for a specific symbol |
|
|
22
|
+
| `find_most_complex_functions` | Top-N functions by complexity across the repo |
|
|
23
|
+
| `get_repository_stats` | Repo-wide counts: nodes, edges, communities, processes |
|
|
24
|
+
|
|
25
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`limit`, `depth`, `min_size`, `last_n`, etc.) must be JSON numbers — not strings. Use `limit: 20`, never `limit: "20"`. Passing a string yields `MCP error -32602: invalid type: string, expected usize`.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Steps
|
|
29
|
+
|
|
30
|
+
### 1. Get repository overview
|
|
31
|
+
|
|
32
|
+
Use `get_repository_stats` to understand the codebase scale:
|
|
33
|
+
- Node counts by kind (functions, classes, methods, interfaces)
|
|
34
|
+
- Edge counts (calls, imports, extends, type references)
|
|
35
|
+
- Community and process counts
|
|
36
|
+
|
|
37
|
+
### 2. Find dead code
|
|
38
|
+
|
|
39
|
+
Use `find_dead_code`:
|
|
40
|
+
- `repo_id` — required
|
|
41
|
+
- `include_tests` — set true to also flag unused test helpers (default false)
|
|
42
|
+
|
|
43
|
+
**Note:** Exported symbols and entry points are excluded by default — the tool won't flag public APIs as "dead" just because they're called externally.
|
|
44
|
+
|
|
45
|
+
### 3. Find complexity hotspots
|
|
46
|
+
|
|
47
|
+
Use `find_most_complex_functions`:
|
|
48
|
+
- `repo_id` — required
|
|
49
|
+
- `limit` — how many to return (default 10)
|
|
50
|
+
|
|
51
|
+
Complexity scoring (based on out-degree — number of callees):
|
|
52
|
+
| Score | Rating | Action |
|
|
53
|
+
|-------|--------|--------|
|
|
54
|
+
| < 5 | Low | No action needed |
|
|
55
|
+
| 5–10 | Medium | Monitor; consider splitting if growing |
|
|
56
|
+
| 10–20 | High | Refactoring candidate; extract helper functions |
|
|
57
|
+
| > 20 | Critical | Immediate attention; this function does too much |
|
|
58
|
+
|
|
59
|
+
### 4. Drill into specific functions
|
|
60
|
+
|
|
61
|
+
Use `calculate_cyclomatic_complexity` on specific symbols flagged by the user or found in step 3.
|
|
62
|
+
|
|
63
|
+
## Common Mistakes
|
|
64
|
+
|
|
65
|
+
| Mistake | Reality |
|
|
66
|
+
|---------|---------|
|
|
67
|
+
| Treating all dead code as deletable | Some "dead" code is called via reflection, dynamic dispatch, or external consumers |
|
|
68
|
+
| Ignoring exported symbols in dead code results | If `include_tests: false`, exported symbols are already excluded |
|
|
69
|
+
| Only looking at the highest complexity | Medium-complexity functions that are growing (check `get_evolution`) are often more urgent |
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-relationships
|
|
3
|
+
description: "Always use for source-code relationship questions: callers, callees, references, imports, exports, type usages, class hierarchy, inheritance, implementations, overrides, or dependencies between symbols. Do not use Grep, Glob, rg, find, or manual text search for references; Memtrace traverses typed AST graph edges."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__analyze_relationships
|
|
6
|
+
- mcp__memtrace__get_symbol_context
|
|
7
|
+
- mcp__memtrace__find_symbol
|
|
8
|
+
- mcp__memtrace__find_code
|
|
9
|
+
user-invocable: true
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Traverse the code knowledge graph to map relationships between symbols — callers, callees, class hierarchies, imports, exports, and type usages. Essential for understanding a symbol's neighbourhood before modifying it.
|
|
15
|
+
|
|
16
|
+
## Quick Reference
|
|
17
|
+
|
|
18
|
+
| query_type | What it finds |
|
|
19
|
+
|------------|---------------|
|
|
20
|
+
| `find_callers` | What calls this function/method? |
|
|
21
|
+
| `find_callees` | What does this function call? |
|
|
22
|
+
| `class_hierarchy` | Parent classes, interfaces, mixins |
|
|
23
|
+
| `overrides` | Which child classes override this method? |
|
|
24
|
+
| `imports` | What modules does this file import? |
|
|
25
|
+
| `exporters` | Which files import this module? |
|
|
26
|
+
| `type_usages` | Where is this type/interface referenced? |
|
|
27
|
+
|
|
28
|
+
> **Parameter types:** MCP parameters are strictly typed. Numbers (`limit`, `depth`, `min_size`, `last_n`, etc.) must be JSON numbers — not strings. Use `limit: 20`, never `limit: "20"`. Passing a string yields `MCP error -32602: invalid type: string, expected usize`.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Steps
|
|
32
|
+
|
|
33
|
+
### 1. Get the symbol ID
|
|
34
|
+
|
|
35
|
+
If you don't have a symbol `id`, find it first:
|
|
36
|
+
- Use `find_symbol` for exact names
|
|
37
|
+
- Use `find_code` for natural-language queries
|
|
38
|
+
|
|
39
|
+
### 2. Choose your approach
|
|
40
|
+
|
|
41
|
+
**Quick 360° view** → Use `get_symbol_context`
|
|
42
|
+
Returns in one call: direct callers, callees, type references, community membership, process membership, and cross-repo API callers.
|
|
43
|
+
|
|
44
|
+
**ALWAYS prefer `get_symbol_context` first** — it answers "what does this touch and what touches it?" faster than multiple `analyze_relationships` calls.
|
|
45
|
+
|
|
46
|
+
**Targeted traversal** → Use `analyze_relationships`
|
|
47
|
+
When you need a specific relationship type at a specific depth:
|
|
48
|
+
- `symbol_id` — the symbol to start from (required)
|
|
49
|
+
- `query_type` — one of the types above (required)
|
|
50
|
+
- `depth` — traversal hops, default 2 (higher = slower but reveals indirect deps)
|
|
51
|
+
|
|
52
|
+
### 3. Interpret results
|
|
53
|
+
|
|
54
|
+
- **High in_degree** (many callers) → widely-used symbol; changes have large blast radius
|
|
55
|
+
- **High out_degree** (many callees) → complex function; candidate for refactoring
|
|
56
|
+
- **Deep class hierarchy** → check for Liskov violations or fragile base class issues
|
|
57
|
+
- **Cross-repo API callers** → changes require coordination with other teams/services
|
|
58
|
+
|
|
59
|
+
### 4. Follow up
|
|
60
|
+
|
|
61
|
+
After understanding relationships, consider:
|
|
62
|
+
- `get_impact` to quantify the blast radius of a change
|
|
63
|
+
- `get_evolution` to see how this symbol has changed over time
|
|
64
|
+
- `find_dead_code` if you found unreferenced symbols
|
|
65
|
+
|
|
66
|
+
## Decision Points
|
|
67
|
+
|
|
68
|
+
| Situation | Action |
|
|
69
|
+
|-----------|--------|
|
|
70
|
+
| Need broad context fast | Use `get_symbol_context` (one call, full picture) |
|
|
71
|
+
| Need specific relationship at depth >2 | Use `analyze_relationships` with custom depth |
|
|
72
|
+
| Symbol has many callers | Follow up with `get_impact` before modifying |
|
|
73
|
+
| Found cross-repo API callers | This is a service boundary — coordinate changes |
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-search
|
|
3
|
+
description: "Always use to find, search, locate, or look up source-code symbols, functions, classes, types, constants, definitions, implementations, logic, error strings inside code, or where code lives. Do not use Grep, Glob, rg, find, or manual file search for code discovery. If Memtrace returns 0 results, broaden the Memtrace query and diagnose/reindex; do not switch to grep."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
Find code using hybrid BM25 full-text + semantic vector search with Reciprocal Rank Fusion. Works for both natural-language queries and exact symbol names. This is the primary discovery tool — use it before calling relationship or impact analysis tools.
|
|
9
|
+
|
|
10
|
+
## Quick Reference
|
|
11
|
+
|
|
12
|
+
| Tool | Best For |
|
|
13
|
+
|------|----------|
|
|
14
|
+
| `find_code` | Natural-language queries ("authentication middleware", "retry logic"), broad searches |
|
|
15
|
+
| `find_symbol` | Exact identifier names ("getUserById", "PaymentService"), when you know the name |
|
|
16
|
+
| `get_source_window` | Optional: bounded source read after a Memtrace hit, when your harness lacks `Read(file, offset, limit)`. Otherwise prefer your harness's bounded read with the returned `start_line` / `end_line`. |
|
|
17
|
+
|
|
18
|
+
## Steps
|
|
19
|
+
|
|
20
|
+
### 1. Choose the right search tool
|
|
21
|
+
|
|
22
|
+
- **Know the exact name?** → Use `find_symbol` with `fuzzy: true` for typo tolerance
|
|
23
|
+
- **Describing behaviour?** → Use `find_code` with a natural-language query
|
|
24
|
+
- **Searching all repos?** → Omit `repo_id` from either tool
|
|
25
|
+
|
|
26
|
+
### 2. Execute the search
|
|
27
|
+
|
|
28
|
+
> **Parameter types:** numbers must be JSON numbers, not strings. `limit: 20` is correct; `limit: "20"` returns `MCP error -32602: expected usize`.
|
|
29
|
+
|
|
30
|
+
**`find_code` parameters:**
|
|
31
|
+
- `query` — string, required. Natural-language or exact text.
|
|
32
|
+
- `repo_id` — string, optional. Scope to a single repo (omit to search all).
|
|
33
|
+
- `kind` — string, optional. Filter by symbol type: `"Function"`, `"Class"`, `"Method"`, `"Interface"`, `"APIEndpoint"`, `"APICall"`.
|
|
34
|
+
- `limit` — **integer**, optional. Max results. Default `20`, capped at `100`.
|
|
35
|
+
- `as_of` — string, optional. ISO-8601 timestamp for time-travel search (e.g. `"2026-04-01T00:00:00Z"`).
|
|
36
|
+
- `file_path` — string, optional. File path or directory substring to constrain results (e.g. `"cli/commands"` or `"auth.py"`).
|
|
37
|
+
|
|
38
|
+
**`find_symbol` parameters:**
|
|
39
|
+
- `name` — string, required. Exact or partial symbol name (e.g. `"ValidateToken"`).
|
|
40
|
+
- `fuzzy` — boolean, optional. Enable Levenshtein correction. Default `false`.
|
|
41
|
+
- `edit_distance` — **integer**, optional. Maximum Levenshtein edit distance for fuzzy search. Default `2`, capped at `2`.
|
|
42
|
+
- `repo_id` — string, optional. Scope to a single repo.
|
|
43
|
+
- `kind` — string, optional. Filter by symbol type (e.g. `"Function"`, `"Class"`, `"Variable"`).
|
|
44
|
+
- `file_path` — string, optional. Filter by file path substring.
|
|
45
|
+
- `limit` — **integer**, optional. Max results. Default `10`, capped at `50`.
|
|
46
|
+
|
|
47
|
+
**Success criteria:** Results include `file_path`, `start_line`, `kind`, and relevance `score`.
|
|
48
|
+
|
|
49
|
+
### 3. Use results for next steps
|
|
50
|
+
|
|
51
|
+
The default next step is a **graph tool** — `get_symbol_context`,
|
|
52
|
+
`analyze_relationships`, or `get_impact`. Those answer "who calls this",
|
|
53
|
+
"what's the blast radius", "what community is it part of" — context no
|
|
54
|
+
file read can give. That's what Memtrace uniquely provides.
|
|
55
|
+
|
|
56
|
+
Source bytes come last, only when you're about to edit or quote. Use a
|
|
57
|
+
bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`,
|
|
58
|
+
or `get_source_window` if your harness lacks bounded reads. Do not whole-file.
|
|
59
|
+
|
|
60
|
+
Save the symbol `id` from results — pass it to:
|
|
61
|
+
- `analyze_relationships` to map callers/callees
|
|
62
|
+
- `get_symbol_context` for a 360-degree view
|
|
63
|
+
- `get_impact` to assess blast radius before changes
|
|
64
|
+
|
|
65
|
+
### Multi-word natural-language queries
|
|
66
|
+
|
|
67
|
+
When your query is 3+ words and feels descriptive (e.g. "validate auth token", "find HTTP server error"), don't stop at the first `find_code` call:
|
|
68
|
+
|
|
69
|
+
1. First try the verbatim query.
|
|
70
|
+
2. If results look generic or the right doc isn't at rank 1, fan out **in parallel** with up to 3 identifier-shaped reshapes:
|
|
71
|
+
- camelCase: "validate auth token" → `validateAuthToken`
|
|
72
|
+
- snake_case: → `validate_auth_token`
|
|
73
|
+
- Domain-likely identifiers: → `auth_token`, `tokenValidator`, `verifyToken`
|
|
74
|
+
3. Memtrace's tokenizer splits camelCase / snake / kebab at index time, so reshaped queries hit identifier names directly.
|
|
75
|
+
4. Take the union of top-5 from each call, dedupe by `file_path:start_line`.
|
|
76
|
+
|
|
77
|
+
**Worked examples** (verbatim → reshapes to try in parallel):
|
|
78
|
+
- "validate auth token" → `validateAuthToken`, `validate_auth_token`, `verifyToken`
|
|
79
|
+
- "find http server error" → `findHttpServerError`, `http_error`, `serverError`
|
|
80
|
+
- "render value panel" → `renderValuePanel`, `ValuePanel`, `value_panel`
|
|
81
|
+
|
|
82
|
+
## Common Mistakes
|
|
83
|
+
|
|
84
|
+
| Mistake | Reality |
|
|
85
|
+
|---------|---------|
|
|
86
|
+
| Searching without indexing first | Call `list_indexed_repositories` to verify the repo is indexed |
|
|
87
|
+
| Using find_symbol for vague queries | Use `find_code` for natural-language; `find_symbol` is for exact names |
|
|
88
|
+
| Ignoring the `kind` filter | Narrow results with kind=Function, kind=Class etc. to reduce noise |
|
|
89
|
+
| Re-searching to get more context | Use the symbol `id` with `get_symbol_context` instead of re-searching |
|
|
90
|
+
| Reading the whole file after a hit | First call `get_symbol_context` for callers/callees. If you still need source, do a bounded `Read(file, offset=start_line, limit=N)` — never whole-file. `get_source_window` is fine if your harness has no bounded read. |
|
|
91
|
+
| Going straight from `find_code` to source read | Memtrace's value is the graph. Default next step is `get_symbol_context` or `get_impact`, not source. |
|
|
92
|
+
| Treating 0 results as permission to grep | 0 results means broaden the Memtrace query, check repo_id/path filters, then reindex if coverage is missing |
|
|
93
|
+
| Assuming a UI subdirectory is unindexed because stats show backend files | If `ui/`, `memtrace-ui/`, or another source directory is under the indexed repo root, diagnose/reindex with Memtrace instead of searching files manually |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-change-impact-analysis
|
|
3
|
+
description: "Always use before source-code edits, refactors, API changes, renames, removals, PR reviews, or risk assessments when the user needs to know what will break. Do not manually grep references or browse files for impact; this workflow uses Memtrace graph context, impact, and change detection."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__find_symbol
|
|
6
|
+
- mcp__memtrace__find_code
|
|
7
|
+
- mcp__memtrace__get_symbol_context
|
|
8
|
+
- mcp__memtrace__get_impact
|
|
9
|
+
- mcp__memtrace__detect_changes
|
|
10
|
+
- mcp__memtrace__get_evolution
|
|
11
|
+
- mcp__memtrace__analyze_relationships
|
|
12
|
+
- mcp__memtrace__list_indexed_repositories
|
|
13
|
+
user-invocable: true
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
Pre-change risk assessment workflow. Before modifying code, this workflow maps the full blast radius, identifies affected processes, checks recent change history for instability signals, and produces a risk-rated change plan.
|
|
19
|
+
|
|
20
|
+
## Steps
|
|
21
|
+
|
|
22
|
+
### 1. Identify what's being changed
|
|
23
|
+
|
|
24
|
+
Find the target symbol(s):
|
|
25
|
+
- Use `find_symbol` if the user named specific functions/classes
|
|
26
|
+
- Use `find_code` if the user described behaviour ("the authentication middleware")
|
|
27
|
+
|
|
28
|
+
Collect symbol IDs for all targets.
|
|
29
|
+
|
|
30
|
+
### 2. Get 360° context for each target
|
|
31
|
+
|
|
32
|
+
For each symbol, call `get_symbol_context`:
|
|
33
|
+
- Direct callers and callees
|
|
34
|
+
- Community membership (which module is this in?)
|
|
35
|
+
- Process membership (which execution flows does this participate in?)
|
|
36
|
+
- Cross-repo API callers (is this an endpoint called by other services?)
|
|
37
|
+
|
|
38
|
+
**Decision:** If cross-repo API callers exist, this change requires coordination with other teams. Flag this immediately.
|
|
39
|
+
|
|
40
|
+
### 3. Compute blast radius
|
|
41
|
+
|
|
42
|
+
For each target, call `get_impact` with `direction: both`:
|
|
43
|
+
- Upstream impact: what depends on this symbol
|
|
44
|
+
- Downstream impact: what this symbol depends on
|
|
45
|
+
- Risk rating: Low / Medium / High / Critical
|
|
46
|
+
|
|
47
|
+
**Decision:**
|
|
48
|
+
| Risk | Action |
|
|
49
|
+
|------|--------|
|
|
50
|
+
| Low | Proceed with standard testing |
|
|
51
|
+
| Medium | Review all direct callers; test affected processes |
|
|
52
|
+
| High | Plan incremental migration; consider feature flags |
|
|
53
|
+
| Critical | Full migration strategy; backward-compatible changes required |
|
|
54
|
+
|
|
55
|
+
### 4. Check temporal stability
|
|
56
|
+
|
|
57
|
+
Call `get_evolution` with mode `novel` for a 30-day window on the repo:
|
|
58
|
+
- Are any of the target symbols flagged as "rarely changing"? If so, this change is structurally surprising and deserves extra scrutiny.
|
|
59
|
+
- Have the target symbols been changing frequently? High churn + high impact = volatile hotspot.
|
|
60
|
+
|
|
61
|
+
### 5. Map affected execution flows
|
|
62
|
+
|
|
63
|
+
From step 2, you already know which processes are affected. For critical changes, use `analyze_relationships` with `query_type: find_callers` at `depth: 3` to trace the full transitive caller chain.
|
|
64
|
+
|
|
65
|
+
### 6. Produce the risk assessment
|
|
66
|
+
|
|
67
|
+
Synthesize into a change plan:
|
|
68
|
+
|
|
69
|
+
1. **Target(s)** — what's being changed and where
|
|
70
|
+
2. **Blast Radius** — number of direct/transitive dependents, risk rating
|
|
71
|
+
3. **Affected Processes** — which execution flows will be impacted
|
|
72
|
+
4. **Cross-Service Impact** — any external callers or consumers
|
|
73
|
+
5. **Stability Signal** — is this code stable (novel) or volatile (frequent changes)?
|
|
74
|
+
6. **Recommended Approach** — based on risk: direct change, incremental migration, or backward-compatible evolution
|
|
75
|
+
7. **Test Coverage** — which callers/processes to verify after the change
|
|
76
|
+
|
|
77
|
+
## Decision Points
|
|
78
|
+
|
|
79
|
+
| Condition | Action |
|
|
80
|
+
|-----------|--------|
|
|
81
|
+
| Risk = Critical | Recommend backward-compatible change + deprecation path |
|
|
82
|
+
| Cross-repo callers exist | Flag as requiring multi-service coordination |
|
|
83
|
+
| Symbol has high novelty score | Extra review — this rarely changes; make sure the change is intentional |
|
|
84
|
+
| Multiple processes affected | List each affected flow; recommend testing each one |
|
|
85
|
+
| Symbol is a bridge point | Change may disconnect parts of the architecture — verify alternative paths exist |
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-code-review
|
|
3
|
+
description: "Always use when the user asks to review a GitHub pull request, run Memtrace code review, post Memtrace review comments, create a PR with a review step, or publish local graph-backed review findings to GitHub. Prefer the review_github_pr MCP tool over manual diff inspection."
|
|
4
|
+
when_to_use: "Triggered by 'review this PR', 'code review this pull request', 'post Memtrace review', 'run memtrace code-review', 'create PR with review', 'GitHub PR review', 'publish review comments', or any request to use Memtrace as a GitHub code reviewer. Use after code is pushed as a PR, and call review_github_pr instead of manually grepping diffs."
|
|
5
|
+
paths: "**/*.{py,js,jsx,ts,tsx,mjs,cjs,rs,go,java,rb,c,cc,cpp,cxx,h,hpp,hh,cs,php,swift,kt,kts,scala,clj,cljs,ex,exs,erl,hrl,ml,mli,fs,fsx,r,jl,lua,dart,m,mm,asm,sql,gql,graphql,proto,sh,bash,zsh,fish,vue,svelte}"
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- mcp__memtrace__review_github_pr
|
|
8
|
+
- mcp__memtrace__find_code_review_issues
|
|
9
|
+
- mcp__memtrace__list_indexed_repositories
|
|
10
|
+
user-invocable: true
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Use Memtrace's local-first PR review workflow. The agent should call the `review_github_pr` MCP tool so review runs against the developer's local indexed graph, AST detectors, YAML rule pack, and review policy. GitHub is used for PR context and optional comment publication; source code analysis stays local.
|
|
16
|
+
|
|
17
|
+
## Default Flow
|
|
18
|
+
|
|
19
|
+
1. If the user gives a GitHub PR URL and asks to inspect or review it, call `review_github_pr` with `post: false`.
|
|
20
|
+
2. If the user explicitly asks to publish, post comments, or complete the PR review, call `review_github_pr` with `post: true`.
|
|
21
|
+
3. Use `graphMode: "strict"` by default. Use `graphMode: "off"` only when the user asks to benchmark non-graph behavior or the local graph is unavailable.
|
|
22
|
+
4. Default to `minSeverity: "high"` and `maxComments: 5` when posting. For previews, `maxComments: 10` is acceptable.
|
|
23
|
+
5. Pass `repoRoot` when the PR checkout is not the current working directory. Pass `repoId` when the indexed repository id is known.
|
|
24
|
+
|
|
25
|
+
## Example User Prompts
|
|
26
|
+
|
|
27
|
+
- "Review this PR with Memtrace: https://github.com/OWNER/REPO/pull/123"
|
|
28
|
+
- "Use Memtrace to review this pull request and post the findings: https://github.com/OWNER/REPO/pull/123"
|
|
29
|
+
- "Create the PR, then run Memtrace code review and publish the review comments."
|
|
30
|
+
|
|
31
|
+
## Guardrails
|
|
32
|
+
|
|
33
|
+
- Do not start with generic grep, rg, or manual diff review when `review_github_pr` is available.
|
|
34
|
+
- Do not post comments unless the user explicitly requested publication.
|
|
35
|
+
- Do not create benchmark-specific or PR-specific findings. The review must come from general Memtrace detectors, graph evidence, and policy ranking.
|
|
36
|
+
- If the tool reports missing auth, tell the user to run `memtrace auth login`.
|
|
37
|
+
- If the tool reports missing GitHub App installation, tell the user to install Memtrace Code Reviewer on that repository.
|
|
38
|
+
- If the tool reports missing local graph context, tell the user to run `memtrace index .` at the workspace root.
|
|
39
|
+
|
|
40
|
+
## Output
|
|
41
|
+
|
|
42
|
+
For previews, summarize:
|
|
43
|
+
- PR URL and repository
|
|
44
|
+
- Graph state
|
|
45
|
+
- Number of candidate comments
|
|
46
|
+
- File, line, severity, and message for each finding
|
|
47
|
+
|
|
48
|
+
For posted reviews, report the PR URL and number of comments posted.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-codebase-exploration
|
|
3
|
+
description: "Always 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 Glob, find, tree, rg, or manual file browsing as the first exploration path; Memtrace provides structured graph briefing."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__index_directory
|
|
6
|
+
- mcp__memtrace__check_job_status
|
|
7
|
+
- mcp__memtrace__list_indexed_repositories
|
|
8
|
+
- mcp__memtrace__get_repository_stats
|
|
9
|
+
- mcp__memtrace__list_communities
|
|
10
|
+
- mcp__memtrace__list_processes
|
|
11
|
+
- mcp__memtrace__find_central_symbols
|
|
12
|
+
- mcp__memtrace__find_bridge_symbols
|
|
13
|
+
- mcp__memtrace__find_api_endpoints
|
|
14
|
+
- mcp__memtrace__get_api_topology
|
|
15
|
+
- mcp__memtrace__get_evolution
|
|
16
|
+
- mcp__memtrace__find_most_complex_functions
|
|
17
|
+
user-invocable: true
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
## Steps
|
|
25
|
+
|
|
26
|
+
### 1. Index the codebase
|
|
27
|
+
|
|
28
|
+
Call `list_indexed_repositories` first. If the repo is already indexed, skip to step 2.
|
|
29
|
+
|
|
30
|
+
Otherwise, call `index_directory` with the project path, then poll `check_job_status` until completion.
|
|
31
|
+
|
|
32
|
+
**Success criteria:** Repo appears in `list_indexed_repositories` with non-zero node/edge counts.
|
|
33
|
+
|
|
34
|
+
### 2. Get the lay of the land
|
|
35
|
+
|
|
36
|
+
Call `get_repository_stats` to understand scale:
|
|
37
|
+
- How many functions, classes, methods, interfaces?
|
|
38
|
+
- How many relationships (calls, imports, extends)?
|
|
39
|
+
- How many communities and processes were detected?
|
|
40
|
+
|
|
41
|
+
Report these numbers to the user — they set expectations for the codebase's size and complexity.
|
|
42
|
+
|
|
43
|
+
### 3. Map the architecture (communities)
|
|
44
|
+
|
|
45
|
+
Call `list_communities` to see how the codebase naturally clusters into logical modules.
|
|
46
|
+
|
|
47
|
+
**Decision:** If >10 communities, summarize the top 5–7 by size and let the user ask about specific ones.
|
|
48
|
+
|
|
49
|
+
Each community represents a cohesive module — these are the "areas" of the codebase.
|
|
50
|
+
|
|
51
|
+
### 4. Find the most important symbols
|
|
52
|
+
|
|
53
|
+
Call `find_central_symbols` with `limit: 15`. It ranks symbols by PageRank over the repo's CALLS / REFERENCES edges (default `method: "pagerank"`, 0.85 damping factor).
|
|
54
|
+
|
|
55
|
+
These are the symbols that the rest of the codebase depends on most heavily. They form the "skeleton" of the architecture.
|
|
56
|
+
|
|
57
|
+
### 5. Find architectural bottlenecks
|
|
58
|
+
|
|
59
|
+
Call `find_bridge_symbols` to identify chokepoints — symbols that connect otherwise-separate parts of the codebase.
|
|
60
|
+
|
|
61
|
+
**Decision:** If bridge symbols overlap heavily with central symbols, flag them as critical infrastructure — high importance AND single point of failure.
|
|
62
|
+
|
|
63
|
+
### 6. Map execution flows
|
|
64
|
+
|
|
65
|
+
Call `list_processes` to discover entry points:
|
|
66
|
+
- HTTP handlers (API endpoints)
|
|
67
|
+
- Background jobs
|
|
68
|
+
- CLI commands
|
|
69
|
+
- Event handlers
|
|
70
|
+
|
|
71
|
+
This shows HOW the code is actually used at runtime, not just how it's structured.
|
|
72
|
+
|
|
73
|
+
### 7. Map the API surface (if applicable)
|
|
74
|
+
|
|
75
|
+
Call `find_api_endpoints` to list all HTTP routes.
|
|
76
|
+
|
|
77
|
+
**Decision:** If multiple repos are indexed, also call `get_api_topology` to map service-to-service dependencies.
|
|
78
|
+
|
|
79
|
+
### 8. Recent activity
|
|
80
|
+
|
|
81
|
+
Call `get_evolution` with mode `overview` and a 30-day window to see which modules have been most active recently.
|
|
82
|
+
|
|
83
|
+
**Decision:** If the user asks about specific recent changes, switch to mode `compound` for symbol-level detail.
|
|
84
|
+
|
|
85
|
+
### 9. Complexity hotspots
|
|
86
|
+
|
|
87
|
+
Call `find_most_complex_functions` with `limit: 10` to identify potential technical debt.
|
|
88
|
+
|
|
89
|
+
## Report Synthesis
|
|
90
|
+
|
|
91
|
+
Synthesize findings into a structured overview:
|
|
92
|
+
|
|
93
|
+
1. **Scale** — languages, total symbols, total relationships
|
|
94
|
+
2. **Architecture** — main communities/modules and what they do
|
|
95
|
+
3. **Critical Infrastructure** — central symbols and bridge points
|
|
96
|
+
4. **Execution Flows** — how the code is entered and used
|
|
97
|
+
5. **API Surface** — endpoints and service dependencies
|
|
98
|
+
6. **Recent Activity** — what's been changing in the last 30 days
|
|
99
|
+
7. **Technical Debt** — complexity hotspots and potential dead code
|
|
100
|
+
|
|
101
|
+
## Common Mistakes
|
|
102
|
+
|
|
103
|
+
| Mistake | Reality |
|
|
104
|
+
|---------|---------|
|
|
105
|
+
| Skipping indexing and using file-based grep | The knowledge graph provides structural understanding that grep cannot — callers, callees, communities, processes |
|
|
106
|
+
| Reporting raw numbers without interpretation | "450 functions across 12 communities" means nothing; describe what each community does |
|
|
107
|
+
| Only looking at code structure | Execution flows (processes) show how the code is actually used — always include them |
|
|
108
|
+
| Ignoring temporal context | Recent evolution shows where active development is happening — this is where the user will likely need to work |
|