记忆增加引擎 — Persistent memory engine with hotness-prioritized semantic recall.
Memories that are recalled more often appear first — not just keyword matches.
# Node.js API
const { MemorySystem } = require('./memory-enhancement-engine/memory.js');
const mem = new MemorySystem();
# CLI tool (view / search / compact)
node memory-enhancement-engine/memo.cjs status
node memory-enhancement-engine/memo.cjs query "something to find"
const { MemorySystem } = require('./memory-enhancement-engine/memory.js');
// Create engine (stores to MEMORY_STORE.json automatically)
const mem = new MemorySystem({ decayHalfLifeHours: 2 });
// Write a memory
mem.add({
content: "Paris is the capital of France.",
importance: 1.5,
metadata: { tags: ["geography", "fact"] }
});
// Semantic search
const results = mem.query("France capital");
console.log(results);
// Get recent memories
const recent = mem.recent(10);
// Compact old memories (summarize low-importance clusters)
mem.compact(5, 0.3);
| Method | Description |
|---|---|
| -------- | ------------- |
add(content, importance, metadata) | Write a memory |
retrieve(query, k) | Semantic search (returns sorted by score) |
getRecent(n) | Get N most recent memories |
remove(predicate) | Remove memories matching predicate |
compact(groupSize, minImportance) | Compact old memories into summaries |
getStatus() | Get engine stats (count, size, etc.) |
score = similarity × 0.5 + recency × 0.3 + hotness × 0.2
Where hotness = log(1 + access_count) × exp(-time_delta / 86400)
| Method | Command |
|---|---|
| -------- | --------- |
| Copy | Copy memory.js + memo.cjs to your project |
| ClawHub | clawhub install memory-enhancement-engine |
memory-enhancement-engine/
├── SKILL.md
├── memory.js # Core engine
├── memo.cjs # CLI tool
├── package.json
├── assets/
│ └── icon.svg
├── references/
│ ├── API_SPEC.md
│ └── USE_GUIDE.md
└── scripts/
├── init-memory.mjs # One-time migration
└── test-client.js
MIT
共 1 个版本