open-memex 0.10.0-alpha.4 → 0.11.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -5
- package/CHANGELOG.md +5 -1
- package/README.md +41 -20
- package/README.zh-CN.md +19 -7
- package/dist/.build-stamp +1 -1
- package/dist/cli.js +95 -21
- package/dist/curate.js +374 -16
- package/dist/init.js +4 -0
- package/dist/mcp.js +8 -3
- package/dist/store/curate.js +418 -102
- package/dist/store/curation-feedback.js +51 -0
- package/dist/submit.js +124 -6
- package/dist/tools/ops.js +40 -6
- package/docs/V2-DESIGN.md +2 -2
- package/docs/design/decisions.md +4 -1
- package/package.json +66 -66
- package/scripts/curate-eval.ts +345 -19
- package/scripts/smoke-pure.ts +116 -1
- package/server.json +2 -2
- package/src/cli.ts +95 -20
- package/src/curate.ts +460 -17
- package/src/init.ts +4 -0
- package/src/mcp.ts +8 -3
- package/src/store/curate.ts +675 -270
- package/src/store/curation-feedback.ts +81 -0
- package/src/submit.ts +135 -4
- package/src/tools/ops.ts +38 -6
package/AGENTS.md
CHANGED
|
@@ -45,8 +45,8 @@ npm run cli -- push # push current bran
|
|
|
45
45
|
npm run cli -- export [--scope project|personal|both] [--all] [-o <file>] # portable .tar.gz bundle (markdown + manifest); private excluded unless --all
|
|
46
46
|
npm run cli -- import <bundle.tar.gz> [--dry-run] # restore: personal → personal dir, project → outbox re-keyed; conflicts reported, never overwritten
|
|
47
47
|
npm run cli -- distill-agents [--type t1,t2] [-o <file>] # propose an AGENTS.md snippet from project memories (assist only; you merge by hand)
|
|
48
|
-
npm run cli -- submit <id...> [--branch <name>] [--base <branch>] [--
|
|
49
|
-
npm run cli -- curate undo <id>
|
|
48
|
+
npm run cli -- submit <id...> [--branch <name>] [--base <branch>] [--accept-batch|--decline-batch] # lint + auto tier + one batch decision, then drafts → .ai/open-memex/ (current branch + local commit; never auto-branches)
|
|
49
|
+
npm run cli -- curate undo <id> | --batch <batch-id> | stats # reverse one auto action / a whole accepted batch / show feedback counters
|
|
50
50
|
npm run cli -- propose <id...> --to project [--local-approve] # copy personal → project outbox (batch OK)
|
|
51
51
|
npm run cli -- promote <id> [--reject] [--resubmit] [--note "..."] # proposed → approved → published (audit trail appended)
|
|
52
52
|
npm run cli -- pr-status [--apply] # map branch PR's GitHub state onto review_state (report; apply = local only)
|
|
@@ -181,7 +181,7 @@ verb for the ritual.
|
|
|
181
181
|
- Chain integrity is self-healing: on read, a missing counterpart is auto-completed with a warning; a dangling pointer warns but is never fabricated. Don't "fix" chains by editing frontmatter directly — let the read path do it.
|
|
182
182
|
- Frontmatter is `schema_version: 2`. The SQLite index schema is versioned separately and rebuilds automatically on version change — never hand-edit `index.db`.
|
|
183
183
|
|
|
184
|
-
**Pre-submit curation (D78/D93) —
|
|
184
|
+
**Pre-submit curation (D78/D93/D95) — two tiers, every action undoable.** `submit` reports graph lint (report-only, never blocks), then applies the **auto tier**: exact duplicates (`contentHash`-identical normalized body) merge into the oldest free active canonical via the supersede chain, empty/whitespace-only bodies archive, a ragged first non-empty line is whitespace-normalized, and a HIGH-confidence type/tag inference auto-applies **only** when `source: keyword` (the hook never chose a type or tag, so nothing explicit is overwritten; tags are additive and capped at 3). The **batch tier** — semantic merges (near-dup ≥ 0.9 with a ≥0.6 length ratio; 0.8–0.9 stays report-only because one flipped word lands there), splits of an overlong body with two unrelated paragraphs (MIN_SPLIT_BODY_CHARS 320, each half ≥ 100, overlap < 0.25, code fences excluded), and any uncertain type/tag inference — is ONE screen: no decision flag means submit throws `BatchDecisionRequired` **before the first write**; `--accept-batch` applies all, `--decline-batch` changes nothing (never per-item gates). Planner is pure (`src/curate.ts`), writes go through `src/store/curate.ts` using `atomicWriteTextSync`/`setStatus` and append a `curation:` receipt (with its `signal` and, for a batch, the `batch <id>` token) to `review_history`; `open-memex curate undo <id>` reverses the latest action on one memory, `curate undo --batch <id>` replays the exact markers of one accepted batch, `open-memex status <id> active` restores an archived empty. Never choose a chain-managed record as canonical, never merge into a non-active record, and never submit a non-active record — curated-out files stay in the outbox as history, not as proposed memories. A split keeps both halves: the original keeps the first part, a new memory gets the second with `derived_from` set, and that new id rides the same submit. Curation failure is reported and skipped, never fatal to the human's submit; a failed batch is rolled back as a unit, and a failure before the local commit rolls applied curation back. The printed `gh pr create` command's title/count/ids come from the actual submitted set, and its body carries the lint counts, the auto-action counts and the batch decision (shell-safe, no nested quotes). `curation_feedback` (in `index.db`, `CREATE TABLE IF NOT EXISTS` like D77's counters, never dropped by a rebuild) records accepted / declined / undone per signal; it is observational only — **no threshold learns from it yet**. Keep the CLI, MCP `memory_submit` output, READMEs, and the fixture (`scripts/curate-eval.ts`) saying the same thing.
|
|
185
185
|
|
|
186
186
|
Keyword capture fires from `chat.message` on the user's message parts (`UserMessage`). Patterns live in `src/capture/keywords.ts` / config `keywordPatterns`; regex group 1 is the memory body. Scope routing: personal patterns (`cfg.keywordPersonalPatterns`) force the personal scope — the rule is 我 → personal (记住我/替我记/帮我记/我觉得/我喜欢/remember for me/help me remember), 我们 → current scope (我们认为/我们决定/帮我们记住); personal patterns run first and claim their line so a generic trigger can't double-fire (a rejected personal match keeps the claim — see D67).
|
|
187
187
|
|
|
@@ -228,9 +228,9 @@ through the normal flow, not write them.
|
|
|
228
228
|
|
|
229
229
|
## Design constraints — read the frozen design first
|
|
230
230
|
|
|
231
|
-
`docs/V2-DESIGN.md` is the frozen protocol v0.2 (decisions settled through
|
|
231
|
+
`docs/V2-DESIGN.md` is the frozen protocol v0.2 (decisions settled through D94 — log in `docs/design/decisions.md`; open questions tracked at the end of the doc). Per its §12:
|
|
232
232
|
AGENTS.md answers "how should AI work here"; the design doc answers "why is it
|
|
233
|
-
built this way" (principles, iron rules, the append-only decision log in `docs/design/decisions.md`, currently D1–
|
|
233
|
+
built this way" (principles, iron rules, the append-only decision log in `docs/design/decisions.md`, currently D1–D94). Before changing
|
|
234
234
|
architecture, scope semantics, lifecycle, or the protocol surface (frontmatter
|
|
235
235
|
schema, MCP tools, CLI contract), read the relevant design section — the decision
|
|
236
236
|
log records what was already considered and rejected.
|
package/CHANGELOG.md
CHANGED
|
@@ -7,7 +7,11 @@ rationale behind each decision lives in the decision log in
|
|
|
7
7
|
[docs/V2-DESIGN.md](docs/V2-DESIGN.md). Pre-release builds published under
|
|
8
8
|
the `@alpha` tag are development snapshots and are not listed individually.
|
|
9
9
|
|
|
10
|
-
## [
|
|
10
|
+
## [0.11.0-alpha.1] - 2026-11-20
|
|
11
|
+
|
|
12
|
+
- D78 pre-submit curation, second slice (D95): submit now has a real **batch-confirm** tier next to the deterministic one. Semantic merges (near-duplicates whose similarity is >= 0.9 and whose lengths are within 60% - 0.8-0.9 stays report-only, because one flipped word lands there), **splits** of an overlong memory whose paragraphs share < 25% vocabulary (accepting keeps BOTH halves: the original keeps the first, a new memory with `derived_from` takes the second and rides the same submit), and uncertain **type/tag inferences** all appear as ONE summary screen. With proposals and no decision flag, submit stops **before writing anything** and prints the summary; `--accept-batch` applies the whole batch, `--decline-batch` changes none of it (never per-item approval). The auto tier gained high-confidence type/tag inference (e.g. an explicit `TODO:`, `We decided`, `#hashtag`) that applies **only** to keyword captures, where the hook never chose a type or tag - a tool/CLI save may have chosen it deliberately, so it goes to the batch screen instead, and an explicit non-default type is never touched. Tags are additive only, capped at 3 per memory. Every action stays reversible: `open-memex curate undo <id>` reverses the latest one, and the new `open-memex curate undo --batch <id>` reverses a whole accepted batch by replaying its exact receipts (a split undo rejoins the halves and retracts the derived part). Accepted/declined/undone counts are recorded per signal in a local `curation_feedback` table (created with `CREATE TABLE IF NOT EXISTS` next to the D77 counters, never dropped by a rebuild) and printed by `open-memex curate stats` - data for future threshold learning only, no threshold changes yet. The generated `gh pr create` body now carries the batch decision too. Fixture (`scripts/curate-eval.ts`) pins the new cases before and after: no-flag run leaves the outbox byte-identical, accepted batch = 5 auto actions + 4 batch items + 1 split part, declined batch changes nothing, and one command reverses the batch. MCP `memory_submit` gains `curateBatch="accept"|"decline"` and returns the summary as a normal result, so an agent asks once for the whole batch.
|
|
13
|
+
|
|
14
|
+
## [0.10.0] - 2026-11-13
|
|
11
15
|
|
|
12
16
|
- D94 OptMem small items (§18 item 5): open-memex's prompt/token overhead is now **measured and published**, not asserted — `scripts/token-cost.ts` renders the real `buildContextBlock` output (8 project + 5 personal + the compiled graph outline) and the real `TOOL_DESCRIPTIONS` text on a scratch store, estimating tokens as characters ÷ 4 (no tokenizer dependency); measured: injection block 2125 chars (~531 tokens), 13 tool descriptions 8814 chars (~2204 tokens), total 10939 chars (~2735 tokens), quoted as approximations in both READMEs with the method stated and the once-per-session (not per-turn) injection spelled out. A **wake convention** documents the session-start ritual — read the injected `[OPEN-MEMEX]` block (working-state note + graph outline ride it); if empty or insufficient, one `memory_search` with the task's keywords; never re-ask the user for what memory holds — stated identically in README (en + zh), the bundled Agent Skill, and the MCP handshake instructions, with no new tool or CLI verb and no invented tool name. A **capture length nudge**: bodies over 500 characters save normally and the result carries a one-line hint (`lengthNudge`, pure, smoke-tested) on `memory_add` and CLI `add` — nothing is refused; and a keyword match over the unchanged 2000-character hard cap, previously dropped with only a debug log line, is now surfaced to the agent in the D73 hand-off note so it can re-save a shortened version.
|
|
13
17
|
|
package/README.md
CHANGED
|
@@ -470,7 +470,7 @@ they only matter once you share memories through Git.
|
|
|
470
470
|
| ● `memory_workingstate` | Read/write/clear the per-project working-state note (§3.6, D89) — resumes an interrupted task; scratch state, never a memory |
|
|
471
471
|
| ● `memory_useful` | Mark a memory as useful (D77) — explicit confirmation only; exposure is counted separately as `retrieved_count` |
|
|
472
472
|
| `memory_status` | Show the sync queue (outbox drafts, repo review states, uncommitted files) plus the D77 reuse report |
|
|
473
|
-
| `memory_submit` | Curate deterministic
|
|
473
|
+
| `memory_submit` | Curate (deterministic auto tier + one batch decision), then move named drafts into the repo memory dir (local branch + commit) |
|
|
474
474
|
| `memory_propose` | Copy personal memories into the project scope as review candidates |
|
|
475
475
|
| `memory_promote` | Advance `proposed → approved → published` (or reject / resubmit) |
|
|
476
476
|
| `memory_resolve` | List conflicted memory files / 3-way-merge one of them |
|
|
@@ -537,12 +537,18 @@ capture → outbox (draft, local) → submit → repo (.ai/open-memex/) → PR r
|
|
|
537
537
|
shows what's pending.
|
|
538
538
|
3. **Submit** — you name the memories; they move into `<repo>/.ai/open-memex/`
|
|
539
539
|
with a local commit on your current branch. Before copying, `submit` prints
|
|
540
|
-
a report-only graph lint and auto-applies
|
|
541
|
-
duplicates
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
540
|
+
a report-only graph lint and auto-applies the deterministic tier: exact
|
|
541
|
+
duplicates merge through the supersede chain, empty bodies are archived,
|
|
542
|
+
ragged first-line titles are normalized, and a high-confidence type/tag
|
|
543
|
+
inference from a keyword capture is accepted. The judgement calls — semantic
|
|
544
|
+
merges (near-duplicates with the same token content), splits of an overloaded
|
|
545
|
+
memory, and uncertain type/tag inferences — appear together as **one
|
|
546
|
+
batch-confirm screen**: one flag accepts the whole batch, one flag declines
|
|
547
|
+
it, and a decline leaves every proposed memory untouched (the deterministic
|
|
548
|
+
tier above still ran). Never per-item dialogs.
|
|
549
|
+
Every change prints its undo command, an accepted batch is undone as a unit
|
|
550
|
+
(`curate undo --batch <id>`), and `--no-curate` skips curation while keeping
|
|
551
|
+
the lint report. open-memex never pushes on its own; it prints the push + PR
|
|
546
552
|
commands, and an agent holding your explicit yes can carry them out.
|
|
547
553
|
4. **PR review** — memories are plain Markdown; reviewers approve, request
|
|
548
554
|
changes, or reject through the normal branch/PR process.
|
|
@@ -849,16 +855,23 @@ open-memex sync-status
|
|
|
849
855
|
# and any uncommitted repo memory files.
|
|
850
856
|
|
|
851
857
|
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
858
|
+
[--accept-batch | --decline-batch]
|
|
852
859
|
# move your named drafts into .ai/open-memex/ as "proposed":
|
|
853
860
|
# copies, flips review_state, local git commit ON THE CURRENT BRANCH.
|
|
854
861
|
# Never creates a branch on its own — branch creation is your call
|
|
855
862
|
# (or the agent's, only with your explicit approval for the full chain).
|
|
856
|
-
# Before copying: report-only graph lint + deterministic
|
|
857
|
-
# (exact-duplicate merge, empty-body archive, first-line title cleanup
|
|
858
|
-
#
|
|
859
|
-
#
|
|
860
|
-
#
|
|
861
|
-
#
|
|
863
|
+
# Before copying: report-only graph lint + deterministic auto-apply
|
|
864
|
+
# (exact-duplicate merge, empty-body archive, first-line title cleanup,
|
|
865
|
+
# high-confidence type/tag inference on keyword captures).
|
|
866
|
+
# Then the batch tier: semantic merges, splits, and uncertain type/tag
|
|
867
|
+
# inferences are printed as ONE summary. With proposals and no decision
|
|
868
|
+
# flag, submit stops before writing anything; rerun with --accept-batch
|
|
869
|
+
# (apply all) or --decline-batch (decline the whole batch). Never per-item
|
|
870
|
+
# dialogs.
|
|
871
|
+
# --no-curate skips curation entirely but still prints lint.
|
|
872
|
+
# Every applied action prints its undo command. The generated gh pr create
|
|
873
|
+
# body carries the lint + curation summary and counts only the ids actually
|
|
874
|
+
# submitted (not the pre-curation batch).
|
|
862
875
|
# All-or-nothing; conflicts (same id, different content) abort cleanly.
|
|
863
876
|
# Prints the push + gh pr commands; an agent holding your Yes carries
|
|
864
877
|
# through push/PR itself. --branch <name> creates the branch first
|
|
@@ -867,10 +880,17 @@ open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
|
867
880
|
# wherever you review.
|
|
868
881
|
|
|
869
882
|
open-memex curate undo <id>
|
|
870
|
-
# reverse the latest automatic curation on one memory (merge
|
|
871
|
-
# The receipt lives in the file's review_history, so
|
|
872
|
-
# branches and machines; an empty-body archive is
|
|
873
|
-
# `open-memex status <id> active`.
|
|
883
|
+
# reverse the latest automatic curation on one memory (merge, title fix,
|
|
884
|
+
# inferred type/tags). The receipt lives in the file's review_history, so
|
|
885
|
+
# this works across branches and machines; an empty-body archive is
|
|
886
|
+
# restored with `open-memex status <id> active`.
|
|
887
|
+
|
|
888
|
+
open-memex curate undo --batch <batch-id>
|
|
889
|
+
# reverse a whole accepted batch at once (the id is printed by submit).
|
|
890
|
+
|
|
891
|
+
open-memex curate stats
|
|
892
|
+
# accepted / declined / undone counters per curation signal — the local
|
|
893
|
+
# feedback the confidence thresholds will learn from (nothing is tuned yet).
|
|
874
894
|
|
|
875
895
|
open-memex pr-status [--apply]
|
|
876
896
|
# read the branch's GitHub PR and map its state onto each in-repo memory:
|
|
@@ -994,9 +1014,10 @@ open-memex graph lint [--json] # orphans, dangling edges, near-stale pai
|
|
|
994
1014
|
```
|
|
995
1015
|
|
|
996
1016
|
`lint` reports only — nothing is auto-resolved; a human decides. The same report
|
|
997
|
-
is the input for D78's pre-submit curation (D93): `submit` prints it before
|
|
998
|
-
|
|
999
|
-
its thirteen memory
|
|
1017
|
+
is the input for D78's pre-submit curation (D93/D95): `submit` prints it before
|
|
1018
|
+
curation, and a stale pair it flags is a candidate for the batch-confirm screen.
|
|
1019
|
+
The graph interface is CLI-only; the MCP surface stays at its thirteen memory
|
|
1020
|
+
tools.
|
|
1000
1021
|
|
|
1001
1022
|
## MCP server
|
|
1002
1023
|
|
package/README.zh-CN.md
CHANGED
|
@@ -302,7 +302,7 @@ MCP 服务器暴露十三个工具;opencode 原生插件暴露其中七个核
|
|
|
302
302
|
| ● `memory_workingstate` | 读/写/清除每项目的工作状态笔记(§3.6,D89)——让被中断的任务得以续接;只是草稿状态,永远不会成为记忆 |
|
|
303
303
|
| ● `memory_useful` | 确认一条记忆有用(D77)——只认显式确认;被动的搜索/列表出现只计入 `retrieved_count`,绝不算有用 |
|
|
304
304
|
| `memory_status` | 显示同步队列(outbox 草稿、仓库评审状态、未提交文件),并附带 D77 复用报告 |
|
|
305
|
-
| `memory_submit` |
|
|
305
|
+
| `memory_submit` | 先做策展(确定性自动层 + 一次批次决定),再把指定草稿移进仓库记忆目录(本地分支 + 提交) |
|
|
306
306
|
| `memory_propose` | 把个人记忆复制到项目作用域,作为评审候选 |
|
|
307
307
|
| `memory_promote` | 推进 `proposed → approved → published`(或拒绝 / 重新提交) |
|
|
308
308
|
| `memory_resolve` | 列出冲突的记忆文件 / 对某个做三方合并 |
|
|
@@ -344,7 +344,7 @@ MCP 服务器暴露十三个工具;opencode 原生插件暴露其中七个核
|
|
|
344
344
|
|
|
345
345
|
1. **捕获**——日常工作中随手存下决策、坑、教训,都是草稿。
|
|
346
346
|
2. **评审**——草稿停在本地 outbox 里(你机器上,git 看不见);`open-memex sync-status`——或者直接在聊天里说"sync memory"("同步记忆")——看有啥待处理的。
|
|
347
|
-
3. **提交**——由你点名记忆;它们进入 `<仓库>/.ai/open-memex/` 并在当前分支形成一个本地提交。复制之前,`submit` 先打印只读的图谱 lint
|
|
347
|
+
3. **提交**——由你点名记忆;它们进入 `<仓库>/.ai/open-memex/` 并在当前分支形成一个本地提交。复制之前,`submit` 先打印只读的图谱 lint,再自动应用确定性层:完全重复合并进 supersede 链、空正文归档、首行标题空白规范化,以及关键词捕获上高置信度的类型/标签推断。需要判断的部分——语义合并(token 内容相同的近重复)、超载记忆的拆分、不确定的类型/标签推断——一起显示为**一屏 batch-confirm**:一个参数接受整批,一个参数拒绝整批,拒绝时每条提案记忆原样不动(上面那层确定性动作已经跑过),永不逐条弹确认。每个动作都打印撤销命令,接受的批次可用 `curate undo --batch <id>` 整批撤销;`--no-curate` 跳过策展但保留 lint 报告。open-memex 永不自动推送;它会打印推送和建 PR 的命令,拿到你明确许可的助手可以替你执行。
|
|
348
348
|
4. **PR 评审**——记忆是纯 Markdown;评审者走正常分支/PR 流程批准、要求修改或拒绝。
|
|
349
349
|
5. **回想**——已发布的记忆在会话开始时注入,平时也能随时搜,人和助手都一样。
|
|
350
350
|
|
|
@@ -531,12 +531,17 @@ open-memex sync-status
|
|
|
531
531
|
# 以及任何未提交的仓库记忆文件。
|
|
532
532
|
|
|
533
533
|
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
534
|
+
[--accept-batch | --decline-batch]
|
|
534
535
|
# 把你点名的草稿移进 .ai/open-memex/,标为 "proposed":
|
|
535
536
|
# 复制、翻转 review_state、在当前分支本地 git 提交。
|
|
536
537
|
# 永不自己建分支——建分支是你(或拿到完整链路明确许可的助手)的事。
|
|
537
|
-
# 复制前:只读图谱 lint +
|
|
538
|
-
#
|
|
539
|
-
#
|
|
538
|
+
# 复制前:只读图谱 lint + 确定性自动应用(完全重复合并、空正文归档、
|
|
539
|
+
# 首行标题清理、关键词捕获上的高置信度类型/标签推断)。
|
|
540
|
+
# 然后是批次层:语义合并、拆分、不确定的类型/标签推断打成一屏摘要。
|
|
541
|
+
# 有提案又没带决定参数时,submit 在写任何东西之前停下;重跑时带
|
|
542
|
+
# --accept-batch(全部应用)或 --decline-batch(拒绝整批),永不逐条确认。
|
|
543
|
+
# --no-curate 完全跳过策展但仍打印 lint。
|
|
544
|
+
# 每个已应用动作都会打印撤销命令。
|
|
540
545
|
# 生成的 gh pr create body 带 lint + 策展摘要,人数只算实际提交的 id
|
|
541
546
|
#(不是提交前的批次)。
|
|
542
547
|
# 全有全无;冲突(同 id 不同内容)干净地中止。
|
|
@@ -545,10 +550,17 @@ open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
|
545
550
|
# (记忆 PR 叠在你的工作分支上);--base 可改指到 main 或你的评审分支。
|
|
546
551
|
|
|
547
552
|
open-memex curate undo <id>
|
|
548
|
-
#
|
|
553
|
+
# 撤销某条记忆上最近一次自动策展(合并、标题修正、推断的类型/标签)。
|
|
549
554
|
# 凭据写在文件 review_history 里,所以跨分支/跨机器都能撤销;
|
|
550
555
|
# 空正文归档用 `open-memex status <id> active` 恢复。
|
|
551
556
|
|
|
557
|
+
open-memex curate undo --batch <batch-id>
|
|
558
|
+
# 一次撤销整个已接受的批次(id 由 submit 打印)。
|
|
559
|
+
|
|
560
|
+
open-memex curate stats
|
|
561
|
+
# 每个策展信号的 accepted / declined / undone 计数——本地反馈,
|
|
562
|
+
# 供置信度阈值将来学习(目前还不调参)。
|
|
563
|
+
|
|
552
564
|
open-memex pr-status [--apply]
|
|
553
565
|
# 读分支的 GitHub PR,把状态映射到每条仓库内记忆:
|
|
554
566
|
# PR 合并 → published,PR 批准 → approved(approved_by = 评审者),
|
|
@@ -637,7 +649,7 @@ open-memex graph path <a> <b> # 最短跳链,带凭据
|
|
|
637
649
|
open-memex graph lint [--json] # 孤立节点、悬空边、近陈旧对
|
|
638
650
|
```
|
|
639
651
|
|
|
640
|
-
`lint` 只报告——不自动处理,由人决定。同一份报告就是 D78 提交前策展(D93)的输入:`submit`
|
|
652
|
+
`lint` 只报告——不自动处理,由人决定。同一份报告就是 D78 提交前策展(D93/D95)的输入:`submit` 在策展前先打印它,它标出的近陈旧对正是 batch-confirm 屏幕的候选。图谱接口仅限 CLI;MCP 表面保持十三个记忆工具不变。
|
|
641
653
|
|
|
642
654
|
## MCP 服务器
|
|
643
655
|
|
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c97deff8e96e65c091a003dae84c06bf3fb6300d2a014c4643e787cfb9559cb5
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import { migrateScope, scopeHasFiles } from "./store/migrate.js";
|
|
|
7
7
|
import { migrateV2 } from "./store/v2migrate.js";
|
|
8
8
|
import { findDuplicates, supersede, setStatus } from "./store/lifecycle.js";
|
|
9
9
|
import { proposeMemories, promoteMemory, listConflicts, resolveConflict, formatReviewHistory, currentAuthor } from "./review.js";
|
|
10
|
-
import { getSyncStatus, formatSyncStatus, submitMemories } from "./submit.js";
|
|
10
|
+
import { getSyncStatus, formatSyncStatus, submitMemories, BatchDecisionRequired } from "./submit.js";
|
|
11
11
|
import { getPrStatus, formatPrStatus, applyPrStatus } from "./github.js";
|
|
12
12
|
import { search, list, countList, hitStateLabel } from "./retrieve/search.js";
|
|
13
13
|
import { recordUseful, getUsage, reuseRate, usefulCount, usefulKindFor, deleteUsage, loadReuseReport } from "./store/usage.js";
|
|
@@ -23,8 +23,9 @@ import { readWorkingState, clearWorkingState, workingStatePath } from "./working
|
|
|
23
23
|
import { refreshGraph, refreshGraphQuiet, ensureGraph, loadGraphEdges, loadGraphNodes, loadAllMemoryIds } from "./store/graph.js";
|
|
24
24
|
import { graphNeighbours, shortestPath } from "./graph/queries.js";
|
|
25
25
|
import { lintGraph } from "./graph/lint.js";
|
|
26
|
-
import { formatCurationAction } from "./curate.js";
|
|
27
|
-
import { undoCuration } from "./store/curate.js";
|
|
26
|
+
import { formatCurationAction, formatBatchSummary, formatBatchProposal } from "./curate.js";
|
|
27
|
+
import { undoCuration, undoBatch } from "./store/curate.js";
|
|
28
|
+
import { loadCurationFeedback, formatCurationFeedback } from "./store/curation-feedback.js";
|
|
28
29
|
import { resolveMcpCommand } from "./init.js";
|
|
29
30
|
import fs from "node:fs";
|
|
30
31
|
import path from "node:path";
|
|
@@ -294,32 +295,52 @@ commits locally on the CURRENT branch, and moves the outbox originals out.
|
|
|
294
295
|
Never creates a branch on its own — branch creation is your call.
|
|
295
296
|
|
|
296
297
|
Usage: open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
298
|
+
[--accept-batch | --decline-batch]
|
|
297
299
|
|
|
298
|
-
D78: submit reports graph lint (report-only, never blocks)
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
D78: submit reports graph lint (report-only, never blocks). The deterministic
|
|
301
|
+
auto tier — exact duplicate merges, empty-body archives, first-line title
|
|
302
|
+
whitespace, high-confidence type/tag inference from keyword captures — is
|
|
303
|
+
applied automatically. Every change is listed with its undo command.
|
|
304
|
+
|
|
305
|
+
D95: semantic merges, splits and uncertain type/tag inferences are one
|
|
306
|
+
batch-confirm screen. With proposals present and no decision flag, submit stops
|
|
307
|
+
before writing anything and prints the summary. One flag decides the whole
|
|
308
|
+
batch: --accept-batch applies all, --decline-batch changes nothing. Undo the
|
|
309
|
+
accepted batch as a unit with \`open-memex curate undo --batch <id>\`.
|
|
302
310
|
|
|
303
311
|
Flags:
|
|
304
|
-
--branch
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
--
|
|
312
|
+
--branch create this branch and submit onto it (only with your
|
|
313
|
+
explicit approval for the full chain); default: stay on
|
|
314
|
+
current branch
|
|
315
|
+
--base PR base override (default: the branch you're on)
|
|
316
|
+
--no-curate skip curation entirely (auto and batch); lint still reports
|
|
317
|
+
--accept-batch accept every batch proposal (never per-item dialogs)
|
|
318
|
+
--decline-batch decline the batch; every memory stays untouched
|
|
308
319
|
|
|
309
320
|
Example:
|
|
310
321
|
open-memex submit 01ABC 01DEF
|
|
311
|
-
open-memex submit 01ABC --
|
|
312
|
-
|
|
322
|
+
open-memex submit 01ABC 01DEF --decline-batch
|
|
323
|
+
open-memex submit 01ABC 01DEF --accept-batch`,
|
|
324
|
+
curate: `Undo deterministic curation applied by submit, or inspect the
|
|
325
|
+
feedback counters.
|
|
313
326
|
|
|
314
327
|
Every action is recorded in the memory file's review_history, so undo works
|
|
315
328
|
across branches and machines. Only the most recent curation action on an id is
|
|
316
329
|
undoable: an undo appends its own receipt, so a second run refuses. Inspect the
|
|
317
330
|
file's review_history for the older trail.
|
|
318
331
|
|
|
332
|
+
D95: an accepted batch is undone as a unit. \`--batch\` replays the exact
|
|
333
|
+
curation receipts that carry that batch token - one memory can hold two (type,
|
|
334
|
+
then tags) - and reports anything it cannot reverse instead of guessing.
|
|
335
|
+
|
|
319
336
|
Usage: open-memex curate undo <id>
|
|
337
|
+
open-memex curate undo --batch <batch-id>
|
|
338
|
+
open-memex curate stats
|
|
320
339
|
|
|
321
|
-
|
|
322
|
-
open-memex curate undo 01ABC
|
|
340
|
+
Examples:
|
|
341
|
+
open-memex curate undo 01ABC
|
|
342
|
+
open-memex curate undo --batch b1a2b3c4d5
|
|
343
|
+
open-memex curate stats`,
|
|
323
344
|
"pr-status": `Map the current branch's GitHub PR state back onto review_state:
|
|
324
345
|
merged → published, approval → approved (approved_by = the reviewer),
|
|
325
346
|
changes-requested → suggestion only (never auto-rejects).
|
|
@@ -506,8 +527,8 @@ Usage:
|
|
|
506
527
|
open-memex export [--scope project|personal|both] [--type T] [--tag t] [--all] [-o <file>]
|
|
507
528
|
open-memex import <bundle.tar.gz> [--dry-run]
|
|
508
529
|
open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N] [-o <file>]
|
|
509
|
-
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
510
|
-
open-memex curate undo <id>
|
|
530
|
+
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate] [--accept-batch|--decline-batch]
|
|
531
|
+
open-memex curate undo <id> | --batch <batch-id> | stats
|
|
511
532
|
open-memex pr-status [--apply]
|
|
512
533
|
open-memex reindex
|
|
513
534
|
open-memex audit [--scope project|personal|both]
|
|
@@ -1794,17 +1815,26 @@ async function main() {
|
|
|
1794
1815
|
return;
|
|
1795
1816
|
}
|
|
1796
1817
|
if (cmd === "submit") {
|
|
1797
|
-
const booleans = new Set(["no-curate"]);
|
|
1818
|
+
const booleans = new Set(["no-curate", "accept-batch", "decline-batch"]);
|
|
1798
1819
|
const flags = parseFlags(rest, booleans);
|
|
1799
1820
|
const ids = positionalArgs(rest, booleans);
|
|
1800
1821
|
if (ids.length === 0)
|
|
1801
1822
|
usage();
|
|
1823
|
+
if (flags["accept-batch"] === "true" && flags["decline-batch"] === "true") {
|
|
1824
|
+
console.error("submit failed: pass either --accept-batch or --decline-batch, not both.");
|
|
1825
|
+
process.exit(2);
|
|
1826
|
+
}
|
|
1802
1827
|
syncScope(project.key, "submit");
|
|
1803
1828
|
try {
|
|
1804
1829
|
const r = submitMemories(ids, {
|
|
1805
1830
|
branch: flags.branch,
|
|
1806
1831
|
base: flags.base,
|
|
1807
1832
|
noCurate: flags["no-curate"] === "true",
|
|
1833
|
+
batch: flags["accept-batch"] === "true"
|
|
1834
|
+
? "accept"
|
|
1835
|
+
: flags["decline-batch"] === "true"
|
|
1836
|
+
? "decline"
|
|
1837
|
+
: undefined,
|
|
1808
1838
|
});
|
|
1809
1839
|
const c = r.curation;
|
|
1810
1840
|
console.log(`curation: ${c.lintFindings.length} lint finding(s) - orphans ${c.lintCounts.orphan}, dangling ${c.lintCounts["dangling-edge"]}, stale ${c.lintCounts.stale}. Reports only - a human decides; nothing is auto-resolved.`);
|
|
@@ -1828,6 +1858,21 @@ async function main() {
|
|
|
1828
1858
|
for (const s of c.skipped) {
|
|
1829
1859
|
console.log(` curation skipped ${s.id}: ${s.reason}`);
|
|
1830
1860
|
}
|
|
1861
|
+
if (c.batchDecision === "accepted") {
|
|
1862
|
+
console.log(`batch-confirm ${c.batchId} accepted: ${c.batchApplied.length} applied`);
|
|
1863
|
+
for (const a of c.batchApplied)
|
|
1864
|
+
console.log(` ${formatBatchProposal(a.proposal)}`);
|
|
1865
|
+
for (const id of c.batchCreated) {
|
|
1866
|
+
console.log(` split part created: ${id}`);
|
|
1867
|
+
}
|
|
1868
|
+
console.log(` undo the whole batch: open-memex curate undo --batch ${c.batchId}`);
|
|
1869
|
+
}
|
|
1870
|
+
else if (c.batchDecision === "declined") {
|
|
1871
|
+
console.log(`batch-confirm ${c.batchId} declined: ${c.proposals.length} proposal(s), nothing changed.`);
|
|
1872
|
+
}
|
|
1873
|
+
else if (c.proposals.length > 0) {
|
|
1874
|
+
console.log(formatBatchSummary(c.plan, { ids }));
|
|
1875
|
+
}
|
|
1831
1876
|
for (const w of c.warnings)
|
|
1832
1877
|
console.log(` curation note: ${w}`);
|
|
1833
1878
|
for (const s of r.submitted) {
|
|
@@ -1847,23 +1892,52 @@ async function main() {
|
|
|
1847
1892
|
console.log(` ${r.prCommand}`);
|
|
1848
1893
|
}
|
|
1849
1894
|
catch (e) {
|
|
1895
|
+
if (e instanceof BatchDecisionRequired) {
|
|
1896
|
+
console.log(e.message);
|
|
1897
|
+
process.exit(2);
|
|
1898
|
+
}
|
|
1850
1899
|
console.error(`submit failed: ${e.message}`);
|
|
1851
1900
|
process.exit(2);
|
|
1852
1901
|
}
|
|
1853
1902
|
return;
|
|
1854
1903
|
}
|
|
1855
1904
|
if (cmd === "curate") {
|
|
1905
|
+
const booleans = new Set();
|
|
1906
|
+
const flags = parseFlags(rest.slice(1), booleans);
|
|
1907
|
+
const args = positionalArgs(rest.slice(1), booleans);
|
|
1856
1908
|
const sub = rest[0];
|
|
1857
|
-
const id = rest[1];
|
|
1858
|
-
if (sub !== "undo" || !id)
|
|
1859
|
-
usage();
|
|
1860
1909
|
syncScope(project.key, "cli");
|
|
1910
|
+
if (sub === "stats") {
|
|
1911
|
+
console.log(formatCurationFeedback(loadCurationFeedback()));
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
if (sub !== "undo")
|
|
1915
|
+
usage();
|
|
1861
1916
|
try {
|
|
1917
|
+
if (flags.batch) {
|
|
1918
|
+
const r = undoBatch(flags.batch, project.key, { by: currentAuthor() });
|
|
1919
|
+
refreshGraphQuiet(project.key, cfg);
|
|
1920
|
+
console.log(`batch ${r.batchId} undone: ${r.undone.length} item(s)${r.skipped.length > 0 ? `, ${r.skipped.length} skipped` : ""}`);
|
|
1921
|
+
for (const u of r.undone)
|
|
1922
|
+
console.log(` ${u.kind} ${u.id}`);
|
|
1923
|
+
for (const s of r.skipped)
|
|
1924
|
+
console.log(` skipped ${s.id}: ${s.reason}`);
|
|
1925
|
+
if (r.undone.length === 0) {
|
|
1926
|
+
console.log(" nothing to undo - the batch may already be reversed, or its memories moved on.");
|
|
1927
|
+
}
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
const id = args[0];
|
|
1931
|
+
if (!id)
|
|
1932
|
+
usage();
|
|
1862
1933
|
const r = undoCuration(id, { by: currentAuthor() });
|
|
1863
1934
|
refreshGraphQuiet(project.key, cfg);
|
|
1864
1935
|
console.log(`curation undone: ${r.kind} ${id}`);
|
|
1865
1936
|
for (const p of r.filePaths) {
|
|
1866
1937
|
console.log(` ${path.relative(process.cwd(), p)}`);
|
|
1938
|
+
if (isInRepoMemoryFile(p)) {
|
|
1939
|
+
console.log(" (in-repo memory: local until committed and pushed)");
|
|
1940
|
+
}
|
|
1867
1941
|
}
|
|
1868
1942
|
}
|
|
1869
1943
|
catch (e) {
|