persistent-memory

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Persistent Memory

持久化内存

Use this skill as the single memory system for this repository.
请将该Skill作为此仓库的唯一内存系统使用。

Commands

命令

Use either command style:
  • python3 .agents/skills/persistent-memory/scripts/memory.py <command>
  • .agents/skills/persistent-memory/scripts/pmem <command>
Supported commands:
  • init
  • sync
    (database-only health check)
  • cleanup-legacy
  • backfill-embeddings --batch 500
  • prune --source "<label>" [--older-than <days>]
  • search "<query>" --limit 8
  • add "<memory text>" --tags "<comma,tags>" --source "assistant"
  • recent --limit 10
  • stats
可使用以下任意一种命令格式:
  • python3 .agents/skills/persistent-memory/scripts/memory.py <command>
  • .agents/skills/persistent-memory/scripts/pmem <command>
支持的命令:
  • init
  • sync
    (仅数据库健康检查)
  • cleanup-legacy
  • backfill-embeddings --batch 500
  • prune --source "<label>" [--older-than <days>]
  • search "<query>" --limit 8
  • add "<memory text>" --tags "<comma,tags>" --source "assistant"
  • recent --limit 10
  • stats

Required Workflow

必备工作流

  1. Initialize memory in a fresh workspace:
  • pmem init
  1. At the start of substantial tasks:
  • pmem sync
    (database-only health check)
  • pmem search "<topic keywords>" --limit 8
  1. When user explicitly says
    remember
    or when a durable preference/fact is learned:
  • pmem add "<memory text>" --tags "<tags>" --source "assistant"
  1. Before finalizing memory-sensitive work, verify recall state:
  • pmem stats
  1. 在新工作区中初始化内存:
  • pmem init
  1. 在执行重要任务前:
  • pmem sync
    (仅数据库健康检查)
  • pmem search "<topic keywords>" --limit 8
  1. 当用户明确说出“记住”或获取到持久化偏好/事实时:
  • pmem add "<memory text>" --tags "<tags>" --source "assistant"
  1. 在完成对内存敏感的工作前,验证召回状态:
  • pmem stats

One-Time Migration (If Upgrading From Older Setup)

一次性迁移(从旧版本升级时)

  1. Remove legacy imported rows:
  • pmem cleanup-legacy
  1. Generate vectors for existing notes:
  • pmem backfill-embeddings
  1. 删除旧版导入的记录:
  • pmem cleanup-legacy
  1. 为现有笔记生成向量:
  • pmem backfill-embeddings

Storage Rules

存储规则

  • Store durable preferences, long-lived facts, stable workflows, and repeated constraints.
  • Do not store noisy one-off transient details unless requested.
  • Keep entries concise and specific.
  • Prefer tags that improve retrieval quality (
    preferences
    ,
    calendar
    ,
    comms
    ,
    product
    ).
  • 存储持久化偏好、长期事实、稳定工作流以及重复出现的约束条件。
  • 除非有要求,否则不要存储杂乱的一次性临时细节。
  • 确保记录简洁且具体。
  • 优先使用能提升检索质量的标签(如
    preferences
    calendar
    comms
    product
    )。

Retrieval Rules

检索规则

  • Use targeted search queries instead of broad terms.
  • Keep default
    --limit
    low unless deeper recall is needed.
  • search
    automatically reinforces recalled entries by updating
    hits
    and
    last_seen_at
    .
  • hits
    are analytics-oriented and not used as a direct ranking boost.
  • Search uses hybrid retrieval: lexical + semantic.
  • Semantic search tries
    sqlite-vec
    first and auto-falls back to Python cosine if needed.
  • 使用针对性的搜索查询,而非宽泛的术语。
  • 除非需要深度召回,否则保持默认的
    --limit
    值较低。
  • search
    命令会通过更新
    hits
    last_seen_at
    字段自动强化已召回的记录。
  • hits
    字段用于分析,不会直接作为排名提升的依据。
  • 搜索采用混合检索方式:词法检索 + 语义检索。
  • 语义检索会优先尝试
    sqlite-vec
    ,必要时自动回退到Python余弦相似度计算。

Bootstrapping and Recovery

引导与恢复

  • If
    .memory/
    is missing, run
    pmem init
    .
  • pmem sync
    is a lightweight database-only check (no markdown import/export).
  • If semantic mode degrades, run
    pmem stats
    to inspect
    semantic_backend
    and
    embedding_coverage
    .
  • For command examples and quick troubleshooting, read
    references/usage.md
    .
  • 如果
    .memory/
    目录缺失,请运行
    pmem init
  • pmem sync
    是轻量级的仅数据库检查(不涉及Markdown导入/导出)。
  • 如果语义模式性能下降,请运行
    pmem stats
    检查
    semantic_backend
    embedding_coverage
  • 如需命令示例和快速故障排查,请查阅
    references/usage.md