← 返回 Skills 市场
jameseball

Enhanced Memory

作者 JamesEBall · GitHub ↗ · v1.0.0
cross-platform ✓ 安全检测通过
994
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install enhanced-memory
功能描述
Enhanced memory search with hybrid vector+keyword scoring, temporal routing, filepath scoring, adaptive weighting, pseudo-relevance feedback, salience scoring, and knowledge graph cross-references. Replaces the default memory search with a 4-signal fusion retrieval system. Use when searching memories, indexing memory files, building cross-references, or scoring memory salience. Requires Ollama with nomic-embed-text model.
使用说明 (SKILL.md)

Enhanced Memory

Drop-in enhancement for OpenClaw's memory system. Replaces flat vector search with a 4-signal hybrid retrieval pipeline that achieved 0.782 MRR (vs ~0.45 baseline vector-only).

Setup

# Install Ollama and pull the embedding model
ollama pull nomic-embed-text

# Index your memory files (run from workspace root)
python3 skills/enhanced-memory/scripts/embed_memories.py

# Optional: build cross-reference graph
python3 skills/enhanced-memory/scripts/crossref_memories.py build

Re-run embed_memories.py whenever memory files change significantly.

Scripts

scripts/search_memory.py — Primary Search

Hybrid 4-signal retrieval with automatic adaptation:

python3 skills/enhanced-memory/scripts/search_memory.py "query" [top_n]

Signals fused:

  1. Vector similarity (0.4) — cosine similarity via nomic-embed-text embeddings
  2. Keyword matching (0.25) — query term overlap with chunk text
  3. Header matching (0.1) — query terms in section headers
  4. Filepath scoring (0.25) — query terms matching file/directory names

Automatic behaviors:

  • Temporal routing — date references ("yesterday", "Feb 8", "last Monday") get 3x boost on matching files
  • Adaptive weighting — when keyword overlap is low, shifts to 85% vector weight
  • Pseudo-relevance feedback (PRF) — when top score \x3C 0.45, expands query with terms from initial results and re-scores

scripts/enhanced_memory_search.py — JSON-Compatible Search

Same pipeline with JSON output format compatible with OpenClaw's memory_search tool:

python3 skills/enhanced-memory/scripts/enhanced_memory_search.py --json "query"

Returns {results: [{path, startLine, endLine, score, snippet, header}], ...}.

scripts/embed_memories.py — Indexing

Chunks all .md files in memory/ plus core workspace files (MEMORY.md, AGENTS.md, etc.) by markdown headers and embeds them:

python3 skills/enhanced-memory/scripts/embed_memories.py

Outputs memory/vectors.json. Batches embeddings in groups of 20, truncates chunks to 2000 chars.

scripts/memory_salience.py — Salience Scoring

Surfaces stale/important memory items for heartbeat self-prompting:

python3 skills/enhanced-memory/scripts/memory_salience.py          # Human-readable prompts
python3 skills/enhanced-memory/scripts/memory_salience.py --json   # Programmatic output
python3 skills/enhanced-memory/scripts/memory_salience.py --top 5  # More items

Scores importance × staleness considering: file type (topic > core > daily), size, access frequency, and query gap correlation.

scripts/crossref_memories.py — Knowledge Graph

Builds cross-reference links between memory chunks using embedding similarity:

python3 skills/enhanced-memory/scripts/crossref_memories.py build          # Build index
python3 skills/enhanced-memory/scripts/crossref_memories.py show \x3Cfile>    # Show refs for file
python3 skills/enhanced-memory/scripts/crossref_memories.py graph          # Graph statistics

Uses file-representative approach (top 5 chunks per file) to reduce O(n²) to manageable comparisons. Threshold: 0.75 cosine similarity.

Configuration

All tunable constants are at the top of each script. Key parameters:

Parameter Default Script Purpose
VECTOR_WEIGHT 0.4 search_memory.py Weight for vector similarity
KEYWORD_WEIGHT 0.25 search_memory.py Weight for keyword overlap
FILEPATH_WEIGHT 0.25 search_memory.py Weight for filepath matching
TEMPORAL_BOOST 3.0 search_memory.py Multiplier for date-matching files
PRF_THRESHOLD 0.45 search_memory.py Score below which PRF activates
SIMILARITY_THRESHOLD 0.75 crossref_memories.py Min similarity for cross-ref links
MODEL nomic-embed-text all Ollama embedding model

To use a different embedding model (e.g., mxbai-embed-large), change MODEL in each script and re-run embed_memories.py.

Integration

To replace the default memory search, point your agent's search tool at these scripts. The scripts expect:

  • memory/ directory relative to workspace root containing .md files
  • memory/vectors.json (created by embed_memories.py)
  • Ollama running locally on port 11434

