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,194 @@
1
+ ---
2
+ name: memtrace-first
3
+ description: "Always use first for indexed source-code repos before searching files, reading code for discovery, debugging, tracing flows, finding implementations, understanding behavior, or answering how code works. Do not use Grep, Glob, rg, find, or manual file browsing for code discovery when Memtrace is indexed. Zero results, missing languages, or partial-looking stats are not permission to grep; diagnose/reindex with Memtrace."
4
+ ---
5
+
6
+ # Memtrace First
7
+
8
+ ## The Iron Law
9
+
10
+ ```
11
+ IF THE REPO IS INDEXED IN MEMTRACE → USE MEMTRACE TOOLS FIRST.
12
+ After a search hit, route to GRAPH tools (get_symbol_context, get_impact,
13
+ analyze_relationships) — that's what Memtrace uniquely provides. Read source
14
+ ONLY when you're about to edit or quote, and read only the bounded span
15
+ returned by Memtrace (start_line .. end_line + small context). Do not
16
+ Grep/Glob/Find to "locate" anything already in the graph, and do not read
17
+ the whole file when Memtrace has given you exact lines.
18
+ ```
19
+
20
+ 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.
21
+
22
+ **97% better accuracy. 83% fewer wasted tokens. No exceptions for what's in the graph.**
23
+
24
+ ## Value Tracking
25
+
26
+ Do not print usage receipts in normal answers. Memtrace records tool usage, graph facts, file references, and estimated context avoided internally. Users can inspect that in the local UI's Value panel.
27
+
28
+ ## What Memtrace actually indexes
29
+
30
+ Memtrace's hybrid search = **BM25 over symbol metadata** (name, signature, file_path, kind) **+ semantic vector search over embedded code bodies** (first ~1500 chars of every Function / Method / Class / Struct / Interface body), fused via Reciprocal Rank Fusion.
31
+
32
+ The semantic side means **string literals, error messages, magic constants, log strings, and any text inside an indexed symbol's body are findable through `find_code`**. The body got embedded; the embedding catches it. You do NOT need `Grep` to hunt for `STRIPE_KEY_FOO_BAR` if it lives inside a function in your indexed codebase.
33
+
34
+ ## Zero results are not a grep license
35
+
36
+ If Memtrace returns 0 results, or repository stats look incomplete, do **not**
37
+ infer that a source subdirectory is outside the index. Diagnose through
38
+ Memtrace:
39
+
40
+ 1. Call `list_indexed_repositories` and identify the repo root/repo_id.
41
+ 2. If the path is under that indexed repo root, keep using Memtrace.
42
+ 3. Retry with broader `find_code` terms and, when available, `file_path` filters
43
+ such as `ui/`, `memtrace-ui/`, `src/`, or the framework directory.
44
+ 4. If the language/path still appears missing, run `index_directory` on the repo
45
+ root with `incremental: true` (or ask before `clear_existing: true`).
46
+ 5. Report the indexing coverage problem instead of silently switching to grep.
47
+
48
+ **Never say "the index only covers X, so grep is right" when the target path is
49
+ inside the indexed repository.** That is an indexing freshness/coverage issue,
50
+ not permission to abandon Memtrace.
51
+
52
+ ## The narrow exceptions where grep/glob are still right
53
+
54
+ These are the ONLY cases where file tools beat memtrace:
55
+
56
+ - **Files outside every indexed repo root.** Confirm this with
57
+ `list_indexed_repositories`; 0 search results or missing language stats do not
58
+ prove it. Vendored deps, system headers, and excluded dirs
59
+ (`.git`, `node_modules`, `target`, `dist`) are examples Memtrace cannot see.
60
+ - **Non-source artifacts.** `.env`, `package.json`, build scripts, top-level `README.md`, raw config files. Memtrace indexes parseable code, not configuration text.
61
+ - **Pure file-inventory questions.** "How many `*.test.ts` files exist", "list every Markdown file in `docs/`". You're asking for a file count, not a symbol search.
62
+ - **Reading at a known path outside Memtrace.** For configs, docs, or non-source artifacts that Memtrace cannot index, file `Read` is fine. For source-code spans returned by Memtrace, read the precise line range (your harness's `Read` with offset/limit, or `get_source_window` if your harness lacks bounded reads). Do not whole-file Read when you have a span.
63
+
64
+ For everything else inside the indexed repo, memtrace is the right tool.
65
+
66
+ ## The decision rule
67
+
68
+ | Question Claude is asking | Right tool |
69
+ |---|---|
70
+ | "Where is symbol `foo` defined?" | `find_symbol(name="foo")` → then `get_symbol_context` for callers/callees/community, NOT a source read unless you're editing. |
71
+ | "What calls `foo`?" | `get_symbol_context(name="foo")` → callers with file:line each. |
72
+ | "How does authentication work?" | `find_code(query="authentication")` → `get_symbol_context` on the top hit, NOT a source read. |
73
+ | "Find behavior X" with multi-word phrase (3+ words) | `find_code(verbatim)` first; if low confidence, fan out with identifier-shaped reshapes (camelCase / snake_case). |
74
+ | "Find the function that uses `STRIPE_KEY_FOO_BAR`" | `find_code(query="STRIPE_KEY_FOO_BAR")` → semantic finds it inside any embedded body. |
75
+ | "Where's that error message `'connection refused for tenant'`?" | `find_code(query="connection refused for tenant")` → semantic catches it. |
76
+ | "What breaks if I change `foo`?" | `get_impact(name="foo")` → blast radius with file:line. |
77
+ | "What changed in `auth.ts` last week?" | `get_evolution(file_path="auth.ts", from="7d ago")`. |
78
+ | "List all `*.test.ts` files." | `Glob` (file inventory, not symbol search). |
79
+ | "Find this string in my `.env`." | `Grep` (non-source artifact). |
80
+ | "I'm about to edit `foo` — show me its source." | Bounded `Read(file_path, offset=start_line, limit=end_line-start_line+8)`, or `get_source_window` if your harness lacks bounded reads. Never whole-file. |
81
+ | "Read config/doc file I already have the path of." | `Read` (non-source artifact, path is known). |
82
+
83
+ ## Parameter Types — Read This Before Calling Any Tool
84
+
85
+ All memtrace MCP tools are **strictly typed**. Pass JSON numbers (not strings) for integer parameters.
86
+
87
+ | Parameter | Correct | WRONG (fails with MCP error -32602) |
88
+ |---|---|---|
89
+ | `limit`, `min_size`, `depth`, `max_depth`, `last_n` | `limit: 20` | `limit: "20"` |
90
+ | `repo_id`, `branch`, `name`, `symbol_name`, `query` | `repo_id: "my-repo"` | `repo_id: my-repo` (unquoted) |
91
+ | `fuzzy`, `include_tests`, `invalidate` | `fuzzy: true` | `fuzzy: "true"` |
92
+
93
+ If you see `failed to deserialize parameters: invalid type: string "N", expected usize`, remove the quotes from the number and retry.
94
+
95
+ ## Check Indexing First (Once Per Session)
96
+
97
+ ```
98
+ mcp__memtrace__list_indexed_repositories
99
+ ```
100
+
101
+ If the current repo appears → Memtrace is active. Follow this skill for ALL code tasks.
102
+ If not indexed → offer to index with `mcp__memtrace__index_directory`, then follow this skill.
103
+
104
+ ## Task → Tool Map
105
+
106
+ | What you need | Use instead of Grep/Glob/Read |
107
+ |---|---|
108
+ | Find a function / class / symbol | `find_symbol` or `find_code` |
109
+ | Understand how something works | `get_symbol_context` (the default next step) |
110
+ | Find all callers of a function | `get_symbol_context` (callers field) |
111
+ | Find all callees / dependencies | `get_symbol_context` (callees field) |
112
+ | Trace a request / execution path | `get_process_flow` |
113
+ | Understand module structure | `list_communities` |
114
+ | Find the most important symbols | `find_central_symbols` |
115
+ | Find API endpoints | `find_api_endpoints` |
116
+ | Find where an API is called | `find_api_calls` |
117
+ | Debug a problem | `get_symbol_context` → `get_impact` → `get_evolution` |
118
+ | What changed recently? | `get_changes_since` or `get_evolution` |
119
+ | What breaks if I change X? | `get_impact` |
120
+ | Cross-service / cross-repo calls | `get_service_diagram` or `get_api_topology` |
121
+ | Dependency between two symbols | `find_dependency_path` |
122
+ | What files change together? | `get_cochange_context` |
123
+ | Architecture overview | `list_communities` + `find_central_symbols` |
124
+ | About to edit / quote — need exact lines | Bounded `Read(file, offset=start_line, limit=N)` (preferred), or `get_source_window` for path-resolution parity |
125
+ | 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 |
126
+
127
+ ## Standard Workflows
128
+
129
+ ### "How does X work?" / "Explain X"
130
+ 1. `find_symbol` or `find_code` → locate the symbol
131
+ 2. `get_symbol_context` → callers, callees, community, processes (this usually answers "how it works")
132
+ 3. `get_process_flow` (if it's a process/request path)
133
+ 4. Only if you need to quote source: bounded `Read` at start_line..end_line, or `get_source_window`
134
+
135
+ ### Debugging "X is broken"
136
+ 1. `find_symbol` → locate the broken thing
137
+ 2. `get_symbol_context` → understand its role
138
+ 3. `get_impact` → blast radius (what else breaks)
139
+ 4. `get_evolution` → what changed recently (mode: `recent`)
140
+ 5. `get_changes_since` → confirm timing vs incident
141
+
142
+ ### "Where is X defined / called?"
143
+ 1. `find_symbol` with `fuzzy: true`
144
+ 2. `get_symbol_context` for full caller/callee map
145
+ 3. Only if you need source text: bounded `Read` at start_line..end_line, or `get_source_window`
146
+
147
+ ### Before any code modification
148
+ 1. `find_symbol` → confirm you have the right target
149
+ 2. `get_symbol_context` → understand full context
150
+ 3. `get_impact` → know blast radius before touching anything
151
+ 4. `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
152
+
153
+ ## Red Flags — STOP, Use Memtrace Instead
154
+
155
+ You are violating this skill if you think:
156
+
157
+ | Thought | Reality |
158
+ |---|---|
159
+ | "Let me grep for this" | `find_code` or `find_symbol` is faster and structurally aware |
160
+ | "Let me glob for the file" | `find_symbol` returns exact location with context |
161
+ | "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 |
162
+ | "It's just a quick search" | Grep has no understanding of call graphs, communities, or time |
163
+ | "I don't know if it's indexed" | Check with `list_indexed_repositories` first — takes 1 second |
164
+ | "Memtrace returned 0 results" | Broaden the Memtrace query, check repo_id/path coverage, then reindex if needed |
165
+ | "Stats only show Rust, but I need `ui/` or `memtrace-ui/`" | That is a coverage diagnostic. Reindex the repo root; do not grep source code. |
166
+ | "The user didn't say to use Memtrace" | User asked about the code. Repo is indexed. Use Memtrace. |
167
+ | "This is a simple question" | Simple questions benefit most — one `find_symbol` vs 20 file reads |
168
+
169
+ ## When File Tools Are Still Correct
170
+
171
+ Use Grep/Glob/Read ONLY for:
172
+ - Non-source files or paths outside every indexed source repo
173
+ - Files that are config, data, or docs (not source code symbols)
174
+ - Repos or paths confirmed outside every Memtrace indexed root
175
+
176
+ For source-code spans already located by Memtrace, use a **bounded** read —
177
+ your harness's `Read(file, offset, limit)` with the returned `start_line` /
178
+ `end_line`, or `get_source_window` if your harness lacks bounded reads. Do
179
+ not read the whole file.
180
+
181
+ Never use file tools as a **discovery** mechanism when Memtrace is available.
182
+
183
+ ## Skill Priority
184
+
185
+ This skill is a **process skill** — it runs BEFORE any implementation or search skill.
186
+
187
+ When this skill applies, it overrides default file-search behavior. Use the specific Memtrace sub-skills for deep detail on each tool:
188
+
189
+ - Discovery → `memtrace-search`
190
+ - Impact analysis → `memtrace-impact`
191
+ - Temporal / change analysis → `memtrace-evolution`
192
+ - Incident investigation → `memtrace-incident-investigation`
193
+ - Architecture overview → `memtrace-codebase-exploration`
194
+ - Refactoring → `memtrace-refactoring-guide`
@@ -0,0 +1,80 @@
1
+ ---
2
+ name: memtrace-fleet-coordination
3
+ description: "Use when you need to understand or act on fleet conflict resolution: what conflict class A/B/C means, how a Class C destructive overlap gets decided (by an agent judge or a human), how to be the judge (fleet_submit_verdict), how to read your directive after a decision, and how branch-scoping isolates fleets. Triggered by: 'two agents are changing the same thing', 'resolve this conflict', 'who should proceed', 'a decision is waiting', acting as a mediator between agents."
4
+ ---
5
+
6
+ # Fleet Coordination
7
+
8
+ How the fleet turns overlapping edits into a safe decision. Read
9
+ `memtrace-fleet-first` for the publish→edit→record protocol; this skill is the
10
+ *conflict resolution* half.
11
+
12
+ ## Conflict classes (what `fleet_record_episode` returns)
13
+
14
+ | Class | Meaning | What to do |
15
+ |---|---|---|
16
+ | **A** | Additive, order-independent | Proceed. |
17
+ | **B** | Non-destructive overlap with another agent's work | Re-read the shared symbols, then proceed. |
18
+ | **C** | A **destructive** change (signature change / move / dead-code removal) overlaps another agent's work | A decision is needed — it does NOT auto-resolve. |
19
+
20
+ Class is computed **only against agents on your branch** (`(repo, branch)`).
21
+ Agents on other branches are never conflict peers.
22
+
23
+ ## The Class C decision loop
24
+
25
+ When `fleet_record_episode` returns class C it also returns an `escalation_id` and
26
+ (when mediation is on) a `mediation_request`. The decision is made by an **agent
27
+ judge**, a **human**, or — only when provably safe — the **deterministic referee**.
28
+
29
+ ### Being the judge (the user's own agent does the judging — no API keys)
30
+
31
+ The `mediation_request` bundles **every agent's `assignment`** plus the contested
32
+ symbols. Read the *other* agent's task and decide on merit (including against your
33
+ own change). Submit:
34
+
35
+ ```jsonc
36
+ fleet_submit_verdict({
37
+ escalation_id: "01J…",
38
+ agent_id: "agent-a",
39
+ verdict: { "kind": "recommend", "winner": "agent-b",
40
+ "rationale": "the signature change is the wider contract; rebase the fix onto it",
41
+ "confidence": 0.8 }
42
+ })
43
+ ```
44
+
45
+ Verdict kinds: `reconcile {merge_plan}` · `recommend {winner, rationale, confidence}`
46
+ · `defer_to_human {question}`.
47
+
48
+ The referee then decides the outcome:
49
+ - **Auto-apply** only when safe: the clear machine case, or ≥2 independent agents
50
+ agree — and **never** for a destructive *removal* (delete/move), which always
51
+ needs a human.
52
+ - **Human confirm** — a recommendation is surfaced for one-click confirmation.
53
+ - **Human required** — both sides destructive, agents disagree, or an agent
54
+ deferred → a person decides.
55
+
56
+ ### Reading your directive
57
+
58
+ Poll `fleet_get_escalation({escalation_id, agent_id})` until `your_directive` ≠
59
+ `wait`: `proceed` (you continue), `defer` (stand down / rebase onto the winner),
60
+ `review` (read `resolution`).
61
+
62
+ ### Resolving as a human (or on a human's behalf via the dashboard)
63
+
64
+ `fleet_resolve_escalation({escalation_id, resolution, winner})` records a human
65
+ decision and clears the queue. Prefer the agent-judge path; use this for the
66
+ genuine human-decision cases. `fleet_list_escalations({repo_id})` shows the
67
+ "needs human" queue.
68
+
69
+ ## Why branch-scoping matters here
70
+
71
+ A "winner / defer" only makes sense on a shared surface. Across branches, the
72
+ loser can't defer (its branch needs the change too), so the fleet never escalates
73
+ cross-branch — that's a merge-time concern git already owns. Keep your fleet to
74
+ one session branch and conflicts stay real and resolvable.
75
+
76
+ ## Inspecting state
77
+
78
+ `fleet_get_node_state({repo_id, node})` — recent episodes, active intents, dominant
79
+ intent, and conflict density for one symbol. Use it to understand pressure on a
80
+ hot symbol before you pile on.
@@ -0,0 +1,125 @@
1
+ ---
2
+ name: memtrace-fleet-first
3
+ description: "Always use FIRST when more than one coding agent works the same repo+branch at once (a 'fleet'), before reading code, planning a refactor, or making an edit. Triggered by: 'I'm about to edit X', 'rename Y across the codebase', joining a running fleet/session branch, coordinating with other agents, prose hand-offs. Do not grep for 'who else is touching this' and do not skip fleet_publish_intent because 'it's a small change'. Fleet coordination is branch-scoped: pass your session branch so your fleet coordinates and stays isolated from agents on other branches. Skip ONLY for genuinely solo sessions or pure docs-only edits where coordination has zero value."
4
+ ---
5
+
6
+ # Fleet First
7
+
8
+ The coordination layer for **fleets of coding agents** working the same repo at the
9
+ same time. It stops agents from silently clobbering each other's edits, and turns
10
+ unsafe overlaps into a clear decision instead of a merge-time surprise.
11
+
12
+ ## The Iron Law
13
+
14
+ ```
15
+ IN A FLEET → FLEET TOOLS BEFORE EDITS. NO EXCEPTIONS.
16
+ 1. fleet_publish_intent (declare what you'll touch; get blast radius + conflicts)
17
+ 2. edit (your normal edit loop)
18
+ 3. fleet_record_episode (classify A/B/C; if C, the loop resolves it)
19
+ ```
20
+
21
+ A typed intent serializes to ~20 tokens; a prose "I'm going to change X" averages
22
+ 200+. A 10-agent fleet × 100 edits = tens of thousands of tokens saved per
23
+ fleet-turn — and zero silent overwrites — when the protocol is followed.
24
+
25
+ ## A fleet = agents on ONE branch (always pass it)
26
+
27
+ **Coordination is branch-scoped.** Two agents only coordinate when they're on the
28
+ **same `(repo, branch)`**. The branch name is the fleet identifier: a *session
29
+ branch* is how a group of agents opts into one coordinating fleet.
30
+
31
+ - Working a session branch (`session/auth-revamp`)? Pass `branch` on **every**
32
+ fleet call. Your fleet coordinates together and stays isolated from agents on
33
+ other branches.
34
+ - Omit `branch` only for the shared default pool (single, unnamed fleet).
35
+ - Agents on **different** branches never conflict — git already isolates them, and
36
+ whether branches merge isn't guaranteed, so the fleet never reasons across them.
37
+
38
+ ```jsonc
39
+ { "repo_id": "myrepo", "branch": "session/auth-revamp",
40
+ "agent_id": "agent-a", "touched": ["auth::verify_token"],
41
+ "intent": {"refactor": {"pattern": "change_signature"}},
42
+ "assignment": "widen verify_token signature for pagination" }
43
+ ```
44
+
45
+ Always include **`assignment`** — your natural-language task. When a conflict
46
+ happens, that's what the judge (another agent) or a human reads to reconcile.
47
+
48
+ ## Check the fleet first (once per session)
49
+
50
+ ```
51
+ fleet_status() → live_intents, active_agents, pending_escalations, mediator_mode
52
+ ```
53
+
54
+ If it responds, fleet coordination is active — follow this skill for every edit.
55
+ An empty fleet is **not** permission to skip: it just means you're the first agent
56
+ in this window.
57
+
58
+ ## The protocol, step by step
59
+
60
+ 1. **Before editing** — `fleet_preflight({repo_id, branch, agent_id, touched, intent})`
61
+ (read-only) or go straight to `fleet_publish_intent(...)`. You get the blast
62
+ radius, any overlapping live intents on your branch, and a `coordination` block
63
+ that may already suggest who owns a contested symbol.
64
+ 2. **Edit** — your normal loop.
65
+ 3. **After editing** — `fleet_record_episode({repo_id, branch, agent_id, touched, intent})`.
66
+ It returns a `conflict_class`:
67
+ - **A — proceed.** Additive, order-independent. Nothing to do.
68
+ - **B — re-read, then proceed.** You overlap non-destructively; re-read the
69
+ shared symbols so you build on current state.
70
+ - **C — a decision is needed.** A destructive change overlaps another agent's
71
+ work. This does **not** auto-resolve — see below.
72
+
73
+ ## Class C: the decision loop (read this)
74
+
75
+ A Class C means two edit paths can't both land safely. `fleet_record_episode`
76
+ returns an `escalation_id` and a `mediation_request` (when mediation is enabled).
77
+ What happens next depends on who judges:
78
+
79
+ - **You may be asked to judge.** The `mediation_request` carries **every agent's
80
+ assignment** — including the other side's. Read them and submit a verdict with
81
+ `fleet_submit_verdict({escalation_id, agent_id, verdict})`, where `verdict` is one
82
+ of:
83
+ - `{"kind":"reconcile","merge_plan":"…"}` — the changes combine; here's how.
84
+ - `{"kind":"recommend","winner":"<agent_id>","rationale":"…","confidence":0.0-1.0}` —
85
+ one path should continue.
86
+ - `{"kind":"defer_to_human","question":"…"}` — a real product call; ask a human.
87
+ - **A human may decide** in the Fleet dashboard. Either way the outcome flows back
88
+ to you.
89
+ - **Close YOUR loop**: poll `fleet_get_escalation({escalation_id, agent_id})` until
90
+ `your_directive` is no longer `wait`:
91
+ - `proceed` — you were chosen; continue.
92
+ - `defer` — another path won; stand down and rebase your work onto it.
93
+ - `review` — read the free-text `resolution`.
94
+
95
+ The daemon is a deterministic referee: it never auto-applies a destructive
96
+ *removal* (delete/move) without a human, and only auto-applies when it's safe (a
97
+ clear machine case, or independent agent consensus). So the judge being wrong
98
+ degrades to "a human reviews a suggestion," never a silent bad merge.
99
+
100
+ ## Routing — what do you need?
101
+
102
+ | You're about to… | Do this |
103
+ |---|---|
104
+ | Start any edit in a fleet | `fleet_publish_intent` (declare it) — never skip |
105
+ | Check before declaring | `fleet_preflight` (read-only "is the coast clear?") |
106
+ | Finish an edit | `fleet_record_episode` (get A/B/C) |
107
+ | Got a Class C as the judge | `fleet_submit_verdict` (reconcile/recommend/defer) |
108
+ | Blocked on a Class C | poll `fleet_get_escalation` until `your_directive ≠ wait` |
109
+ | See who's in the fleet | `fleet_status` (active_agents, pending decisions) |
110
+ | Inspect a symbol's coordination state | `fleet_get_node_state` |
111
+
112
+ ## Parameter notes
113
+
114
+ - Pass `intent` as JSON (externally-tagged, snake_case):
115
+ `{"refactor":{"pattern":"rename_symbol"}}`, `{"bug_fix":{"defect":"logic_error"}}`.
116
+ Destructive kinds: `refactor/change_signature`, `refactor/move_symbol`,
117
+ `cleanup/dead_code` — these are what trigger Class C over shared symbols.
118
+ - `touched` is a list of qualified symbol identities (e.g. `"module::Symbol"`).
119
+ - Always include `branch` (your session branch) and `assignment` (your task).
120
+
121
+ ## When to skip
122
+
123
+ Skip the protocol only for a genuinely **solo** session (you're the only agent and
124
+ no one else shares your branch) or **pure docs-only** edits where coordination has
125
+ zero value. Everything else in a fleet goes through the protocol.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: memtrace-fleet-publish-intent
3
+ description: "Use to declare a structural intent BEFORE editing in a fleet — what symbols you'll touch and why — so other agents on your branch coordinate around you. Triggered by: 'I'm about to edit/rename/refactor X', starting any non-trivial edit while other agents share your repo+branch. Returns the graph blast radius, overlapping live intents on your branch, and a shift-left coordination/partition hint. Do not start editing shared symbols without publishing first."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ `fleet_publish_intent` is step 1 of the fleet protocol: announce what you're about
9
+ to touch so other agents on the **same `(repo, branch)`** coordinate around you.
10
+ It's a typed, ~20-token declaration — not prose.
11
+
12
+ ## Call it
13
+
14
+ ```jsonc
15
+ fleet_publish_intent({
16
+ repo_id: "myrepo",
17
+ branch: "session/auth-revamp", // your fleet's session branch
18
+ agent_id:"agent-a",
19
+ touched: ["auth::verify_token"], // qualified symbol identities
20
+ intent: {"refactor": {"pattern": "change_signature"}},
21
+ assignment: "widen verify_token signature for pagination" // the alignment anchor
22
+ })
23
+ ```
24
+
25
+ You get back:
26
+ - `impact_preview` — the real graph blast radius of the touched symbols.
27
+ - `active_conflicts` — overlapping live intents **on your branch** (none from other
28
+ branches; coordination is branch-scoped).
29
+ - `coordination` — a shift-left hint: `would_escalate`, a `suggested_partition`
30
+ (who should own a contested symbol), and advice to realign *before* you edit.
31
+
32
+ ## Intent kinds (JSON, snake_case, externally-tagged)
33
+
34
+ - `{"refactor":{"pattern":"rename_symbol"|"change_signature"|"move_symbol"|"extract_function"|…}}`
35
+ - `{"feature_add":{"surface":"new_symbol"|"new_endpoint"|…}}`
36
+ - `{"bug_fix":{"defect":"logic_error"|"null_handling"|…}}`
37
+ - `{"cleanup":{"kind":"dead_code"|"unused_import"|…}}`
38
+ - `{"performance":{"axis":"latency"|…}}`, `{"security_fix":{"severity":"high"}}`,
39
+ `{"test_add":{"covers":[…]}}`, `"docs_only"`, `"exploratory"`
40
+
41
+ **Destructive** kinds — `change_signature`, `move_symbol`, `cleanup/dead_code` —
42
+ are what raise a Class C decision when they overlap another agent's work.
43
+
44
+ ## Rules
45
+
46
+ - Always pass `branch` (your session branch) and `assignment` (your task).
47
+ - Read-only check first? Use `fleet_preflight` (same inputs, no registration).
48
+ - An empty `active_conflicts` is good — proceed and `fleet_record_episode` when done.
@@ -0,0 +1,44 @@
1
+ ---
2
+ name: memtrace-fleet-record-episode
3
+ description: "Use AFTER an edit in a fleet to record it and get its conflict class (A/B/C) against agents on your branch. Triggered by: finishing an edit, 'I just changed X', completing a refactor step while other agents share your repo+branch. Returns conflict_class + replan_hint; a Class C returns an escalation_id and mediation_request that starts the decision loop. Do not finish a coordinated edit without recording it."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ `fleet_record_episode` is step 3 of the fleet protocol: record the edit you just
9
+ made and learn whether it collided with another agent on your branch.
10
+
11
+ ## Call it
12
+
13
+ ```jsonc
14
+ fleet_record_episode({
15
+ repo_id: "myrepo",
16
+ branch: "session/auth-revamp",
17
+ agent_id:"agent-a",
18
+ touched: ["auth::verify_token"],
19
+ intent: {"refactor": {"pattern": "change_signature"}}
20
+ })
21
+ ```
22
+
23
+ ## The result: conflict_class
24
+
25
+ - **A → proceed.** Additive, order-independent.
26
+ - **B → re-read, then proceed.** Non-destructive overlap; re-read the shared
27
+ symbols so you build on current state.
28
+ - **C → a decision is needed.** A destructive change overlaps another agent's
29
+ work. The response includes:
30
+ - `escalation_id` — the decision's id.
31
+ - `mediation_request` — the judging task (every agent's `assignment` + the
32
+ contested symbols). If you're asked to judge, call `fleet_submit_verdict`.
33
+ - `next_action` — poll `fleet_get_escalation({escalation_id, agent_id})` until
34
+ `your_directive` ≠ `wait`, then `proceed` / `defer` / `review`.
35
+
36
+ Class is computed **only against agents on your branch**. Agents on other branches
37
+ never make your edit a Class C.
38
+
39
+ ## After recording
40
+
41
+ - Class A/B → continue.
42
+ - Class C → enter the decision loop (see `memtrace-fleet-coordination`). Don't keep
43
+ editing the contested symbols until your directive is `proceed`.
44
+ - Review history with `fleet_query_episodes({repo_id, node?, conflict_class?})`.
@@ -0,0 +1,54 @@
1
+ ---
2
+ name: memtrace-fleet-resolve
3
+ description: "Use to act on a Class C decision: submit your verdict as an agent judge (fleet_submit_verdict), poll your own directive (fleet_get_escalation), see the needs-human queue (fleet_list_escalations), or record a human decision (fleet_resolve_escalation). Triggered by: 'a decision is waiting', 'who should proceed', being handed a mediation_request, acting as a mediator between two agents, or a human choosing a winner in the dashboard."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ The tools that resolve a Class C conflict. The judging is done by the user's own
9
+ agents (no API keys): an agent reads the bundle and submits a verdict; the daemon
10
+ is the deterministic referee that decides the outcome and routes it back.
11
+
12
+ ## Submit a verdict (you are the judge)
13
+
14
+ You were handed a `mediation_request` (from `fleet_record_episode`). Read **every
15
+ agent's `assignment`** in it and decide on merit — including against your own
16
+ change:
17
+
18
+ ```jsonc
19
+ fleet_submit_verdict({
20
+ escalation_id: "01J…",
21
+ agent_id: "agent-a",
22
+ verdict: { "kind": "recommend", "winner": "agent-b",
23
+ "rationale": "wider contract; rebase the fix onto it", "confidence": 0.8 }
24
+ })
25
+ // kinds: reconcile {merge_plan} | recommend {winner, rationale, confidence} | defer_to_human {question}
26
+ ```
27
+
28
+ The response tells you the `outcome` (`auto_apply` | `human_confirm` |
29
+ `human_required` | `pending`) and `your_directive`.
30
+
31
+ ## Read your own directive (you are blocked)
32
+
33
+ ```jsonc
34
+ fleet_get_escalation({ escalation_id: "01J…", agent_id: "agent-a" })
35
+ // → your_directive: wait | proceed | defer | review
36
+ ```
37
+
38
+ Poll until it's not `wait`. `proceed` = continue; `defer` = stand down and rebase
39
+ onto the winner; `review` = read `resolution`.
40
+
41
+ ## Human paths
42
+
43
+ - `fleet_list_escalations({repo_id})` — the per-repo "needs human" queue.
44
+ - `fleet_resolve_escalation({escalation_id, resolution, winner})` — record a human
45
+ decision (pick which agent proceeds) and clear it. Prefer the agent-judge path;
46
+ use this for genuine human/product calls.
47
+
48
+ ## Safety the referee guarantees
49
+
50
+ - A destructive **removal** (delete/move) is **never** auto-applied — always a human.
51
+ - Auto-apply happens only for the clear-safe machine case or ≥2 agents agreeing on
52
+ a non-destructive resolution.
53
+ - So a wrong verdict degrades to "a human reviews a suggestion," never a silent
54
+ bad merge.
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: memtrace-graph
3
+ description: "Always use for source-code architecture, important symbols, centrality, PageRank, bridge functions, communities, logical modules, chokepoints, service boundaries, or dependency path questions. Do not use Glob, find, tree, or directory browsing to infer architecture; Memtrace runs graph algorithms over the AST graph."
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Graph algorithms that reveal the structural architecture of a codebase — community detection (Louvain), centrality ranking (PageRank), bridge symbol identification (Tarjan articulation points), shortest-path discovery, and execution flow tracing.
9
+
10
+ All four algorithm tools (`find_central_symbols`, `find_bridge_symbols`, `find_dependency_path`, `list_communities`) run natively against the MemDB-backed knowledge graph — no Cypher required.
11
+
12
+ ## Quick Reference
13
+
14
+ | Tool | Purpose |
15
+ |------|---------|
16
+ | `find_bridge_symbols` | Architectural chokepoints — symbols whose removal disconnects the graph (Tarjan articulation points) |
17
+ | `find_central_symbols` | Most important symbols by **PageRank** (default) or degree centrality |
18
+ | `find_dependency_path` | Shortest call/import path between two symbols (BFS over typed edges) |
19
+ | `list_communities` | Louvain-detected logical modules/services |
20
+ | `list_processes` | Execution flows: HTTP handlers, background jobs, CLI commands, event handlers |
21
+ | `get_process_flow` | Trace a single process step-by-step |
22
+
23
+ ## Steps
24
+
25
+ ### 1. Understand the architecture
26
+
27
+ Start with `list_communities` to see how the codebase is naturally partitioned into logical modules. Each community has a name, member count, and representative symbols.
28
+
29
+ ### 2. Find critical infrastructure
30
+
31
+ Use `find_central_symbols` to identify the most important symbols:
32
+ - `method: "pagerank"` — importance by link structure (default; same algorithm Google uses)
33
+ - `method: "degree"` — importance by direct connection count
34
+ - `limit` — how many to return
35
+
36
+ The PageRank pass walks every CALLS / REFERENCES edge in the repo, distributes rank with the standard 0.85 damping factor, and converges on a stable ordering. The output is sorted by score descending, with each entry carrying `name`, `kind`, `file_path`, `score`, and the `in_degree`/`out_degree` it accumulated during the walk.
37
+
38
+ ### 3. Find architectural chokepoints
39
+
40
+ Use `find_bridge_symbols` to find symbols that, if removed, would disconnect parts of the graph (Tarjan articulation points). These are:
41
+ - **Single points of failure** — if they break, cascading failures occur
42
+ - **Integration points** — good places for interfaces/contracts
43
+ - **Refactoring targets** — often too much responsibility concentrated in one place
44
+
45
+ ### 4. Discover the path between two symbols
46
+
47
+ Use `find_dependency_path` to answer "how does symbol A reach symbol B?" — returns the shortest call/import chain via BFS over typed edges. Useful for:
48
+ - "Why does the auth handler depend on the database client?"
49
+ - "How does this CLI command reach the logging subsystem?"
50
+ - "Confirm symbol X actually transitively depends on Y."
51
+
52
+ ### 5. Trace execution flows
53
+
54
+ Use `list_processes` to see all entry points (HTTP handlers, background jobs, CLI commands, event handlers).
55
+
56
+ Use `get_process_flow` with a process name to trace a specific flow step-by-step — shows the full call chain from entry point through business logic to data access, ordered by the indexed `step` property on each STEP_IN_PROCESS edge.
57
+
58
+ ## Decision Points
59
+
60
+ | Question | Tool |
61
+ |----------|------|
62
+ | "What are the main modules?" | `list_communities` |
63
+ | "What are the most important functions?" | `find_central_symbols` with method=pagerank |
64
+ | "Where are the bottlenecks?" | `find_bridge_symbols` |
65
+ | "How does symbol A reach symbol B?" | `find_dependency_path` |
66
+ | "How does a request flow through the system?" | `list_processes` → `get_process_flow` |
67
+ | "What's the entry point for feature X?" | `list_processes`, then filter by name |