opencode-fractal-memory 0.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/LICENSE +21 -0
- package/README.md +493 -0
- package/agent/memory-hints.md +98 -0
- package/agent/memory-researcher.md +56 -0
- package/commands/memory-auto-test.md +10 -0
- package/commands/memory-cache-status.md +13 -0
- package/commands/memory-check-context.md +4 -0
- package/commands/memory-compress.md +13 -0
- package/commands/memory-dashboard.md +23 -0
- package/commands/memory-delete.md +24 -0
- package/commands/memory-detect-topics.md +28 -0
- package/commands/memory-distill.md +35 -0
- package/commands/memory-drilldown-query.md +28 -0
- package/commands/memory-drilldown.md +11 -0
- package/commands/memory-extract-patterns.md +4 -0
- package/commands/memory-generate-embeddings.md +26 -0
- package/commands/memory-get.md +26 -0
- package/commands/memory-help.md +55 -0
- package/commands/memory-injection-feedback.md +26 -0
- package/commands/memory-injection-stats.md +11 -0
- package/commands/memory-list.md +4 -0
- package/commands/memory-llm-compress.md +34 -0
- package/commands/memory-mcp.md +20 -0
- package/commands/memory-prune.md +4 -0
- package/commands/memory-rate.md +48 -0
- package/commands/memory-reflect.md +37 -0
- package/commands/memory-replace.md +26 -0
- package/commands/memory-retrieve.md +34 -0
- package/commands/memory-search.md +28 -0
- package/commands/memory-session-stats.md +4 -0
- package/commands/memory-set.md +31 -0
- package/commands/memory-stats.md +11 -0
- package/commands/memory-summarize.md +29 -0
- package/commands/memory-tool-stats.md +4 -0
- package/commands/memory-total-tokens.md +10 -0
- package/commands/memory-verify.md +4 -0
- package/commands/memory-version.md +9 -0
- package/dist/cache.js +39 -0
- package/dist/config.js +120 -0
- package/dist/embeddings.js +125 -0
- package/dist/ensure-models.js +70 -0
- package/dist/file-summary.js +143 -0
- package/dist/frontmatter.js +28 -0
- package/dist/hnsw-index.js +138 -0
- package/dist/hooks/auto-discover.js +4 -0
- package/dist/hooks/auto-distill.js +120 -0
- package/dist/hooks/auto-retrieve/content.js +47 -0
- package/dist/hooks/auto-retrieve/detection.js +50 -0
- package/dist/hooks/auto-retrieve/formatting.js +19 -0
- package/dist/hooks/auto-retrieve/index.js +163 -0
- package/dist/hooks/auto-retrieve/scoring.js +56 -0
- package/dist/hooks/auto-retrieve.js +1 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/predictive-rating.js +87 -0
- package/dist/journal.js +279 -0
- package/dist/logging.js +147 -0
- package/dist/management/helpers.js +227 -0
- package/dist/management/router.js +48 -0
- package/dist/management/routes.js +197 -0
- package/dist/management-server.js +4 -0
- package/dist/management-standalone.js +31 -0
- package/dist/mcp/logging.js +57 -0
- package/dist/mcp/server.js +251 -0
- package/dist/mcp/transform.js +48 -0
- package/dist/mcp-server.js +18 -0
- package/dist/memory.js +2 -0
- package/dist/ollama.js +74 -0
- package/dist/plugin/hooks.js +168 -0
- package/dist/plugin/index.js +28 -0
- package/dist/plugin/init.js +109 -0
- package/dist/plugin/state.js +75 -0
- package/dist/plugin/tools.js +45 -0
- package/dist/plugin.js +2 -0
- package/dist/procedural/store.js +1 -0
- package/dist/procedural/types.js +1 -0
- package/dist/seed-nodes.js +804 -0
- package/dist/storage/compress-ops.js +129 -0
- package/dist/storage/compression/formatters.js +243 -0
- package/dist/storage/compression/index.js +107 -0
- package/dist/storage/compression/patterns.js +138 -0
- package/dist/storage/expiration.js +66 -0
- package/dist/storage/index.js +1 -0
- package/dist/storage/injection-events.js +82 -0
- package/dist/storage/lifecycle.js +65 -0
- package/dist/storage/maintenance.js +60 -0
- package/dist/storage/migrations/definitions.js +374 -0
- package/dist/storage/migrations/index.js +21 -0
- package/dist/storage/navigation.js +98 -0
- package/dist/storage/queries/base.js +44 -0
- package/dist/storage/queries/links.js +32 -0
- package/dist/storage/queries/nodes.js +189 -0
- package/dist/storage/queries/search-helpers.js +239 -0
- package/dist/storage/scoring.js +36 -0
- package/dist/storage/search.js +233 -0
- package/dist/storage/session-tracking.js +180 -0
- package/dist/storage/sqlite.js +329 -0
- package/dist/storage/tool-usage.js +56 -0
- package/dist/storage/types.js +1 -0
- package/dist/storage/utils.js +94 -0
- package/dist/tools/auto-test.js +24 -0
- package/dist/tools/cache-status.js +36 -0
- package/dist/tools/compress.js +186 -0
- package/dist/tools/core.js +307 -0
- package/dist/tools/dashboard.js +97 -0
- package/dist/tools/help.js +59 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/inject.js +91 -0
- package/dist/tools/injection-debug.js +48 -0
- package/dist/tools/journal.js +105 -0
- package/dist/tools/llm-compress.js +41 -0
- package/dist/tools/middle-term.js +68 -0
- package/dist/tools/playbook.js +64 -0
- package/dist/tools/reflect.js +291 -0
- package/dist/tools/search.js +188 -0
- package/dist/tools/session.js +189 -0
- package/dist/tools/shared.js +74 -0
- package/dist/tools/skill.js +37 -0
- package/dist/tools/stats.js +256 -0
- package/dist/tools/version.js +13 -0
- package/dist/tools.js +18 -0
- package/dist/utils/hybridScore.js +67 -0
- package/management/public/app.js +1529 -0
- package/management/public/index.html +486 -0
- package/management/public/three.min.js +6 -0
- package/package.json +65 -0
- package/scripts/download-models.ts +16 -0
- package/scripts/postinstall.cjs +30 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Compress memory nodes into summaries
|
|
3
|
+
---
|
|
4
|
+
Compress old memory nodes into higher-level summaries using fractal compression. Use memory_compress with scope="all" and force=true to create L1 summaries from L0 nodes. Shows how many nodes were compressed and how many summaries were created.
|
|
5
|
+
|
|
6
|
+
Compressed summaries have structured format:
|
|
7
|
+
- **Decisions**: "decided", "chose", "will use"
|
|
8
|
+
- **Files**: modified/referenced (.ts, .py, .json, etc.)
|
|
9
|
+
- **Tools**: commands used (memory_*, git, npm, bun)
|
|
10
|
+
- **Patterns**: conventions, learnings
|
|
11
|
+
- **Topics**: section headings from sources
|
|
12
|
+
|
|
13
|
+
Example: Run /memory-compress with force=true to compress all eligible nodes now.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Display memory dashboard with top nodes by usefulness, type distribution, and recent activity
|
|
3
|
+
---
|
|
4
|
+
Display the memory dashboard showing:
|
|
5
|
+
|
|
6
|
+
1. **Top nodes by access count** - Which memories are used most
|
|
7
|
+
2. **Type distribution** - Breakdown by type (note, core, summary, etc.)
|
|
8
|
+
3. **Compression health** - Tree depth, fractal dimension, embedding coverage
|
|
9
|
+
4. **Usefulness tracking** - timesUsed, usefulnessScore for top nodes
|
|
10
|
+
|
|
11
|
+
Useful for understanding what's in memory and identifying compression opportunities.
|
|
12
|
+
|
|
13
|
+
**Usage:**
|
|
14
|
+
```
|
|
15
|
+
memory_dashboard
|
|
16
|
+
memory_dashboard { scope: "project", limit: 20 }
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Arguments:**
|
|
20
|
+
- `scope`: "all" | "global" | "project" (default: "all")
|
|
21
|
+
- `limit`: Number of top nodes to show (default: 10)
|
|
22
|
+
- `show_tree_depth`: boolean – include the tree‑depth line in the Compression Health section (default: true)
|
|
23
|
+
- `show_embedding_coverage`: boolean – include the “Nodes with embeddings” line (default: true)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Delete a memory node by ID or label - use with caution
|
|
3
|
+
---
|
|
4
|
+
Delete a memory node. Use with caution - deletion is permanent.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Remove outdated or incorrect memories
|
|
8
|
+
- Clean up duplicate entries
|
|
9
|
+
- Delete test/temporary nodes
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `id` OR `label` (one required): Which node to delete
|
|
13
|
+
- `scope` (optional): "global" or "project"
|
|
14
|
+
|
|
15
|
+
**Usage:**
|
|
16
|
+
```
|
|
17
|
+
memory_delete(id="ab3f2")
|
|
18
|
+
memory_delete(label="outdated-decision")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Tips:**
|
|
22
|
+
- Use `memory_get` first to verify correct node
|
|
23
|
+
- Deletion is permanent - no undo
|
|
24
|
+
- Consider using `memory_compress` instead to keep summary
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Detect topic boundaries - group related memories into semantic clusters
|
|
3
|
+
---
|
|
4
|
+
Detect topic boundaries by grouping related memories into semantic clusters.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Find related memories
|
|
8
|
+
- Identify topic structure
|
|
9
|
+
- Organize memory into groups
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `scope` (optional): "all", "global", or "project" (default: all)
|
|
13
|
+
- `min_similarity` (optional): 0-1, similarity threshold (default: 0.7)
|
|
14
|
+
|
|
15
|
+
**Usage:**
|
|
16
|
+
```
|
|
17
|
+
memory_detect_topics()
|
|
18
|
+
memory_detect_topics(min_similarity=0.8)
|
|
19
|
+
memory_detect_topics(scope="project")
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Output:**
|
|
23
|
+
Shows clusters of related memories with first 3 nodes each.
|
|
24
|
+
|
|
25
|
+
**Tips:**
|
|
26
|
+
- Lower min_similarity = more clusters
|
|
27
|
+
- Good for organizing memory
|
|
28
|
+
- Use after building up a memory corpus
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Extract actionable rules from lesson nodes - update rule:mandatory nodes
|
|
3
|
+
---
|
|
4
|
+
Extract actionable rules from recent lesson nodes and update rule:mandatory nodes.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- After memory_reflect created lessons
|
|
8
|
+
- To turn failures into rules
|
|
9
|
+
- Update behavioral rules
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `dry_run` (optional): true to preview without applying
|
|
13
|
+
- `use_llm` (optional): true for LLM-enhanced rules
|
|
14
|
+
|
|
15
|
+
**Usage:**
|
|
16
|
+
```
|
|
17
|
+
memory_distill()
|
|
18
|
+
memory_distill(dry_run=true)
|
|
19
|
+
memory_distill(use_llm=true)
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**How it works:**
|
|
23
|
+
1. Finds recent lesson nodes
|
|
24
|
+
2. Extracts unique fixes
|
|
25
|
+
3. Deduplicates and refines
|
|
26
|
+
4. Updates rule:mandatory nodes
|
|
27
|
+
|
|
28
|
+
**Output:**
|
|
29
|
+
- List of rules to add/update
|
|
30
|
+
- Confirmation after applying
|
|
31
|
+
|
|
32
|
+
**Tips:**
|
|
33
|
+
- Run memory_reflect first to create lessons
|
|
34
|
+
- Use `use_llm=true` for better rules
|
|
35
|
+
- Rules apply next session
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Top-down drilldown query - start from summaries, get specific details
|
|
3
|
+
---
|
|
4
|
+
Top-down drilldown from high-level summaries to specific details.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Explore memory hierarchically
|
|
8
|
+
- Start broad, go specific
|
|
9
|
+
- Navigate memory structure
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `query` (required): Your question or intent
|
|
13
|
+
- `max_results` (optional): Max results (default: 20)
|
|
14
|
+
|
|
15
|
+
**Usage:**
|
|
16
|
+
```
|
|
17
|
+
memory_drilldown_query("How does auth work?")
|
|
18
|
+
memory_drilldown_query("What decisions were made?", max_results=10)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**How it works:**
|
|
22
|
+
1. Searches high-level summaries first
|
|
23
|
+
2. Follows parent links to lower-level details
|
|
24
|
+
3. Returns hierarchical results
|
|
25
|
+
|
|
26
|
+
**Tips:**
|
|
27
|
+
- Good for exploration
|
|
28
|
+
- Use with memory_search for direct lookup
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Drill down into a memory node
|
|
3
|
+
---
|
|
4
|
+
Retrieve a memory node with the full path back to its source nodes. Use memory_drilldown to show the chain of summaries from current node to original sources. Provide an id or label.
|
|
5
|
+
|
|
6
|
+
The result includes:
|
|
7
|
+
- The current node content
|
|
8
|
+
- The path of parent nodes back to original sources
|
|
9
|
+
- The chain of summaries leading to this node
|
|
10
|
+
|
|
11
|
+
Structured summaries (L1+) contain: decisions, files, tools, patterns, topics sections.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Extract cross-layer patterns from memory nodes
|
|
3
|
+
---
|
|
4
|
+
Extract cross-layer patterns from memory nodes using memory_extract_patterns. This tool finds recurring decisions, preferences, conventions, tools, and files across diverse topics and creates a pattern summary node at L1. Use this to distill learnings from multiple different projects or sessions into consolidated knowledge.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate embeddings for nodes without them - enables semantic search
|
|
3
|
+
---
|
|
4
|
+
Generate embeddings for memory nodes that don't have them. Enables semantic search and similarity-based compression.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- After importing nodes without embeddings
|
|
8
|
+
- Fix nodes that failed embedding generation
|
|
9
|
+
- Enable similarity search
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `scope` (optional): "all", "global", or "project" (default: project)
|
|
13
|
+
- `level` (optional): Only generate for this level
|
|
14
|
+
- `dry_run` (optional): true to preview without generating
|
|
15
|
+
|
|
16
|
+
**Usage:**
|
|
17
|
+
```
|
|
18
|
+
memory_generate_embeddings()
|
|
19
|
+
memory_generate_embeddings(dry_run=true)
|
|
20
|
+
memory_generate_embeddings(scope="global")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Tips:**
|
|
24
|
+
- Use `dry_run=true` first to see candidates
|
|
25
|
+
- Takes a while for large memory corpora
|
|
26
|
+
- Failed nodes logged in console
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Get a memory node by ID or label - retrieve full content
|
|
3
|
+
---
|
|
4
|
+
Get the full content of a memory node. Use after `memory_search` finds relevant nodes.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Retrieve full details from a node found via search
|
|
8
|
+
- Inspect a specific memory's content
|
|
9
|
+
- Check memory properties (level, type, importance)
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `id` (optional): Node ID or prefix (e.g., "ab3f2")
|
|
13
|
+
- `label` (optional): Node label (e.g., "auth-choice-supabase")
|
|
14
|
+
- `scope` (optional): "global" or "project"
|
|
15
|
+
|
|
16
|
+
**Usage:**
|
|
17
|
+
```
|
|
18
|
+
memory_get(id="ab3f2")
|
|
19
|
+
memory_get(label="auth-choice-supabase")
|
|
20
|
+
memory_get("ab3f2") # shorthand
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Tips:**
|
|
24
|
+
- Use label for cleaner access, ID for exact matches
|
|
25
|
+
- Prefix matching works (first 8 chars usually enough)
|
|
26
|
+
- Check properties to understand node's importance/type
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show all available memory commands
|
|
3
|
+
---
|
|
4
|
+
Show me all available memory commands:
|
|
5
|
+
- `memory_stats` — fractal memory statistics
|
|
6
|
+
- `memory_dashboard` — top nodes by access, type distribution, compression health
|
|
7
|
+
- `memory_list` — list all memory nodes
|
|
8
|
+
- `memory_search` — semantic / BM25 search
|
|
9
|
+
- `memory_get` — get a node by ID or label
|
|
10
|
+
- `memory_fetch` — fetch a node by exact label (returns JSON)
|
|
11
|
+
- `memory_set` — create or update a node
|
|
12
|
+
- `memory_delete` — delete a node
|
|
13
|
+
- `memory_replace` — replace content within a node
|
|
14
|
+
- `memory_drilldown` — fractal retrieval (summary → source nodes)
|
|
15
|
+
- `memory_drilldown_query` — top-down drilldown by intent/query
|
|
16
|
+
- `memory_compress` — compress nodes into level-up summaries
|
|
17
|
+
- `memory_llm_compress` — LLM-powered compression
|
|
18
|
+
- `memory_extract_patterns` — extract cross-layer patterns
|
|
19
|
+
- `memory_prune` — find and remove stale/unused nodes
|
|
20
|
+
- `memory_verify` — verify node correctness, boost confidence
|
|
21
|
+
- `memory_rate` — mark a node as helpful, adjust usefulness
|
|
22
|
+
- `memory_summarize` — generate an LLM prompt to summarize a node
|
|
23
|
+
- `memory_check_context` — token usage check
|
|
24
|
+
- `memory_total_tokens` — complete token analysis (memory + conversation)
|
|
25
|
+
- `memory_injection_stats` — injection efficiency metrics
|
|
26
|
+
- `memory_injection_feedback` — rate injected memory usefulness
|
|
27
|
+
- `memory_tool_stats` — tool call statistics (durations, success rates)
|
|
28
|
+
- `memory_session_stats` — session forensics (tool sequence, files touched)
|
|
29
|
+
- `memory_reflect` — analyze a session, create lesson nodes
|
|
30
|
+
- `memory_distill` — extract actionable rules from lesson nodes
|
|
31
|
+
- `memory_inject` — inject relevant memories into the prompt
|
|
32
|
+
- `memory_injection_debug` — show last injection details
|
|
33
|
+
- `memory_middle_term` — retrieve middle-term context snapshots
|
|
34
|
+
- `memory_cache_status` — show working memory cache usage
|
|
35
|
+
- `memory_version` — show installed plugin version
|
|
36
|
+
- `memory_auto_test` — test auto-retrieval pipeline
|
|
37
|
+
- `memory_detect_topics` — detect topic boundaries
|
|
38
|
+
- `memory_generate_embeddings` — generate embeddings for nodes that lack them
|
|
39
|
+
- `memory_help` — show this help
|
|
40
|
+
|
|
41
|
+
Also explain what fractal memory is:
|
|
42
|
+
- Hierarchical compression: L0 (raw) → L1 (weekly) → L2 (monthly) → L3 (quarterly)
|
|
43
|
+
- Related nodes group into summaries via embedding similarity
|
|
44
|
+
- Compressed nodes have structured format with sections for: decisions, files, tools, patterns, topics
|
|
45
|
+
- Use `memory_drilldown` to see the path from summary back to original sources
|
|
46
|
+
- Use `memory_drilldown_query` for intent-based exploration (starts from summaries, drills down to details)
|
|
47
|
+
- Sticky nodes bypass compression — use `sticky=true` on `memory_set` for critical info
|
|
48
|
+
- Confidence scoring: nodes track reliability, verified nodes rank higher in `memory_search`
|
|
49
|
+
- Memory linking: use `[[label]]` in node content to reference other nodes (e.g., `See [[sqlite-setup]] for details`)
|
|
50
|
+
- Performance: embeddings stored as binary (Float32Array), HNSW index for O(log n) search, BM25 pre-computed
|
|
51
|
+
- Session tracking: all tool calls are tracked with session correlation for effectiveness analysis
|
|
52
|
+
- Behavioral rules: tagged nodes (`tag: rule:mandatory/standard/suggestion`) are injected every cycle to guide tool usage
|
|
53
|
+
- Improvement system: When you discover an error, add the correct pattern to the appropriate rules node
|
|
54
|
+
- Memory trigger — Agent can use `[[memory: query]]` in responses to request memory context inline
|
|
55
|
+
- Session context — Project card + git context auto-injected at session start
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Rate injected memories - upvote helpful, downvote irrelevant
|
|
3
|
+
---
|
|
4
|
+
Rate the usefulness of injected memories after completing a task. Helps improve future injection relevance.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- After a task using injected memory
|
|
8
|
+
- Filter good vs irrelevant injections
|
|
9
|
+
- Improve memory system
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `session_id` (required): From memory_injection_stats
|
|
13
|
+
- `upvotes` (optional): Number of helpful injections (default: 0)
|
|
14
|
+
- `downvotes` (optional): Number of irrelevant injections (default: 0)
|
|
15
|
+
- `task_outcome` (optional): "success", "partial", or "failed"
|
|
16
|
+
- `needed_nodes` (optional): Labels that would have helped but weren't injected
|
|
17
|
+
|
|
18
|
+
**Usage:**
|
|
19
|
+
```
|
|
20
|
+
memory_injection_feedback(session_id="abc123", upvotes=3, downvotes=1, task_outcome="success")
|
|
21
|
+
memory_injection_feedback(session_id="abc123", upvotes=0, downvotes=2, task_outcome="partial")
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Tips:**
|
|
25
|
+
- Use `memory_injection_stats` to find session IDs
|
|
26
|
+
- Helps the system learn what memories are useful
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show injection efficiency metrics
|
|
3
|
+
---
|
|
4
|
+
Show me my memory injection statistics including:
|
|
5
|
+
- How many times memory was injected
|
|
6
|
+
- Total tool calls triggered from injected memory
|
|
7
|
+
- Average nodes per injection
|
|
8
|
+
- Effectiveness scores if available
|
|
9
|
+
- Recent injection history
|
|
10
|
+
|
|
11
|
+
Use memory_injection_stats with limit=10.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Compress old memory nodes using LLM summarization - automatic AI-powered compression
|
|
3
|
+
---
|
|
4
|
+
Automatically compress old memory nodes using LLM summarization. Uses your configured OpenCode model.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Compress many old nodes at once
|
|
8
|
+
- Create semantic summaries via AI
|
|
9
|
+
- Reduce token usage
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `scope` (optional): "all", "global", or "project" (default: all)
|
|
13
|
+
- `level` (optional): 0-3, which level to compress (default: 0)
|
|
14
|
+
- `dry_run` (optional): true to preview without compressing
|
|
15
|
+
- `force` (optional): true to bypass age check
|
|
16
|
+
|
|
17
|
+
**Usage:**
|
|
18
|
+
```
|
|
19
|
+
memory_llm_compress() # Compress all level 0 nodes
|
|
20
|
+
memory_llm_compress(level=1) # Compress level 1 nodes
|
|
21
|
+
memory_llm_compress(dry_run=true) # Preview what would compress
|
|
22
|
+
memory_llm_compress(scope="project") # Only project scope
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Compression levels:**
|
|
26
|
+
- Level 0 → 1: 7 days old
|
|
27
|
+
- Level 1 → 2: 30 days old
|
|
28
|
+
- Level 2 → 3: 90 days old
|
|
29
|
+
- Level 3 → 4: 180 days old
|
|
30
|
+
|
|
31
|
+
**Tips:**
|
|
32
|
+
- Use `dry_run=true` first to see candidates
|
|
33
|
+
- Compressed nodes keep parent links
|
|
34
|
+
- New summaries created at next level
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Start the fractal memory MCP server for AI tool access
|
|
3
|
+
---
|
|
4
|
+
Start the MCP server for external AI tool access to the memory store.
|
|
5
|
+
|
|
6
|
+
The MCP server exposes 7 tools (memory_search, memory_get, memory_fetch, memory_list,
|
|
7
|
+
memory_stats, memory_set, memory_delete) and 2 resources (memory://stats/project,
|
|
8
|
+
memory://stats/global) via the Model Context Protocol over stdio.
|
|
9
|
+
|
|
10
|
+
To configure in opencode.jsonc:
|
|
11
|
+
```jsonc
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"fractal-memory": {
|
|
15
|
+
"command": "bun",
|
|
16
|
+
"args": ["run", "PATH_TO_PLUGIN/dist/mcp-server.js"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Find and prune stale/unused memory nodes
|
|
3
|
+
---
|
|
4
|
+
Find and prune stale/unused memory nodes using memory_prune. By default runs in dry-run mode (shows what would be pruned). Use dryRun=false to actually delete nodes that haven't been accessed recently or have low importance.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# memory_rate
|
|
2
|
+
|
|
3
|
+
Mark a memory node as helpful (or not) and optionally adjust its usefulness score.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
memory_rate { id?: string, label?: string, scope?: "global" | "project", helpful?: boolean, usefulness_score?: number }
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Arguments
|
|
12
|
+
|
|
13
|
+
| Arg | Type | Required | Description |
|
|
14
|
+
|-----|------|-----------|-------------|
|
|
15
|
+
| `id` | string | No* | Memory node ID (mutually exclusive with label) |
|
|
16
|
+
| `label` | string | No* | Memory node label (mutually exclusive with id) |
|
|
17
|
+
| `scope` | "global" \| "project" | No | Scope of the node (default: "project") |
|
|
18
|
+
| `helpful` | boolean | No | If true, increments timesHelpful counter |
|
|
19
|
+
| `usefulness_score` | number (0-5) | No | Rate how helpful this memory was |
|
|
20
|
+
|
|
21
|
+
*Must provide either `id` or `label`
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
Rate a memory as helpful with score 4:
|
|
26
|
+
```
|
|
27
|
+
memory_rate { label: "rule:mandatory:memory", helpful: true, usefulness_score: 4 }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Mark a node as not helpful:
|
|
31
|
+
```
|
|
32
|
+
memory_rate { id: "abc123", helpful: false }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Just update the usefulness score without incrementing counter:
|
|
36
|
+
```
|
|
37
|
+
memory_rate { label: "my-project-config", usefulness_score: 5 }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## How it works
|
|
41
|
+
|
|
42
|
+
The usefulness tracking system measures how valuable each memory node is to the agent:
|
|
43
|
+
|
|
44
|
+
- **usefulness_score**: Self-reported rating (0-5) of how useful the memory was
|
|
45
|
+
- **timesHelpful**: Counter incremented each time the agent marks memory as helpful
|
|
46
|
+
- **timesUsed**: Automatically incremented each time memory is returned in search
|
|
47
|
+
|
|
48
|
+
These scores influence future retrieval rankings - memories rated more useful will be returned higher in search results.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze session failures to create lesson nodes - learn from mistakes
|
|
3
|
+
---
|
|
4
|
+
Analyze a session to create lesson nodes from tool failures. Call after session ends to learn from mistakes.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- After a session with failures
|
|
8
|
+
- To create reusable lessons
|
|
9
|
+
- Before memory_distill
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `session_id` (optional): Session to analyze (defaults to current)
|
|
13
|
+
- `dry_run` (optional): true to preview without creating nodes
|
|
14
|
+
- `use_llm` (optional): true for LLM-enhanced analysis
|
|
15
|
+
|
|
16
|
+
**Usage:**
|
|
17
|
+
```
|
|
18
|
+
memory_reflect()
|
|
19
|
+
memory_reflect(session_id="abc123")
|
|
20
|
+
memory_reflect(dry_run=true)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Output:**
|
|
24
|
+
- Session summary (status, total calls, failed calls)
|
|
25
|
+
- Failed tool analysis with patterns
|
|
26
|
+
- Files with failures
|
|
27
|
+
- Generated lessons
|
|
28
|
+
|
|
29
|
+
**Lesson patterns:**
|
|
30
|
+
- `memory_drilldown` → "use memory_search first"
|
|
31
|
+
- `memory_get` → "verify label exists"
|
|
32
|
+
- `read/glob` → "check file exists"
|
|
33
|
+
- `edit` → "read file first"
|
|
34
|
+
|
|
35
|
+
**Tips:**
|
|
36
|
+
- Creates `lesson:<timestamp>` nodes
|
|
37
|
+
- Use with memory_distill to create rules
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Replace content in a memory node - edit without rewriting full node
|
|
3
|
+
---
|
|
4
|
+
Replace specific text in a memory node. Good for small edits without rewriting the entire node.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Fix typos in stored memories
|
|
8
|
+
- Update a detail without replacing full content
|
|
9
|
+
- Fix outdated information
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `id` OR `label` (one required): Which node to edit
|
|
13
|
+
- `oldText`: Exact text to replace
|
|
14
|
+
- `newText`: Replacement text
|
|
15
|
+
- `scope` (optional): "global" or "project"
|
|
16
|
+
|
|
17
|
+
**Usage:**
|
|
18
|
+
```
|
|
19
|
+
memory_replace(id="ab3f2", oldText="Chose Supabase", newText="Chose Clerk")
|
|
20
|
+
memory_replace(label="auth-choice", oldText="v1", newText="v2")
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Tips:**
|
|
24
|
+
- Use `memory_get` first to see exact text
|
|
25
|
+
- Supports fuzzy whitespace matching
|
|
26
|
+
- Best for targeted fixes, not full rewrites
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Retrieve memory nodes as JSON - programmatic access to search results
|
|
3
|
+
---
|
|
4
|
+
Retrieve raw memory nodes as JSON for programmatic consumption. Returns array of node objects.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Process memory results in scripts
|
|
8
|
+
- Access multiple fields (id, label, level, importance)
|
|
9
|
+
- Integrate with external tools
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `query` (required): Search query
|
|
13
|
+
- `limit` (optional): Max nodes to return (default: 10)
|
|
14
|
+
- `min_level` (optional): Minimum compression level (0=raw)
|
|
15
|
+
- `max_level` (optional): Maximum compression level
|
|
16
|
+
- `bm25_weight` (optional): 0-1, keyword vs semantic weight (default: 0.4)
|
|
17
|
+
- `query_text` (optional): Explicit query text for BM25
|
|
18
|
+
|
|
19
|
+
**Usage:**
|
|
20
|
+
```
|
|
21
|
+
memory_retrieve("authentication")
|
|
22
|
+
memory_retrieve("auth", limit=5)
|
|
23
|
+
memory_retrieve("session", min_level=0, max_level=1)
|
|
24
|
+
memory_retrieve("bug", bm25_weight=0.8) # More keyword-focused
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Returns:**
|
|
28
|
+
```json
|
|
29
|
+
[{"id":"...","label":"...","scope":"project","level":0,"content":"...","importance":0.8}]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Tips:**
|
|
33
|
+
- Use for automation/scripts
|
|
34
|
+
- Check memory_search first for human-readable results
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Search memory for relevant context - call when you need past decisions, patterns, or information
|
|
3
|
+
---
|
|
4
|
+
Search your memory for relevant context. Call this tool when you need to recall:
|
|
5
|
+
- Past decisions and why they were made
|
|
6
|
+
- Patterns that worked or failed
|
|
7
|
+
- User preferences and conventions
|
|
8
|
+
- Bug workarounds and solutions
|
|
9
|
+
|
|
10
|
+
**How it works:**
|
|
11
|
+
- Provide keywords describing what you're looking for
|
|
12
|
+
- Search uses semantic similarity + keyword matching (BM25)
|
|
13
|
+
- Returns distilled summaries ranked by relevance
|
|
14
|
+
- Follows memory links to related nodes
|
|
15
|
+
|
|
16
|
+
**Usage:**
|
|
17
|
+
```
|
|
18
|
+
memory_search("authentication implementation patterns")
|
|
19
|
+
memory_search("SQLite concurrency issues")
|
|
20
|
+
memory_search("user prefers", bm25_weight=0.6) # More keyword-focused
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Tips:**
|
|
24
|
+
- Use specific terms: "session tracking" > "stuff we did"
|
|
25
|
+
- Check summary content first, drill down with `memory_drilldown` for full details
|
|
26
|
+
- Memory nodes have levels: L0=raw, L1=summaries - use min_level to filter
|
|
27
|
+
- **After using memory**: The system auto-rates useful memories after successful edits
|
|
28
|
+
- **Filter by usefulness**: Use `min_usefulness` to only show high-rated memories (0-5)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create or update a memory node - store decisions, preferences, lessons learned
|
|
3
|
+
---
|
|
4
|
+
Create or update a memory node. Use to store important information that you want to retrieve later.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Store architecture decisions ("Chose X because Y")
|
|
8
|
+
- Save user preferences ("User prefers concise responses")
|
|
9
|
+
- Record lessons learned ("Package Y needs --legacy-peer-deps")
|
|
10
|
+
- Remember bug workarounds
|
|
11
|
+
|
|
12
|
+
**Arguments:**
|
|
13
|
+
- `content` (required): The memory content
|
|
14
|
+
- `label` (optional): Human-readable label, e.g., "auth-decision"
|
|
15
|
+
- `scope` (optional): "global" or "project" (default: project)
|
|
16
|
+
- `summary` (optional): Brief summary for search results
|
|
17
|
+
- `type` (optional): "event", "episode", "concept", "summary", "core", "note"
|
|
18
|
+
- `sticky` (optional): true to prevent compression
|
|
19
|
+
- `importance` (optional): 0-1, higher = more important
|
|
20
|
+
- `usefulness_score` (optional): Rate how helpful (0-5)
|
|
21
|
+
|
|
22
|
+
**Usage:**
|
|
23
|
+
```
|
|
24
|
+
memory_set("Chose Supabase for auth because it provides social login + built-in user management", label="auth-choice-supabase", type="event", importance=0.8)
|
|
25
|
+
memory_set("Remember: User prefers inline code explanations over comments", label="user-pref-concise", sticky=true)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Tips:**
|
|
29
|
+
- Use `sticky=true` for critical rules that must survive compression
|
|
30
|
+
- Rate memories with `usefulness_score` after successful retrieval
|
|
31
|
+
- Link related nodes with `parent_ids`
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show fractal memory statistics
|
|
3
|
+
---
|
|
4
|
+
Show me my memory stats including:
|
|
5
|
+
- Nodes per level (L0-L4 hierarchy)
|
|
6
|
+
- Compression ratios and fractal dimension
|
|
7
|
+
- Tree depth and children per node
|
|
8
|
+
- HNSW index stats (nodes indexed, dimension)
|
|
9
|
+
- Storage info (binary embeddings vs JSON)
|
|
10
|
+
|
|
11
|
+
Use memory_stats with scope="all".
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Generate a prompt to summarize a memory node via LLM - manual summary creation
|
|
3
|
+
---
|
|
4
|
+
Generate an LLM prompt to summarize a memory node. Use this before creating a manual summary.
|
|
5
|
+
|
|
6
|
+
**When to use:**
|
|
7
|
+
- Prepare better summaries before compression
|
|
8
|
+
- Get help summarizing complex memories
|
|
9
|
+
- Manual summary creation workflow
|
|
10
|
+
|
|
11
|
+
**Arguments:**
|
|
12
|
+
- `id` OR `label` (one required): Which node to summarize
|
|
13
|
+
- `scope` (optional): "global" or "project"
|
|
14
|
+
|
|
15
|
+
**Usage:**
|
|
16
|
+
```
|
|
17
|
+
memory_summarize(id="ab3f2")
|
|
18
|
+
memory_summarize(label="auth-choice")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Output:**
|
|
22
|
+
Returns a prompt you can paste into an LLM. After getting the summary, create a new node:
|
|
23
|
+
```
|
|
24
|
+
memory_set(content="<summary>", type="summary", level=1, parent_ids="ab3f2")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Tips:**
|
|
28
|
+
- Use level=1 for summaries of level=0 nodes
|
|
29
|
+
- Include parent_ids to link back to original
|