musememory 2.0.0 → 2.2.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/.agents/context/architecture.md +5 -2
- package/.agents/context/current.md +5 -2
- package/.agents/context/product.md +6 -0
- package/.agents/context/roadmap.md +15 -8
- package/.agents/skills/muse-drift/SKILL.md +70 -0
- package/.agents/skills/muse-health/SKILL.md +56 -0
- package/.agents/skills/muse-mesh/SKILL.md +66 -0
- package/.agents/skills/muse-sync/SKILL.md +63 -0
- package/.agents/skills/muse-why/SKILL.md +60 -0
- package/README.md +115 -65
- package/dist/index.js +14995 -11766
- package/package.json +1 -1
|
@@ -65,7 +65,8 @@ musememory/
|
|
|
65
65
|
│ ├── harvester.ts # Universal agent transcript discovery and auto-learner engine
|
|
66
66
|
│ ├── intelligence/ # Pluggable code intelligence providers (CodeGraph, Graphify, LSP, AST)
|
|
67
67
|
│ ├── learning/ # Observation, candidate distillation, negative anti-patterns
|
|
68
|
-
│ ├── mcp.ts # Model Context Protocol stdio server (
|
|
68
|
+
│ ├── mcp.ts # Model Context Protocol stdio server (69 tools with profiles)
|
|
69
|
+
│ ├── mesh/ # Multi-repo & monorepo workspace discovery, query resolver, contracts
|
|
69
70
|
│ ├── orchestrator/ # Flagship muse_context fusion, bidirectional lookups, MCP profiles
|
|
70
71
|
│ ├── promotion/ # 3-tier promotion ladder, 5x success rule, archival lifecycle
|
|
71
72
|
│ ├── quality/ # Deduplication, semantic contradiction engine, utility & ROI
|
|
@@ -74,12 +75,14 @@ musememory/
|
|
|
74
75
|
│ ├── schema.ts # JSON Schema & store referential validator
|
|
75
76
|
│ ├── secrets.ts # Vibeguard zero-leakage secret scanner & redactor
|
|
76
77
|
│ ├── store.ts # Dual-scope storage layout & lifecycle state machine
|
|
78
|
+
│ ├── sync/ # Cross-agent knowledge sync, P2P gossip protocol, shared pool
|
|
77
79
|
│ ├── transcript.ts # Universal JSONL parser, dialogue windowing & search
|
|
78
80
|
│ ├── types.ts # Core TypeScript interfaces & enums
|
|
81
|
+
│ ├── ui.ts # Full Web Observability Studio & 3D knowledge graph
|
|
79
82
|
│ ├── user.ts # Persona & working preference engine
|
|
80
83
|
│ ├── agents/ # Workstation coding agents detection & registry (80+ platforms)
|
|
81
84
|
│ └── migrator/ # Multi-provider auto-detection & migration engine (24+ formats)
|
|
82
|
-
├── test/ # Automated
|
|
85
|
+
├── test/ # Automated Bun test suites (498 tests across 81 suites)
|
|
83
86
|
├── package.json # Package metadata & dependencies (v2.0.0)
|
|
84
87
|
└── dist/ # Compiled Node/Bun bundle
|
|
85
88
|
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# 📍 Current Shipped State & Active Invariants
|
|
2
2
|
|
|
3
|
-
> **Version**: `v2.
|
|
4
|
-
> **Status**: Production Release (
|
|
3
|
+
> **Version**: `v2.1.0`
|
|
4
|
+
> **Status**: Production Release (P2P Sync, Studio, and Monorepo Mesh)
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
22. **First-Class Architecture Decision Records (ADRs) & Bidirectional Drift Engine**: ADRs as living memory entities (`proposed`, `accepted`, `superseded`, `rejected`) with native code anchors and supersession lineage; bidirectional documentation ↔ code drift engine classifying alignment (`DOCUMENTED`, `IMPLEMENTED`, `PARTIAL`, `CONFLICTING`, `STALE`, `MISSING`) and scoring repository health.
|
|
32
32
|
23. **Autonomous Engineering Cognition & "Why" Reasoner**: Historical "Why" explanation engine synthesizing ADRs, bug fixes, trade-offs, and invariants; recurring bug and fragility clustering across 5 root causes; and technical debt scanner detecting TODOs/FIXMEs, `as any` type bypasses, and drifted anchors.
|
|
33
33
|
24. **Unified 5-Pillar Project Health Gate (`muse_health`)**: Comprehensive architectural health evaluation auditing store integrity, native code anchors, doc/code alignment, anti-pattern sentry, and technical debt; computes composite grade (A-F), gate status (PASS/WARN/FAIL), prioritized remediation checklist, and CLI dashboard.
|
|
34
|
+
25. **Cross-Agent Knowledge Sync & P2P Gossip Protocol (R14)**: Portable sealed `SyncPacket` with SHA-256 integrity, vector clock causal ordering, bidirectional shared pool drop-directory gossip exchange, deduplication, Vibeguard secret scrubbing, and semantic contradiction tagging with mutual `conflict_ids`.
|
|
35
|
+
26. **Full Web Observability Studio & Interactive Visual Dashboard (R15)**: Integrated web studio served over local HTTP (`memory studio`), featuring a 5-pillar health scorecard, overall letter grade, prioritized remediation action checklist, ADR registry with code-to-doc drift inspector, autonomous "Why" reasoner, bug friction clusters heatmap, debt hotspots, and live P2P mesh topology visualizer.
|
|
36
|
+
27. **Multi-Repo & Monorepo Cross-Project Mesh (R16)**: Automatic workspace detection across pnpm, npm, bun, lerna, and multi-repo sibling groups; cross-project memory querying with origin package provenance; cross-package contract and entrypoint export auditing; explicit mesh linking (`mesh_links.json`); and shared invariant propagation across the entire mesh.
|
|
34
37
|
|
|
35
38
|
---
|
|
36
39
|
|
|
@@ -31,6 +31,12 @@ Muse Memory is a zero-daemon, file-backed cognitive memory engine designed to gi
|
|
|
31
31
|
| `memory_promote_scope` | **Scoped Promotion** | Promotes memory along 3-tier ladder (`local` $\rightarrow$ `project` $\rightarrow$ `global`) with 5× repeated success policy and universal generalization. |
|
|
32
32
|
| `memory_archive` / `rehydrate` | **Archival Lifecycle** | Evaluates and manages `active` $\rightarrow$ `cold` $\rightarrow$ `dormant` $\rightarrow$ `archived` lifecycle with query rehydration. |
|
|
33
33
|
| `anchor_create` / `verify` / `audit` | **Code Identity** | Creates, verifies, and audits line-independent structural code anchors. |
|
|
34
|
+
| `muse_sync_broadcast` / `ingest` | **P2P Gossip Mesh** | Broadcasts and ingests portable sealed SyncPackets with deduplication and contradiction flagging. |
|
|
35
|
+
| `muse_sync_status` / `pool` | **Sync Coordination** | Tracks peer vector clocks and synchronizes memories bidirectionally via shared drop-directory pool. |
|
|
36
|
+
| `muse_mesh_status` | **Monorepo Topology** | Discovers monorepo workspaces and multi-repo sibling groups with package dependencies and stores. |
|
|
37
|
+
| `muse_mesh_query` | **Cross-Project Query** | Queries memories across the entire workspace mesh with origin package provenance tags. |
|
|
38
|
+
| `muse_mesh_audit` | **Contract Verification** | Audits cross-package dependency contracts, entrypoint exports, and cross-repo code anchors. |
|
|
39
|
+
| `muse_mesh_link` | **Mesh Linking** | Explicitly links or unlinks external repository paths into the workspace mesh registry. |
|
|
34
40
|
|
|
35
41
|
### 🛠️ Core Memory & Lifecycle Tools
|
|
36
42
|
| MCP Tool | Execution Phase | Agent Purpose |
|
|
@@ -2,11 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
## ✅ Completed Milestones
|
|
6
|
+
- **R14: Cross-Agent Knowledge Sync & P2P Gossip Protocol**: Sealed SyncPackets, vector clock causal tracking, filesystem shared pool drop-directory synchronization, contradiction tagging.
|
|
7
|
+
- **R15: Full Web Observability Studio**: Embedded visual web dashboard (`memory studio`) featuring 5-pillar health scorecards, ADR drift inspection, autonomous "Why" reasoner, and live mesh visualization.
|
|
8
|
+
- **R16: Multi-Repo & Monorepo Cross-Project Mesh**: Monorepo auto-discovery (pnpm, npm, bun, lerna), cross-project memory resolution with origin provenance, cross-package contract integrity auditing.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Active Roadmap & Future Horizons
|
|
13
|
+
|
|
14
|
+
1. **Distributed Agentic Swarm Telemetry**:
|
|
15
|
+
- Aggregate multi-agent task traces and memory application telemetry across distributed agency clusters.
|
|
16
|
+
2. **Autonomous Semantic Refactoring Engine**:
|
|
17
|
+
- Proactive codebase refactoring recommendations driven by historical bug friction clusters and ADR drift patterns.
|
|
18
|
+
3. **Enterprise Role-Based Access & Secret Boundary Enclaves**:
|
|
19
|
+
- Cryptographic memory encryption and tenant-isolated compartmentalization for multi-client agency delivery.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muse-drift
|
|
3
|
+
description: Living Architecture Decision Records (ADRs) and bidirectional documentation-to-code drift auditor. Investigates architectural drift, records living decisions, and maintains doc-code harmony.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 🏛️ Muse Drift (`muse-drift`)
|
|
7
|
+
|
|
8
|
+
> **When to use**: Execute when introducing architectural changes, making technology choices, refactoring system boundaries, or checking if documentation matches actual implementation.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Execution Workflow
|
|
13
|
+
|
|
14
|
+
### Step 1: Audit Documentation $\longleftrightarrow$ Code Alignment
|
|
15
|
+
Call the `memory_drift_audit` MCP tool (or run `memory drift`):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"dir": "."
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The auditor classifies documented items across 6 mutually exclusive states:
|
|
24
|
+
- `DOCUMENTED`: Architectural guidelines described in docs/ADRs.
|
|
25
|
+
- `IMPLEMENTED`: Verified clean match between doc and code AST.
|
|
26
|
+
- `PARTIAL`: Incomplete implementation or missing export.
|
|
27
|
+
- `CONFLICTING`: Code directly contradicts documented architecture.
|
|
28
|
+
- `STALE`: Document references removed modules or legacy abstractions.
|
|
29
|
+
- `MISSING`: Code exists with zero architectural documentation.
|
|
30
|
+
|
|
31
|
+
### Step 2: Record Living Architecture Decision Records (ADRs)
|
|
32
|
+
When establishing or changing an architectural design decision, record a first-class ADR using `memory_adr_record`:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"title": "Use SQLite WAL and Microsecond In-Process Memory Cache",
|
|
37
|
+
"decision": "All memory read/write operations must use in-process SQLite WAL mode with an L0 hot cache. No resident background daemons.",
|
|
38
|
+
"status": "accepted",
|
|
39
|
+
"context_and_drivers": [
|
|
40
|
+
"Zero-daemon constraint",
|
|
41
|
+
"Sub-millisecond latency requirement for CLI commands"
|
|
42
|
+
],
|
|
43
|
+
"consequences": {
|
|
44
|
+
"positive": ["Microsecond hot cache lookups", "Concurrent multi-process reads"],
|
|
45
|
+
"negative": ["Requires file locking management on write"]
|
|
46
|
+
},
|
|
47
|
+
"anchors": [
|
|
48
|
+
{ "kind": "file", "file_path": "src/store.ts" },
|
|
49
|
+
{ "kind": "file", "file_path": "src/cache.ts" }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 3: Supersede Obsolete Decisions
|
|
55
|
+
When replacing an existing ADR, provide the `supersedes` parameter with the old ADR ID. The engine automatically marks the old decision as `superseded` and records full provenance in the audit ledger.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 💻 CLI Equivalents (Zero-MCP Fallback)
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Check repository documentation vs code drift
|
|
63
|
+
memory drift
|
|
64
|
+
|
|
65
|
+
# List all living Architecture Decision Records
|
|
66
|
+
memory adr list
|
|
67
|
+
|
|
68
|
+
# Record a new Architecture Decision Record
|
|
69
|
+
memory adr record "Decision Title" --decision "..." --positive "..." --negative "..."
|
|
70
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muse-health
|
|
3
|
+
description: Unified 5-pillar project health gate governor. Audits store integrity, code anchors, doc/code alignment, negative sentry, and technical debt to enforce production hardening gates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 🏥 Muse Health (`muse-health`)
|
|
7
|
+
|
|
8
|
+
> **When to use**: Execute before completing features, opening pull requests, or cutting releases to verify repository hardening and architectural health.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Execution Workflow
|
|
13
|
+
|
|
14
|
+
### Step 1: Run 5-Pillar Health Gate
|
|
15
|
+
Call the `muse_health` MCP tool (or execute `memory health`):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"dir": "."
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Step 2: Evaluate 5-Pillar Scorecard
|
|
24
|
+
The engine evaluates 5 distinct hardening dimensions, outputting an overall letter grade (**A–F**) and a gate status (**PASS**, **WARN**, or **FAIL**):
|
|
25
|
+
|
|
26
|
+
1. **Pillar 1: Store Integrity**:
|
|
27
|
+
- Validates referential integrity, YAML schema conformances, bidirectional links, and missing target memory IDs.
|
|
28
|
+
2. **Pillar 2: Native Code Anchors**:
|
|
29
|
+
- Verifies whether files, functions, and symbols referenced by code anchors exist on disk, flagging drifted structural hashes or orphaned anchors.
|
|
30
|
+
3. **Pillar 3: Doc $\longleftrightarrow$ Code Alignment**:
|
|
31
|
+
- Audits living ADRs and documented invariants against actual code implementations, identifying conflicting, stale, or missing code.
|
|
32
|
+
4. **Pillar 4: Negative Anti-Pattern Sentry**:
|
|
33
|
+
- Checks if any known `DO_NOT_USE` patterns, regression bug fixes, or failed approaches have resurfaced in the active working tree.
|
|
34
|
+
5. **Pillar 5: Technical Debt & Workaround Sentry**:
|
|
35
|
+
- Detects unresolved `TODO`/`FIXME`/`HACK` comments, dangerous type casts (`as any`), and drifted architectural commitments.
|
|
36
|
+
|
|
37
|
+
### Step 3: Execute Actionable Remediation Checklist
|
|
38
|
+
If the gate status is **WARN** or **FAIL**, the engine outputs an ordered remediation checklist. Execute the prioritized items:
|
|
39
|
+
- Prune or re-link orphaned code anchors via `memory reconcile --prune`.
|
|
40
|
+
- Adhere to active ADR decisions.
|
|
41
|
+
- Resolve flagged type assertions or negative pattern recurrences.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 💻 CLI Equivalents (Zero-MCP Fallback)
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Full terminal health dashboard
|
|
49
|
+
memory health
|
|
50
|
+
|
|
51
|
+
# Output raw JSON for CI/CD gating (exits 1 on FAIL)
|
|
52
|
+
memory health --json
|
|
53
|
+
|
|
54
|
+
# Interactively audit and prune orphaned code anchors
|
|
55
|
+
memory reconcile --prune
|
|
56
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muse-mesh
|
|
3
|
+
description: Multi-repo and monorepo cross-project knowledge mesh. Resolves memories across package boundaries, broadcasts shared invariants, and audits cross-package dependency contract integrity.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 🕸️ Muse Mesh (`muse-mesh`)
|
|
7
|
+
|
|
8
|
+
> **When to use**: Execute in monorepo environments (pnpm, npm, bun, lerna) or multi-repo projects when code spans multiple package boundaries or microservices.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Execution Workflow
|
|
13
|
+
|
|
14
|
+
### Step 1: Discover Monorepo Topology
|
|
15
|
+
Call the `muse_mesh_status` MCP tool (or run `memory mesh overview`):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"dir": "."
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Automatically inspects `pnpm-workspace.yaml`, `package.json` workspaces, or `lerna.json`, listing all detected package nodes and explicit mesh links.
|
|
24
|
+
|
|
25
|
+
### Step 2: Query Knowledge Across Package Boundaries
|
|
26
|
+
Call `muse_mesh_query` to search memories across all connected packages:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"query": "authentication session store",
|
|
31
|
+
"scope": "all"
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Results include origin package provenance badges (e.g. `[mesh:@scope/core]`), preventing agents in frontend apps from hallucinating backend contract violations.
|
|
36
|
+
|
|
37
|
+
### Step 3: Broadcast Shared Invariants to All Packages
|
|
38
|
+
When establishing a monorepo-wide rule (e.g., "All microservices must use JWT v2 tokens"):
|
|
39
|
+
- Use `memory mesh propagate --constraint "Use JWT v2 tokens across all services"`.
|
|
40
|
+
- The invariant is atomically stamped into every package's `.memory/CURRENT.md`.
|
|
41
|
+
|
|
42
|
+
### Step 4: Audit Cross-Package Contracts
|
|
43
|
+
Call `muse_mesh_audit` (or run `memory mesh check`):
|
|
44
|
+
- Verifies that cross-package imports match valid export entrypoints.
|
|
45
|
+
- Flags drifted cross-repo code anchors.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 💻 CLI Equivalents (Zero-MCP Fallback)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Display monorepo mesh topology and linked packages
|
|
53
|
+
memory mesh overview
|
|
54
|
+
|
|
55
|
+
# Query memories across all monorepo packages
|
|
56
|
+
memory mesh query "database pool" --scope all
|
|
57
|
+
|
|
58
|
+
# Audit cross-package contract integrity
|
|
59
|
+
memory mesh check
|
|
60
|
+
|
|
61
|
+
# Propagate a critical security constraint across all packages
|
|
62
|
+
memory mesh propagate --constraint "Never expose database connection strings"
|
|
63
|
+
|
|
64
|
+
# Explicitly link an external sibling repository
|
|
65
|
+
memory mesh link ../external-service
|
|
66
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muse-sync
|
|
3
|
+
description: Cross-agent knowledge sync and P2P gossip mesh protocol. Enables multi-agent swarms and isolated subagent teams to exchange insights, deduplicate knowledge, and resolve contradictions asynchronously.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 🤝 Muse Sync (`muse-sync`)
|
|
7
|
+
|
|
8
|
+
> **When to use**: Execute when coordinating multi-agent workflows (e.g., frontend, backend, and test subagents), sharing verified bug fixes between worktrees, or consolidating swarm learnings.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Execution Workflow
|
|
13
|
+
|
|
14
|
+
### Step 1: Check Peer Mesh & Vector Clock Status
|
|
15
|
+
Call the `muse_sync_status` MCP tool (or run `memory sync --status`):
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"dir": "."
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Returns peer agent vector clocks, tracked packet generations, and pending incoming packets.
|
|
24
|
+
|
|
25
|
+
### Step 2: Broadcast a Sealed Knowledge Packet
|
|
26
|
+
To export recent confirmed memories, bug fixes, and active constraints into a portable packet:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"project": "my-project",
|
|
31
|
+
"export_constraints": true
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The engine creates a cryptographically sealed `SyncPacket` with:
|
|
36
|
+
- Whole-packet SHA-256 checksum verification.
|
|
37
|
+
- Vector clock causal sequencing (`sender_id` + logical sequence).
|
|
38
|
+
- Automatic Vibeguard secret inspection prior to packaging.
|
|
39
|
+
|
|
40
|
+
### Step 3: Synchronize via Zero-Daemon Shared Pool
|
|
41
|
+
Call `muse_sync_pool` (or run `memory sync --pool`):
|
|
42
|
+
- Broadcasts un-synced memories into `.memory/sync_pool/`.
|
|
43
|
+
- Ingests new packets dropped by peer subagents.
|
|
44
|
+
- Eliminates duplicate entries automatically.
|
|
45
|
+
- Flags semantic contradictions with mutual `conflict_ids` and triggers dispute resolution.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 💻 CLI Equivalents (Zero-MCP Fallback)
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# View peer agent sync status and vector clocks
|
|
53
|
+
memory sync --status
|
|
54
|
+
|
|
55
|
+
# Broadcast confirmed memories to an exported packet
|
|
56
|
+
memory sync --broadcast --out ./shared_sync.json
|
|
57
|
+
|
|
58
|
+
# Ingest peer knowledge packet with secret scrubbing
|
|
59
|
+
memory sync --ingest ./shared_sync.json
|
|
60
|
+
|
|
61
|
+
# Bidirectionally sync with the shared filesystem gossip pool
|
|
62
|
+
memory sync --pool
|
|
63
|
+
```
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: muse-why
|
|
3
|
+
description: Historical rationale and code evolution explainer. Synthesizes past ADRs, bug fixes, trade-offs, and invariants to explain why code was written the way it is before refactoring.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 🤔 Muse Why (`muse-why`)
|
|
7
|
+
|
|
8
|
+
> **When to use**: Execute before modifying unfamiliar code, refactoring complex logic, or when encountering code patterns that look unusual or overly defensive.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🚀 Execution Workflow
|
|
13
|
+
|
|
14
|
+
### Step 1: Query Code Rationale ("Why is this code like this?")
|
|
15
|
+
Call the `muse_why` MCP tool:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"target": "src/mcp.ts",
|
|
20
|
+
"symbol": "createServer",
|
|
21
|
+
"query": "Why do we filter tools dynamically by profile?"
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The "Why" reasoner traces backwards through history and synthesizes:
|
|
26
|
+
1. **Governing Architecture Decisions**: Living ADRs that authorized or mandated this structure.
|
|
27
|
+
2. **Historical Bug Fixes**: Edge cases and production regressions that necessitated defensive checks.
|
|
28
|
+
3. **Accepted Trade-offs**: Documented compromises between performance, complexity, and safety.
|
|
29
|
+
4. **Timeless Constraints**: Core architectural laws that must remain invariant.
|
|
30
|
+
|
|
31
|
+
### Step 2: Audit Fragility & Bug Friction Clusters
|
|
32
|
+
Call the `muse_bug_clusters` MCP tool:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"dir": "."
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Clusters recurring issues across 5 core root causes:
|
|
41
|
+
- `concurrency_race`: Race conditions, lock timeouts, async synchronization.
|
|
42
|
+
- `type_mismatch`: Dangerous type bypasses, undefined property access.
|
|
43
|
+
- `state_drift`: Out-of-sync cache entries, missing invalidation.
|
|
44
|
+
- `resource_leak`: Unclosed file descriptors, runaway memory consumption.
|
|
45
|
+
- `edge_case`: Boundary errors, empty array handling, malformed input.
|
|
46
|
+
|
|
47
|
+
### Step 3: Check Pre-Flight Code & Memory Impact
|
|
48
|
+
Call `muse_code_impact` (or run `memory code-impact <file> --symbol <sym>`) to check direct callers, affected test suites, and composite risk levels before editing.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 💻 CLI Equivalents (Zero-MCP Fallback)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Query unified code & memory impact before editing
|
|
56
|
+
memory code-impact src/mcp.ts --symbol createServer
|
|
57
|
+
|
|
58
|
+
# View technical debt hotspots
|
|
59
|
+
memory tech-debt
|
|
60
|
+
```
|