Files
oc/memory/ROOT.md
T
xiaoshuai a64ea2acb3 Add memory plugin: three-tier markdown store with plugin-driven retrieval
A durable memory layer for OpenCode. Structure:

  ROOT.md          total plan: goals, hard rules, directory registry,
                   and a scenario -> file routing table
  <category>/
    index.md       one line per file, COMPILED from frontmatter
    <slug>.md      the memory itself

Two roots, same shape: <config>/memory/ (global) and
<project canonical>/.memory/ (project). Project wins on conflict; global
hard rules stay resident everywhere.

Why a plugin rather than a skill that tells the model to read a folder:
model-driven retrieval is unreliable — the model forgets, reads half the
files, or reads the wrong ones. Markdown is the human-facing format; the
plugin is the engine that parses, scores, and injects.

Measured, not assumed: FTS5's two built-in tokenizers both fail on this
corpus. On SQLite 3.53.4 with "部署脚本用 pnpm 而不是 npm...": unicode61
emits 7 terms for the whole sentence and matches 0 hits for "部署";
trigram needs >= 3 characters and also returns 0 for that two-character
word. So tokenization happens in the plugin (CJK bigrams, latin words)
and no SQL index is used — a thousand memories are fine to scan.

index.md and ROOT's two tables are compiled, never hand-edited: a
hand-maintained index drifts, a generated one cannot. Hit counters live
in .state.json so cross-device sync does not conflict on every recall.

Tools are named recall/remember/forget/inspect rather than
write/read/status: generic names were observed shadowing the harness's
own built-in tools.
2026-10-09 10:17:45 +08:00

42 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 记忆总纲 — 全局
> 跨项目通用记忆:你的偏好、技术决策、通用约定、踩过的坑。
> 由 memory 插件维护。`auto:begin` / `auto:end` 之间的表格是编译产物,不要手改;
> 其余区域随便写。
## 当前目标
<!-- 手写:现在在做什么。插件不会碰这里。 -->
## 铁规则(常驻,永不衰减)
<!-- 手写:只写硬性要求。rules/ 目录下的文件会被自动常驻注入。 -->
## 目录登记
<!-- auto:begin registry
| 目录 | 概述 | 条目 |
|---|---|---|
| decisions/ | 选 Markdown 因为人类可纠正性和可同步性,检索由插件做而非模型。 | 1 |
| pitfalls/ | unicode61 把整段中文当一个 token,trigram 漏掉两字词,必 | 1 |
| rules/ | 不可违反的硬规则,常驻 | 1 (1 钉住) |
<!-- auto:end
## 加载路由表
<!-- auto:begin routing
| 场景 / 触发 | 读哪个文件 | 类型 |
|---|---|---|
| FTS5 | pitfalls/sqlite-cjk-tokenizer.md | fact |
| memory | decisions/memory-store-format.md | fact |
| SQLite | pitfalls/sqlite-cjk-tokenizer.md | fact |
| 中文检索 | pitfalls/sqlite-cjk-tokenizer.md | fact |
| 为什么用 markdown | decisions/memory-store-format.md | fact |
| 全文检索 | pitfalls/sqlite-cjk-tokenizer.md | fact |
| 分词 | pitfalls/sqlite-cjk-tokenizer.md | fact |
| 存储选型 | decisions/memory-store-format.md | fact |
| 记忆 | decisions/memory-store-format.md | fact |
<!-- auto:end