All scripts use only Python stdlib + Ollama HTTP API. No pip dependencies.

安全使用建议
This skill appears to do what it says — locally index and search Markdown memories using Ollama embeddings — but review the following before installing or running: 1) Inspect the files under memory/ and the listed core files (MEMORY.md, USER.md, AGENTS.md, SOUL.md, research.md) and remove or relocate any sensitive content you don't want embedded. 2) Ensure OLLAMA_URL is the local Ollama instance (default http://localhost:11434). Do not point OLLAMA_URL to an untrusted remote server because the skill will send your memory text to that endpoint. 3) The scripts read access_log.json and query_log.json; if these logs contain sensitive queries, expect them to be used for salience scoring. 4) The tool writes memory/vectors.json and memory/crossrefs.json — treat these files as sensitive (they contain embeddings and references) and protect them accordingly. 5) Run the scripts in an isolated or non-production workspace if you are unsure. If you want tighter scope, set MEMORY_DIR to a directory containing only the content you consent to index.
功能分析
Type: OpenClaw Skill Name: enhanced-memory Version: 1.0.0 The OpenClaw AgentSkills skill bundle is classified as benign. All scripts are written in Python using only standard library modules, with no external dependencies, reducing supply chain risk. File access is confined to the designated 'memory/' directory and specific core workspace markdown files, which is appropriate for a memory management skill. Network communication is limited to a local Ollama instance (http://localhost:11434/api/embed) for generating embeddings. There is no evidence of data exfiltration, malicious execution, persistence mechanisms, or prompt injection attempts in SKILL.md that would instruct the agent to perform unauthorized actions.
能力评估
Purpose & Capability
Name/description (enhanced memory search using embeddings + keyword/filepath/temporal signals) match the provided scripts: embedding, search, cross-referencing, and salience scoring. Required resources (Ollama embeddings, local memory/ .md files, vectors.json) are coherent with the stated purpose.
Instruction Scope
SKILL.md and scripts instruct the agent to index all .md files under memory/ plus several core workspace files (MEMORY.md, AGENTS.md, USER.md, SOUL.md, research.md) and to read access_log.json and query_log.json for salience scoring. This is within scope for a memory tool, but it means the skill will read any Markdown in the workspace (including potentially sensitive files and search logs).
Install Mechanism
No install spec; instruction-only with bundled Python scripts. No external binary downloads or archived install actions are performed by the skill. The SKILL.md suggests installing Ollama and pulling the model, which is appropriate and expected.
Credentials
The scripts do not require secrets or credentials. They use environment overrides (MEMORY_DIR, OLLAMA_URL, EMBED_MODEL) which is reasonable. Important risk: embeddings and text are sent to the configured OLLAMA_URL — by default this is http://localhost:11434/api/embed (local Ollama), but if OLLAMA_URL is set to a remote endpoint it would transmit your memory contents to that host. Also, because the tool indexes workspace files and logs, it could expose PII or sensitive content if those files exist.
Persistence & Privilege
The skill is not always-enabled and does not modify other skills or system-wide configs. It writes vectors.json and crossrefs.json into the memory directory (expected for indexing). No elevated privileges or persistent background processes are requested.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install enhanced-memory
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /enhanced-memory 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of enhanced-memory: a drop-in replacement for OpenClaw's memory search with a 4-signal hybrid retrieval system (vector, keyword, header, filepath). - Adds adaptive weighting, temporal routing for date queries, pseudo-relevance feedback, and salience scoring for important/stale memory items. - Introduces memory cross-reference knowledge graph building and graph statistics tools. - Indexes and embeds markdown files using Ollama’s nomic-embed-text model; tunable parameters in each script. - Includes standalone scripts for memory search, indexing, salience scoring, and cross-reference management; no external Python dependencies required.
元数据
Slug enhanced-memory
版本 1.0.0
许可证
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Enhanced Memory 是什么?

Enhanced memory search with hybrid vector+keyword scoring, temporal routing, filepath scoring, adaptive weighting, pseudo-relevance feedback, salience scoring, and knowledge graph cross-references. Replaces the default memory search with a 4-signal fusion retrieval system. Use when searching memories, indexing memory files, building cross-references, or scoring memory salience. Requires Ollama with nomic-embed-text model. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 994 次。

如何安装 Enhanced Memory?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install enhanced-memory」即可一键安装,无需额外配置。

Enhanced Memory 是免费的吗?

是的,Enhanced Memory 完全免费(开源免费),可自由下载、安装和使用。

Enhanced Memory 支持哪些平台?

Enhanced Memory 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Enhanced Memory?

由 JamesEBall(@jameseball)开发并维护,当前版本 v1.0.0。

💬 留言讨论