Token导航 LogoToken导航

Agent Skill · 研究检索

engram(engram 搜索)

engram 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

engram 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 72,323。

总安装 188周安装 8GitHub Stars 1下载 66核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:engram(engram 搜索)
来源仓库:https://github.com/qwexs/engram
仓库路径:skills/engram
安装命令:
npx skills add https://github.com/qwexs/engram --skill engram
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/qwexs/engram --skill engram

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于查找、检索和筛选相关信息。engram 属于研究检索类 Skill,可作为该场景下的辅助能力补充。适合根据关键词或任务场景快速定位候选结果。通过 npx 安装,需确认权限范围和维护状态后再使用。可能触发联网、命令执行或文件读写,建议提前评估风险。可结合原始 README 进一步核验具体功能与使用方式。

来源仓库内路径:skills/engram

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/qwexs/engram --skill engram;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

engram 怎么安装?

在终端执行 npx skills add https://github.com/qwexs/engram --skill engram。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

engram 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

engram 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

engram 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

engram 用的人多吗?

公开数据是累计安装 188 次,近一周安装 8 次,下载 66 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

engram 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
engram

engram 搜索 · 本页

1881只读未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

⚠️ READ-ONLY SKILL: This skill is a reference implementation. Do not edit files directly. When installing, copy scripts to your workspace folder: ``bash # Scripts → workspace scripts/ cp skills/engram/scripts/*.js scripts/ ` Templates and assets remain in the skill folder. Specify the path via env: `bash export ENGRAM_SKILL_DIR=skills/engram # or absolute path bun skills/engram/scripts/init.js ` Without ENGRAM_SKILL_DIR, scripts look for assets relative to ../` from their location.

Memory System

Three-layer memory architecture for OpenClaw agents: curated long-term memory (MEMORY.md), structured knowledge graph (life/), and session-isolated daily notes (memory/).

Quick Start

# 1. Install QMD (if not installed)
bun skills/engram/scripts/install-qmd.js

# 2. Initialize everything
bun skills/engram/scripts/init.js

# Add a group session
bun skills/engram/scripts/add-session.js --platform telegram --id 3382546134

# Validate integrity
bun skills/engram/scripts/validate.js

# Migrate to v2 schema
bun skills/engram/scripts/migrate-v2.js --dry-run

Architecture Overview

┌─────────────────────────────────────────────┐
║  Layer 3: MEMORY.md (Curated Wisdom)        ║
║  Long-term personal insights, decisions     ║
├─────────────────────────────────────────────┤
║  Layer 2: Knowledge Graph (life/)           ║
║  KG entities with atomic facts              ║
├─────────────────────────────────────────────┤
║  Layer 1: Daily Notes (memory/)             ║
║  Raw session notes, per-session isolation   ║
└─────────────────────────────────────────────┘

Data flows upward: Daily notes → extracted to Knowledge Graph → distilled to MEMORY.md

For full architecture details, see references/architecture.md.

Memory Rules

Session Isolation

Golden Rule: Memory is isolated by session.

Session TypeMemory PathQMD CollectionAccess
Main (personal)memory/agent-{id}/main/openclaw-memory-agent-{id}-mainFull: MEMORY.md + life/
Telegram groupmemory/agent-{id}/telegram-{gid}/openclaw-memory-agent-{id}-telegram-{gid}Own daily notes ONLY
Discord channelmemory/agent-{id}/discord-{cid}/openclaw-memory-agent-{id}-discord-{cid}Own daily notes ONLY

Rules:

  • NEVER cross-reference memory between sessions
  • Group chats CANNOT see MEMORY.md or life/
  • Always specify -c <collection> in QMD queries

Every Session Startup (Fast/Full Init)

First, detect init mode based on the incoming message:

  • If the message matches the heartbeat prompt → Fast Init
  • Otherwise → Full Init
Fast Init (Heartbeat)

Heartbeats need speed, not full context. SOUL.md and USER.md are typically already in project context (OpenClaw loads them automatically).

Automated by hooks (do NOT repeat manually): - Daily note creation → engram-daily-note (gateway:startup) - <!-- session:start --> marker → engram-session-start (agent:bootstrap) - QMD index refresh → engram-bootstrap-qmd (agent:bootstrap)
  1. Determine session
  2. Read memory/heartbeat-state.json
  3. Proceed to HEARTBEAT.md

Skipped: SOUL.md, USER.md, yesterday's daily note, MEMORY.md, QMD query — none needed for heartbeat flow.

