memtrace 0.1.37 → 0.1.45

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.
Files changed (54) hide show
  1. package/README.md +2 -2
  2. package/bin/memtrace.js +102 -14
  3. package/install.js +21 -179
  4. package/installer/dist/commands/doctor.d.ts +16 -0
  5. package/installer/dist/commands/doctor.js +86 -0
  6. package/installer/dist/commands/install.d.ts +9 -0
  7. package/installer/dist/commands/install.js +104 -0
  8. package/installer/dist/commands/picker.d.ts +6 -0
  9. package/installer/dist/commands/picker.js +22 -0
  10. package/installer/dist/fs-safe.d.ts +21 -0
  11. package/installer/dist/fs-safe.js +35 -0
  12. package/installer/dist/index.d.ts +2 -0
  13. package/installer/dist/index.js +52 -0
  14. package/installer/dist/skills.d.ts +17 -0
  15. package/installer/dist/skills.js +64 -0
  16. package/installer/dist/transformers/claude.d.ts +41 -0
  17. package/installer/dist/transformers/claude.js +400 -0
  18. package/installer/dist/transformers/cursor.d.ts +7 -0
  19. package/installer/dist/transformers/cursor.js +84 -0
  20. package/installer/dist/transformers/index.d.ts +7 -0
  21. package/installer/dist/transformers/index.js +7 -0
  22. package/installer/dist/transformers/types.d.ts +39 -0
  23. package/installer/dist/transformers/types.js +1 -0
  24. package/installer/dist/utils.d.ts +5 -0
  25. package/installer/dist/utils.js +22 -0
  26. package/installer/package.json +49 -0
  27. package/installer/skills/commands/memtrace-api-topology.md +65 -0
  28. package/installer/skills/commands/memtrace-cochange.md +76 -0
  29. package/installer/skills/commands/memtrace-evolution.md +135 -0
  30. package/installer/skills/commands/memtrace-graph.md +117 -0
  31. package/installer/skills/commands/memtrace-impact.md +64 -0
  32. package/installer/skills/commands/memtrace-index.md +66 -0
  33. package/installer/skills/commands/memtrace-quality.md +69 -0
  34. package/installer/skills/commands/memtrace-relationships.md +73 -0
  35. package/installer/skills/commands/memtrace-search.md +67 -0
  36. package/installer/skills/workflows/memtrace-change-impact-analysis.md +85 -0
  37. package/installer/skills/workflows/memtrace-codebase-exploration.md +108 -0
  38. package/installer/skills/workflows/memtrace-episode-replay.md +100 -0
  39. package/installer/skills/workflows/memtrace-first.md +120 -0
  40. package/installer/skills/workflows/memtrace-incident-investigation.md +125 -0
  41. package/installer/skills/workflows/memtrace-refactoring-guide.md +116 -0
  42. package/installer/skills/workflows/memtrace-session-continuity.md +98 -0
  43. package/package.json +10 -5
  44. package/skills/commands/memtrace-api-topology.md +3 -0
  45. package/skills/commands/memtrace-cochange.md +3 -0
  46. package/skills/commands/memtrace-evolution.md +3 -0
  47. package/skills/commands/memtrace-graph.md +54 -4
  48. package/skills/commands/memtrace-impact.md +3 -0
  49. package/skills/commands/memtrace-index.md +3 -0
  50. package/skills/commands/memtrace-quality.md +3 -0
  51. package/skills/commands/memtrace-relationships.md +3 -0
  52. package/skills/commands/memtrace-search.md +18 -13
  53. package/skills/workflows/memtrace-first.md +12 -0
  54. package/uninstall.js +22 -28
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: memtrace-impact
3
+ description: "Use when the user asks about blast radius, what will break if I change this, risk of modifying a symbol, upstream or downstream dependencies, impact analysis before refactoring, or wants to understand the consequences of a code change"
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,66 @@
1
+ ---
2
+ name: memtrace-index
3
+ description: "Use when the user asks to index a project, set up code intelligence, parse a codebase, build a knowledge graph, prepare a repo for analysis, or as the very first step before any code exploration, search, or relationship analysis"
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
+ ### 2. Index the directory
36
+
37
+ Use the `index_directory` MCP tool:
38
+
39
+ - Set `path` to the project root (absolute path)
40
+ - Set `incremental: true` if re-indexing after changes
41
+ - Set `clear_existing: true` only if a full rebuild is needed
42
+
43
+ **Success criteria:** You receive a `job_id` immediately.
44
+
45
+ ### 3. Poll for completion
46
+
47
+ Use `check_job_status` with the `job_id` every 2–3 seconds.
48
+
49
+ Pipeline stages in order: **scan → parse → resolve → communities → processes → persist → embeddings → api_detect → done**
50
+
51
+ Wait until `status = "completed"`. If `status = "failed"`, report the error message to the user.
52
+
53
+ ### 4. Report to user
54
+
55
+ 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.
56
+
57
+ **Save the `repo_id`** — most other memtrace tools require it.
58
+
59
+ ## Error Handling
60
+
61
+ | Error | Action |
62
+ |-------|--------|
63
+ | Path does not exist | Ask user to verify the absolute path |
64
+ | Job status "failed" | Report the error message; suggest `clear_existing: true` for a fresh rebuild |
65
+ | Timeout (job running > 5 min) | Large repos are normal; keep polling. For monorepos, index subdirectories separately |
66
+ | Already indexed | Use `incremental: true` to update, or skip indexing entirely |
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: memtrace-quality
3
+ description: "Use when the user asks about dead code, unused functions, code complexity, cyclomatic complexity, refactoring candidates, code smells, code quality metrics, functions that are too complex, or wants to find code that should be cleaned up"
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: "Use when the user asks who calls a function, what a function calls, class hierarchy, inheritance, imports, exports, type usages, dependencies between symbols, or wants to understand how code connects before making changes"
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,67 @@
1
+ ---
2
+ name: memtrace-search
3
+ description: "Use when the user asks to find code, search for a function, locate a symbol, look up where something is defined, search across repos, find implementations, or needs to discover where a piece of logic lives before making changes"
4
+ allowed-tools:
5
+ - mcp__memtrace__find_code
6
+ - mcp__memtrace__find_symbol
7
+ - mcp__memtrace__list_indexed_repositories
8
+ user-invocable: true
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ 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.
14
+
15
+ ## Quick Reference
16
+
17
+ | Tool | Best For |
18
+ |------|----------|
19
+ | `find_code` | Natural-language queries ("authentication middleware", "retry logic"), broad searches |
20
+ | `find_symbol` | Exact identifier names ("getUserById", "PaymentService"), when you know the name |
21
+
22
+ ## Steps
23
+
24
+ ### 1. Choose the right search tool
25
+
26
+ - **Know the exact name?** → Use `find_symbol` with `fuzzy: true` for typo tolerance
27
+ - **Describing behaviour?** → Use `find_code` with a natural-language query
28
+ - **Searching all repos?** → Omit `repo_id` from either tool
29
+
30
+ ### 2. Execute the search
31
+
32
+ > **Parameter types:** numbers must be JSON numbers, not strings. `limit: 20` is correct; `limit: "20"` returns `MCP error -32602: expected usize`.
33
+
34
+ **`find_code` parameters:**
35
+ - `query` — string, required. Natural-language or exact text.
36
+ - `repo_id` — string, optional. Scope to a single repo (omit to search all).
37
+ - `kind` — string, optional. Filter by symbol type: `"Function"`, `"Class"`, `"Method"`, `"Interface"`, `"APIEndpoint"`, `"APICall"`.
38
+ - `limit` — **integer**, optional. Max results. Default `20`, capped at `100`.
39
+ - `as_of` — string, optional. ISO-8601 timestamp for time-travel search (e.g. `"2026-04-01T00:00:00Z"`).
40
+ - `file_path` — string, optional. File path or directory substring to constrain results (e.g. `"cli/commands"` or `"auth.py"`).
41
+
42
+ **`find_symbol` parameters:**
43
+ - `name` — string, required. Exact or partial symbol name (e.g. `"ValidateToken"`).
44
+ - `fuzzy` — boolean, optional. Enable Levenshtein correction. Default `false`.
45
+ - `edit_distance` — **integer**, optional. Maximum Levenshtein edit distance for fuzzy search. Default `2`, capped at `2`.
46
+ - `repo_id` — string, optional. Scope to a single repo.
47
+ - `kind` — string, optional. Filter by symbol type (e.g. `"Function"`, `"Class"`, `"Variable"`).
48
+ - `file_path` — string, optional. Filter by file path substring.
49
+ - `limit` — **integer**, optional. Max results. Default `10`, capped at `50`.
50
+
51
+ **Success criteria:** Results include `file_path`, `start_line`, `kind`, and relevance `score`.
52
+
53
+ ### 3. Use results for next steps
54
+
55
+ Save the symbol `id` from results — pass it to:
56
+ - `analyze_relationships` to map callers/callees
57
+ - `get_symbol_context` for a 360-degree view
58
+ - `get_impact` to assess blast radius before changes
59
+
60
+ ## Common Mistakes
61
+
62
+ | Mistake | Reality |
63
+ |---------|---------|
64
+ | Searching without indexing first | Call `list_indexed_repositories` to verify the repo is indexed |
65
+ | Using find_symbol for vague queries | Use `find_code` for natural-language; `find_symbol` is for exact names |
66
+ | Ignoring the `kind` filter | Narrow results with kind=Function, kind=Class etc. to reduce noise |
67
+ | Re-searching to get more context | Use the symbol `id` with `get_symbol_context` instead of re-searching |
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: memtrace-change-impact-analysis
3
+ description: "Use when the user is about to modify code, planning a refactoring, wants to know what will break, needs a pre-change risk assessment, is reviewing a PR, or wants to understand the full consequences of a code change before making it"
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,108 @@
1
+ ---
2
+ name: memtrace-codebase-exploration
3
+ description: "Use when the user asks to explore a codebase, understand a project, onboard to a new repo, get an overview of how code is structured, map the architecture, or wants a comprehensive understanding of a codebase they're new to"
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 `method: "pagerank"` and `limit: 15`.
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 |
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: memtrace-episode-replay
3
+ description: "Use when an agent needs to understand why code looks the way it does, replay implementation steps between commits, find what was tried and reverted, understand a colleague's (or your past self's) reasoning, or avoid repeating a previously-abandoned approach"
4
+ allowed-tools:
5
+ - mcp__memtrace__get_episode_replay
6
+ - mcp__memtrace__get_timeline
7
+ - mcp__memtrace__find_symbol
8
+ - mcp__memtrace__list_indexed_repositories
9
+ user-invocable: true
10
+ ---
11
+
12
+ ## Overview
13
+
14
+ Replay the sub-commit implementation narrative for any symbol. Between any two commits, Memtrace recorded every file save as a `working_tree` episode. This tool surfaces that sequence — the attempts, the reversions, the iterative refinements — not just the final committed state.
15
+
16
+ **Git shows A→B. Episode replay shows every step in between.**
17
+
18
+ This is the only tool that can answer: "why does this code look like this?" without relying on commit messages or comments.
19
+
20
+ ## Steps
21
+
22
+ ### 1. Identify the symbol and time window
23
+
24
+ Use `find_symbol` to get the exact symbol name if needed. Determine the window:
25
+ - `from` — when to start (e.g. a few days before a confusing commit)
26
+ - `to` — when to end (usually the commit timestamp or now)
27
+
28
+ If you don't know the window, call `get_timeline` first to find when the symbol changed.
29
+
30
+ ### 2. Call `get_episode_replay`
31
+
32
+ ```
33
+ get_episode_replay(
34
+ repo_id: "...",
35
+ symbol: "execute",
36
+ from: "2026-04-10T00:00:00Z",
37
+ to: "2026-04-13T00:00:00Z",
38
+ include_working_tree: true, // false = commits only
39
+ compress: true // collapse identical-hash runs
40
+ )
41
+ ```
42
+
43
+ ### 3. Read the narrative_hint sequence
44
+
45
+ Each episode has a `narrative_hint` — derived automatically from AST hash patterns:
46
+
47
+ | Hint | What it means |
48
+ |---|---|
49
+ | `committed` | A real git commit — the "public record" checkpoint |
50
+ | `pre_commit_finalization` | Last working_tree save before a commit — the final draft |
51
+ | `iterative_refinement` | 3+ consecutive working_tree saves — active development in progress |
52
+ | `attempted_and_reverted` | Hash returned to a prior state — something was tried and backed out |
53
+ | `no_change` | File was saved but this symbol didn't change |
54
+ | `working_tree_save` | A single file save with structural changes |
55
+
56
+ ### 4. Reconstruct the implementation story
57
+
58
+ Read the sequence like a narrative:
59
+
60
+ ```
61
+ committed ← "here's where we started"
62
+ working_tree_save ← "first attempt"
63
+ iterative_refinement ← "refining the approach"
64
+ attempted_and_reverted ← "tried X, it was wrong, backed out"
65
+ pre_commit_finalization← "final version before commit"
66
+ committed ← "here's what shipped"
67
+ ```
68
+
69
+ The gap between `committed` entries is the implementation story.
70
+
71
+ ### 5. Identify what to act on
72
+
73
+ | Pattern | Implication |
74
+ |---|---|
75
+ | `attempted_and_reverted` appears | There was a tried-and-abandoned approach — understand why before trying similar |
76
+ | Multiple `iterative_refinement` clusters | The author was unsure — this area may need extra care |
77
+ | No working_tree episodes (commits only) | Code was written elsewhere or pasted in — less implementation history available |
78
+ | Very short episode sequence | Straightforward change — low implementation complexity |
79
+
80
+ ## When to Use
81
+
82
+ - **Before modifying unfamiliar code** — understand the intent, not just the current state
83
+ - **Post-session debugging** — replay what was tried during a broken session
84
+ - **Code review** — understand the reasoning behind non-obvious implementations
85
+ - **Avoiding dead ends** — check if the approach you're about to try was already attempted and reverted
86
+
87
+ ## Compression
88
+
89
+ With `compress: true` (default), consecutive episodes with identical `ast_hash` are collapsed to first+last of the run. Cosmetic saves and whitespace-only edits are filtered out. Only structurally significant transitions are shown.
90
+
91
+ With `compress: false`, every single save is shown — useful when you want to see exact timing between saves.
92
+
93
+ ## Common Mistakes
94
+
95
+ | Mistake | Reality |
96
+ |---------|---------|
97
+ | Only reading the final committed code | The commit shows *what*, the episode replay shows *why* — always check both for unfamiliar code |
98
+ | Ignoring `attempted_and_reverted` hints | These are the most valuable entries — they represent knowledge about what doesn't work |
99
+ | Using `include_working_tree: false` by default | Commits-only loses all the sub-commit narrative — only use this if you explicitly want commit-level granularity |
100
+ | Large windows with compress off | Very long histories produce noise; use `compress: true` unless you need exact save-by-save granularity |