memtrace 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/memtrace.js +43 -15
- package/hooks/posttool-mcp-telemetry.sh +0 -0
- package/hooks/userprompt-claude.sh +0 -0
- package/installer/dist/commands/doctor.js +11 -0
- package/installer/dist/index.js +1 -1
- package/installer/dist/rail-install.js +4 -15
- package/installer/dist/transformers/codex.js +7 -80
- package/installer/dist/transformers/index.d.ts +2 -1
- package/installer/dist/transformers/index.js +3 -1
- package/installer/dist/transformers/opencode.js +5 -21
- package/installer/dist/transformers/rail-hooks.d.ts +13 -0
- package/installer/dist/transformers/rail-hooks.js +50 -0
- package/installer/dist/transformers/types.d.ts +1 -1
- package/installer/dist/transformers/warp.d.ts +4 -0
- package/installer/dist/transformers/warp.js +83 -0
- package/installer/package.json +1 -1
- package/installer/skills/commands/memtrace-decision-recall.md +7 -4
- package/installer/skills/commands/memtrace-docs-ask.md +99 -0
- package/installer/skills/commands/memtrace-docs-read.md +91 -0
- package/installer/skills/commands/memtrace-docs-search.md +94 -0
- package/installer/skills/commands/memtrace-preflight.md +17 -1
- package/installer/skills/commands/memtrace-provenance.md +7 -4
- package/installer/skills/workflows/memtrace-change-impact-analysis.md +23 -7
- package/installer/skills/workflows/memtrace-decision-memory.md +16 -12
- package/installer/skills/workflows/memtrace-docs.md +129 -0
- package/installer/skills/workflows/memtrace-first.md +25 -3
- package/installer/skills/workflows/memtrace-refactoring-guide.md +25 -9
- package/lib/child-supervisor.js +104 -0
- package/lib/install-consent.js +1 -1
- package/package.json +7 -7
- package/skills/commands/memtrace-decision-recall.md +7 -4
- package/skills/commands/memtrace-docs-ask.md +99 -0
- package/skills/commands/memtrace-docs-read.md +91 -0
- package/skills/commands/memtrace-docs-search.md +94 -0
- package/skills/commands/memtrace-preflight.md +17 -1
- package/skills/commands/memtrace-provenance.md +7 -4
- package/skills/workflows/memtrace-change-impact-analysis.md +23 -7
- package/skills/workflows/memtrace-decision-memory.md +16 -12
- package/skills/workflows/memtrace-docs.md +129 -0
- package/skills/workflows/memtrace-first.md +25 -3
- package/skills/workflows/memtrace-refactoring-guide.md +25 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-first
|
|
3
|
-
description: "Route code discovery, debugging, flow tracing,
|
|
3
|
+
description: "Route code discovery, debugging, flow tracing, how-code-works questions, and pre-edit rationale checks in indexed source-code repos to Memtrace graph plus Cortex decision tools. Use first before searching/reading code, and before editing, refactoring, deleting, or re-picking an approach that may have a recorded decision, ban, convention, or contract. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results are not permission to grep; diagnose/reindex with Memtrace."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- mcp__memtrace__list_indexed_repositories
|
|
6
6
|
- mcp__memtrace__index_directory
|
|
@@ -23,6 +23,10 @@ allowed-tools:
|
|
|
23
23
|
- mcp__memtrace__get_style_fingerprint
|
|
24
24
|
- mcp__memtrace__find_most_complex_functions
|
|
25
25
|
- mcp__memtrace__get_source_window
|
|
26
|
+
- mcp__memtrace__recall_decision
|
|
27
|
+
- mcp__memtrace__verify_intent
|
|
28
|
+
- mcp__memtrace__why_is_this_here
|
|
29
|
+
- mcp__memtrace__governing_contracts
|
|
26
30
|
- Read
|
|
27
31
|
- Grep
|
|
28
32
|
- Glob
|
|
@@ -44,6 +48,12 @@ ONLY when you're about to edit or quote, and read only the bounded span
|
|
|
44
48
|
returned by Memtrace (start_line .. end_line + small context). Do not
|
|
45
49
|
Grep/Glob/Find to "locate" anything already in the graph, and do not read
|
|
46
50
|
the whole file when Memtrace has given you exact lines.
|
|
51
|
+
|
|
52
|
+
BEFORE you edit/refactor/delete existing code or choose/re-pick a pattern,
|
|
53
|
+
call Cortex decision memory: recall_decision for the symbol/subsystem/approach,
|
|
54
|
+
and use provenance/contracts when a symbol_id is available. Use Memtrace's graph
|
|
55
|
+
tools for structure and blast radius; use Cortex for rationale, bans, and
|
|
56
|
+
contracts.
|
|
47
57
|
```
|
|
48
58
|
|
|
49
59
|
Memtrace is the **memory layer** of the codebase, not a search engine that returns code. It has the full knowledge graph — every symbol, call, import, community, process, and API — with a time dimension. The point is to navigate that graph: who calls this, what's the blast radius, when did this change, what community is it part of. File tools are blind to all of that.
|
|
@@ -103,6 +113,8 @@ For everything else inside the indexed repo, memtrace is the right tool.
|
|
|
103
113
|
| "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
|
|
104
114
|
| "Where's that error message `'connection refused for tenant'`?" | `find_code(query="connection refused for tenant")` → semantic catches it. |
|
|
105
115
|
| "What breaks if I change `foo`?" | `get_impact(repo_id, target="foo")` → blast radius. |
|
|
116
|
+
| "Should I change/delete/refactor `foo`?" | `find_symbol`/`get_symbol_context` → `recall_decision("foo / subsystem / approach")`; if a symbol id is available, `why_is_this_here` + `governing_contracts`; then `get_impact`. |
|
|
117
|
+
| "Can I use/switch to pattern or library X?" | `recall_decision("X")` FIRST; bans and conventions are decisions. Verify a matching decision with `verify_intent(decision_id)` before relying on it. |
|
|
106
118
|
| "What changed in `auth.ts` last week?" | `get_evolution(repo_id, from="7d ago", mode="recent", file_path="auth.ts")`. |
|
|
107
119
|
| "List all `*.test.ts` files." | `Glob` (file inventory, not symbol search). |
|
|
108
120
|
| "Find this string in my `.env`." | `Grep` (non-source artifact). |
|
|
@@ -160,6 +172,8 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
|
|
|
160
172
|
| What files change together? | `get_cochange_context` |
|
|
161
173
|
| Architecture overview | `list_communities` + `find_central_symbols` |
|
|
162
174
|
| About to edit / quote — need exact lines | Bounded `Read(file, offset=start_line, limit=N)` (preferred), or `get_source_window` for path-resolution parity |
|
|
175
|
+
| About to edit/refactor/delete existing code | `recall_decision` for the intent + `why_is_this_here`/`governing_contracts` when a symbol id is available, then `get_impact` |
|
|
176
|
+
| About to choose or replace a library/pattern/architecture | `recall_decision` first; use `verify_intent` on any matching decision before contradicting it |
|
|
163
177
|
| About to choose between competing idioms (ternary vs if-else, arrow vs fn-decl, const vs let, await vs `.then`) | `get_style_fingerprint(repo_id, file_path)` — empirical codebase norm; see `memtrace-style-fingerprint` workflow |
|
|
164
178
|
|
|
165
179
|
## Standard Workflows
|
|
@@ -185,8 +199,10 @@ If not indexed → offer to index with `mcp__memtrace__index_directory`, then fo
|
|
|
185
199
|
### Before any code modification
|
|
186
200
|
1. `find_symbol` → confirm you have the right target
|
|
187
201
|
2. `get_symbol_context` → understand full context
|
|
188
|
-
3. `
|
|
189
|
-
4. `
|
|
202
|
+
3. `recall_decision("<symbol/subsystem/approach>")` → surface recorded choices, bans, and conventions before deciding what to do
|
|
203
|
+
4. If a `symbol_id` is available, `why_is_this_here(symbol_id)` + `governing_contracts(symbol_id)` before deleting, rewriting, or "cleaning up" odd code
|
|
204
|
+
5. `get_impact` → know blast radius before touching anything
|
|
205
|
+
6. `get_style_fingerprint(repo_id, file_path=<file>)` → match the codebase's empirical idiom (ternary vs if-else, arrow vs fn-decl, etc.) — see `memtrace-style-fingerprint` workflow for the full decision rule
|
|
190
206
|
|
|
191
207
|
## Red Flags — STOP, Use Memtrace Instead
|
|
192
208
|
|
|
@@ -197,6 +213,9 @@ You are violating this skill if you think:
|
|
|
197
213
|
| "Let me grep for this" | `find_code` or `find_symbol` is faster and structurally aware |
|
|
198
214
|
| "Let me glob for the file" | `find_symbol` returns exact location with context |
|
|
199
215
|
| "Let me read the whole file" | `get_symbol_context` for the WHY (callers/callees/community); a bounded source read at start_line..end_line for the WHAT |
|
|
216
|
+
| "I know why this is written this way" | Check Cortex first. Use `recall_decision`; use `why_is_this_here`/`governing_contracts` when you have a symbol id. |
|
|
217
|
+
| "This looks unused/weird; I'll remove it" | `why_is_this_here` + `governing_contracts` first, then blast radius. CannotProve is unknown, not permission. |
|
|
218
|
+
| "I'll just switch to library/pattern X" | `recall_decision("X")` first — you may be reintroducing a banned approach. |
|
|
200
219
|
| "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
|
|
201
220
|
| "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
|
|
202
221
|
| "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
|
|
@@ -210,6 +229,7 @@ Use Grep/Glob/Read ONLY for:
|
|
|
210
229
|
- Non-source files or paths outside every indexed source repo
|
|
211
230
|
- Files that are config, data, or docs (not source code symbols)
|
|
212
231
|
- Repos or paths confirmed outside every Memtrace indexed root
|
|
232
|
+
- **Official Memtrace product documentation** — use `memtrace-docs` (`ask_docs` / `search_docs` / `read_doc`), not file tools or web search
|
|
213
233
|
|
|
214
234
|
For source-code spans already located by Memtrace, use a **bounded** read —
|
|
215
235
|
your harness's `Read(file, offset, limit)` with the returned `start_line` /
|
|
@@ -227,9 +247,11 @@ When this skill applies, it overrides default file-search behavior. Use the spec
|
|
|
227
247
|
- Discovery → `memtrace-search`
|
|
228
248
|
- Impact analysis → `memtrace-impact`
|
|
229
249
|
- Temporal / change analysis → `memtrace-evolution`
|
|
250
|
+
- Rationale / prior decisions / bans / contracts → `memtrace-decision-memory`
|
|
230
251
|
- Incident investigation → `memtrace-incident-investigation`
|
|
231
252
|
- Architecture overview → `memtrace-codebase-exploration`
|
|
232
253
|
- Refactoring → `memtrace-refactoring-guide`
|
|
254
|
+
- Memtrace **product docs** (install, CLI, MCP, enterprise) → `memtrace-docs`
|
|
233
255
|
|
|
234
256
|
## Output
|
|
235
257
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-refactoring-guide
|
|
3
|
-
description: "Build a phased, risk-scored refactoring plan from Memtrace complexity, dead-code, bridge, and
|
|
3
|
+
description: "Build a phased, risk-scored refactoring plan from Memtrace complexity, dead-code, bridge, impact analysis, and Cortex decision-memory constraints. Use when the user wants to refactor source code, reduce complexity, clean technical debt, delete dead code, split large functions, extract modules, reorganize code, or choose refactoring priorities. Do not plan refactors from grep/manual reference search alone; check graph impact and decision rationale/bans/contracts before changing existing code."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- mcp__memtrace__find_most_complex_functions
|
|
6
6
|
- mcp__memtrace__find_dead_code
|
|
@@ -10,6 +10,10 @@ allowed-tools:
|
|
|
10
10
|
- mcp__memtrace__get_symbol_context
|
|
11
11
|
- mcp__memtrace__analyze_relationships
|
|
12
12
|
- mcp__memtrace__list_communities
|
|
13
|
+
- mcp__memtrace__recall_decision
|
|
14
|
+
- mcp__memtrace__why_is_this_here
|
|
15
|
+
- mcp__memtrace__governing_contracts
|
|
16
|
+
- mcp__memtrace__verify_intent
|
|
13
17
|
metadata:
|
|
14
18
|
author: "Syncable <support@syncable.dev>"
|
|
15
19
|
version: "1.0.0"
|
|
@@ -19,7 +23,7 @@ user-invocable: true
|
|
|
19
23
|
|
|
20
24
|
## Overview
|
|
21
25
|
|
|
22
|
-
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,
|
|
26
|
+
Guided refactoring workflow — identifies refactoring candidates using structural analysis, scores them by risk and priority, checks Cortex decision memory for rationale/bans/contracts, and produces a phased refactoring plan. Combines complexity metrics, dead code detection, bridge analysis, temporal evolution, and decision memory to prioritize what to refactor first and how to do it safely.
|
|
23
27
|
|
|
24
28
|
## Steps
|
|
25
29
|
|
|
@@ -63,7 +67,17 @@ Also call `get_symbol_context` to check:
|
|
|
63
67
|
- How many processes does this symbol participate in? (More = more testing needed)
|
|
64
68
|
- Is it part of a cross-repo API? (If yes, coordinate with consumers)
|
|
65
69
|
|
|
66
|
-
### 4.
|
|
70
|
+
### 4. Check decision memory before refactoring/removing
|
|
71
|
+
|
|
72
|
+
For each top candidate, call `recall_decision("<symbol/subsystem/refactor intent>")`.
|
|
73
|
+
If you have a numeric `symbol_id`, call `why_is_this_here(symbol_id)` and
|
|
74
|
+
`governing_contracts(symbol_id)`.
|
|
75
|
+
|
|
76
|
+
- A matching held decision/ban can veto or reshape the refactor.
|
|
77
|
+
- Contracts become acceptance criteria for the new design.
|
|
78
|
+
- CannotProve is unknown, not permission to delete.
|
|
79
|
+
|
|
80
|
+
### 5. Understand the neighbourhood
|
|
67
81
|
|
|
68
82
|
For each refactoring target, call `analyze_relationships`:
|
|
69
83
|
- `find_callees` — what does it depend on? These become candidates for extraction
|
|
@@ -72,13 +86,13 @@ For each refactoring target, call `analyze_relationships`:
|
|
|
72
86
|
|
|
73
87
|
Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bundled at the memtrace-skills plugin root).
|
|
74
88
|
|
|
75
|
-
###
|
|
89
|
+
### 6. Check community boundaries
|
|
76
90
|
|
|
77
91
|
Call `list_communities` and check: does the refactoring target sit at a community boundary?
|
|
78
92
|
- If yes, the refactoring may involve splitting responsibilities across modules
|
|
79
93
|
- If it belongs clearly to one community, the refactoring is more contained
|
|
80
94
|
|
|
81
|
-
###
|
|
95
|
+
### 7. Produce the refactoring plan
|
|
82
96
|
|
|
83
97
|
Synthesize into a phased plan:
|
|
84
98
|
|
|
@@ -98,8 +112,9 @@ For each item, include:
|
|
|
98
112
|
1. **Target** — function/class name, file, current complexity score
|
|
99
113
|
2. **Why** — complexity + volatility + blast radius rationale
|
|
100
114
|
3. **How** — specific refactoring approach (extract method, split class, introduce interface)
|
|
101
|
-
4. **
|
|
102
|
-
5. **
|
|
115
|
+
4. **Decision Memory** — relevant Cortex decisions/bans/contracts, or CannotProve as unknown
|
|
116
|
+
5. **Risk** — impact analysis rating + affected processes
|
|
117
|
+
6. **Test Plan** — which callers/processes to verify
|
|
103
118
|
|
|
104
119
|
## Decision Points
|
|
105
120
|
|
|
@@ -107,9 +122,10 @@ For each item, include:
|
|
|
107
122
|
|-----------|--------|
|
|
108
123
|
| Complex + volatile + high blast radius | Highest priority — but plan carefully; incremental approach |
|
|
109
124
|
| Complex + stable + low blast radius | Can wait; refactor when you're already touching nearby code |
|
|
110
|
-
| Dead code with zero callers |
|
|
125
|
+
| Dead code with zero callers | Run Cortex provenance/recall first; zero callers is not proof that no decision/contract keeps it |
|
|
111
126
|
| Bridge symbol with many dependents | Extract interface first, then refactor implementation behind it |
|
|
112
127
|
| Symbol in cross-repo API | Coordinate with consumers; backward-compatible changes only |
|
|
128
|
+
| Cortex returns a held ban/contract | Preserve it or ask before overriding it |
|
|
113
129
|
|
|
114
130
|
## Output
|
|
115
131
|
|
|
@@ -123,7 +139,7 @@ A phased plan (Phases 1–3). One worked entry:
|
|
|
123
139
|
| Risk | High — upstream spans 3 processes incl. `checkout_flow`; incremental migration |
|
|
124
140
|
|
|
125
141
|
Acceptance criteria:
|
|
126
|
-
- Every plan item cites complexity, volatility,
|
|
142
|
+
- Every plan item cites complexity, volatility, blast radius, and decision-memory status — no gut-feel picks.
|
|
127
143
|
- High/Critical-risk items include a test plan naming affected callers/processes.
|
|
128
144
|
|
|
129
145
|
## Common Mistakes
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Signal-forwarding supervisor for the native memtrace binary.
|
|
4
|
+
//
|
|
5
|
+
// The npm shim (bin/memtrace.js) spawns the Rust `memtrace` binary as a
|
|
6
|
+
// child. When the shim itself receives a signal — from a supervisor
|
|
7
|
+
// (systemd, npm, Warp's agent runner, CI), a terminal close (SIGHUP), or a
|
|
8
|
+
// Ctrl-C the OS delivers to the shim PID rather than the whole foreground
|
|
9
|
+
// process group — the child MUST receive the same signal so a long-running
|
|
10
|
+
// `memtrace start` daemon shuts down cleanly instead of being orphaned
|
|
11
|
+
// (still holding port 3030, the MemDB lock, and the embed model).
|
|
12
|
+
//
|
|
13
|
+
// Pre-fix, the `mcp` branch spawned the child async but forwarded NO
|
|
14
|
+
// signals, and the `else` branch that serves `start` used `spawnSync`,
|
|
15
|
+
// which can't forward at all. Both orphaned the daemon when the shim was
|
|
16
|
+
// killed by anything other than a foreground-process-group Ctrl-C. The next
|
|
17
|
+
// `memtrace start` then hit "already running" / port-in-use — the root
|
|
18
|
+
// cause of the "`npx memtrace@latest start` isn't working" reports under
|
|
19
|
+
// npx / Warp / supervisors.
|
|
20
|
+
//
|
|
21
|
+
// Contract this module pins:
|
|
22
|
+
// * For every signal in the forwarded set, install ONE listener on
|
|
23
|
+
// `process` that calls `child.kill(signal)`.
|
|
24
|
+
// * Never throw — a signal handler that throws would terminate the shim
|
|
25
|
+
// with an uncaught exception AND orphan the child we're trying to
|
|
26
|
+
// signal. Swallow; let the child's own exit drive the shim's exit.
|
|
27
|
+
// * Stop forwarding once the child exits (so a reused process object
|
|
28
|
+
// doesn't leak listeners / kill a reaped PID).
|
|
29
|
+
// * Idempotent WITHIN one call — a signal listed twice in the `signals`
|
|
30
|
+
// array registers a single listener. Cross-call dedup is deliberately
|
|
31
|
+
// NOT promised (one forwarder per child is the contract the bin relies
|
|
32
|
+
// on; a shared global listener could not disambiguate which child to
|
|
33
|
+
// kill).
|
|
34
|
+
// * Do NOT forward memtrace-internal signals (SIGUSR1 embed-breaker
|
|
35
|
+
// reset, SIGUSR2, SIGPIPE) — the child handles those on its own PID.
|
|
36
|
+
//
|
|
37
|
+
// The only side effect is registering/deregistering listeners on the
|
|
38
|
+
// `process` and `child` objects you pass in. Both are injectable so the
|
|
39
|
+
// unit + property tests drive fake EventEmitters without real signals.
|
|
40
|
+
|
|
41
|
+
const DEFAULT_SIGNALS = Object.freeze(["SIGINT", "SIGTERM", "SIGHUP"]);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Forward a set of signals from `process` (or an injectable stand-in) to a
|
|
45
|
+
* spawned child. Returns a handle with a `detach()` that removes every
|
|
46
|
+
* listener. Auto-detaches on the child's `exit` event so a late signal on a
|
|
47
|
+
* long-lived shim never reaches a reaped PID.
|
|
48
|
+
*
|
|
49
|
+
* @param {object} child Node ChildProcess (or EventEmitter fake
|
|
50
|
+
* with `.pid`, `.kill(signal)`, `.on`/`.off`).
|
|
51
|
+
* @param {string[]} [signals] Signals to forward. Defaults to
|
|
52
|
+
* DEFAULT_SIGNALS (SIGINT, SIGTERM, SIGHUP).
|
|
53
|
+
* @param {object} [opts]
|
|
54
|
+
* @param {object} [opts.process] Process-like EventEmitter to listen on.
|
|
55
|
+
* Defaults to the real `process`.
|
|
56
|
+
* @returns {{ detach(): void }}
|
|
57
|
+
*/
|
|
58
|
+
function forwardSignalsTo(child, signals, opts) {
|
|
59
|
+
const sigs = Array.isArray(signals) && signals.length > 0 ? signals : DEFAULT_SIGNALS;
|
|
60
|
+
const proc = (opts && opts.process) || process;
|
|
61
|
+
const handlers = new Map();
|
|
62
|
+
|
|
63
|
+
const install = (sig) => {
|
|
64
|
+
// Idempotent: a second call for an already-installed signal is a
|
|
65
|
+
// no-op, so overlapping installs (e.g. if a future caller wires
|
|
66
|
+
// both the mcp and start branches) never double-fire on one
|
|
67
|
+
// emission.
|
|
68
|
+
if (handlers.has(sig)) return;
|
|
69
|
+
const handler = () => {
|
|
70
|
+
try {
|
|
71
|
+
if (child && typeof child.kill === "function" && child.pid != null) {
|
|
72
|
+
child.kill(sig);
|
|
73
|
+
}
|
|
74
|
+
} catch (_) {
|
|
75
|
+
// A signal handler must never throw — that would orphan the
|
|
76
|
+
// child AND crash the shim with an uncaught exception.
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
handlers.set(sig, handler);
|
|
80
|
+
if (typeof proc.on === "function") proc.on(sig, handler);
|
|
81
|
+
};
|
|
82
|
+
for (const sig of sigs) install(sig);
|
|
83
|
+
|
|
84
|
+
const detach = () => {
|
|
85
|
+
for (const [sig, handler] of handlers) {
|
|
86
|
+
try {
|
|
87
|
+
if (typeof proc.removeListener === "function") proc.removeListener(sig, handler);
|
|
88
|
+
} catch (_) { /* best effort */ }
|
|
89
|
+
}
|
|
90
|
+
handlers.clear();
|
|
91
|
+
try {
|
|
92
|
+
if (typeof child.off === "function") child.off("exit", detach);
|
|
93
|
+
else if (typeof child.removeListener === "function") child.removeListener("exit", detach);
|
|
94
|
+
} catch (_) { /* best effort */ }
|
|
95
|
+
};
|
|
96
|
+
if (typeof child.on === "function") child.on("exit", detach);
|
|
97
|
+
|
|
98
|
+
return { detach };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = {
|
|
102
|
+
forwardSignalsTo,
|
|
103
|
+
DEFAULT_SIGNALS,
|
|
104
|
+
};
|
package/lib/install-consent.js
CHANGED
|
@@ -85,7 +85,7 @@ function buildMutationList({ home, cwd, projectOnly = false, noHooks = false })
|
|
|
85
85
|
{ path: path.join(claude, "plugins", "installed_plugins.json"), change: "plugin registry entry (written by the `claude` CLI when available)" },
|
|
86
86
|
{ path: path.join(home, ".claude.json"), change: "possible memtrace MCP entry (written by `claude mcp add-json --scope user` when the `claude` CLI is available)" },
|
|
87
87
|
{ path: path.join(home, ".memtrace") + path.sep, change: "create memtrace data dir: persisted uninstall.js + install-backup/ (backups + manifest)" },
|
|
88
|
-
{ path: path.join(home, "{.cursor,.codex,.gemini,.codeium,.hermes,.kiro,.copilot,.config/opencode,VS Code user config}"), change: "skills + memtrace MCP registration for other detected agents (same merge-add pattern)" },
|
|
88
|
+
{ path: path.join(home, "{.cursor,.codex,.gemini,.codeium,.hermes,.kiro,.copilot,.warp,.config/opencode,VS Code user config}"), change: "skills + memtrace MCP registration for other detected agents (same merge-add pattern)" },
|
|
89
89
|
);
|
|
90
90
|
return list;
|
|
91
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memtrace",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"description": "Code intelligence graph — MCP server + AI agent skills + visualization UI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"fs-extra": "^11.0.0"
|
|
40
40
|
},
|
|
41
41
|
"optionalDependencies": {
|
|
42
|
-
"@memtrace/darwin-arm64": "0.8.
|
|
43
|
-
"@memtrace/linux-x64": "0.8.
|
|
44
|
-
"@memtrace/linux-arm64": "0.8.
|
|
45
|
-
"@memtrace/win32-x64": "0.8.
|
|
46
|
-
"@memtrace/linux-x64-noavx2": "0.8.
|
|
47
|
-
"@memtrace/win32-x64-noavx2": "0.8.
|
|
42
|
+
"@memtrace/darwin-arm64": "0.8.5",
|
|
43
|
+
"@memtrace/linux-x64": "0.8.5",
|
|
44
|
+
"@memtrace/linux-arm64": "0.8.5",
|
|
45
|
+
"@memtrace/win32-x64": "0.8.5",
|
|
46
|
+
"@memtrace/linux-x64-noavx2": "0.8.5",
|
|
47
|
+
"@memtrace/win32-x64-noavx2": "0.8.5"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=18"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memtrace-decision-recall
|
|
3
|
-
description: "Recall ranked decisions, bans, and conventions from Cortex decision memory by free-text query. Use when the user asks what was decided
|
|
3
|
+
description: "Recall ranked decisions, bans, and conventions from Cortex decision memory by free-text query through the normal Memtrace MCP server. Use when the user asks what was decided/chosen/rejected, whether there is a convention/ban/policy, and before any non-trivial edit/refactor/delete or re-picking a library, pattern, architecture, or subsystem behavior that may already be settled. Do not reconstruct decisions from git log or guesswork. To verify whether a known decision held, use memtrace-intent-verification; for symbol lineage/contracts, use memtrace-provenance."
|
|
4
4
|
allowed-tools:
|
|
5
5
|
- mcp__memtrace__recall_decision
|
|
6
6
|
- mcp__memtrace__verify_intent
|
|
@@ -16,7 +16,8 @@ metadata:
|
|
|
16
16
|
`recall_decision` is the **free-text entry point** to decision memory. Given a query,
|
|
17
17
|
it returns the statistically-ranked set of decisions/conversations that bear on it —
|
|
18
18
|
including **bans** ("never use X", "don't do Y"), which are recorded as decisions.
|
|
19
|
-
Use it before re-litigating a settled choice
|
|
19
|
+
Use it before re-litigating a settled choice, changing existing behavior, or
|
|
20
|
+
contradicting a convention.
|
|
20
21
|
|
|
21
22
|
This is the one decision-memory tool that takes plain text. The ranked decisions it
|
|
22
23
|
returns carry the `decision_id`s the other tools (`verify_intent`, `get_arc`) need.
|
|
@@ -41,7 +42,8 @@ Full parameter spec for every Memtrace tool: `references/mcp-parameters.md` (bun
|
|
|
41
42
|
|
|
42
43
|
`recall_decision(query)` — `query` is free text. Use the noun phrase of the thing in
|
|
43
44
|
question: a library (`"redis vs in-memory cache"`), a pattern (`"error handling
|
|
44
|
-
strategy"`), a subsystem (`"auth tokens"`), or the exact
|
|
45
|
+
strategy"`), a subsystem (`"auth tokens"`), a symbol, or the exact edit/refactor/delete
|
|
46
|
+
you are about to do.
|
|
45
47
|
|
|
46
48
|
### 2. Read the ranked result
|
|
47
49
|
|
|
@@ -71,7 +73,8 @@ require a Decision node and will honestly return CannotProve. See
|
|
|
71
73
|
|
|
72
74
|
| Situation | Action |
|
|
73
75
|
|-----------|--------|
|
|
74
|
-
| About to
|
|
76
|
+
| About to edit/refactor/delete existing code where intent may matter | `recall_decision("<symbol/subsystem/behavior>")` FIRST — you may be crossing a recorded decision, ban, or convention |
|
|
77
|
+
| About to choose or replace a library/pattern/architecture | `recall_decision` FIRST — you may be undoing a deliberate choice or ban |
|
|
75
78
|
| User asks "did we decide X?" / "what's our convention on Y?" | `recall_decision("X" / "Y")` |
|
|
76
79
|
| You suspect a "don't do this" rule exists | `recall_decision` — bans are decisions and will surface |
|
|
77
80
|
| Recall returns a decision you're about to contradict | Surface it to the user verbatim; don't silently override |
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-docs-ask
|
|
3
|
+
description: "Answer questions from official Memtrace documentation only — installation, CLI, MCP tools, fleet, Cortex, enterprise MemDB deploy, skills, configuration. Use when the user asks how Memtrace works or wants a cited explanation. Calls ask_docs on memtrace.io (RAG + guardrails). Do not guess product behavior from training data."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__ask_docs
|
|
6
|
+
- mcp__memtrace__search_docs
|
|
7
|
+
- mcp__memtrace__read_doc
|
|
8
|
+
metadata:
|
|
9
|
+
author: "Syncable <support@syncable.dev>"
|
|
10
|
+
version: "1.0.0"
|
|
11
|
+
category: development
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
`ask_docs` sends the user's question to the hosted docs RAG backend. The server
|
|
17
|
+
retrieves relevant doc chunks, generates an answer **only from that context**, and
|
|
18
|
+
returns citations. Off-topic or ungrounded questions return `refused: true`.
|
|
19
|
+
|
|
20
|
+
This is the **default** tool for "how does Memtrace X work?" questions.
|
|
21
|
+
|
|
22
|
+
Umbrella routing: `memtrace-docs` workflow.
|
|
23
|
+
|
|
24
|
+
## `ask_docs` parameters
|
|
25
|
+
|
|
26
|
+
| Param | Required | Notes |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `question` | yes | Pass the user's question verbatim when possible |
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{ "question": "How do I deploy MemDB with Docker Compose?" }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Response shape
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"ok": true,
|
|
39
|
+
"answer": "…markdown with /docs/… links…",
|
|
40
|
+
"citations": ["enterprise/memdb-deploy", "cli/connect"],
|
|
41
|
+
"refused": false
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Field | Meaning |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `answer` | Grounded response text |
|
|
48
|
+
| `citations` | Doc slugs used as context |
|
|
49
|
+
| `refused` | `true` when no context or injection detected |
|
|
50
|
+
| `refusalReason` | `no_context` or `injection` when refused |
|
|
51
|
+
|
|
52
|
+
## Steps
|
|
53
|
+
|
|
54
|
+
### 1. Ask
|
|
55
|
+
|
|
56
|
+
Use the user's exact wording when it is already a clear question:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{ "question": "What MCP tools are available?" }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Handle refusal
|
|
63
|
+
|
|
64
|
+
If `refused: true` with `no_context`:
|
|
65
|
+
|
|
66
|
+
1. Retry `search_docs` with shorter keywords
|
|
67
|
+
2. `read_doc` on the best slug
|
|
68
|
+
3. If still empty — tell the user docs did not cover it; do not invent
|
|
69
|
+
|
|
70
|
+
### 3. Deepen with read_doc
|
|
71
|
+
|
|
72
|
+
When the user needs exhaustive tables (e.g. all MCP tools):
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{ "slug": "mcp/tools" }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
After `ask_docs` gave a summary.
|
|
79
|
+
|
|
80
|
+
## Example questions → ask_docs
|
|
81
|
+
|
|
82
|
+
| User asks | ask_docs question |
|
|
83
|
+
|---|---|
|
|
84
|
+
| How to install Memtrace? | `"How do I install Memtrace?"` |
|
|
85
|
+
| What is Rail? | `"What is Memtrace Rail and how do I enable it?"` |
|
|
86
|
+
| Enterprise MemDB on Azure | `"How do I deploy self-hosted MemDB on Azure?"` |
|
|
87
|
+
| How to connect local memtrace to shared MemDB | `"How do engineers connect with memtrace connect?"` |
|
|
88
|
+
| What skills exist? | `"What agent skills does Memtrace ship?"` |
|
|
89
|
+
|
|
90
|
+
## Privacy note
|
|
91
|
+
|
|
92
|
+
`ask_docs` sends the **question string** to memtrace.io, which runs retrieval and
|
|
93
|
+
calls a hosted LLM (DeepSeek) server-side. No repo source code is transmitted.
|
|
94
|
+
Do not paste secrets into questions.
|
|
95
|
+
|
|
96
|
+
## Offline behavior
|
|
97
|
+
|
|
98
|
+
`ok: false` → network or API error. Quote the `error` and `hint` fields; suggest
|
|
99
|
+
checking connectivity or `MEMTRACE_DOCS_API_URL`.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-docs-read
|
|
3
|
+
description: "Read the full plain-text body of an official Memtrace docs page by slug. Use when you know the page path (from search_docs, ask_docs citations, or user link) and need complete content — CLI reference, enterprise deploy guide, MCP tool tables. Calls read_doc or memtrace://docs/* resources on memtrace.io."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__read_doc
|
|
6
|
+
- mcp__memtrace__search_docs
|
|
7
|
+
metadata:
|
|
8
|
+
author: "Syncable <support@syncable.dev>"
|
|
9
|
+
version: "1.0.0"
|
|
10
|
+
category: development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
`read_doc` fetches the full rendered text of one docs page. Use after `search_docs`
|
|
16
|
+
or `ask_docs` when excerpts are not enough — long flag tables, deploy runbooks,
|
|
17
|
+
MCP tool inventories.
|
|
18
|
+
|
|
19
|
+
Alternative: MCP resource `memtrace://docs/<slug>` via `read_resource` if your
|
|
20
|
+
client prefers resources over tools.
|
|
21
|
+
|
|
22
|
+
Umbrella routing: `memtrace-docs` workflow.
|
|
23
|
+
|
|
24
|
+
## `read_doc` parameters
|
|
25
|
+
|
|
26
|
+
| Param | Required | Notes |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| `slug` | yes | Path without `/docs/` prefix |
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{ "slug": "enterprise/memdb-deploy" }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Valid examples:
|
|
35
|
+
|
|
36
|
+
- `getting-started`
|
|
37
|
+
- `cli/start`
|
|
38
|
+
- `mcp/tools`
|
|
39
|
+
- `enterprise/connect`
|
|
40
|
+
- `cli/rail` (hidden from sidebar but indexed)
|
|
41
|
+
|
|
42
|
+
## Response shape
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"ok": true,
|
|
47
|
+
"slug": "enterprise/memdb-deploy",
|
|
48
|
+
"title": "Deploy MemDB",
|
|
49
|
+
"body": "…full plain text…"
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Steps
|
|
54
|
+
|
|
55
|
+
### 1. Resolve slug
|
|
56
|
+
|
|
57
|
+
From user URL `https://memtrace.io/docs/cli/connect` → slug `cli/connect`.
|
|
58
|
+
|
|
59
|
+
From `ask_docs` citations array → use slug directly.
|
|
60
|
+
|
|
61
|
+
From unknown topic → `search_docs` first, then `read_doc` on top hit.
|
|
62
|
+
|
|
63
|
+
### 2. Read and summarize
|
|
64
|
+
|
|
65
|
+
Read the `body`, answer the user, keep `/docs/<slug>` links when citing.
|
|
66
|
+
|
|
67
|
+
### 3. Multi-page topics
|
|
68
|
+
|
|
69
|
+
Enterprise deploy + engineer connect:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{ "slug": "enterprise/memdb-deploy" }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
then
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{ "slug": "enterprise/connect" }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## When NOT to use read_doc
|
|
82
|
+
|
|
83
|
+
| Situation | Use instead |
|
|
84
|
+
|---|---|
|
|
85
|
+
| User asked a natural-language question | `ask_docs` first |
|
|
86
|
+
| You don't know which page | `search_docs` first |
|
|
87
|
+
| User's **source code** in their repo | `memtrace-search` / `memtrace-first` |
|
|
88
|
+
|
|
89
|
+
## Offline behavior
|
|
90
|
+
|
|
91
|
+
`ok: false` → docs API unreachable. Do not substitute local README guesses.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: memtrace-docs-search
|
|
3
|
+
description: "Search official Memtrace documentation with semantic full-text search. Use when the user wants to find doc pages, locate a guide, or discover which docs cover a topic (fleet, MCP, CLI, enterprise MemDB, skills). Calls search_docs on memtrace.io. Do not grep local files or web-search for Memtrace product docs."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- mcp__memtrace__search_docs
|
|
6
|
+
- mcp__memtrace__read_doc
|
|
7
|
+
metadata:
|
|
8
|
+
author: "Syncable <support@syncable.dev>"
|
|
9
|
+
version: "1.0.0"
|
|
10
|
+
category: development
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
`search_docs` queries the hosted Memtrace docs corpus (same index as memtrace.io/docs
|
|
16
|
+
and the Ask AI widget). Returns ranked **chunks** — not full pages. Follow with
|
|
17
|
+
`read_doc` when you need the complete page.
|
|
18
|
+
|
|
19
|
+
Umbrella routing: `memtrace-docs` workflow.
|
|
20
|
+
|
|
21
|
+
## Quick Reference
|
|
22
|
+
|
|
23
|
+
| Tool | Best for |
|
|
24
|
+
|------|----------|
|
|
25
|
+
| `search_docs` | Find which doc pages/sections match a topic |
|
|
26
|
+
| `read_doc` | Load full page text after search hits |
|
|
27
|
+
|
|
28
|
+
## `search_docs` parameters
|
|
29
|
+
|
|
30
|
+
| Param | Required | Default | Notes |
|
|
31
|
+
|---|---|---|---|
|
|
32
|
+
| `query` | yes | — | Natural-language search string |
|
|
33
|
+
| `limit` | no | 8 | Max chunks to return |
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{ "query": "deploy MemDB helm azure", "limit": 8 }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Steps
|
|
40
|
+
|
|
41
|
+
### 1. Search
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{ "query": "memtrace rail enable hook", "limit": 6 }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Inspect results
|
|
48
|
+
|
|
49
|
+
Each hit includes:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"slug": "cli/rail",
|
|
54
|
+
"pageTitle": "memtrace rail & route",
|
|
55
|
+
"h2Title": "Subcommands",
|
|
56
|
+
"h2Id": "enable-sub",
|
|
57
|
+
"excerpt": "…",
|
|
58
|
+
"distance": 0.12
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Lower `distance` ≈ better match.
|
|
63
|
+
|
|
64
|
+
### 3. Read full pages when needed
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{ "slug": "cli/rail" }
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Slug uses forward slashes: `enterprise/memdb-deploy`, `mcp/tools`, `getting-started`.
|
|
71
|
+
|
|
72
|
+
## Common slugs
|
|
73
|
+
|
|
74
|
+
| Topic | Slug |
|
|
75
|
+
|---|---|
|
|
76
|
+
| Getting started | `getting-started` |
|
|
77
|
+
| MCP tools list | `mcp/tools` |
|
|
78
|
+
| MCP docs tools | `mcp/docs-tools` |
|
|
79
|
+
| Agent skills | `mcp/skills` |
|
|
80
|
+
| Deploy MemDB (enterprise) | `enterprise/memdb-deploy` |
|
|
81
|
+
| Connect to shared MemDB | `enterprise/connect` |
|
|
82
|
+
| memtrace connect CLI | `cli/connect` |
|
|
83
|
+
| Rail | `cli/rail` |
|
|
84
|
+
|
|
85
|
+
## Offline behavior
|
|
86
|
+
|
|
87
|
+
If `ok: false`, the docs API is unreachable. Report the error; do not fall back to
|
|
88
|
+
hallucinated documentation. Local code-graph tools are unaffected.
|
|
89
|
+
|
|
90
|
+
## Hand off
|
|
91
|
+
|
|
92
|
+
- Natural-language "how do I…" → `memtrace-docs-ask` (`ask_docs`) instead
|
|
93
|
+
- Found the right slug → `memtrace-docs-read` (`read_doc`)
|
|
94
|
+
- User's **source code** → `memtrace-first` / `memtrace-search` (different corpus)
|