← Back to Skills Marketplace
whoisme007

Co Occurrence Engine

by whoisme007 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
153
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install co-occurrence-engine
Description
独立的 Hebbian 共现图引擎,记录记忆共现,计算关联权重,支持关联查询和数据库维护,服务星型记忆架构。
README (SKILL.md)

co-occurrence-engine

独立的 Hebbian 共现图引擎,为星型记忆架构提供记忆关联发现与权重计算服务。

功能

  • 共现记录:自动记录同时被检索的记忆对,建立关联边
  • 关联查询:查询与指定记忆最相关的其他记忆
  • 权重计算:基于使用频率与时间衰减计算关联强度
  • 统计信息:提供边数、唯一记忆数、平均权重等统计
  • 维护工具:清理过旧的边,保持数据库健康

架构

┌─────────────────────────────────────────────────────┐
│               共现图引擎 (独立插件)                  │
│                                                     │
│  • CoOccurrenceEngine 类                            │
│  • SQLite 数据库 (共现图)                            │
│  • 遗忘曲线集成 (可选)                               │
└─────────────────────────────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────┐
│               适配器 (co_occurrence_adapter)         │
│                                                     │
│  • 实现统一记忆接口                                   │
│  • 注册到星型架构适配器框架                           │
└─────────────────────────────────────────────────────┘

核心类

CoOccurrenceEngine

主引擎类,提供共现图的所有操作。

engine = CoOccurrenceEngine(db_path="~/.config/cortexgraph/co_occurrence.db")

主要方法

  • record_co_occurrence(memory_ids: List[str], context: str = "")
  • get_co_occurrence_score(memory_id: str, related_ids: List[str] = None) -> float
  • get_related_memories(memory_id: str, top_k: int = 10) -> List[Tuple[str, float]]
  • get_stats() -> Dict
  • decay_old_edges(days: int = 90) -> int

## 数据库

默认数据库位置:`~/.config/cortexgraph/co_occurrence.db`

表结构:
```sql
CREATE TABLE co_occurrence (
    memory_a TEXT,
    memory_b TEXT,
    weight REAL,
    last_updated TEXT,
    created_at TEXT,
    PRIMARY KEY (memory_a, memory_b)
)

集成

1. 独立使用

from scripts.co_occurrence_tracker import CoOccurrenceEngine

engine = CoOccurrenceEngine()
engine.record_co_occurrence(["mem_001", "mem_002"])
related = engine.get_related_memories("mem_001")

2. 通过适配器集成

from adapter_factory import AdapterFactory

factory = AdapterFactory()
adapter = factory.get_adapter("co_occurrence")
results = adapter.search("mem_001", max_results=10)

配置

通过环境变量或配置文件:

  • CO_OCCURRENCE_DB_PATH:数据库路径(默认:~/.config/cortexgraph/co_occurrence.db
  • CO_OCCURRENCE_HALF_LIFE_DAYS:衰减半衰期(默认:30天)

依赖

  • Python 3.8+
  • SQLite3(内置)
  • 可选forgetting-curve 插件(提供更精确的衰减计算)

版本历史

  • v0.1.0(初始版本):从 memory-sync-enhanced 中提取的共现图引擎
Usage Guidance
This skill appears coherent and local-only: it creates and updates a SQLite DB at ~/.config/cortexgraph/co_occurrence.db and does not contact external endpoints or request secrets. Before installing, consider: (1) any memory IDs you pass to the tracker will be stored on disk — avoid feeding sensitive secrets if you don't want them persisted; (2) the code optionally imports a third-party 'forgetting_curve' module if installed — only install/allow that package from a trusted source; (3) confirm the DB path is acceptable or override CO_OCCURRENCE_DB_PATH if you prefer a different location; (4) if you integrate this with other components (adapter_factory or external adapters), review those adapter implementations to ensure they don't leak data. Overall the skill is internally consistent and low-risk, but treat stored memory contents as persistent data you control.
Capability Analysis
Type: OpenClaw Skill Name: co-occurrence-engine Version: 1.0.0 The skill bundle implements a standard Hebbian co-occurrence engine using a local SQLite database (~/.config/cortexgraph/co_occurrence.db) to track relationships between memory IDs. The code in scripts/co_occurrence_tracker.py uses parameterized SQL queries to prevent injection and lacks any indicators of data exfiltration, malicious execution, or prompt injection.
Capability Assessment
Purpose & Capability
Name/description (Hebbian co-occurrence engine) matches the included implementation: a Python tracker that records co-occurrence edges in a local SQLite DB under ~/.config/cortexgraph. No unrelated services, credentials, or binaries are requested.
Instruction Scope
SKILL.md and the Python file confine operations to local DB read/write, queries, decay, and maintenance. Instructions reference only the DB path and optional half-life setting; they do not instruct reading unrelated system files or sending data externally.
Install Mechanism
No install spec or remote downloads are present. The skill is instruction-only with a bundled Python script, so nothing is fetched from external URLs during install.
Credentials
No required environment variables or credentials are declared. SKILL.md documents optional env vars (CO_OCCURRENCE_DB_PATH, CO_OCCURRENCE_HALF_LIFE_DAYS) that are reasonable for configuration. The code writes only to a per-user config path.
Persistence & Privilege
always is false and the skill does not request elevated privileges or modify other skills. It creates/uses a local DB file under the user's config directory (normal for this kind of tool).
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install co-occurrence-engine
  3. After installation, invoke the skill by name or use /co-occurrence-engine
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release of co-occurrence-engine. - Introduces an independent Hebbian co-occurrence graph engine for associative memory discovery within a star-shaped memory architecture. - Features co-occurrence recording, association queries, frequency & time-based weight calculations, stats reporting, and maintenance tools. - Provides a dedicated SQLite data backend, optional forgetting curve integration, and adapter for unified memory interfaces. - Configurable via environment variables; designed for easy direct use or integration through adapters. - Requires Python 3.8+ and SQLite3.
Metadata
Slug co-occurrence-engine
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Co Occurrence Engine?

独立的 Hebbian 共现图引擎,记录记忆共现,计算关联权重,支持关联查询和数据库维护,服务星型记忆架构。 It is an AI Agent Skill for Claude Code / OpenClaw, with 153 downloads so far.

How do I install Co Occurrence Engine?

Run "/install co-occurrence-engine" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Co Occurrence Engine free?

Yes, Co Occurrence Engine is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Co Occurrence Engine support?

Co Occurrence Engine is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Co Occurrence Engine?

It is built and maintained by whoisme007 (@whoisme007); the current version is v1.0.0.

💬 Comments