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-api-topology
3
+ description: "Always use for API endpoint, HTTP route, fetch/client call, REST surface, service dependency, cross-repo dependency, or API topology questions in source code. Do not use Grep, Glob, rg, find, or manual file search for routes or HTTP calls; Memtrace maps endpoints and call edges from the indexed AST graph."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Map the HTTP API surface of a codebase — exposed endpoints, outbound HTTP calls, and cross-repo service-to-service dependency graphs. Supports auto-detection for Express, Encore, NestJS, Axum, FastAPI, Flask, Gin, Spring Boot, and more.
9
+
10
+ ## Quick Reference
11
+
12
+ | Tool | Purpose |
13
+ |------|---------|
14
+ | `find_api_endpoints` | All exposed HTTP endpoints (GET /users, POST /orders, etc.) |
15
+ | `find_api_calls` | All outbound HTTP calls (fetch, axios, reqwest, etc.) |
16
+ | `get_api_topology` | Cross-repo call graph: which service calls which endpoint |
17
+ | `link_repositories` | Manually link repos for cross-repo edge detection |
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. Discover endpoints
25
+
26
+ Use `find_api_endpoints`:
27
+ - `repo_id` — required
28
+ - Returns: method, path, handler function, framework detected
29
+
30
+ ### 2. Discover outbound calls
31
+
32
+ Use `find_api_calls`:
33
+ - `repo_id` — required
34
+ - Returns: target URL/path, HTTP method, calling function, library used (fetch, axios, reqwest, etc.)
35
+
36
+ ### 3. Map service topology
37
+
38
+ Use `get_api_topology` to see the cross-repo HTTP call graph:
39
+ - Which services call which endpoints
40
+ - Confidence scores for each detected link
41
+ - Service-to-service dependency direction
42
+
43
+ **Prerequisite:** Multiple repos must be indexed. If cross-repo links aren't appearing, use `link_repositories` to explicitly connect them.
44
+
45
+ ### 4. Deep-dive into an endpoint
46
+
47
+ For any specific endpoint, use `get_symbol_context` with the endpoint's symbol ID to see:
48
+ - Which internal functions handle the request
49
+ - Which processes (execution flows) include this endpoint
50
+ - Which external services call this endpoint
51
+
52
+ ## Common Mistakes
53
+
54
+ | Mistake | Reality |
55
+ |---------|---------|
56
+ | Expecting cross-repo links with only one repo indexed | Index ALL related services first; cross-repo HTTP edges are linked automatically after indexing |
57
+ | Missing endpoints from custom frameworks | Memtrace auto-detects major frameworks; for custom routers, the endpoints may appear as regular functions |
58
+ | Not using `link_repositories` | If auto-linking missed a connection, use this to manually establish cross-repo edges |
@@ -0,0 +1,75 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ ## Steps
11
+
12
+ ### 1. Identify what's being changed
13
+
14
+ Find the target symbol(s):
15
+ - Use `find_symbol` if the user named specific functions/classes
16
+ - Use `find_code` if the user described behaviour ("the authentication middleware")
17
+
18
+ Collect symbol IDs for all targets.
19
+
20
+ ### 2. Get 360° context for each target
21
+
22
+ For each symbol, call `get_symbol_context`:
23
+ - Direct callers and callees
24
+ - Community membership (which module is this in?)
25
+ - Process membership (which execution flows does this participate in?)
26
+ - Cross-repo API callers (is this an endpoint called by other services?)
27
+
28
+ **Decision:** If cross-repo API callers exist, this change requires coordination with other teams. Flag this immediately.
29
+
30
+ ### 3. Compute blast radius
31
+
32
+ For each target, call `get_impact` with `direction: both`:
33
+ - Upstream impact: what depends on this symbol
34
+ - Downstream impact: what this symbol depends on
35
+ - Risk rating: Low / Medium / High / Critical
36
+
37
+ **Decision:**
38
+ | Risk | Action |
39
+ |------|--------|
40
+ | Low | Proceed with standard testing |
41
+ | Medium | Review all direct callers; test affected processes |
42
+ | High | Plan incremental migration; consider feature flags |
43
+ | Critical | Full migration strategy; backward-compatible changes required |
44
+
45
+ ### 4. Check temporal stability
46
+
47
+ Call `get_evolution` with mode `novel` for a 30-day window on the repo:
48
+ - Are any of the target symbols flagged as "rarely changing"? If so, this change is structurally surprising and deserves extra scrutiny.
49
+ - Have the target symbols been changing frequently? High churn + high impact = volatile hotspot.
50
+
51
+ ### 5. Map affected execution flows
52
+
53
+ 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.
54
+
55
+ ### 6. Produce the risk assessment
56
+
57
+ Synthesize into a change plan:
58
+
59
+ 1. **Target(s)** — what's being changed and where
60
+ 2. **Blast Radius** — number of direct/transitive dependents, risk rating
61
+ 3. **Affected Processes** — which execution flows will be impacted
62
+ 4. **Cross-Service Impact** — any external callers or consumers
63
+ 5. **Stability Signal** — is this code stable (novel) or volatile (frequent changes)?
64
+ 6. **Recommended Approach** — based on risk: direct change, incremental migration, or backward-compatible evolution
65
+ 7. **Test Coverage** — which callers/processes to verify after the change
66
+
67
+ ## Decision Points
68
+
69
+ | Condition | Action |
70
+ |-----------|--------|
71
+ | Risk = Critical | Recommend backward-compatible change + deprecation path |
72
+ | Cross-repo callers exist | Flag as requiring multi-service coordination |
73
+ | Symbol has high novelty score | Extra review — this rarely changes; make sure the change is intentional |
74
+ | Multiple processes affected | List each affected flow; recommend testing each one |
75
+ | Symbol is a bridge point | Change may disconnect parts of the architecture — verify alternative paths exist |
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: memtrace-cochange
3
+ description: "Always use for historical coupling, co-change, what changes with this, hidden dependency, or what else needs to move questions for source code. Do not use git log, git diff, Grep, or manual file search to correlate changes; Memtrace queries co-change and temporal graph data directly."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Find symbols that historically co-change with a target symbol — ranked by co-occurrence frequency across all episodes. This surfaces **behavioral coupling** that the static call graph cannot see.
9
+
10
+ `get_impact` answers "who calls this?" (structural).
11
+ `get_cochange_context` answers "what always moves when this moves?" (historical).
12
+
13
+ They are complementary. A symbol with no direct callers can still have strong cochange partners if it's always modified alongside another in every commit.
14
+
15
+ > **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`.
16
+
17
+
18
+ ## Steps
19
+
20
+ ### 1. Identify the target symbol
21
+
22
+ Use `find_symbol` if you need the exact name. The tool matches by `name` field.
23
+
24
+ ### 2. Call `get_cochange_context`
25
+
26
+ ```
27
+ get_cochange_context(
28
+ repo_id: "...",
29
+ symbol: "execute", // exact symbol name
30
+ limit: 20 // default 20, increase for broader view
31
+ )
32
+ ```
33
+
34
+ ### 3. Interpret results
35
+
36
+ The response contains `cochanges[]`, each with:
37
+ - `name` — symbol name
38
+ - `kind` — Function / Method / Class / Struct
39
+ - `file_path` — where it lives
40
+ - `cochange_count` — how many episodes it shared with the target
41
+
42
+ ```
43
+ High cochange_count = strong historical coupling
44
+ → If you modify the target, you will likely need to touch this too
45
+ → Or it may be the real root cause you should investigate first
46
+ ```
47
+
48
+ ### 4. Cross-reference with call graph
49
+
50
+ For the top cochange partners, optionally run `get_impact` to see if the coupling is also structural:
51
+
52
+ | Structural coupling | Historical coupling | Interpretation |
53
+ |---|---|---|
54
+ | Yes | Yes | Core architectural dependency — highest risk |
55
+ | No | Yes | Hidden coupling — only visible through history |
56
+ | Yes | No | Called frequently but changed independently — lower risk |
57
+
58
+ ## When to Use
59
+
60
+ - **Before modifying a symbol** — get blast awareness beyond what `get_impact` shows
61
+ - **Incident investigation** — when `get_impact` doesn't explain the blast radius, check cochange history
62
+ - **Code review** — verify that a PR touched all historically-coupled partners
63
+ - **Refactoring** — discover implicit coupling before extracting a module
64
+
65
+ ## Common Mistakes
66
+
67
+ | Mistake | Reality |
68
+ |---------|---------|
69
+ | Only using `get_impact` for blast radius | Structural coupling misses behavioral coupling — always pair with cochange |
70
+ | Ignoring low-`in_degree` cochange partners | A rarely-called utility with high cochange_count is a strong coupling signal |
71
+ | Using cochange as a dependency map | It's not a dependency graph — it's a change correlation. Two symbols can cochange without any direct relationship. |
@@ -0,0 +1,41 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ ## Default Flow
11
+
12
+ 1. If the user gives a GitHub PR URL and asks to inspect or review it, call `review_github_pr` with `post: false`.
13
+ 2. If the user explicitly asks to publish, post comments, or complete the PR review, call `review_github_pr` with `post: true`.
14
+ 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.
15
+ 4. Default to `minSeverity: "high"` and `maxComments: 5` when posting. For previews, `maxComments: 10` is acceptable.
16
+ 5. Pass `repoRoot` when the PR checkout is not the current working directory. Pass `repoId` when the indexed repository id is known.
17
+
18
+ ## Example User Prompts
19
+
20
+ - "Review this PR with Memtrace: https://github.com/OWNER/REPO/pull/123"
21
+ - "Use Memtrace to review this pull request and post the findings: https://github.com/OWNER/REPO/pull/123"
22
+ - "Create the PR, then run Memtrace code review and publish the review comments."
23
+
24
+ ## Guardrails
25
+
26
+ - Do not start with generic grep, rg, or manual diff review when `review_github_pr` is available.
27
+ - Do not post comments unless the user explicitly requested publication.
28
+ - Do not create benchmark-specific or PR-specific findings. The review must come from general Memtrace detectors, graph evidence, and policy ranking.
29
+ - If the tool reports missing auth, tell the user to run `memtrace auth login`.
30
+ - If the tool reports missing GitHub App installation, tell the user to install Memtrace Code Reviewer on that repository.
31
+ - If the tool reports missing local graph context, tell the user to run `memtrace index .` at the workspace root.
32
+
33
+ ## Output
34
+
35
+ For previews, summarize:
36
+ - PR URL and repository
37
+ - Graph state
38
+ - Number of candidate comments
39
+ - File, line, severity, and message for each finding
40
+
41
+ For posted reviews, report the PR URL and number of comments posted.
@@ -0,0 +1,94 @@
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
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ ## Steps
11
+
12
+ ### 1. Index the codebase
13
+
14
+ Call `list_indexed_repositories` first. If the repo is already indexed, skip to step 2.
15
+
16
+ Otherwise, call `index_directory` with the project path, then poll `check_job_status` until completion.
17
+
18
+ **Success criteria:** Repo appears in `list_indexed_repositories` with non-zero node/edge counts.
19
+
20
+ ### 2. Get the lay of the land
21
+
22
+ Call `get_repository_stats` to understand scale:
23
+ - How many functions, classes, methods, interfaces?
24
+ - How many relationships (calls, imports, extends)?
25
+ - How many communities and processes were detected?
26
+
27
+ Report these numbers to the user — they set expectations for the codebase's size and complexity.
28
+
29
+ ### 3. Map the architecture (communities)
30
+
31
+ Call `list_communities` to see how the codebase naturally clusters into logical modules.
32
+
33
+ **Decision:** If >10 communities, summarize the top 5–7 by size and let the user ask about specific ones.
34
+
35
+ Each community represents a cohesive module — these are the "areas" of the codebase.
36
+
37
+ ### 4. Find the most important symbols
38
+
39
+ 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).
40
+
41
+ These are the symbols that the rest of the codebase depends on most heavily. They form the "skeleton" of the architecture.
42
+
43
+ ### 5. Find architectural bottlenecks
44
+
45
+ Call `find_bridge_symbols` to identify chokepoints — symbols that connect otherwise-separate parts of the codebase.
46
+
47
+ **Decision:** If bridge symbols overlap heavily with central symbols, flag them as critical infrastructure — high importance AND single point of failure.
48
+
49
+ ### 6. Map execution flows
50
+
51
+ Call `list_processes` to discover entry points:
52
+ - HTTP handlers (API endpoints)
53
+ - Background jobs
54
+ - CLI commands
55
+ - Event handlers
56
+
57
+ This shows HOW the code is actually used at runtime, not just how it's structured.
58
+
59
+ ### 7. Map the API surface (if applicable)
60
+
61
+ Call `find_api_endpoints` to list all HTTP routes.
62
+
63
+ **Decision:** If multiple repos are indexed, also call `get_api_topology` to map service-to-service dependencies.
64
+
65
+ ### 8. Recent activity
66
+
67
+ Call `get_evolution` with mode `overview` and a 30-day window to see which modules have been most active recently.
68
+
69
+ **Decision:** If the user asks about specific recent changes, switch to mode `compound` for symbol-level detail.
70
+
71
+ ### 9. Complexity hotspots
72
+
73
+ Call `find_most_complex_functions` with `limit: 10` to identify potential technical debt.
74
+
75
+ ## Report Synthesis
76
+
77
+ Synthesize findings into a structured overview:
78
+
79
+ 1. **Scale** — languages, total symbols, total relationships
80
+ 2. **Architecture** — main communities/modules and what they do
81
+ 3. **Critical Infrastructure** — central symbols and bridge points
82
+ 4. **Execution Flows** — how the code is entered and used
83
+ 5. **API Surface** — endpoints and service dependencies
84
+ 6. **Recent Activity** — what's been changing in the last 30 days
85
+ 7. **Technical Debt** — complexity hotspots and potential dead code
86
+
87
+ ## Common Mistakes
88
+
89
+ | Mistake | Reality |
90
+ |---------|---------|
91
+ | Skipping indexing and using file-based grep | The knowledge graph provides structural understanding that grep cannot — callers, callees, communities, processes |
92
+ | Reporting raw numbers without interpretation | "450 functions across 12 communities" means nothing; describe what each community does |
93
+ | Only looking at code structure | Execution flows (processes) show how the code is actually used — always include them |
94
+ | Ignoring temporal context | Recent evolution shows where active development is happening — this is where the user will likely need to work |
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: memtrace-continuous-memory
3
+ description: "Always use when the user asks to keep Memtrace fresh while editing, watch a repo, enable live or incremental indexing, set up always-on memory, or make just-saved source code queryable immediately. Do not fall back to repeated Grep or manual rescans; configure Memtrace watching."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Memtrace keeps the knowledge graph live as you edit. Once you call `watch_directory`, every save runs through the **incremental indexing fast-path** — a notify-based file watcher debounces saves, the indexer re-parses only the touched files, and the engine commits the delta in a single WAL transaction. Steady-state latency is **~80 ms from save to queryable** on a typical project.
9
+
10
+ This is what makes "session continuity" actually work: by the time you ask `find_symbol` after a save, the new symbol is already in the graph.
11
+
12
+ ## Steps
13
+
14
+ ### 1. Confirm the repo is indexed
15
+
16
+ ```
17
+ mcp__memtrace__list_indexed_repositories
18
+ ```
19
+
20
+ If the repo isn't there, run `index_directory` first. The watcher requires an existing repo_id — it never bootstraps from scratch.
21
+
22
+ ### 2. Start watching
23
+
24
+ ```
25
+ mcp__memtrace__watch_directory(
26
+ path: "/abs/path/to/repo"
27
+ )
28
+ ```
29
+
30
+ The tool registers a `notify` watcher on the directory tree, debounces save bursts (so a `:wq` that touches a swap file doesn't trigger twice), and routes deltas through the indexer's incremental fast-path. Returns immediately — watching runs in the background.
31
+
32
+ ### 3. Confirm it's live
33
+
34
+ ```
35
+ mcp__memtrace__list_watched_paths
36
+ ```
37
+
38
+ Each entry shows the watched root, the bound repo_id, and the last delta's `persist_ms`.
39
+
40
+ ### 4. Edit normally — Memtrace catches up
41
+
42
+ After every save the watcher emits a `labels_updated` WebSocket event:
43
+
44
+ ```json
45
+ {
46
+ "event": "labels_updated",
47
+ "repo_id": "demo",
48
+ "nodes_changed": 12,
49
+ "persist_ms": 78,
50
+ "timestamp": "2026-04-27T10:42:13Z"
51
+ }
52
+ ```
53
+
54
+ Dashboards and IDE plugins subscribe to this on `/ws` and refresh themselves. As an agent you don't have to listen — your next `find_symbol` / `find_code` / `get_symbol_context` call will see the new state automatically.
55
+
56
+ ### 5. Stop watching
57
+
58
+ ```
59
+ mcp__memtrace__unwatch_directory(path: "/abs/path/to/repo")
60
+ ```
61
+
62
+ Idempotent — unwatching an already-unwatched path is a no-op.
63
+
64
+ ## When to Use
65
+
66
+ - **Long sessions on the same repo** — keeps `get_symbol_context` accurate without rerunning `index_directory`
67
+ - **Pair programming with an IDE plugin** — the dashboard's WebSocket subscription auto-refreshes panels
68
+ - **Demo / live coding** — every save reflects in the graph within 80–150 ms
69
+ - **Long-running agents** — instead of polling `index_directory`, the watcher pushes deltas
70
+
71
+ ## When NOT to Use
72
+
73
+ - **One-shot batch edits** — running `index_directory --incremental` at the end is cheaper than spinning up a watcher
74
+ - **Generated / build output trees** — exclude paths under `target/`, `dist/`, `node_modules/` (the watcher honours common ignore patterns but a noisy build can still saturate the debounce queue)
75
+ - **CI / containerised runs** — file events are unreliable across container boundaries; index explicitly instead
76
+
77
+ ## Latency Expectations
78
+
79
+ | Operation | Typical wall time |
80
+ |---|---|
81
+ | File save → watcher fires | < 5 ms |
82
+ | Debounce window | 50 ms |
83
+ | Incremental parse + delta persist | ~80 ms |
84
+ | `labels_updated` broadcast | < 1 ms after persist |
85
+ | Total: save → queryable | ~80–150 ms |
86
+
87
+ If you see `persist_ms` consistently above 500 ms, the saved files are larger than expected (e.g., generated bundles) — narrow the watch root or add ignore patterns.
88
+
89
+ ## Common Mistakes
90
+
91
+ | Mistake | Reality |
92
+ |---|---|
93
+ | Calling `watch_directory` on an unindexed repo | Returns an error — run `index_directory` first |
94
+ | Watching `node_modules/` or `target/` | Saturates the watcher with build noise — point at the source root only |
95
+ | Polling `find_symbol` every second to "wait" for indexing | Subscribe to the `labels_updated` WS event, or just call once after the save — the delta is already there |
96
+ | Forgetting to `unwatch_directory` between sessions | Watchers are per-process; restarting `memtrace start` wipes them, but for hosted instances unwatching cleanly avoids leaks |
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: memtrace-episode-replay
3
+ description: "Always use to replay source-code evolution, understand why code looks this way, inspect implementation attempts, reversions, past reasoning, or abandoned approaches across commits and working-tree episodes. Do not use git log, git diff, Grep, or manual history reconstruction; Memtrace has episodic symbol replay."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ 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.
9
+
10
+ **Git shows A→B. Episode replay shows every step in between.**
11
+
12
+ This is the only tool that can answer: "why does this code look like this?" without relying on commit messages or comments.
13
+
14
+ ## Steps
15
+
16
+ ### 1. Identify the symbol and time window
17
+
18
+ Use `find_symbol` to get the exact symbol name if needed. Determine the window:
19
+ - `from` — when to start (e.g. a few days before a confusing commit)
20
+ - `to` — when to end (usually the commit timestamp or now)
21
+
22
+ If you don't know the window, call `get_timeline` first to find when the symbol changed.
23
+
24
+ ### 2. Call `get_episode_replay`
25
+
26
+ ```
27
+ get_episode_replay(
28
+ repo_id: "...",
29
+ symbol: "execute",
30
+ from: "2026-04-10T00:00:00Z",
31
+ to: "2026-04-13T00:00:00Z",
32
+ include_working_tree: true, // false = commits only
33
+ compress: true // collapse identical-hash runs
34
+ )
35
+ ```
36
+
37
+ ### 3. Read the narrative_hint sequence
38
+
39
+ Each episode has a `narrative_hint` — derived automatically from AST hash patterns:
40
+
41
+ | Hint | What it means |
42
+ |---|---|
43
+ | `committed` | A real git commit — the "public record" checkpoint |
44
+ | `pre_commit_finalization` | Last working_tree save before a commit — the final draft |
45
+ | `iterative_refinement` | 3+ consecutive working_tree saves — active development in progress |
46
+ | `attempted_and_reverted` | Hash returned to a prior state — something was tried and backed out |
47
+ | `no_change` | File was saved but this symbol didn't change |
48
+ | `working_tree_save` | A single file save with structural changes |
49
+
50
+ ### 4. Reconstruct the implementation story
51
+
52
+ Read the sequence like a narrative:
53
+
54
+ ```
55
+ committed ← "here's where we started"
56
+ working_tree_save ← "first attempt"
57
+ iterative_refinement ← "refining the approach"
58
+ attempted_and_reverted ← "tried X, it was wrong, backed out"
59
+ pre_commit_finalization← "final version before commit"
60
+ committed ← "here's what shipped"
61
+ ```
62
+
63
+ The gap between `committed` entries is the implementation story.
64
+
65
+ ### 5. Identify what to act on
66
+
67
+ | Pattern | Implication |
68
+ |---|---|
69
+ | `attempted_and_reverted` appears | There was a tried-and-abandoned approach — understand why before trying similar |
70
+ | Multiple `iterative_refinement` clusters | The author was unsure — this area may need extra care |
71
+ | No working_tree episodes (commits only) | Code was written elsewhere or pasted in — less implementation history available |
72
+ | Very short episode sequence | Straightforward change — low implementation complexity |
73
+
74
+ ## When to Use
75
+
76
+ - **Before modifying unfamiliar code** — understand the intent, not just the current state
77
+ - **Post-session debugging** — replay what was tried during a broken session
78
+ - **Code review** — understand the reasoning behind non-obvious implementations
79
+ - **Avoiding dead ends** — check if the approach you're about to try was already attempted and reverted
80
+
81
+ ## Compression
82
+
83
+ 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.
84
+
85
+ With `compress: false`, every single save is shown — useful when you want to see exact timing between saves.
86
+
87
+ ## Common Mistakes
88
+
89
+ | Mistake | Reality |
90
+ |---------|---------|
91
+ | Only reading the final committed code | The commit shows *what*, the episode replay shows *why* — always check both for unfamiliar code |
92
+ | Ignoring `attempted_and_reverted` hints | These are the most valuable entries — they represent knowledge about what doesn't work |
93
+ | 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 |
94
+ | Large windows with compress off | Very long histories produce noise; use `compress: true` unless you need exact save-by-save granularity |
@@ -0,0 +1,128 @@
1
+ ---
2
+ name: memtrace-evolution
3
+ description: "Always use for source-code change history, recent modifications, what changed since a date, symbol timeline, evolution, unexpected changes, or incident timeline questions. Do not use git log, git diff, Grep, or manual file search to reconstruct history; Memtrace has symbol-level temporal memory."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Multi-mode temporal analysis engine that answers "what changed and why should I care?" across arbitrary time windows. Uses Structural Significance Budgeting (SSB) to surface the most important changes without overwhelming you with noise.
9
+
10
+ This is memtrace's most powerful analytical tool. It implements six distinct scoring algorithms — choose the right one based on what the user needs.
11
+
12
+ ## Query Modes — Choose the Right Algorithm
13
+
14
+ | Mode | Algorithm | Best For |
15
+ |------|-----------|----------|
16
+ | `compound` | Rank-fusion: 0.50×impact + 0.35×novel + 0.15×recent | **Default.** General-purpose "what changed?" — use when unsure |
17
+ | `impact` | Structural Significance: `sig(n) = in_degree^0.7 × (1 + out_degree)^0.3` | "What broke?" — finds changes with the largest blast radius |
18
+ | `novel` | Change Surprise Index: `surprise(n) = (1 + in_degree) / (1 + change_freq_90d)` | "What's unexpected?" — anomaly detection for rarely-changing code |
19
+ | `recent` | Temporal Proximity: `impact × exp(−0.5 × Δhours)` | "What changed near the incident?" — time-weighted for root cause |
20
+ | `directional` | Asymmetric scoring (added→out_degree, removed→in_degree, modified→impact) | "What was added vs removed?" — structural change direction |
21
+ | `overview` | Fast module-level rollup only | Quick summary — no per-symbol scoring, just module counts |
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. Determine the time window
29
+
30
+ Ask the user or infer:
31
+ - `from` — ISO-8601 start timestamp (required)
32
+ - `to` — ISO-8601 end timestamp (defaults to now)
33
+ - `repo_id` — scope to a repo (call `list_indexed_repositories` if unknown)
34
+
35
+ ### 2. Choose the mode
36
+
37
+ **Decision tree:**
38
+
39
+ ```
40
+ User wants to know...
41
+ ├── "what changed?" → compound (default)
42
+ ├── "what could have broken?" → impact
43
+ ├── "anything unexpected?" → novel
44
+ ├── "what changed near X?" → recent (set to to incident time)
45
+ ├── "what was added/removed?" → directional
46
+ └── "quick summary?" → overview
47
+ ```
48
+
49
+ ### 3. Execute the query
50
+
51
+ Use the `get_evolution` MCP tool with:
52
+ - `repo_id` — required
53
+ - `from` / `to` — the time window
54
+ - `mode` — one of: compound, impact, novel, recent, directional, overview
55
+
56
+ ### 4. Interpret results
57
+
58
+ The response contains:
59
+
60
+ - **`added[]`** — new symbols that appeared in the time window
61
+ - **`removed[]`** — symbols that were deleted
62
+ - **`modified[]`** — symbols that changed
63
+ - **`by_module[]`** — module-level rollup (NEVER truncated — always shows all modules)
64
+ - **`significance_coverage`** — fraction of total significance captured (target: ≥0.80)
65
+ - **`budget_exhausted`** — if true, there were more significant changes than the budget allowed
66
+
67
+ Each symbol includes: `name`, `kind`, `file_path`, `scope_path`, `in_degree`, `out_degree`, and all four scores (`impact`, `novel`, `recent`, `compound`).
68
+
69
+ ### 5. Drill deeper
70
+
71
+ - **For a single symbol's full history:** Use `get_timeline` with the symbol name
72
+ - **For diff-based change scope:** Use `detect_changes` when you have a specific diff/patch
73
+ - **For blast radius of a specific change:** Use `get_impact` on high-scoring symbols
74
+
75
+ ## Scoring Algorithms — Detailed Reference
76
+
77
+ ### Impact Score (Structural Significance Budgeting)
78
+ ```
79
+ sig(n) = in_degree^0.7 × (1 + out_degree)^0.3
80
+ ```
81
+ - Heavily weights callers (in_degree) — symbols called by many others have high blast radius
82
+ - Mild boost for outbound complexity (out_degree) — complex functions that changed are notable
83
+ - SSB selects the minimum set covering ≥80% of total significance mass
84
+
85
+ ### Novelty Score (Change Surprise Index)
86
+ ```
87
+ surprise(n) = (1 + in_degree) / (1 + change_freq_90d)
88
+ ```
89
+ - High in_degree + low change frequency = **maximum surprise**
90
+ - A core utility that hasn't changed in 90 days suddenly changing → likely worth investigating
91
+ - Low in_degree + high frequency = routine churn, deprioritized
92
+
93
+ ### Recent Score (Temporal Proximity Weighting)
94
+ ```
95
+ recent(n) = impact(n) × exp(−0.5 × |Δhours to reference|)
96
+ ```
97
+ - Exponential decay from the reference timestamp (the `to` parameter)
98
+ - Changes close to an incident get amplified; older changes fade
99
+ - Best for incident timelines: set `to` to the incident timestamp
100
+
101
+ ### Compound Score (Rank Fusion)
102
+ ```
103
+ compound = 0.50×rank(impact) + 0.35×rank(novel) + 0.15×rank(recent)
104
+ ```
105
+ - Rank-based fusion avoids scale sensitivity between different score types
106
+ - Impact-dominant but boosted by novelty and recency
107
+ - Best default when you don't have a specific hypothesis
108
+
109
+ ## Auto-overview Safety
110
+
111
+ If a time window produces more than 500 candidates and mode is not `overview`, the query **automatically downgrades to overview mode** and returns `auto_overview: true`. This prevents timeouts on wide windows. When you see `auto_overview: true`:
112
+ - Narrow the window, OR
113
+ - Switch to `get_changes_since` (which handles this automatically), OR
114
+ - Use the `by_module` rollup to identify the specific area and query a tighter window
115
+
116
+ ## Session-Aware Alternative
117
+
118
+ If you're resuming work after a break and don't know the right `from` timestamp, use `get_changes_since` instead — it accepts a `last_episode_id` anchor and never requires timestamp guessing.
119
+
120
+ ## Common Mistakes
121
+
122
+ | Mistake | Reality |
123
+ |---------|---------|
124
+ | Using `overview` when user needs details | Overview only gives module-level counts — use `compound` for symbol-level |
125
+ | Ignoring `budget_exhausted` flag | If true, there are more significant changes beyond what was returned — narrow the time window or use module rollup |
126
+ | Not checking `by_module` first | Module rollup is never truncated — scan it to identify which areas changed before diving into symbol-level |
127
+ | Using `recent` without setting `to` | The `to` timestamp is the reference point for proximity weighting — set it to the incident/event time |
128
+ | Guessing timestamps when resuming work | Use `get_changes_since` with a stored `session_anchor` instead — exact episode boundary, no guessing |