Full Init (Interactive)
Automated by hooks (do NOT repeat manually): - SOUL.md / USER.md → injected via OpenClaw project context - Daily note creation → engram-daily-note (gateway:startup) - <!-- session:start --> marker → engram-session-start (agent:bootstrap) - <!-- session:end --> marker → engram-session-end (command:new/reset) - QMD index refresh → engram-bootstrap-qmd (agent:bootstrap)
  1. Determine session (main, telegram group, discord channel, etc.)
  2. Read session memory:

- Main: today's daily note (full) + yesterday's daily note (tail from ## Active Threads onwards, or last 80 lines if marker absent) - Group: today + yesterday daily notes only (same tail rule for yesterday)

  1. Knowledge Graph (main session only): run qmd query "<topic of first user message>" -c life once, on the first substantive user message — not on every message, not during startup before the user speaks

- Extract the main topic/entity from the user's first request and query it - If message is a greeting or vague → defer to QMD Query Triggers below - ⚠️ This step fires exactly once per session; subsequent queries follow QMD Query Triggers rules

QMD Query Triggers

Apply during a session (after Full Init). Run qmd query whenever a trigger fires. Main session only — group chats do not have access to the Knowledge Graph (life/).
🔴 Mandatory Triggers (always run)
TriggerConditionQuery
First substantive requestUser's first non-greeting message in a sessionqmd query "<topic>" -c life
Named entity appearsProject, person, or system mentioned for the first time in this sessionqmd query "<entity name>" -c life
Decision requestedUser asks for advice, recommendation, or "what should I do"qmd query "<topic>" -c life + check memory/domains/ if relevant
🟡 Situational Triggers (use judgment)
TriggerCondition
Topic shiftConversation moves to a clearly different domain (e.g. dev → infra → marketing)
Long session + new subject>20 messages in session and a new subject appears
"We did this before"Request that could have history in prior sessions/notes
Contradiction detectedSomething the user says conflicts with what you believe you know
How to run
# Combined KG + session memory (recommended)
qmd query "topic" -c life -c openclaw-memory-agent-{id}-main

# KG only (when session memory not relevant)
qmd query "topic" -c life

Use the most specific term you can extract. If multiple entities are relevant, run separate queries.

Daily Notes

  • Path: memory/agent-{id}/{session}/YYYY-MM-DD.md
  • Header: # YYYY-MM-DD
  • Three-Layer Rotation (>1000 lines during heartbeat):

1. Archive — full file moved to archives/YYYY-MM/ (nothing lost) 2. Stub — auto-summary (10-20 lines) with line refs to archive and KG links 3. QMD index — archive indexed for granular search via qmd query - Run rotation AFTER KG Extraction to minimize stub duplication

Knowledge Graph

Structured memory in life/ using a flat three-folder structure (people/projects/archives):

life/
├── people/<name>/    # People (summary.md + items.json)
├── projects/<name>/  # Active work, tools, groups, AI agents (summary.md + items.json)
├── archives/<name>/  # Inactive entities
└── index.md          # Master entity index

Tiered retrieval:

  1. qmd query "topic" -c life — search first
  2. Read summary.md — quick context (~90% sufficient)
  3. Read items.json — only for granular detail

Entity creation rules:

  • Mentioned 3+ times across conversations
  • Has a direct relationship to the user
  • Is a significant project, person, or company

For the atomic fact schema (v2), see references/fact-schema.md.

Writing Memory

TypeDestination
Operational lessonTOOLS.md or AGENTS.md
Personal insightMEMORY.md (main session only)
Event/factToday's daily note
Durable knowledgeKnowledge Graph (life/)

When someone says "remember this":

  1. Determine the type
  2. Write to the appropriate file
  3. Run qmd update

QMD Search

# Hybrid search (BM25 + vectors + rerank)
qmd query "search text" -c <collection>

# Multi-collection search (searches across multiple collections)
qmd query "search text" -c life -c openclaw-memory-agent-main-main

# BM25-only search (no GPU required, faster)
qmd search "search text" -c <collection>

# Update index after changes
qmd update          # BM25 (instant)
qmd embed           # Vectors (heartbeat only)

Strategy:

  • Always use -c flag for session isolation
  • Multi-collection (-c col1 -c col2) for cross-cutting searches (e.g., KG + daily notes)
  • Use qmd search (BM25-only) when GPU is busy or unavailable
  • Top 2-3 results usually sufficient
  • Run qmd update after writing memory
  • Do NOT run qmd embed manually (heartbeat handles it)

For QMD installation and configuration, see references/qmd-setup.md.

Heartbeat Integration

Add to your HEARTBEAT.md:

## Heartbeat Flow (every 30 minutes)

0. Three-Layer Rotation check (daily note creation → handled by engram-daily-note hook)
1. Monday? → Weekly Synthesis
2. Knowledge Graph Extraction (if notes changed)
3. Memory Maintenance (every few days)
3.5. Domain Supervisor Scan (if domains exist)
4. QMD Index Update (qmd update + qmd embed)

Weekly Synthesis (Mondays)

Rewrites summary.md with memory decay applied:

  • Hot (7 days) — prominent in summary
  • Warm (8-30 days) — lower priority
  • Cold (30+ days) — omitted from summary (stays in items.json)

Modifiers:

  • confidence < 0.5 → Cold threshold is 14 days
  • accessCount >= 10 → bumps Cold to Warm
  • principle (L3) → always in summary
  • pattern (L2) → in summary if Warm+

For full decay rules, see references/decay-rules.md.

Knowledge Graph Extraction

During heartbeats, scan daily notes for durable facts:

  • Watermark-based incremental parsing: Check for <!-- extracted:L{N}:{timestamp} --> at the end of each daily note. If found, only parse lines after the last watermark. No watermark = parse entire file (backward compatible).
  • Relationships, milestones, status changes, decisions, preferences
  • Write to entity items.json with confidence and abstraction level
  • Update summary.md for new Hot facts
  • Create new entities when creation rules are met
  • After extraction, append watermark: <!-- extracted:L{lastLine}:{ISO timestamp} -->
  • Only heartbeat writes watermarks — inline extraction does NOT (dedup handles overlap)
  • After rotation, watermark moves to archive with the original file; the stub has no watermark and is parsed entirely (cheap, 10-20 lines)
  • Skip casual chat and transient requests

For the complete heartbeat flow, see references/HEARTBEAT.md.

Domain Supervisor Scan

If subagent domains exist (memory/domains/), heartbeat acts as supervisor:

  1. PROPOSAL review — qmd query "PROPOSAL" -c domains → auto-approve low-risk, alert user for high-risk
  2. Liveness check — read each domain's status.md, alert if missed >2x schedule
  3. Changelog rotation — rotate changelog.md >1000 lines to archives/
  4. KG extraction — extract significant facts from changelogs to Knowledge Graph

For full details, see references/HEARTBEAT.md and references/subagent-memory.md.

Memory Decay

Facts decay based on recency, with modifiers for confidence, frequency, and abstraction:

TierRecencyIn summary?
Hot≤7 days✅ Prominent
Warm8-30 days✅ Lower priority
Cold30+ days❌ (searchable via QMD)

Full rules: references/decay-rules.md

Operational Learning Loop (OLL)

System observes its own friction — what worked, what failed, what patterns emerged — and accumulates these observations for review.

Storage Structure

workspace/ops/
├── observations/          # Operational observations
│   ├── index.json         # Registry of all observations
│   └── obs-0001.json      # Individual observation files
└── tensions/              # Contradictions between facts
    ├── index.json         # Registry of all tensions
    └── tension-0001.json  # Individual tension files

Capturing Observations

Only the agent writes observations — subagents return Flags: in handoffs for the agent to review.

# Friction, surprise, or pattern (inline during session)
bun skills/engram/scripts/memory-observe.js --observation "KG extraction missed facts about email" --category friction
bun skills/engram/scripts/memory-observe.js --observation "..." --category surprise --description "Why this matters"

Categories: friction (weight ×3), surprise (weight ×2), pattern (weight ×1)

Capturing Tensions

Tensions are auto-created when memory-write.js --check-contradictions finds Jaccard ≥0.5 + ≥3 common keywords. Manual creation:

bun skills/engram/scripts/memory-tension.js \
  --tension "Fact A contradicts fact B" \
  --fact1 "sergey-001" --fact2 "sergey-005" \
  --type factual \
  --confidence 0.8 \
  --description "Context about the contradiction"

Types: factual (default), temporal, priority

Promoting or Archiving Observations

# Promote obs → KG fact (with backlink)
bun skills/engram/scripts/memory-promote.js \
  --obs-id obs-0002 --entity "projects/engram" \
  --fact "Extraction finds no facts in heartbeat-only daily notes" \
  --category context --confidence 0.8 --abstraction pattern \
  --tags "extraction,heartbeat" [--dry-run]

# Archive (noise, status report, resolved friction)
bun skills/engram/scripts/memory-promote.js --archive \
  --obs-id obs-0003 --reason "domain status report, not friction"

Backlink: promoted KG fact gets source: obs-id; obs file gets kgFactId.

OLL Rethink Trigger (Heartbeat Phase 5)

Phase 5 computes weighted score and spawns hb-rethink when triggered:

ConditionThreshold
Weighted score (f×3 + s×2 + p×1)≥ 15
Pending tensions≥ 3
Days since last rethink≥ 14

hb-rethink (sonnet-4-6) reviews observations + tensions, identifies patterns, generates proposals, and returns a HB-RETHINK HANDOFF block. process-handoff.js auto-executes low-risk actions (archive noise, promote facts) and surfaces an ALERT.

Resolving Tensions

# Resolved: one fact supersedes the other
bun skills/engram/scripts/memory-tension-resolve.js \
  --id tension-0001 --resolution "fact-abc superseded by fact-xyz"

# Dissolved: not actually contradictory
bun skills/engram/scripts/memory-tension-resolve.js \
  --id tension-0001 --dissolved \
  --resolution "facts are scope-dependent (work vs personal context)"

Schemas

Observation:

{
  "id": "obs-0001",
  "observation": "KG extraction missed facts about email",
  "category": "friction",
  "status": "pending | promoted | implemented | archived",
  "createdAt": "2026-02-25T12:00:00.000Z",
  "promotedAt": null,
  "archivedAt": null,
  "kgFactId": null,
  "accessCount": 0
}

Tension:

{
  "id": "tension-0001",
  "tension": "Possible contradiction: ...",
  "type": "factual | temporal | priority",
  "confidence": 0.72,
  "fact1": "sergey-001",
  "fact1Text": "Prefers Bun over Node.js",
  "fact2": "sergey-005",
  "fact2Text": "Uses Node.js for all projects",
  "description": "Auto-detected (Jaccard 0.72, 4 common words)",
  "status": "pending | resolved | dissolved",
  "createdAt": "2026-03-03T15:00:00.000Z"
}

index.json stats:

{
  "observations": ["obs-0001", ...],
  "lastId": 10,
  "stats": { "total": 10, "pending": 1, "promoted": 2, "implemented": 1, "archived": 6 }
}

For full OLL details, see references/HEARTBEAT.md (Phase 5) and references/HB-RETHINK.md.

Fact Schema v2

Each fact in items.json includes:

{
  "id": "<entity>-NNN",
  "fact": "Human-readable statement",
  "category": "relationship|milestone|status|preference|context|decision|correction",
  "confidence": 0.85,
  "abstractionLevel": "episode|pattern|principle",
  "tags": ["tag1"],
  "timestamp": "2026-02-08",
  "source": "2026-02-07",
  "status": "active|superseded",
  "supersededBy": null,
  "relatedEntities": ["people/sergey"],
  "lastAccessed": "2026-02-08",
  "accessCount": 1
}

No-Deletion Rule: Facts are NEVER deleted. Set status: "superseded" and link via supersededBy.

Write Pipeline Rule: NEVER write items.json directly. Always use bun skills/engram/scripts/memory-write.js. Direct writes bypass dedup, validation, and hash registration, causing schema mismatches (e.g., content vs fact, created vs timestamp). This applies to heartbeats, inline extraction, and entity creation. No exceptions.

Full schema: references/fact-schema.md

Subagent Memory

Pattern for subagents with cleanup: "delete" and long-term memory via domains.

Quick Start

# Create a domain
bun skills/engram/scripts/add-domain.js --domain monitoring --description "Server monitoring"

# Configure rules in decisions.md
# Launch subagent with prompt from templates/spawn-prompt.md

Domain Structure

memory/domains/{domain}/
├── decisions.md    # Rules (read-only for subagent)
├── workflow.md     # HOW the domain works: scripts, scope, tools (optional)
├── status.md       # Current state (written by subagent)
├── changelog.md    # Append-only log (written by subagent)
├── archives/       # Changelog rotation
└── README.md

workflow.md — optional file describing the domain's infrastructure (scripts, API, task scope, wiki links). Recommended for domains with 2+ task types. Simple domains (single task) can work without it.

Separation of concerns:

  • decisions.md — WHAT can be done (rules, thresholds, constraints)
  • workflow.md — HOW the domain works (scripts, API, scope, links)
  • Template (spawn-prompt) — WHICH specific task to execute

Rules

  1. One domain = one active subagent at any given time
  2. decisions.md — read-only for subagents; changes via PROPOSAL in changelog
  3. Subagent does NOT write to daily notes or life/
  4. QMD: one domains collection for all domains
  5. Heartbeat: review PROPOSAL, rotate changelog, optionally KG extraction

Project Domains

Domains can be linked to projects in the Knowledge Graph (life/projects/). This provides a two-way binding:

  • KG entity (life/projects/{name}/) — what the bot knows about the project (facts, summary)
  • Domain (memory/domains/{name}/) — context for the subagent (decisions, status, changelog)

The binding is defined via the domain registry (memory/domains/registry.json):

{
  "domains": {
    "engram": {
      "type": "dev-project",
      "kgEntity": "projects/engram",
      "description": "Memory architecture skill",
      "subagentLabel": "engram",
      "spawnTemplate": "dev-project.md"
    },
    "monitoring": {
      "type": "cron-task",
      "description": "Server monitoring",
      "subagentLabel": "monitoring",
      "spawnTemplate": "cron-task.md"
    }
  }
}

Registry fields:

FieldRequiredDescription
type✅dev-project or cron-task
description✅Brief description
spawnTemplate⚠️ recommendedFile from templates/spawn-prompts/
subagentLabel⚠️ recommendedFixed label for sessions_spawn
kgEntitynoLink to Knowledge Graph entity

Domain types:

  • dev-project — development, linked to KG entity, subagent on demand
  • cron-task — periodic tasks, subagent on schedule

Spawn Templates

Rule: always use a template. Don't write prompts manually — use spawnTemplate from the registry. This ensures the subagent receives the Domain Lifecycle (paths to decisions, status, changelog).

Templates are in templates/spawn-prompts/:

  • dev-project.md — for development (decisions + status + changelog tail)
  • cron-task.md — for periodic tasks (decisions + status)

Templates use placeholders: {{domain}}, {{task}}, {{workflow}}, {{decisions}}, {{status}}, {{changelog_tail}}.

Context chain: Template → workflow.md → decisions.md → wiki (if needed) → execution.

Workflow:

  1. User gives a project task
  2. Main bot finds the domain via registry.json
  3. Loads the template from spawnTemplate
  4. Injects domain context (decisions, status, changelog)
  5. Spawns subagent with subagentLabel and cleanup: "delete"
  6. Subagent determines where to work (repo, API, scripts — depends on the task)
  7. After completion, main bot updates the domain (changelog, status)

Where to work — not specified in the domain. The bot determines the working directory from its memory and conversation context.

Spawn Workflow

The main agent (not a script) handles spawning:

  1. Find domain in registry.json → get spawnTemplate, subagentLabel
  2. Read status.md + changelog.md (tail) → understand current state
  3. Formulate exact task based on user request + domain context
  4. Read decisions.md + workflow.md → include verbatim in prompt
  5. Load template from templates/spawn-prompts/{spawnTemplate}
  6. Replace {{domain}}, {{decisions}}, {{workflow}}, {{task}}
  7. Spawn with sessions_spawn(label: subagentLabel, cleanup: "delete", task: <prompt>)

Key principle: the agent's judgment in interpreting status/changelog and formulating a precise task IS the value. Templates provide structure, not automation.

Detailed documentation: references/subagent-memory.md

Real-Time Extraction

Instead of waiting for heartbeats (up to 30 min), extract high-signal facts inline during conversations.

Message → Signal Scan (regex, <10ms) → Classify
  ├── HIGH (preference, decision, correction, milestone, instruction, identity)
  │     → Dedup (SHA-256) → Contradiction check → Write to KG → QMD update
  ├── LOW (context, work) → Daily note → Heartbeat extracts later
  └── NONE (casual) → Skip

Signal Detection

bun skills/engram/scripts/memory-signal.js --text "Я предпочитаю TypeScript"
# → { "signal": "high", "categories": ["preference"], "confidence": 0.88 }

Supports Russian and English. Six categories: correction, preference, decision, identity, instruction, milestone.

Write with Dedup + Contradiction Check

bun skills/engram/scripts/memory-write.js \
  --entity "people/sergey" \
  --fact "Prefers Bun over Node.js" \
  --category preference \
  --confidence 0.9 \
  --abstraction pattern \
  --tags "tools,runtime" \
  --source "2026-02-16"

# With contradiction detection
bun skills/engram/scripts/memory-write.js --entity "..." --fact "..." --category ... \
  --check-contradictions --cross-entity

# With semantic similarity check (BM25)
bun skills/engram/scripts/memory-write.js --entity "..." --fact "..." --category ... \
  --semantic-check --search-collections "life,openclaw-memory-agent-main-main"

Automatically: content-hash dedup → optional contradiction/semantic check → write fact → validate KG → update QMD.

Contradiction Detection

# Intra-entity (fast, no QMD)
bun skills/engram/scripts/memory-contradict.js --fact "Uses Node.js" --entity "people/sergey"

# Cross-entity (via QMD BM25, searches all entities)
bun skills/engram/scripts/memory-contradict.js --fact "Uses Node.js" --entity "people/sergey" \
  --cross-entity --collections "life,openclaw-memory-agent-main-main"

Rules for Inline Extraction

  • Only in main session (group chats don't touch KG)
  • HIGH signal → extract immediately via memory-write.js
  • LOW signal → daily note only (heartbeat extracts later)
  • Do NOT write extraction watermarks during inline extraction (heartbeat only)
  • Dedup is automatic — duplicates from inline + heartbeat silently skipped

Session Recording

Daily notes capture session activity. Two-level protection:

Level 1: Agent inline (primary)     — best quality, during session
         ↓ forgot?
Level 2: Compaction memoryFlush     — safety net before context compression

Level 1: Agent Inline (Primary)

Record to daily note when:

  • Topic completed — a task/discussion block finishes (every 5-10 messages)
  • Decision made — any explicit decision → --section decisions
  • Topic shift — conversation moves to a new subject
  • Significant result — something was built, fixed, or discovered
bun skills/engram/scripts/daily-note-append.js \
  --session main --section events --text "Fixed 44 semantic duplicates in KG"

bun skills/engram/scripts/daily-note-append.js \
  --session main --section decisions --text "Jaccard ≥ 0.5 now blocks writes (was warning-only)"

Level 2: Compaction memoryFlush

Configured in OpenClaw (agents.defaults.compaction.memoryFlush). Before context compression, the agent receives a prompt to write lasting notes to memory files. Configure with a specific instruction:

{
  "memoryFlush": {
    "enabled": true,
    "prompt": "Write session events/decisions/learnings to today's daily note via: bun skills/engram/scripts/daily-note-append.js --session main --section <section> --text '<text>'. Then reply NO_REPLY.",
    "systemPrompt": "Session nearing compaction. Record substantive work to daily note now."
  }
}

Rules

  • Keep entries brief (1-2 lines each)
  • Record facts, not feelings ("Fixed X" not "Had a great session")
  • Operational events → events, explicit choices → decisions, insights → learnings
  • Do NOT wait for session end — record as you go
  • Session-End Checklist (AGENTS.md) handles threads and next sections

Scripts

install-qmd.js — Install QMD search engine

bun skills/engram/scripts/install-qmd.js [--variant local|jina] [--jina-key <key>]

Interactive installer for QMD. Two variants:

  • local — GPU/CPU embeddings via Vulkan/llama.cpp (recommended for desktop)
  • jina — Cloud embeddings via Jina AI API, free tier 1M tokens/month (recommended for Docker/VPS)

Handles npm install, API key configuration,.env file creation, and verification.

init.js — Initialize memory system

bun skills/engram/scripts/init.js [--agent-id main] [--qmd-variant auto|local|jina] [--force]

Creates complete directory structure, copies templates, sets up QMD collections, runs initial index. Use --force to merge with existing directories.

add-session.js — Add new session

bun skills/engram/scripts/add-session.js --platform telegram --id <groupId> [--agent-id main]

Creates session directory, copies group-knowledge templates, adds QMD collection, updates heartbeat-state.json.

add-domain.js — Create subagent domain

bun skills/engram/scripts/add-domain.js --domain <name> [--description "Description"]

Creates memory/domains/{domain}/ with decisions.md, status.md, changelog.md, README.md. Registers QMD collection domains (one for all domains). Warns if >20 domains.

validate.js — Check integrity

bun skills/engram/scripts/validate.js [--fix] [--agent-id main]

Checks directory structure, required files, items.json validity, v2 schema compliance, ID uniqueness, supersededBy references. Use --fix to auto-repair.

migrate-v2.js — Migrate to v2 schema

bun skills/engram/scripts/migrate-v2.js [--dry-run]

Adds missing v2 fields (confidence, abstractionLevel, tags) to all items.json files with sensible defaults.

memory-signal.js — Signal detection

bun skills/engram/scripts/memory-signal.js --text "I prefer TypeScript"

Classifies text as high/low/none signal. Regex-based, no LLM, <10ms. Returns categories, keywords, confidence.

memory-write.js — Unified write pipeline

# Write a fact
bun skills/engram/scripts/memory-write.js --entity <path> --fact <text> --category <cat> \
  [--confidence 0.9] [--abstraction pattern] [--tags "a,b"] [--source "2026-02-16"] \
  [--description "Why this fact matters (max 150 chars)"] \
  [--entity-create] [--check-contradictions] [--cross-entity] \
  [--semantic-check] [--search-collections "life,collection2"]

# Track access (updates lastAccessed + accessCount for decay)
bun skills/engram/scripts/memory-write.js --access --entity <path> --id <fact-id>

Single entry point for all KG writes. Handles dedup, validation, QMD update, optional contradiction/semantic checks. Use --entity-create to create new entities on the fly. Use --access mode to bump a fact's recency (important for decay tiers).

memory-dedup.js — Deduplication index

bun skills/engram/scripts/memory-dedup.js --seed    # Index all existing facts
bun skills/engram/scripts/memory-dedup.js --check --hash <sha256>  # Check if exists

Manages workspace/memory-state/fact-hashes.json. Run --seed after initial setup or weekly synthesis.

memory-contradict.js — Contradiction detection

bun skills/engram/scripts/memory-contradict.js --fact <text> --entity <path> \
  [--cross-entity] [--collections "life,other"]

Finds conflicting facts via Jaccard similarity. Intra-entity by default; --cross-entity discovers related entities via QMD BM25.

memory-observe.js — Capture operational observations

bun skills/engram/scripts/memory-observe.js --observation "text" --category friction [--description "desc"] [--dry-run]

Captures observations about system friction, surprises, or patterns. Categories: friction, surprise, pattern. Includes novelty check (Jaccard >0.7 rejects duplicates). Only the agent writes observations directly — subagents return Flags: in handoffs.

memory-tension.js — Capture contradictions

bun skills/engram/scripts/memory-tension.js \
  --tension "text" --fact1 <id> --fact2 <id> \
  [--type factual|temporal|priority] [--confidence 0.8] [--description "desc"] [--dry-run]

Captures tensions between two KG facts. Validates both IDs exist in KG. Stores fact1Text/fact2Text from KG for hb-rethink review. Auto-created by memory-write.js --check-contradictions when Jaccard ≥0.5 + ≥3 common keywords. Novelty check (>0.7 → skip duplicate).

memory-tension-resolve.js — Resolve or dissolve tensions

bun skills/engram/scripts/memory-tension-resolve.js --id tension-0001 --resolution "text"
bun skills/engram/scripts/memory-tension-resolve.js --id tension-0001 --dissolved --resolution "text"

Marks tension as resolved (contradiction fixed) or dissolved (not actually contradictory). Idempotent if already closed.

memory-promote.js — Promote observation to KG or archive it

# Promote obs → KG fact (with backlink: obs.kgFactId ← fact.source = obs-id)
bun skills/engram/scripts/memory-promote.js \
  --obs-id obs-0002 --entity "projects/engram" --fact "text" \
  --category context --confidence 0.8 [--abstraction pattern] [--tags "..."] [--dry-run]

# Archive observation
bun skills/engram/scripts/memory-promote.js --archive --obs-id obs-0003 --reason "noise"

Updates index.json stats (total/pending/promoted/implemented/archived) after every status change.

daily-note-append.js — Record session activity to daily note

bun skills/engram/scripts/daily-note-append.js \
  --session main --agent-id main --section events --text "Fixed 44 semantic duplicates in KG"

Atomically appends a bullet entry to a named section of today's daily note. Creates the note from template if it doesn't exist. Sections: events, decisions, learnings, threads, next. Never overwrites existing content, never touches watermarks or Heartbeat Report.

rebuild-summaries.js — Rebuild summary.md from items.json

bun skills/engram/scripts/rebuild-summaries.js [--dry-run] [--entity people/sergey] [--apply-decay]

Deterministically regenerates summary.md for all entities in life/ from their items.json. No LLM involved.

Without --apply-decay: groups active facts by category, lists top 5 by confidence, shows counts per category and superseded stats. Outputs {"updated": N, "skipped": N, "errors": N}.

With --apply-decay: applies Memory Decay tiers (Hot/Warm/Cold) based on lastAccessed/createdAt/source date. Summary format changes to tiered sections: ## Current (Hot), ## Background (Warm), ## Enduring (Principles). Cold facts (except principles) are excluded from summary but remain in items.json. Outputs {"updated": N, "skipped": N, "errors": N, "hot": N, "warm": N, "coldExcluded": N}.

Decay algorithm: see references/decay-rules.md. Used by HB-SYNTHESIS.md subagent during Monday heartbeat.

Use --dry-run to preview diffs without writing. Use --entity to process one entity.

rotate-notes.js — Three-Layer Rotation

bun skills/engram/scripts/rotate-notes.js --check --session main              # Check if daily note needs rotation
bun skills/engram/scripts/rotate-notes.js --check-domains                      # Check all domain changelogs
bun skills/engram/scripts/rotate-notes.js --rotate --file <path> --type daily  # Rotate daily note (>1000 lines)
bun skills/engram/scripts/rotate-notes.js --rotate --file <path> --type changelog  # Rotate changelog
# exit 0: nothing to rotate / done | exit 10: needs rotation (--check mode)

Handles Three-Layer Rotation for daily notes (archive + stub + QMD index) and simple rotation for domain changelogs. Called by heartbeat Phase 0.5. Daily note stubs contain a <!-- STUB:... --> marker for the agent to fill with a summary later.

heartbeat-state.js — State management

bun skills/engram/scripts/heartbeat-state.js --get-all
bun skills/engram/scripts/heartbeat-state.js --set pendingObservations 5

Atomic read/write of memory/heartbeat-state.json. All heartbeat phase trackers (lastExtraction, lastDomainScan, subagentRuns, etc.) must be updated via this script — never edit the JSON directly.

heartbeat-report.js — Daily note report section

bun skills/engram/scripts/heartbeat-report.js --session main --date 2026-02-27 \
  --extraction "spawned (result pending)" \
  --synthesis  "skipped (not Monday)" \
  --domains    "spawned (result pending)" \
  --maintenance "ok — validate-kg.js: 0 errors"

Creates or updates ## Heartbeat Report section in a daily note. Called by heartbeat orchestrator in Phase 6 (initial write) and by process-handoff.js (status update after subagent handoff). Omit any flag to preserve its current value.

process-handoff.js — HB subagent handoff processor

printf '%s' "<handoff block>" | bun skills/engram/scripts/process-handoff.js --session main --date 2026-02-27
# exit 0: ok | exit 1: error | exit 2: alerts present ([ALERT] lines in stdout)

Processes === HB-* HANDOFF === blocks from subagent results. Handles HB-EXTRACT (watermark advance, lastExtraction, facts count), HB-DOMAINS (lastDomainScan), HB-SYNTHESIS (lastWeeklySynthesis). Updates heartbeat-state.json, advances watermark in daily note, and calls heartbeat-report.js automatically. Called by the heartbeat orchestrator Handoff Handler — do not call manually.

OpenClaw Hooks

Engram ships 5 OpenClaw hooks that automate mechanical session tasks. Hooks run automatically — agents do NOT need to repeat these steps manually.

HookEventWhat it does
engram-daily-notegateway:startupCreates today's daily note for all sessions
engram-session-startagent:bootstrapAppends <!-- session:start:{ISO} --> to daily note
engram-session-endcommand:new, command:resetAppends <!-- session:end:{ISO} --> to daily note
engram-bootstrap-qmdagent:bootstrapRuns qmd update (15s timeout, silent skip if unavailable)
engram-message-logmessage:receivedLogs messages to workspace/message-log/YYYY-MM-DD.jsonl
engram-session-memorycommand:new, command:resetSave session transcript to sessions/ subdir (QMD-indexed). Replaces native session-memory.
Note: Disable the built-in session-memory hook when enabling engram-session-memory — they serve the same purpose but write to different locations.

Execution order on /new

  1. engram-session-end fires on command:new → writes <!-- session:end -->
  2. New agent session starts → agent:bootstrap fires
  3. engram-session-start → writes <!-- session:start -->
  4. engram-bootstrap-qmd → refreshes QMD index

Installation

Hooks are installed automatically by scripts/init.js (copies skills/engram/hooks/engram-* → hooks/engram-* in workspace root, only if not already present).

Manual installation:

# Copy hooks to workspace
cp -r skills/engram/hooks/engram-* hooks/

# Restart Gateway to activate
openclaw gateway restart

Hook source files are in skills/engram/hooks/. The workspace hooks/ directory contains the live copies — do not edit skill source directly.

Configuration

Hooks use ENGRAM_TZ (or TZ) environment variable for timezone. Default: UTC.

# Set in OpenClaw config (env.vars) or shell:
export ENGRAM_TZ="Europe/Moscow"   # or America/New_York, Asia/Tokyo, etc.

平台分布

Codex

35.45%
按下载量换算23

Claude

29.14%
按下载量换算19

Cursor

18.76%
按下载量换算12

Gemini CLI

9.72%
按下载量换算6

安全审计

Gen Agent Trust Hub

可疑

Socket

可疑

Snyk

可疑

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills