memtrace 0.5.14 → 0.6.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memtrace",
3
- "version": "0.5.14",
3
+ "version": "0.6.0",
4
4
  "description": "Code intelligence graph — MCP server + AI agent skills + visualization UI",
5
5
  "keywords": [
6
6
  "mcp",
@@ -39,11 +39,11 @@
39
39
  "fs-extra": "^11.0.0"
40
40
  },
41
41
  "optionalDependencies": {
42
- "@memtrace/darwin-arm64": "0.5.14",
43
- "@memtrace/linux-x64": "0.5.14",
44
- "@memtrace/win32-x64": "0.5.14",
45
- "@memtrace/linux-x64-noavx2": "0.5.14",
46
- "@memtrace/win32-x64-noavx2": "0.5.14"
42
+ "@memtrace/darwin-arm64": "0.6.0",
43
+ "@memtrace/linux-x64": "0.6.0",
44
+ "@memtrace/win32-x64": "0.6.0",
45
+ "@memtrace/linux-x64-noavx2": "0.6.0",
46
+ "@memtrace/win32-x64-noavx2": "0.6.0"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=18"
@@ -0,0 +1,51 @@
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
+ allowed-tools:
5
+ - mcp__memtrace__fleet_publish_intent
6
+ - mcp__memtrace__fleet_preflight
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ `fleet_publish_intent` is step 1 of the fleet protocol: announce what you're about
12
+ to touch so other agents on the **same `(repo, branch)`** coordinate around you.
13
+ It's a typed, ~20-token declaration — not prose.
14
+
15
+ ## Call it
16
+
17
+ ```jsonc
18
+ fleet_publish_intent({
19
+ repo_id: "myrepo",
20
+ branch: "session/auth-revamp", // your fleet's session branch
21
+ agent_id:"agent-a",
22
+ touched: ["auth::verify_token"], // qualified symbol identities
23
+ intent: {"refactor": {"pattern": "change_signature"}},
24
+ assignment: "widen verify_token signature for pagination" // the alignment anchor
25
+ })
26
+ ```
27
+
28
+ You get back:
29
+ - `impact_preview` — the real graph blast radius of the touched symbols.
30
+ - `active_conflicts` — overlapping live intents **on your branch** (none from other
31
+ branches; coordination is branch-scoped).
32
+ - `coordination` — a shift-left hint: `would_escalate`, a `suggested_partition`
33
+ (who should own a contested symbol), and advice to realign *before* you edit.
34
+
35
+ ## Intent kinds (JSON, snake_case, externally-tagged)
36
+
37
+ - `{"refactor":{"pattern":"rename_symbol"|"change_signature"|"move_symbol"|"extract_function"|…}}`
38
+ - `{"feature_add":{"surface":"new_symbol"|"new_endpoint"|…}}`
39
+ - `{"bug_fix":{"defect":"logic_error"|"null_handling"|…}}`
40
+ - `{"cleanup":{"kind":"dead_code"|"unused_import"|…}}`
41
+ - `{"performance":{"axis":"latency"|…}}`, `{"security_fix":{"severity":"high"}}`,
42
+ `{"test_add":{"covers":[…]}}`, `"docs_only"`, `"exploratory"`
43
+
44
+ **Destructive** kinds — `change_signature`, `move_symbol`, `cleanup/dead_code` —
45
+ are what raise a Class C decision when they overlap another agent's work.
46
+
47
+ ## Rules
48
+
49
+ - Always pass `branch` (your session branch) and `assignment` (your task).
50
+ - Read-only check first? Use `fleet_preflight` (same inputs, no registration).
51
+ - An empty `active_conflicts` is good — proceed and `fleet_record_episode` when done.
@@ -0,0 +1,48 @@
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
+ allowed-tools:
5
+ - mcp__memtrace__fleet_record_episode
6
+ - mcp__memtrace__fleet_get_escalation
7
+ - mcp__memtrace__fleet_query_episodes
8
+ ---
9
+
10
+ ## Overview
11
+
12
+ `fleet_record_episode` is step 3 of the fleet protocol: record the edit you just
13
+ made and learn whether it collided with another agent on your branch.
14
+
15
+ ## Call it
16
+
17
+ ```jsonc
18
+ fleet_record_episode({
19
+ repo_id: "myrepo",
20
+ branch: "session/auth-revamp",
21
+ agent_id:"agent-a",
22
+ touched: ["auth::verify_token"],
23
+ intent: {"refactor": {"pattern": "change_signature"}}
24
+ })
25
+ ```
26
+
27
+ ## The result: conflict_class
28
+
29
+ - **A → proceed.** Additive, order-independent.
30
+ - **B → re-read, then proceed.** Non-destructive overlap; re-read the shared
31
+ symbols so you build on current state.
32
+ - **C → a decision is needed.** A destructive change overlaps another agent's
33
+ work. The response includes:
34
+ - `escalation_id` — the decision's id.
35
+ - `mediation_request` — the judging task (every agent's `assignment` + the
36
+ contested symbols). If you're asked to judge, call `fleet_submit_verdict`.
37
+ - `next_action` — poll `fleet_get_escalation({escalation_id, agent_id})` until
38
+ `your_directive` ≠ `wait`, then `proceed` / `defer` / `review`.
39
+
40
+ Class is computed **only against agents on your branch**. Agents on other branches
41
+ never make your edit a Class C.
42
+
43
+ ## After recording
44
+
45
+ - Class A/B → continue.
46
+ - Class C → enter the decision loop (see `memtrace-fleet-coordination`). Don't keep
47
+ editing the contested symbols until your directive is `proceed`.
48
+ - Review history with `fleet_query_episodes({repo_id, node?, conflict_class?})`.
@@ -0,0 +1,59 @@
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
+ allowed-tools:
5
+ - mcp__memtrace__fleet_submit_verdict
6
+ - mcp__memtrace__fleet_get_escalation
7
+ - mcp__memtrace__fleet_list_escalations
8
+ - mcp__memtrace__fleet_resolve_escalation
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ The tools that resolve a Class C conflict. The judging is done by the user's own
14
+ agents (no API keys): an agent reads the bundle and submits a verdict; the daemon
15
+ is the deterministic referee that decides the outcome and routes it back.
16
+
17
+ ## Submit a verdict (you are the judge)
18
+
19
+ You were handed a `mediation_request` (from `fleet_record_episode`). Read **every
20
+ agent's `assignment`** in it and decide on merit — including against your own
21
+ change:
22
+
23
+ ```jsonc
24
+ fleet_submit_verdict({
25
+ escalation_id: "01J…",
26
+ agent_id: "agent-a",
27
+ verdict: { "kind": "recommend", "winner": "agent-b",
28
+ "rationale": "wider contract; rebase the fix onto it", "confidence": 0.8 }
29
+ })
30
+ // kinds: reconcile {merge_plan} | recommend {winner, rationale, confidence} | defer_to_human {question}
31
+ ```
32
+
33
+ The response tells you the `outcome` (`auto_apply` | `human_confirm` |
34
+ `human_required` | `pending`) and `your_directive`.
35
+
36
+ ## Read your own directive (you are blocked)
37
+
38
+ ```jsonc
39
+ fleet_get_escalation({ escalation_id: "01J…", agent_id: "agent-a" })
40
+ // → your_directive: wait | proceed | defer | review
41
+ ```
42
+
43
+ Poll until it's not `wait`. `proceed` = continue; `defer` = stand down and rebase
44
+ onto the winner; `review` = read `resolution`.
45
+
46
+ ## Human paths
47
+
48
+ - `fleet_list_escalations({repo_id})` — the per-repo "needs human" queue.
49
+ - `fleet_resolve_escalation({escalation_id, resolution, winner})` — record a human
50
+ decision (pick which agent proceeds) and clear it. Prefer the agent-judge path;
51
+ use this for genuine human/product calls.
52
+
53
+ ## Safety the referee guarantees
54
+
55
+ - A destructive **removal** (delete/move) is **never** auto-applied — always a human.
56
+ - Auto-apply happens only for the clear-safe machine case or ≥2 agents agreeing on
57
+ a non-destructive resolution.
58
+ - So a wrong verdict degrades to "a human reviews a suggestion," never a silent
59
+ bad merge.
@@ -0,0 +1,87 @@
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
+ allowed-tools:
5
+ - mcp__memtrace__fleet_record_episode
6
+ - mcp__memtrace__fleet_submit_verdict
7
+ - mcp__memtrace__fleet_get_escalation
8
+ - mcp__memtrace__fleet_list_escalations
9
+ - mcp__memtrace__fleet_resolve_escalation
10
+ - mcp__memtrace__fleet_get_node_state
11
+ ---
12
+
13
+ # Fleet Coordination
14
+
15
+ How the fleet turns overlapping edits into a safe decision. Read
16
+ `memtrace-fleet-first` for the publish→edit→record protocol; this skill is the
17
+ *conflict resolution* half.
18
+
19
+ ## Conflict classes (what `fleet_record_episode` returns)
20
+
21
+ | Class | Meaning | What to do |
22
+ |---|---|---|
23
+ | **A** | Additive, order-independent | Proceed. |
24
+ | **B** | Non-destructive overlap with another agent's work | Re-read the shared symbols, then proceed. |
25
+ | **C** | A **destructive** change (signature change / move / dead-code removal) overlaps another agent's work | A decision is needed — it does NOT auto-resolve. |
26
+
27
+ Class is computed **only against agents on your branch** (`(repo, branch)`).
28
+ Agents on other branches are never conflict peers.
29
+
30
+ ## The Class C decision loop
31
+
32
+ When `fleet_record_episode` returns class C it also returns an `escalation_id` and
33
+ (when mediation is on) a `mediation_request`. The decision is made by an **agent
34
+ judge**, a **human**, or — only when provably safe — the **deterministic referee**.
35
+
36
+ ### Being the judge (the user's own agent does the judging — no API keys)
37
+
38
+ The `mediation_request` bundles **every agent's `assignment`** plus the contested
39
+ symbols. Read the *other* agent's task and decide on merit (including against your
40
+ own change). Submit:
41
+
42
+ ```jsonc
43
+ fleet_submit_verdict({
44
+ escalation_id: "01J…",
45
+ agent_id: "agent-a",
46
+ verdict: { "kind": "recommend", "winner": "agent-b",
47
+ "rationale": "the signature change is the wider contract; rebase the fix onto it",
48
+ "confidence": 0.8 }
49
+ })
50
+ ```
51
+
52
+ Verdict kinds: `reconcile {merge_plan}` · `recommend {winner, rationale, confidence}`
53
+ · `defer_to_human {question}`.
54
+
55
+ The referee then decides the outcome:
56
+ - **Auto-apply** only when safe: the clear machine case, or ≥2 independent agents
57
+ agree — and **never** for a destructive *removal* (delete/move), which always
58
+ needs a human.
59
+ - **Human confirm** — a recommendation is surfaced for one-click confirmation.
60
+ - **Human required** — both sides destructive, agents disagree, or an agent
61
+ deferred → a person decides.
62
+
63
+ ### Reading your directive
64
+
65
+ Poll `fleet_get_escalation({escalation_id, agent_id})` until `your_directive` ≠
66
+ `wait`: `proceed` (you continue), `defer` (stand down / rebase onto the winner),
67
+ `review` (read `resolution`).
68
+
69
+ ### Resolving as a human (or on a human's behalf via the dashboard)
70
+
71
+ `fleet_resolve_escalation({escalation_id, resolution, winner})` records a human
72
+ decision and clears the queue. Prefer the agent-judge path; use this for the
73
+ genuine human-decision cases. `fleet_list_escalations({repo_id})` shows the
74
+ "needs human" queue.
75
+
76
+ ## Why branch-scoping matters here
77
+
78
+ A "winner / defer" only makes sense on a shared surface. Across branches, the
79
+ loser can't defer (its branch needs the change too), so the fleet never escalates
80
+ cross-branch — that's a merge-time concern git already owns. Keep your fleet to
81
+ one session branch and conflicts stay real and resolvable.
82
+
83
+ ## Inspecting state
84
+
85
+ `fleet_get_node_state({repo_id, node})` — recent episodes, active intents, dominant
86
+ intent, and conflict density for one symbol. Use it to understand pressure on a
87
+ hot symbol before you pile on.
@@ -0,0 +1,132 @@
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
+ allowed-tools:
5
+ - mcp__memtrace__fleet_status
6
+ - mcp__memtrace__fleet_preflight
7
+ - mcp__memtrace__fleet_publish_intent
8
+ - mcp__memtrace__fleet_record_episode
9
+ - mcp__memtrace__fleet_get_escalation
10
+ - mcp__memtrace__fleet_submit_verdict
11
+ ---
12
+
13
+ # Fleet First
14
+
15
+ The coordination layer for **fleets of coding agents** working the same repo at the
16
+ same time. It stops agents from silently clobbering each other's edits, and turns
17
+ unsafe overlaps into a clear decision instead of a merge-time surprise.
18
+
19
+ ## The Iron Law
20
+
21
+ ```
22
+ IN A FLEET → FLEET TOOLS BEFORE EDITS. NO EXCEPTIONS.
23
+ 1. fleet_publish_intent (declare what you'll touch; get blast radius + conflicts)
24
+ 2. edit (your normal edit loop)
25
+ 3. fleet_record_episode (classify A/B/C; if C, the loop resolves it)
26
+ ```
27
+
28
+ A typed intent serializes to ~20 tokens; a prose "I'm going to change X" averages
29
+ 200+. A 10-agent fleet × 100 edits = tens of thousands of tokens saved per
30
+ fleet-turn — and zero silent overwrites — when the protocol is followed.
31
+
32
+ ## A fleet = agents on ONE branch (always pass it)
33
+
34
+ **Coordination is branch-scoped.** Two agents only coordinate when they're on the
35
+ **same `(repo, branch)`**. The branch name is the fleet identifier: a *session
36
+ branch* is how a group of agents opts into one coordinating fleet.
37
+
38
+ - Working a session branch (`session/auth-revamp`)? Pass `branch` on **every**
39
+ fleet call. Your fleet coordinates together and stays isolated from agents on
40
+ other branches.
41
+ - Omit `branch` only for the shared default pool (single, unnamed fleet).
42
+ - Agents on **different** branches never conflict — git already isolates them, and
43
+ whether branches merge isn't guaranteed, so the fleet never reasons across them.
44
+
45
+ ```jsonc
46
+ { "repo_id": "myrepo", "branch": "session/auth-revamp",
47
+ "agent_id": "agent-a", "touched": ["auth::verify_token"],
48
+ "intent": {"refactor": {"pattern": "change_signature"}},
49
+ "assignment": "widen verify_token signature for pagination" }
50
+ ```
51
+
52
+ Always include **`assignment`** — your natural-language task. When a conflict
53
+ happens, that's what the judge (another agent) or a human reads to reconcile.
54
+
55
+ ## Check the fleet first (once per session)
56
+
57
+ ```
58
+ fleet_status() → live_intents, active_agents, pending_escalations, mediator_mode
59
+ ```
60
+
61
+ If it responds, fleet coordination is active — follow this skill for every edit.
62
+ An empty fleet is **not** permission to skip: it just means you're the first agent
63
+ in this window.
64
+
65
+ ## The protocol, step by step
66
+
67
+ 1. **Before editing** — `fleet_preflight({repo_id, branch, agent_id, touched, intent})`
68
+ (read-only) or go straight to `fleet_publish_intent(...)`. You get the blast
69
+ radius, any overlapping live intents on your branch, and a `coordination` block
70
+ that may already suggest who owns a contested symbol.
71
+ 2. **Edit** — your normal loop.
72
+ 3. **After editing** — `fleet_record_episode({repo_id, branch, agent_id, touched, intent})`.
73
+ It returns a `conflict_class`:
74
+ - **A — proceed.** Additive, order-independent. Nothing to do.
75
+ - **B — re-read, then proceed.** You overlap non-destructively; re-read the
76
+ shared symbols so you build on current state.
77
+ - **C — a decision is needed.** A destructive change overlaps another agent's
78
+ work. This does **not** auto-resolve — see below.
79
+
80
+ ## Class C: the decision loop (read this)
81
+
82
+ A Class C means two edit paths can't both land safely. `fleet_record_episode`
83
+ returns an `escalation_id` and a `mediation_request` (when mediation is enabled).
84
+ What happens next depends on who judges:
85
+
86
+ - **You may be asked to judge.** The `mediation_request` carries **every agent's
87
+ assignment** — including the other side's. Read them and submit a verdict with
88
+ `fleet_submit_verdict({escalation_id, agent_id, verdict})`, where `verdict` is one
89
+ of:
90
+ - `{"kind":"reconcile","merge_plan":"…"}` — the changes combine; here's how.
91
+ - `{"kind":"recommend","winner":"<agent_id>","rationale":"…","confidence":0.0-1.0}` —
92
+ one path should continue.
93
+ - `{"kind":"defer_to_human","question":"…"}` — a real product call; ask a human.
94
+ - **A human may decide** in the Fleet dashboard. Either way the outcome flows back
95
+ to you.
96
+ - **Close YOUR loop**: poll `fleet_get_escalation({escalation_id, agent_id})` until
97
+ `your_directive` is no longer `wait`:
98
+ - `proceed` — you were chosen; continue.
99
+ - `defer` — another path won; stand down and rebase your work onto it.
100
+ - `review` — read the free-text `resolution`.
101
+
102
+ The daemon is a deterministic referee: it never auto-applies a destructive
103
+ *removal* (delete/move) without a human, and only auto-applies when it's safe (a
104
+ clear machine case, or independent agent consensus). So the judge being wrong
105
+ degrades to "a human reviews a suggestion," never a silent bad merge.
106
+
107
+ ## Routing — what do you need?
108
+
109
+ | You're about to… | Do this |
110
+ |---|---|
111
+ | Start any edit in a fleet | `fleet_publish_intent` (declare it) — never skip |
112
+ | Check before declaring | `fleet_preflight` (read-only "is the coast clear?") |
113
+ | Finish an edit | `fleet_record_episode` (get A/B/C) |
114
+ | Got a Class C as the judge | `fleet_submit_verdict` (reconcile/recommend/defer) |
115
+ | Blocked on a Class C | poll `fleet_get_escalation` until `your_directive ≠ wait` |
116
+ | See who's in the fleet | `fleet_status` (active_agents, pending decisions) |
117
+ | Inspect a symbol's coordination state | `fleet_get_node_state` |
118
+
119
+ ## Parameter notes
120
+
121
+ - Pass `intent` as JSON (externally-tagged, snake_case):
122
+ `{"refactor":{"pattern":"rename_symbol"}}`, `{"bug_fix":{"defect":"logic_error"}}`.
123
+ Destructive kinds: `refactor/change_signature`, `refactor/move_symbol`,
124
+ `cleanup/dead_code` — these are what trigger Class C over shared symbols.
125
+ - `touched` is a list of qualified symbol identities (e.g. `"module::Symbol"`).
126
+ - Always include `branch` (your session branch) and `assignment` (your task).
127
+
128
+ ## When to skip
129
+
130
+ Skip the protocol only for a genuinely **solo** session (you're the only agent and
131
+ no one else shares your branch) or **pure docs-only** edits where coordination has
132
+ zero value. Everything else in a fleet goes through the protocol.