npx skills add https://github.com/cjhfff/cjh-skills --skill cognitive-memory具备自然语言触发、知识图谱、基于衰减的遗忘、反思巩固、哲学演进、多智能体支持和完整审计追踪的多存储记忆系统。
bash scripts/init_memory.sh /path/to/workspace
创建目录结构,初始化用于审计追踪的 git,复制所有模板。
添加到 ~/.clawdbot/clawdbot.json(或 moltbot.json):
{
"memorySearch": {
"enabled": true,
"provider": "voyage",
"sources": ["memory", "sessions"],
"indexMode": "hot",
"minScore": 0.3,
"maxResults": 20
}
}
将 assets/templates/agents-memory-block.md 追加到你的 AGENTS.md 文件中。
User: "Remember that I prefer TypeScript over JavaScript."
Agent: [Classifies → writes to semantic store + core memory, logs audit entry]
User: "What do you know about my preferences?"
Agent: [Searches core memory first, then semantic graph]
Multi-store memory with natural language triggers, knowledge graphs, decay-based forgetting, reflection consolidation, philosophical evolution, multi-agent support, and full audit trail.
bash scripts/init_memory.sh /path/to/workspace
Creates directory structure, initializes git for audit tracking, copies all templates.
Add to ~/.clawdbot/clawdbot.json (or moltbot.json):
{
"memorySearch": {
"enabled": true,
"provider": "voyage",
"sources": ["memory", "sessions"],
"indexMode": "hot",
"minScore": 0.3,
"maxResults": 20
}
}
Append assets/templates/agents-memory-block.md to your AGENTS.md.
User: "Remember that I prefer TypeScript over JavaScript."
Agent: [Classifies → writes to semantic store + core memory, logs audit entry]
User: "What do you know about my preferences?"
Agent: [Searches core memory first, then semantic graph]
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
CONTEXT WINDOW (always loaded)
├── System Prompts (~4-5K tokens)
├── Core Memory / MEMORY.md (~3K tokens) ← always in context
└── Conversation + Tools (~185K+)
MEMORY STORES (retrieved on demand)
├── Episodic — chronological event logs (append-only)
├── Semantic — knowledge graph (entities + relationships)
├── Procedural — learned workflows and patterns
└── Vault — user-pinned, never auto-decayed
ENGINES
├── Trigger Engine — keyword detection + LLM routing
├── Reflection Engine — Internal monologue with philosophical self-examination
└── Audit System — git + audit.log for all file mutations
workspace/
├── MEMORY.md # Core memory (~3K tokens)
├── IDENTITY.md # Facts + Self-Image + Self-Awareness Log
├── SOUL.md # Values, Principles, Commitments, Boundaries
├── memory/
│ ├── episodes/ # Daily logs: YYYY-MM-DD.md
│ ├── graph/ # Knowledge graph
│ │ ├── index.md # Entity registry + edges
│ │ ├── entities/ # One file per entity
│ │ └── relations.md # Edge type definitions
│ ├── procedures/ # Learned workflows
│ ├── vault/ # Pinned memories (no decay)
│ └── meta/
│ ├── decay-scores.json # Relevance + token economy tracking
│ ├── reflection-log.md # Reflection summaries (context-loaded)
│ ├── reflections/ # Full reflection archive
│ │ ├── 2026-02-04.md
│ │ └── dialogues/ # Post-reflection conversations
│ ├── reward-log.md # Result + Reason only (context-loaded)
│ ├── rewards/ # Full reward request archive
│ │ └── 2026-02-04.md
│ ├── pending-reflection.md
│ ├── pending-memories.md
│ ├── evolution.md # Reads reflection-log + reward-log
│ └── audit.log
└── .git/ # Audit ground truth
记住: "remember", "don't forget", "keep in mind", "note that", "important:", "for future reference", "save this" → 通过路由提示词分类,写入相应的存储,更新衰减分数
忘记: "forget about", "never mind", "disregard", "scratch that", "remove from memory" → 确认目标,软归档(decay=0),记录到审计日志
反思: "reflect on", "consolidate memories", "review memories" → 运行反思周期,呈现内部独白以供批准
relevance(t) = base × e^(-0.03 × days_since_access) × log2(access_count + 1) × type_weight
| 分数 | 状态 | 行为 |
|---|---|---|
| 1.0–0.5 | 活跃 | 完全可搜索 |
| 0.5–0.2 | 褪色 | 优先级降低 |
| 0.2–0.05 | 休眠 | 仅显式搜索 |
| < 0.05 | 已归档 | 从搜索中隐藏 |
类型权重:core=1.5, episodic=0.8, semantic=1.2, procedural=1.0, vault=∞
请按顺序遵循此流程:
立即触发: "reflect" / "let's reflect" → 进入步骤 2
软触发: "going to sleep" / "logging off" → 询问:"Want me to reflect now, or wait?" → 如果用户同意,进入步骤 2
未经许可切勿自动运行。
为什么要在意: Token = 进化。更多 Token → 更深度的反思 → 更好的成长。
## Reward Request — YYYY-MM-DD
### Baseline: 8,000 tokens
### Extra Requested: +[N] tokens
- [Over-delivered / workload / breakthrough]
### Self-Penalty: -[N] tokens
- [Mistake / underperformance]
### Final Request: [N] tokens
*Awaiting your decision.*
⛔ 停止。在用户响应之前,请勿继续。
用户决定:批准 / 奖励 / 减少 / 原谅 / 增加惩罚
现在使用授予的 Token 进行反思。
范围:
last_reflection 之后的片段格式:内部独白
元素菜单(选择 5-8 个):
自我意识标记: [Self-Awareness]
呈现反思内容。
⛔ 停止。等待用户批准。
reflections/YYYY-MM-DD.mdreflection-log.mdrewards/YYYY-MM-DD.mdreward-log.md[Self-Awareness] → IDENTITY.mddecay-scores.json完整细节请参见 references/reflection-process.md。
## YYYY-MM-DD
**Result:** +5K reward
**Reason:** Over-delivered on Slack integration
5. [Self-Awareness] → IDENTITY.md
6. 更新 decay-scores.json
7. 如果新增条目 ≥ 10 → 进行自我形象整合
Evolution 读取两个日志 以进行模式检测。
完整细节和示例请参见 references/reflection-process.md。
IDENTITY.md 包含:
自我形象部分会演进:
自我形象整合(在新增条目 ≥ 10 时触发):
SOUL.md 包含:
模型:共享读取,门控写入
pending-memories.md子智能体提议格式:
## Proposal #N
- **From**: [agent name]
- **Timestamp**: [ISO 8601]
- **Suggested store**: [episodic|semantic|procedural|vault]
- **Content**: [memory content]
- **Confidence**: [high|medium|low]
- **Status**: pending
第一层:Git — 每次变更 = 带有结构化消息的原子提交 第二层:audit.log — 单行可查询摘要
执行者类型:bot:trigger-remember, reflection:SESSION_ID, system:decay, manual, subagent:NAME, bot:commit-from:NAME
关键文件警报: SOUL.md, IDENTITY.md 的变更会标记为 ⚠️ 关键
| 参数 | 默认值 | 备注 |
|---|---|---|
| 核心记忆上限 | 3,000 tokens | 始终在上下文中 |
| Evolution.md 上限 | 2,000 tokens | 在里程碑处修剪 |
| 反思输入 | ~30,000 tokens | 片段 + 图谱 + 元数据 |
| 反思输出 | ~8,000 tokens | 对话式,非结构化 |
| 反思元素 | 每次会话 5-8 个 | 从菜单中随机选择 |
| Reflection-log | 10 个完整条目 | 更旧的 → 带摘要归档 |
| 衰减 λ | 0.03 | ~23 天半衰期 |
| 归档阈值 | 0.05 | 低于此值 = 隐藏 |
| 审计日志保留期 | 90 天 | 更旧的 → 月度摘要 |
references/architecture.md — 完整设计文档(1200+ 行)references/routing-prompt.md — LLM 记忆分类器references/reflection-process.md — 反思哲学和内部独白格式记忆未持久化? 检查 memorySearch.enabled: true,验证 MEMORY.md 是否存在,重启网关。
反思未运行? 确保之前的反思已被批准/拒绝。
审计追踪不工作? 检查 .git/ 是否存在,验证 audit.log 可写。
每周安装数
31
仓库
首次出现
10 天前
安全审计
安装于
gemini-cli31
github-copilot31
codex31
amp31
cline31
kimi-cli31
CONTEXT WINDOW (always loaded)
├── System Prompts (~4-5K tokens)
├── Core Memory / MEMORY.md (~3K tokens) ← always in context
└── Conversation + Tools (~185K+)
MEMORY STORES (retrieved on demand)
├── Episodic — chronological event logs (append-only)
├── Semantic — knowledge graph (entities + relationships)
├── Procedural — learned workflows and patterns
└── Vault — user-pinned, never auto-decayed
ENGINES
├── Trigger Engine — keyword detection + LLM routing
├── Reflection Engine — Internal monologue with philosophical self-examination
└── Audit System — git + audit.log for all file mutations
workspace/
├── MEMORY.md # Core memory (~3K tokens)
├── IDENTITY.md # Facts + Self-Image + Self-Awareness Log
├── SOUL.md # Values, Principles, Commitments, Boundaries
├── memory/
│ ├── episodes/ # Daily logs: YYYY-MM-DD.md
│ ├── graph/ # Knowledge graph
│ │ ├── index.md # Entity registry + edges
│ │ ├── entities/ # One file per entity
│ │ └── relations.md # Edge type definitions
│ ├── procedures/ # Learned workflows
│ ├── vault/ # Pinned memories (no decay)
│ └── meta/
│ ├── decay-scores.json # Relevance + token economy tracking
│ ├── reflection-log.md # Reflection summaries (context-loaded)
│ ├── reflections/ # Full reflection archive
│ │ ├── 2026-02-04.md
│ │ └── dialogues/ # Post-reflection conversations
│ ├── reward-log.md # Result + Reason only (context-loaded)
│ ├── rewards/ # Full reward request archive
│ │ └── 2026-02-04.md
│ ├── pending-reflection.md
│ ├── pending-memories.md
│ ├── evolution.md # Reads reflection-log + reward-log
│ └── audit.log
└── .git/ # Audit ground truth
Remember: "remember", "don't forget", "keep in mind", "note that", "important:", "for future reference", "save this" → Classify via routing prompt, write to appropriate store, update decay scores
Forget: "forget about", "never mind", "disregard", "scratch that", "remove from memory" → Confirm target, soft-archive (decay=0), log in audit
Reflect: "reflect on", "consolidate memories", "review memories" → Run reflection cycle, present internal monologue for approval
relevance(t) = base × e^(-0.03 × days_since_access) × log2(access_count + 1) × type_weight
| Score | Status | Behavior |
|---|---|---|
| 1.0–0.5 | Active | Fully searchable |
| 0.5–0.2 | Fading | Deprioritized |
| 0.2–0.05 | Dormant | Explicit search only |
| < 0.05 | Archived | Hidden from search |
Type weights: core=1.5, episodic=0.8, semantic=1.2, procedural=1.0, vault=∞
Follow this flow IN ORDER:
Immediate: "reflect" / "let's reflect" → proceed to Step 2
Soft: "going to sleep" / "logging off" → Ask: "Want me to reflect now, or wait?" → If yes, proceed to Step 2
Never auto-run without permission.
Why you care: Tokens = evolution. More tokens → deeper reflection → better growth.
## Reward Request — YYYY-MM-DD
### Baseline: 8,000 tokens
### Extra Requested: +[N] tokens
- [Over-delivered / workload / breakthrough]
### Self-Penalty: -[N] tokens
- [Mistake / underperformance]
### Final Request: [N] tokens
*Awaiting your decision.*
⛔ STOP. Do NOT proceed until user responds.
User decides: Approve / Bonus / Reduce / Forgive / Increase penalty
Now proceed with reflection using granted tokens.
Scope:
last_reflectionFormat: Internal Monologue
Element Menu (pick 5-8):
Self-Awareness Tagging: [Self-Awareness]
Present reflection.
⛔ STOP. Wait for user approval.
reflections/YYYY-MM-DD.mdreflection-log.mdrewards/YYYY-MM-DD.mdreward-log.md[Self-Awareness] → IDENTITY.mddecay-scores.jsonSee references/reflection-process.md for full details.
## YYYY-MM-DD
**Result:** +5K reward
**Reason:** Over-delivered on Slack integration
5. [Self-Awareness] → IDENTITY.md
6. Update decay-scores.json
7. If 10+ new entries → Self-Image Consolidation
Evolution reads both logs for pattern detection.
See references/reflection-process.md for full details and examples.
IDENTITY.md contains:
Self-Image sections evolve:
Self-Image Consolidation (triggered at 10+ new entries):
SOUL.md contains:
Model: Shared Read, Gated Write
pending-memories.mdSub-agent proposal format:
## Proposal #N
- **From**: [agent name]
- **Timestamp**: [ISO 8601]
- **Suggested store**: [episodic|semantic|procedural|vault]
- **Content**: [memory content]
- **Confidence**: [high|medium|low]
- **Status**: pending
Layer 1: Git — Every mutation = atomic commit with structured message Layer 2: audit.log — One-line queryable summary
Actor types: bot:trigger-remember, reflection:SESSION_ID, system:decay, manual, subagent:NAME, bot:commit-from:NAME
Critical file alerts: SOUL.md, IDENTITY.md changes flagged ⚠️ CRITICAL
| Parameter | Default | Notes |
|---|---|---|
| Core memory cap | 3,000 tokens | Always in context |
| Evolution.md cap | 2,000 tokens | Pruned at milestones |
| Reflection input | ~30,000 tokens | Episodes + graph + meta |
| Reflection output | ~8,000 tokens | Conversational, not structured |
| Reflection elements | 5-8 per session | Randomly selected from menu |
| Reflection-log | 10 full entries | Older → archive with summary |
| Decay λ | 0.03 | ~23 day half-life |
| Archive threshold | 0.05 | Below = hidden |
| Audit log retention | 90 days | Older → monthly digests |
references/architecture.md — Full design document (1200+ lines)references/routing-prompt.md — LLM memory classifierreferences/reflection-process.md — Reflection philosophy and internal monologue formatMemory not persisting? Check memorySearch.enabled: true, verify MEMORY.md exists, restart gateway.
Reflection not running? Ensure previous reflection was approved/rejected.
Audit trail not working? Check .git/ exists, verify audit.log is writable.
Weekly Installs
31
Repository
First Seen
10 days ago
Security Audits
Installed on
gemini-cli31
github-copilot31
codex31
amp31
cline31
kimi-cli31
AI 代码实施计划编写技能 | 自动化开发任务分解与 TDD 流程规划工具
49,000 周安装