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.
Files changed (97) hide show
  1. package/dist/commands/doctor.d.ts +16 -0
  2. package/dist/commands/doctor.js +199 -0
  3. package/dist/commands/enterprise-install.d.ts +7 -0
  4. package/dist/commands/enterprise-install.js +129 -0
  5. package/dist/commands/install.d.ts +9 -0
  6. package/dist/commands/install.js +104 -0
  7. package/dist/commands/picker.d.ts +6 -0
  8. package/dist/commands/picker.js +22 -0
  9. package/dist/commands/rail-install.d.ts +7 -0
  10. package/dist/commands/rail-install.js +37 -0
  11. package/dist/fs-safe.d.ts +21 -0
  12. package/dist/fs-safe.js +35 -0
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.js +87 -0
  15. package/dist/rail-install.d.ts +20 -0
  16. package/dist/rail-install.js +183 -0
  17. package/dist/skills.d.ts +17 -0
  18. package/dist/skills.js +64 -0
  19. package/dist/transformers/claude.d.ts +71 -0
  20. package/dist/transformers/claude.js +702 -0
  21. package/dist/transformers/codex.d.ts +8 -0
  22. package/dist/transformers/codex.js +294 -0
  23. package/dist/transformers/cursor.d.ts +7 -0
  24. package/dist/transformers/cursor.js +124 -0
  25. package/dist/transformers/gemini.d.ts +3 -0
  26. package/dist/transformers/gemini.js +78 -0
  27. package/dist/transformers/hermes.d.ts +5 -0
  28. package/dist/transformers/hermes.js +136 -0
  29. package/dist/transformers/index.d.ts +14 -0
  30. package/dist/transformers/index.js +24 -0
  31. package/dist/transformers/kiro.d.ts +2 -0
  32. package/dist/transformers/kiro.js +69 -0
  33. package/dist/transformers/opencode.d.ts +2 -0
  34. package/dist/transformers/opencode.js +77 -0
  35. package/dist/transformers/rail-hooks.d.ts +56 -0
  36. package/dist/transformers/rail-hooks.js +303 -0
  37. package/dist/transformers/shared.d.ts +18 -0
  38. package/dist/transformers/shared.js +129 -0
  39. package/dist/transformers/types.d.ts +40 -0
  40. package/dist/transformers/types.js +1 -0
  41. package/dist/transformers/vscode.d.ts +3 -0
  42. package/dist/transformers/vscode.js +53 -0
  43. package/dist/transformers/windsurf.d.ts +3 -0
  44. package/dist/transformers/windsurf.js +43 -0
  45. package/dist/utils.d.ts +5 -0
  46. package/dist/utils.js +22 -0
  47. package/package.json +50 -0
  48. package/plugins/memtrace-skills/.claude-plugin/plugin.json +23 -0
  49. package/plugins/memtrace-skills/references/mcp-parameters.md +302 -0
  50. package/plugins/memtrace-skills/skills/memtrace-api-topology/SKILL.md +58 -0
  51. package/plugins/memtrace-skills/skills/memtrace-change-impact-analysis/SKILL.md +75 -0
  52. package/plugins/memtrace-skills/skills/memtrace-cochange/SKILL.md +71 -0
  53. package/plugins/memtrace-skills/skills/memtrace-code-review/SKILL.md +41 -0
  54. package/plugins/memtrace-skills/skills/memtrace-codebase-exploration/SKILL.md +94 -0
  55. package/plugins/memtrace-skills/skills/memtrace-continuous-memory/SKILL.md +96 -0
  56. package/plugins/memtrace-skills/skills/memtrace-episode-replay/SKILL.md +94 -0
  57. package/plugins/memtrace-skills/skills/memtrace-evolution/SKILL.md +128 -0
  58. package/plugins/memtrace-skills/skills/memtrace-first/SKILL.md +194 -0
  59. package/plugins/memtrace-skills/skills/memtrace-fleet-coordination/SKILL.md +80 -0
  60. package/plugins/memtrace-skills/skills/memtrace-fleet-first/SKILL.md +125 -0
  61. package/plugins/memtrace-skills/skills/memtrace-fleet-publish-intent/SKILL.md +48 -0
  62. package/plugins/memtrace-skills/skills/memtrace-fleet-record-episode/SKILL.md +44 -0
  63. package/plugins/memtrace-skills/skills/memtrace-fleet-resolve/SKILL.md +54 -0
  64. package/plugins/memtrace-skills/skills/memtrace-graph/SKILL.md +67 -0
  65. package/plugins/memtrace-skills/skills/memtrace-impact/SKILL.md +58 -0
  66. package/plugins/memtrace-skills/skills/memtrace-incident-investigation/SKILL.md +112 -0
  67. package/plugins/memtrace-skills/skills/memtrace-index/SKILL.md +65 -0
  68. package/plugins/memtrace-skills/skills/memtrace-quality/SKILL.md +63 -0
  69. package/plugins/memtrace-skills/skills/memtrace-refactoring-guide/SKILL.md +103 -0
  70. package/plugins/memtrace-skills/skills/memtrace-relationships/SKILL.md +67 -0
  71. package/plugins/memtrace-skills/skills/memtrace-search/SKILL.md +93 -0
  72. package/plugins/memtrace-skills/skills/memtrace-session-continuity/SKILL.md +93 -0
  73. package/plugins/memtrace-skills/skills/memtrace-style-fingerprint/SKILL.md +105 -0
  74. package/skills/commands/memtrace-api-topology.md +65 -0
  75. package/skills/commands/memtrace-cochange.md +76 -0
  76. package/skills/commands/memtrace-evolution.md +135 -0
  77. package/skills/commands/memtrace-fleet-publish-intent.md +51 -0
  78. package/skills/commands/memtrace-fleet-record-episode.md +48 -0
  79. package/skills/commands/memtrace-fleet-resolve.md +59 -0
  80. package/skills/commands/memtrace-graph.md +75 -0
  81. package/skills/commands/memtrace-impact.md +64 -0
  82. package/skills/commands/memtrace-index.md +71 -0
  83. package/skills/commands/memtrace-quality.md +69 -0
  84. package/skills/commands/memtrace-relationships.md +73 -0
  85. package/skills/commands/memtrace-search.md +93 -0
  86. package/skills/workflows/memtrace-change-impact-analysis.md +85 -0
  87. package/skills/workflows/memtrace-code-review.md +48 -0
  88. package/skills/workflows/memtrace-codebase-exploration.md +108 -0
  89. package/skills/workflows/memtrace-continuous-memory.md +104 -0
  90. package/skills/workflows/memtrace-episode-replay.md +100 -0
  91. package/skills/workflows/memtrace-first.md +194 -0
  92. package/skills/workflows/memtrace-fleet-coordination.md +87 -0
  93. package/skills/workflows/memtrace-fleet-first.md +132 -0
  94. package/skills/workflows/memtrace-incident-investigation.md +125 -0
  95. package/skills/workflows/memtrace-refactoring-guide.md +116 -0
  96. package/skills/workflows/memtrace-session-continuity.md +98 -0
  97. package/skills/workflows/memtrace-style-fingerprint.md +111 -0
@@ -0,0 +1,58 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ ## Quick Reference
11
+
12
+ | Tool | Purpose |
13
+ |------|---------|
14
+ | `get_impact` | Blast radius from a specific symbol (by ID) |
15
+ | `detect_changes` | Scope symbols affected by a diff/patch |
16
+
17
+ > **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`.
18
+
19
+
20
+ ## Steps
21
+
22
+ ### 1. Identify the symbol
23
+
24
+ If you have a symbol name but not its ID:
25
+ - Use `find_symbol` for exact names
26
+ - Use `find_code` for natural-language queries
27
+
28
+ ### 2. Run impact analysis
29
+
30
+ Use the `get_impact` MCP tool:
31
+ - `symbol_id` — the symbol you plan to change (required)
32
+ - `direction` — `upstream` (what depends on me), `downstream` (what I depend on), or `both` (default)
33
+ - `depth` — traversal hops (default 3)
34
+
35
+ ### 3. Interpret the risk rating
36
+
37
+ | Risk | Meaning | Action |
38
+ |------|---------|--------|
39
+ | **Low** | Few dependents, leaf node | Safe to modify; minimal testing needed |
40
+ | **Medium** | Moderate dependents | Test direct callers; review interface contracts |
41
+ | **High** | Many dependents across modules | Coordinate changes; comprehensive test coverage |
42
+ | **Critical** | Core infrastructure, many transitive dependents | Plan migration strategy; consider backward-compatible changes |
43
+
44
+ ### 4. For diff-based analysis
45
+
46
+ When you have an actual code diff (not just a symbol), use `detect_changes`:
47
+ - Scopes all symbols affected by the diff
48
+ - Returns blast radius AND affected processes (execution flows)
49
+ - Useful for PR reviews or pre-commit checks
50
+
51
+ ## Decision Points
52
+
53
+ | Situation | Action |
54
+ |-----------|--------|
55
+ | Changing a single function | `get_impact` with `direction: both` |
56
+ | Reviewing a PR or diff | `detect_changes` with the diff content |
57
+ | Renaming/removing a public API | `get_impact` with `direction: upstream`, high depth |
58
+ | Refactoring internals | `get_impact` with `direction: downstream` to check what you depend on |
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: memtrace-incident-investigation
3
+ description: "Always use for source-code bugs, incidents, regressions, production issues, failures, root cause analysis, what broke, or what changed when debugging. Do not start with Grep, Glob, rg, find, or manual file search for code causes; Memtrace combines symbol search, impact, call graph, and temporal history."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Root cause investigation workflow for incidents, regressions, and production issues. Uses temporal analysis with the `recent` scoring mode to surface changes closest to the incident time, then traces blast radius and execution flows to identify the likely cause.
9
+
10
+ ## Steps
11
+
12
+ ### 1. Establish the timeline
13
+
14
+ Determine:
15
+ - **Incident time** — when did the problem start? (This becomes the `to` parameter)
16
+ - **Lookback window** — how far back to search? Start with 24 hours, expand if needed.
17
+ - **Repo(s)** — which services are affected? Call `list_indexed_repositories` to get repo_ids.
18
+
19
+ ### 2. Surface recent changes near the incident
20
+
21
+ Call `get_evolution` with:
22
+ - `mode: "recent"` — temporal proximity weighting: `impact × exp(−0.5 × Δhours)`
23
+ - `from` — lookback start (e.g., 24 hours before incident)
24
+ - `to` — the incident timestamp
25
+ - `repo_id` — the affected repo
26
+
27
+ **Why `recent` mode?** It exponentially amplifies changes close to the incident time while still weighting by structural impact. A high-impact change made 1 hour before the incident scores much higher than the same change made 20 hours before.
28
+
29
+ **Success criteria:** A ranked list of changes, with the most likely culprits at the top.
30
+
31
+ ### 3. Check for unexpected changes
32
+
33
+ Call `get_evolution` again with `mode: "novel"` on the same time window:
34
+ - Flags changes to rarely-modified code (high in_degree, low change frequency)
35
+ - A core utility that hasn't changed in 90 days suddenly changing near an incident is a strong signal
36
+
37
+ **Decision:** If `novel` mode surfaces different symbols than `recent` mode, investigate both — the root cause may be an unexpected change to stable infrastructure.
38
+
39
+ ### 4. Trace the blast radius of top suspects
40
+
41
+ For the top 3–5 symbols from steps 2–3, call `get_impact` with `direction: upstream`:
42
+ - How many downstream consumers were affected?
43
+ - What execution flows pass through this symbol?
44
+
45
+ **Decision:** Prioritize symbols where the blast radius overlaps with the reported failure area.
46
+
47
+ ### 5. Trace execution flows
48
+
49
+ Use `get_symbol_context` on the top suspects to see which processes (HTTP handlers, background jobs, etc.) they participate in.
50
+
51
+ **Decision:** If the incident is in a specific endpoint/flow, focus on suspects that are members of that process.
52
+
53
+ ### 6. Build the full timeline for the suspect
54
+
55
+ Once you have a primary suspect, call `get_timeline` with the symbol name to see its full version history:
56
+ - What changed in each commit?
57
+ - When was the last "stable" version?
58
+ - Was the change a modification, or was it newly added?
59
+
60
+ ### 7. Correlate with surrounding changes
61
+
62
+ Call `get_evolution` with mode `directional` to separate:
63
+ - **Added symbols** — new code introduced (potential new bugs)
64
+ - **Removed symbols** — deleted code (potential missing functionality)
65
+ - **Modified symbols** — changed behaviour (potential regressions)
66
+
67
+ ### 8. Check historical coupling (cochange)
68
+
69
+ For the primary suspect, call `get_cochange_context`:
70
+ - Which symbols historically co-change with this one?
71
+ - If the blast radius from `get_impact` doesn't explain the failure area, check cochange partners — the coupling may be behavioral, not structural.
72
+
73
+ **Decision:** If a cochange partner is in the failure area but has no direct call relationship to the suspect, it's a hidden dependency — investigate both.
74
+
75
+ ### 9. Replay the sub-commit implementation history (if needed)
76
+
77
+ If the suspect's commit history doesn't explain the intent, call `get_episode_replay`:
78
+ - What was tried before the final committed state?
79
+ - Was any approach attempted and reverted in the same session?
80
+ - The `attempted_and_reverted` hint often explains why seemingly-correct code was changed to something subtler.
81
+
82
+ ## Report: Root Cause Analysis
83
+
84
+ 1. **Incident Timeline** — when it started, what was observed
85
+ 2. **Most Likely Cause** — the top-ranked change(s) by `recent` mode with blast radius confirmation
86
+ 3. **Supporting Evidence** — novelty signal (was this an unexpected change?), blast radius overlap with failure area, process membership overlap
87
+ 4. **Change History** — full timeline of the suspect symbol
88
+ 5. **Affected Scope** — all processes and downstream consumers impacted
89
+ 6. **Remediation** — revert the change, fix forward, or mitigate
90
+
91
+ ## Algorithm Selection Guide for Incidents
92
+
93
+ | Phase | Tool / Mode | Why |
94
+ |-------|-------------|-----|
95
+ | Initial triage | `get_evolution` `recent` | Time-weighted ranking surfaces changes near the incident |
96
+ | Anomaly detection | `get_evolution` `novel` | Catches unexpected changes to stable code |
97
+ | Scope assessment | `get_impact` | Ranks by structural significance (blast radius) |
98
+ | Hidden coupling | `get_cochange_context` | Surfaces behavioral coupling not in the call graph |
99
+ | Direction analysis | `get_evolution` `directional` | Separates added/removed/modified |
100
+ | Sub-commit intent | `get_episode_replay` | Reveals what was tried before the committed state |
101
+ | Quick summary | `get_evolution` `overview` | Fast module-level scan before deep-diving |
102
+
103
+ ## Common Mistakes
104
+
105
+ | Mistake | Reality |
106
+ |---------|---------|
107
+ | Starting with `impact` mode | Use `recent` first — time proximity is the strongest signal for incidents |
108
+ | Only looking at the most recent commit | The root cause may be from an earlier change whose effects were delayed |
109
+ | Ignoring `novel` mode | Unexpected changes to stable code are often the root cause |
110
+ | Not checking blast radius overlap | A change is only a suspect if its blast radius reaches the failure area |
111
+ | Stopping at call graph analysis | `get_cochange_context` finds hidden coupling — symbols that move together without calling each other |
112
+ | Reading only committed code | `get_episode_replay` reveals tried-and-reverted approaches that explain the current implementation |
@@ -0,0 +1,65 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ ## Quick Reference
11
+
12
+ | Parameter | Purpose |
13
+ |-----------|---------|
14
+ | `path` | Absolute path to the directory to index |
15
+ | `incremental` | Only re-parse changed files (use for subsequent runs) |
16
+ | `clear_existing` | Wipe and rebuild from scratch |
17
+
18
+ > **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`.
19
+
20
+
21
+ ## Steps
22
+
23
+ ### 1. Check if already indexed
24
+
25
+ Use the `list_indexed_repositories` MCP tool first. If the repo is already indexed and recent, skip to step 4.
26
+
27
+ **Success criteria:** You have a list of repo_ids and their last-indexed timestamps.
28
+
29
+ If a repo is present but searches miss a source subdirectory under that repo
30
+ root (for example `ui/`, `memtrace-ui/`, `web/`, `frontend/`, or `src/`), treat
31
+ that as a stale/partial index. Do not use grep as a workaround. Run incremental
32
+ indexing on the repo root, then retry the Memtrace query.
33
+
34
+ ### 2. Index the directory
35
+
36
+ Use the `index_directory` MCP tool:
37
+
38
+ - Set `path` to the project root (absolute path)
39
+ - Set `incremental: true` if re-indexing after changes
40
+ - Set `clear_existing: true` only if a full rebuild is needed
41
+
42
+ **Success criteria:** You receive a `job_id` immediately.
43
+
44
+ ### 3. Poll for completion
45
+
46
+ Use `check_job_status` with the `job_id` every 2–3 seconds.
47
+
48
+ Pipeline stages in order: **scan → parse → resolve → communities → processes → persist → embeddings → api_detect → done**
49
+
50
+ Wait until `status = "completed"`. If `status = "failed"`, report the error message to the user.
51
+
52
+ ### 4. Report to user
53
+
54
+ 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.
55
+
56
+ **Save the `repo_id`** — most other memtrace tools require it.
57
+
58
+ ## Error Handling
59
+
60
+ | Error | Action |
61
+ |-------|--------|
62
+ | Path does not exist | Ask user to verify the absolute path |
63
+ | Job status "failed" | Report the error message; suggest `clear_existing: true` for a fresh rebuild |
64
+ | Timeout (job running > 5 min) | Large repos are normal; keep polling. For monorepos, index subdirectories separately |
65
+ | Already indexed | Use `incremental: true` to update, or skip indexing entirely |
@@ -0,0 +1,63 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ Identify code quality issues using structural graph analysis — dead code (zero callers), complexity hotspots (high out-degree), and repository-wide statistics.
9
+
10
+ ## Quick Reference
11
+
12
+ | Tool | Purpose |
13
+ |------|---------|
14
+ | `find_dead_code` | Symbols with zero callers (potentially unused) |
15
+ | `calculate_cyclomatic_complexity` | Complexity score for a specific symbol |
16
+ | `find_most_complex_functions` | Top-N functions by complexity across the repo |
17
+ | `get_repository_stats` | Repo-wide counts: nodes, edges, communities, processes |
18
+
19
+ > **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`.
20
+
21
+
22
+ ## Steps
23
+
24
+ ### 1. Get repository overview
25
+
26
+ Use `get_repository_stats` to understand the codebase scale:
27
+ - Node counts by kind (functions, classes, methods, interfaces)
28
+ - Edge counts (calls, imports, extends, type references)
29
+ - Community and process counts
30
+
31
+ ### 2. Find dead code
32
+
33
+ Use `find_dead_code`:
34
+ - `repo_id` — required
35
+ - `include_tests` — set true to also flag unused test helpers (default false)
36
+
37
+ **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.
38
+
39
+ ### 3. Find complexity hotspots
40
+
41
+ Use `find_most_complex_functions`:
42
+ - `repo_id` — required
43
+ - `limit` — how many to return (default 10)
44
+
45
+ Complexity scoring (based on out-degree — number of callees):
46
+ | Score | Rating | Action |
47
+ |-------|--------|--------|
48
+ | < 5 | Low | No action needed |
49
+ | 5–10 | Medium | Monitor; consider splitting if growing |
50
+ | 10–20 | High | Refactoring candidate; extract helper functions |
51
+ | > 20 | Critical | Immediate attention; this function does too much |
52
+
53
+ ### 4. Drill into specific functions
54
+
55
+ Use `calculate_cyclomatic_complexity` on specific symbols flagged by the user or found in step 3.
56
+
57
+ ## Common Mistakes
58
+
59
+ | Mistake | Reality |
60
+ |---------|---------|
61
+ | Treating all dead code as deletable | Some "dead" code is called via reflection, dynamic dispatch, or external consumers |
62
+ | Ignoring exported symbols in dead code results | If `include_tests: false`, exported symbols are already excluded |
63
+ | Only looking at the highest complexity | Medium-complexity functions that are growing (check `get_evolution`) are often more urgent |
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: memtrace-refactoring-guide
3
+ description: "Always use when the user wants to refactor source code, reduce complexity, clean technical debt, split large functions, extract modules, reorganize code, or choose refactoring priorities. Do not use Grep or manual reference search to plan refactors; Memtrace provides complexity, dead-code, relationships, and impact context."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Guided refactoring workflow — identifies refactoring candidates using structural analysis, scores them by risk and priority, and produces a phased refactoring plan. Combines complexity metrics, dead code detection, bridge analysis, and temporal evolution to prioritize what to refactor first and how to do it safely.
9
+
10
+ ## Steps
11
+
12
+ ### 1. Identify refactoring candidates
13
+
14
+ Run these three tools in parallel to build a candidate list:
15
+
16
+ **a) Complexity hotspots:**
17
+ Call `find_most_complex_functions` with `limit: 20`
18
+
19
+ **b) Dead code:**
20
+ Call `find_dead_code` to find unused symbols
21
+
22
+ **c) Architectural bottlenecks:**
23
+ Call `find_bridge_symbols` to find chokepoints with too much responsibility
24
+
25
+ ### 2. Score candidates by volatility
26
+
27
+ Call `get_evolution` with mode `compound` over a 90-day window:
28
+ - Symbols that are BOTH complex AND frequently changing are the highest priority
29
+ - Complex but stable code can wait — it's not causing active pain
30
+ - Volatile but simple code may be fine — frequent changes to simple code is normal
31
+
32
+ **Priority matrix:**
33
+
34
+ | | Low Complexity | High Complexity |
35
+ |---|---|---|
36
+ | **Stable (low change freq)** | Leave alone | Monitor; refactor if touched |
37
+ | **Volatile (high change freq)** | Normal; leave alone | **TOP PRIORITY** — refactor first |
38
+
39
+ ### 3. Assess risk for top candidates
40
+
41
+ For each top-priority candidate, call `get_impact` with `direction: both`:
42
+ - **Low risk** → refactor directly
43
+ - **Medium risk** → refactor with comprehensive tests
44
+ - **High/Critical risk** → plan incremental migration with backward compatibility
45
+
46
+ Also call `get_symbol_context` to check:
47
+ - How many processes does this symbol participate in? (More = more testing needed)
48
+ - Is it part of a cross-repo API? (If yes, coordinate with consumers)
49
+
50
+ ### 4. Understand the neighbourhood
51
+
52
+ For each refactoring target, call `analyze_relationships`:
53
+ - `find_callees` — what does it depend on? (these become candidates for extraction)
54
+ - `find_callers` — what depends on it? (these need updating after refactoring)
55
+ - `class_hierarchy` — is it part of an inheritance chain? (Liskov concerns)
56
+
57
+ ### 5. Check community boundaries
58
+
59
+ Call `list_communities` and check: does the refactoring target sit at a community boundary?
60
+ - If yes, the refactoring may involve splitting responsibilities across modules
61
+ - If it belongs clearly to one community, the refactoring is more contained
62
+
63
+ ### 6. Produce the refactoring plan
64
+
65
+ Synthesize into a phased plan:
66
+
67
+ **Phase 1 — Quick Wins:**
68
+ - Dead code removal (zero-risk deletions)
69
+ - Simple functions with high churn (reduce volatility)
70
+
71
+ **Phase 2 — High-Impact Refactors:**
72
+ - Complex + volatile functions (highest priority by the matrix)
73
+ - Bridge symbols with too many responsibilities (extract interfaces)
74
+
75
+ **Phase 3 — Structural Improvements:**
76
+ - Splitting oversized communities into smaller, focused modules
77
+ - Extracting shared logic from bridge symbols into dedicated services
78
+
79
+ For each item, include:
80
+ 1. **Target** — function/class name, file, current complexity score
81
+ 2. **Why** — complexity + volatility + blast radius rationale
82
+ 3. **How** — specific refactoring approach (extract method, split class, introduce interface)
83
+ 4. **Risk** — impact analysis rating + affected processes
84
+ 5. **Test Plan** — which callers/processes to verify
85
+
86
+ ## Decision Points
87
+
88
+ | Condition | Action |
89
+ |-----------|--------|
90
+ | Complex + volatile + high blast radius | Highest priority — but plan carefully; incremental approach |
91
+ | Complex + stable + low blast radius | Can wait; refactor when you're already touching nearby code |
92
+ | Dead code with zero callers | Safe to delete — quick win |
93
+ | Bridge symbol with many dependents | Extract interface first, then refactor implementation behind it |
94
+ | Symbol in cross-repo API | Coordinate with consumers; backward-compatible changes only |
95
+
96
+ ## Common Mistakes
97
+
98
+ | Mistake | Reality |
99
+ |---------|---------|
100
+ | Refactoring the most complex function first | Complexity alone isn't enough — prioritize by complexity × volatility |
101
+ | Deleting all dead code at once | Some "dead" code is called dynamically; verify before batch deletion |
102
+ | Refactoring without checking blast radius | A "simple" refactor on a bridge symbol can cascade across the codebase |
103
+ | Not checking temporal evolution | A complex function that hasn't changed in a year is lower priority than a simpler one that changes weekly |
@@ -0,0 +1,67 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ ## Quick Reference
11
+
12
+ | query_type | What it finds |
13
+ |------------|---------------|
14
+ | `find_callers` | What calls this function/method? |
15
+ | `find_callees` | What does this function call? |
16
+ | `class_hierarchy` | Parent classes, interfaces, mixins |
17
+ | `overrides` | Which child classes override this method? |
18
+ | `imports` | What modules does this file import? |
19
+ | `exporters` | Which files import this module? |
20
+ | `type_usages` | Where is this type/interface referenced? |
21
+
22
+ > **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`.
23
+
24
+
25
+ ## Steps
26
+
27
+ ### 1. Get the symbol ID
28
+
29
+ If you don't have a symbol `id`, find it first:
30
+ - Use `find_symbol` for exact names
31
+ - Use `find_code` for natural-language queries
32
+
33
+ ### 2. Choose your approach
34
+
35
+ **Quick 360° view** → Use `get_symbol_context`
36
+ Returns in one call: direct callers, callees, type references, community membership, process membership, and cross-repo API callers.
37
+
38
+ **ALWAYS prefer `get_symbol_context` first** — it answers "what does this touch and what touches it?" faster than multiple `analyze_relationships` calls.
39
+
40
+ **Targeted traversal** → Use `analyze_relationships`
41
+ When you need a specific relationship type at a specific depth:
42
+ - `symbol_id` — the symbol to start from (required)
43
+ - `query_type` — one of the types above (required)
44
+ - `depth` — traversal hops, default 2 (higher = slower but reveals indirect deps)
45
+
46
+ ### 3. Interpret results
47
+
48
+ - **High in_degree** (many callers) → widely-used symbol; changes have large blast radius
49
+ - **High out_degree** (many callees) → complex function; candidate for refactoring
50
+ - **Deep class hierarchy** → check for Liskov violations or fragile base class issues
51
+ - **Cross-repo API callers** → changes require coordination with other teams/services
52
+
53
+ ### 4. Follow up
54
+
55
+ After understanding relationships, consider:
56
+ - `get_impact` to quantify the blast radius of a change
57
+ - `get_evolution` to see how this symbol has changed over time
58
+ - `find_dead_code` if you found unreferenced symbols
59
+
60
+ ## Decision Points
61
+
62
+ | Situation | Action |
63
+ |-----------|--------|
64
+ | Need broad context fast | Use `get_symbol_context` (one call, full picture) |
65
+ | Need specific relationship at depth >2 | Use `analyze_relationships` with custom depth |
66
+ | Symbol has many callers | Follow up with `get_impact` before modifying |
67
+ | 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,93 @@
1
+ ---
2
+ name: memtrace-session-continuity
3
+ description: "Always use at session start or resume when the user asks to continue, catch up, see what changed while away, recover prior context, or orient without guessing timestamps in an indexed source-code repo. Do not use git log, Grep, or manual file search for catch-up; Memtrace provides session anchors and change memory."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Session continuity for agents. Instead of guessing a time window and blindly running `get_evolution`, pass a `session_anchor` from your last session and get back exactly what changed — nothing more. The response returns a new anchor to persist for next time.
9
+
10
+ **Core principle:** Agents track a cursor, not a clock. Never guess timestamps.
11
+
12
+ ## Steps
13
+
14
+ ### 1. Find or bootstrap the session anchor
15
+
16
+ Look for a stored `session_anchor` from your last session:
17
+
18
+ ```json
19
+ {
20
+ "last_episode_id": "ep_abc123",
21
+ "last_reference_time": "2026-04-13T10:43:00Z"
22
+ }
23
+ ```
24
+
25
+ If you have no anchor yet (first run), call `list_indexed_repositories`. Each repo now includes `last_episode_id`, `last_episode_time`, and `last_episode_type` — use `last_episode_id` as your bootstrap anchor.
26
+
27
+ ### 2. Call `get_changes_since`
28
+
29
+ ```
30
+ get_changes_since(
31
+ repo_id: "...",
32
+ last_episode_id: "ep_abc123" // preferred — exact episode boundary
33
+ // OR
34
+ last_reference_time: "2026-04-13T10:43:00Z" // fallback
35
+ )
36
+ ```
37
+
38
+ ### 3. Interpret the response
39
+
40
+ | `status` | Meaning | Action |
41
+ |---|---|---|
42
+ | `no_changes` | Nothing changed since your anchor | Safe to proceed; store new anchor |
43
+ | `changes_detected` | Full symbol-level delta returned | Review `modified[]`, `added[]`, `removed[]` |
44
+ | `changes_detected_overview` | >500 candidates — module rollup only | Check `by_module` for affected areas |
45
+ | `error` | Bad anchor or unknown episode | Fall back to `last_reference_time` or re-index |
46
+
47
+ ### 4. Decide whether changes are relevant
48
+
49
+ ```
50
+ changes_detected
51
+ ├── Check modified[]/added[]/removed[] — do any overlap with your current task?
52
+ │ ├── YES → understand what changed before proceeding
53
+ │ └── NO → safe to continue, update anchor
54
+
55
+ changes_detected_overview (large window)
56
+ ├── Check by_module — does any changed module overlap with your task area?
57
+ │ ├── YES → get_evolution(mode: compound) scoped to that window for detail
58
+ │ └── NO → ignore, update anchor
59
+ ```
60
+
61
+ ### 5. Always persist the returned anchor
62
+
63
+ Every response includes a new `session_anchor`. Store it for next session:
64
+
65
+ ```json
66
+ {
67
+ "session_anchor": {
68
+ "last_episode_id": "ep_xyz789",
69
+ "last_reference_time": "2026-04-13T14:22:00Z"
70
+ }
71
+ }
72
+ ```
73
+
74
+ ## Auto-mode Selection
75
+
76
+ `get_changes_since` automatically picks the right mode so it never crashes:
77
+
78
+ | Candidate count | Mode selected | What you get |
79
+ |---|---|---|
80
+ | 0 | — | `no_changes` immediately |
81
+ | 1–499 | `compound` | Full symbol scoring |
82
+ | 500+ | `overview` | Module rollup only |
83
+
84
+ `candidate_count` in the response tells you what was found before selection.
85
+
86
+ ## Common Mistakes
87
+
88
+ | Mistake | Reality |
89
+ |---------|---------|
90
+ | Using `get_evolution` with a guessed timestamp | `get_changes_since` uses an exact episode boundary — no guessing, no over-fetching |
91
+ | Discarding the returned `session_anchor` | Without it, next session reverts to timestamp guessing |
92
+ | Treating `changes_detected_overview` as too large to act on | `by_module` is complete — it tells you exactly which areas changed even in large windows |
93
+ | Calling this tool repeatedly within one session | Call once at session start; use the returned evolution result for the rest of the session |