open-memex 0.10.0-alpha.2 → 0.10.0-alpha.4
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 +16 -1
- package/CHANGELOG.md +4 -0
- package/README.md +72 -9
- package/README.zh-CN.md +38 -6
- package/dist/.build-stamp +1 -1
- package/dist/capture/handoff.js +22 -1
- package/dist/capture/length.js +26 -0
- package/dist/cli.js +94 -12
- package/dist/curate.js +177 -0
- package/dist/graph/lint.js +11 -1
- package/dist/mcp.js +10 -0
- package/dist/plugin-core.js +61 -21
- package/dist/store/curate.js +225 -0
- package/dist/submit.js +244 -84
- package/dist/tools/ops.js +32 -2
- package/docs/V2-DESIGN.md +2 -2
- package/docs/design/decisions.md +9 -3
- package/package.json +66 -66
- package/scripts/curate-eval.ts +399 -0
- package/scripts/smoke-pure.ts +91 -0
- package/scripts/token-cost.ts +142 -0
- package/skills/open-memex/SKILL.md +16 -0
- package/src/capture/handoff.ts +39 -2
- package/src/capture/length.ts +29 -0
- package/src/cli.ts +90 -12
- package/src/curate.ts +236 -0
- package/src/graph/lint.ts +9 -1
- package/src/mcp.ts +10 -0
- package/src/plugin-core.ts +65 -15
- package/src/retrieve/feedback.ts +128 -128
- package/src/store/curate.ts +270 -0
- package/src/submit.ts +273 -84
- package/src/tools/ops.ts +28 -2
package/AGENTS.md
CHANGED
|
@@ -45,7 +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>] # drafts → .ai/open-memex/ (current branch + local commit; never auto-branches)
|
|
48
|
+
npm run cli -- submit <id...> [--branch <name>] [--base <branch>] [--no-curate] # lint + deterministic curation, then drafts → .ai/open-memex/ (current branch + local commit; never auto-branches)
|
|
49
|
+
npm run cli -- curate undo <id> # reverse the latest auto-curation on one memory
|
|
49
50
|
npm run cli -- propose <id...> --to project [--local-approve] # copy personal → project outbox (batch OK)
|
|
50
51
|
npm run cli -- promote <id> [--reject] [--resubmit] [--note "..."] # proposed → approved → published (audit trail appended)
|
|
51
52
|
npm run cli -- pr-status [--apply] # map branch PR's GitHub state onto review_state (report; apply = local only)
|
|
@@ -146,6 +147,7 @@ Every write path (tool, keyword hook, CLI `add`) must:
|
|
|
146
147
|
3. Check `findDuplicates` (design §3.4): identical content is idempotent (return existing id); near-duplicates (similarity ≥ 0.8) warn but save — suggest `supersede` when the new content replaces the old.
|
|
147
148
|
4. `writeMemoryFile` first, then `readMemoryFile` + `upsertFromFile` to keep FTS in sync.
|
|
148
149
|
5. Deletion reports honestly (D63): only ENOENT counts as "deleted"; any other unlink failure keeps the index row and returns failure — the file is the source of truth and would otherwise resurrect the memory on next sync.
|
|
150
|
+
6. **Length nudge (D94): hint, never refusal.** Content over 500 characters still saves normally; append `lengthNudge()` (`src/capture/length.ts`) to the result — tool path via `addMemory`, CLI via `add`. Never reject or truncate a save for length; the only hard cap is keyword capture's `MAX_CAPTURE_CHARS` (2000, D67), unchanged, and an over-cap keyword drop surfaces to the agent in the D73 hand-off note (`formatCaptureDropBlock`) so it can re-save a shortened version. The keywords debug log stays.
|
|
149
151
|
|
|
150
152
|
Capture-time aliases (D61): `memory_add`/`supersede` may carry up to 4
|
|
151
153
|
`aliases` (alternate phrasings) into frontmatter; they index in their own FTS
|
|
@@ -157,6 +159,17 @@ invents aliases. Checkpoint-proposal guidance (propose, never auto-draft) is
|
|
|
157
159
|
copy, not mechanism: keep the rubric wording in sync across the skill, the
|
|
158
160
|
AGENTS.md hygiene footer, the MCP handshake, and the tool descriptions.
|
|
159
161
|
|
|
162
|
+
**Wake convention (D94) — documentation-only, no new surface.** The
|
|
163
|
+
session-start ritual is written in README (en + zh), the bundled Agent
|
|
164
|
+
Skill, and the MCP `SERVER_INSTRUCTIONS`; those three must keep saying the
|
|
165
|
+
same thing, and an agent that reads only one still has to behave. The
|
|
166
|
+
ritual: read the injected `[OPEN-MEMEX]` block (the working-state note and
|
|
167
|
+
the compiled graph outline ride it); if the block is empty or insufficient,
|
|
168
|
+
one `memory_search` with the task's keywords; never ask the user to
|
|
169
|
+
re-explain what memory may already hold. Do not invent tool names for it —
|
|
170
|
+
§18's `memory_recall` does not exist — and do not add an MCP tool or CLI
|
|
171
|
+
verb for the ritual.
|
|
172
|
+
|
|
160
173
|
## Lifecycle invariants (design §3.3)
|
|
161
174
|
|
|
162
175
|
- Statuses: `active → superseded | deprecated | retracted | archived`. Retrieval excludes `retracted`/`archived`, ranks `active` above `deprecated`.
|
|
@@ -168,6 +181,8 @@ AGENTS.md hygiene footer, the MCP handshake, and the tool descriptions.
|
|
|
168
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.
|
|
169
182
|
- Frontmatter is `schema_version: 2`. The SQLite index schema is versioned separately and rebuilds automatically on version change — never hand-edit `index.db`.
|
|
170
183
|
|
|
184
|
+
**Pre-submit curation (D78/D93) — deterministic only, every action undoable.** `submit` reports graph lint (report-only, never blocks) and auto-applies exactly three things: exact duplicates (`contentHash`-identical normalized body) merge into the oldest free active canonical via the supersede chain, empty/whitespace-only bodies archive, and a ragged first non-empty line is whitespace-normalized. Near-duplicates stay report-only; semantic merge/split and inferred type/tags are deliberately out. Planner is pure (`src/curate.ts`), writes go through `src/store/curate.ts` using `atomicWriteTextSync`/`setStatus` and append a `curation:` receipt to `review_history`; `open-memex curate undo <id>` reverses the latest merge/title action, `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. Curation failure is reported and skipped, never fatal to the human's submit; 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 plus applied-action counts (shell-safe, no nested quotes). Keep the CLI, MCP `memory_submit` output, READMEs, and the fixture (`scripts/curate-eval.ts`) saying the same thing.
|
|
185
|
+
|
|
171
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).
|
|
172
187
|
|
|
173
188
|
D73 — one user statement, one memory. The hook and the agent are two writers for one turn, and only the hook knows the sentence is stored. Both hooks therefore take the session id (`chat.message` on v1, `prompt` on v2), `captureFromText` records each capture in `PluginState.captures`, and the system/context hook pushes the hand-off note (`captureHandoff` → `formatHandoffBlock`, `src/capture/handoff.ts`) once per capture. `memory_add` additionally refuses a write overlapping a `source: keyword`/`user` memory created in the same scope within `TURN_ECHO_WINDOW_MS` (`findTurnEcho`, threshold `TURN_ECHO_THRESHOLD` = 0.28) and returns the stored id plus the supersede route. Keep the note, the refusal text, `TOOL_DESCRIPTIONS.memory_add`, the skill, and this paragraph saying the same thing — an agent that reads only one of them still has to behave. Never lower `TURN_ECHO_THRESHOLD` to catch more: the measured reason it is high is that an agent's gloss (0.211) and a genuinely new fact from the same sentence (0.214) are lexically indistinguishable.
|
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,10 @@ the `@alpha` tag are development snapshots and are not listed individually.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
- 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
|
+
|
|
14
|
+
- D78 pre-submit curation, first slice: `submit` now runs a report-only graph lint and a deterministic auto-apply tier before copying drafts into the repo. Lint reports orphans, dangling edges, and near-stale pairs but never blocks; exact duplicates are merged into the oldest free active copy through the existing supersede chain, empty / whitespace-only bodies are archived (not deleted), and a first non-empty line with ragged whitespace is normalized without touching the rest of the body. Near-duplicates stay report-only - semantic merge/split and inferred type/tags need a human. Every applied action prints a receipt and is reversible: `open-memex curate undo <id>` for merges and title fixes, `open-memex status <id> active` for empty-body archives (the marker lives in the file's `review_history`, so undo works across branches and machines). The generated `gh pr create` command counts only the ids actually submitted and puts the lint + applied-action summary in its body. `submit --no-curate` skips the apply tier but still reports lint; it can now appear before or after the ids. Curated-out outbox files remain in appdata as history and are no longer counted as pending drafts (`sync-status` reports them separately); submit refuses non-active records instead of proposing history. `graph lint` no longer calls an intentional supersede-chain duplicate stale. Checked-in fixture (`scripts/curate-eval.ts`): 9 lint findings and 3 deterministic candidates before curation, 6 findings after (orphans 7→4, dangling 1, stale 1), `--no-curate` applies 0, and all 3 undo checks pass. Planner is pure (`src/curate.ts`), writes live in `src/store/curate.ts`; `smoke-pure` and `test-full` cover the new paths.
|
|
15
|
+
|
|
12
16
|
- D79 feedback-weighted ranking, first slice: `search()` can now reorder near-tied BM25 hits by the D77 reuse signal. A memory with `retrieved_count >= 3` and a higher `reuse_rate` moves ahead of equally relevant hits inside the same 25%-score band; the BM25 score is never modified, review tiers are never crossed, and hits with too little telemetry keep their exact BM25 slot (no cold-start penalty). Off by default (`feedbackWeighting: false`, a flat key settable with `config set`), because the counters start empty and the loop is only worth trusting once explicit useful signals exist. Guardrails unchanged: only `memory_useful`, a human approve at review, or a supersede raise usefulness — passive exposure only increments `retrieved_count`. `search --explain` reports whether weighting ran and lists every promoted hit with its reuse rate and move size. Fixture grows to 60 memories / 47 queries with a 3-query reuse slice; measured baseline (off) R@1 0.660 / R@5 0.979 / MRR 0.804 → weighted R@1 0.702 / R@5 0.979 / MRR 0.825 (feedback slice MRR 0.500 → 0.833). Pure band logic in `src/retrieve/feedback.ts`, smoke-tested without SQLite.
|
|
13
17
|
|
|
14
18
|
## [0.9.0] - 2026-11-06
|
package/README.md
CHANGED
|
@@ -407,11 +407,16 @@ Three ways memories get in:
|
|
|
407
407
|
own sentence: the plugin tells the agent what it just stored, and a
|
|
408
408
|
`memory_add` that re-saves the same words within the next few minutes is
|
|
409
409
|
refused with the stored id (D73) — one thing you said is one memory, not
|
|
410
|
-
three copies of it.
|
|
410
|
+
three copies of it. A keyword match over the 2000-character hard cap is
|
|
411
|
+
dropped, never truncated into a memory — the agent is told in its session
|
|
412
|
+
context (D94) and can re-save a shortened version.
|
|
411
413
|
- **The agent saves it**: in any editor, ask your agent to remember something
|
|
412
414
|
(or it saves on its own when you state a fact worth keeping) — it calls
|
|
413
415
|
`memory_add`. The routing above is a heuristic; you can always say "save this
|
|
414
|
-
to my personal memory" or use the CLI with `--scope` to be explicit.
|
|
416
|
+
to my personal memory" or use the CLI with `--scope` to be explicit. Long
|
|
417
|
+
bodies are never refused: over 500 characters the save proceeds and the
|
|
418
|
+
result just carries a soft hint that shorter, self-contained statements
|
|
419
|
+
retrieve better (D94).
|
|
415
420
|
- **Checkpoint proposals**: when a task wraps up, the agent proposes 1–3 short
|
|
416
421
|
candidate memories distilled from the session — decisions and their reasons,
|
|
417
422
|
conventions, gotchas, approaches tried and abandoned — and saves only the
|
|
@@ -465,7 +470,7 @@ they only matter once you share memories through Git.
|
|
|
465
470
|
| ● `memory_workingstate` | Read/write/clear the per-project working-state note (§3.6, D89) — resumes an interrupted task; scratch state, never a memory |
|
|
466
471
|
| ● `memory_useful` | Mark a memory as useful (D77) — explicit confirmation only; exposure is counted separately as `retrieved_count` |
|
|
467
472
|
| `memory_status` | Show the sync queue (outbox drafts, repo review states, uncommitted files) plus the D77 reuse report |
|
|
468
|
-
| `memory_submit` |
|
|
473
|
+
| `memory_submit` | Curate deterministic fixes, then move named drafts into the repo memory dir (local branch + commit) |
|
|
469
474
|
| `memory_propose` | Copy personal memories into the project scope as review candidates |
|
|
470
475
|
| `memory_promote` | Advance `proposed → approved → published` (or reject / resubmit) |
|
|
471
476
|
| `memory_resolve` | List conflicted memory files / 3-way-merge one of them |
|
|
@@ -531,9 +536,14 @@ capture → outbox (draft, local) → submit → repo (.ai/open-memex/) → PR r
|
|
|
531
536
|
git); `open-memex sync-status` — or just saying "sync memory" in chat —
|
|
532
537
|
shows what's pending.
|
|
533
538
|
3. **Submit** — you name the memories; they move into `<repo>/.ai/open-memex/`
|
|
534
|
-
with a local commit on your current branch.
|
|
535
|
-
|
|
536
|
-
|
|
539
|
+
with a local commit on your current branch. Before copying, `submit` prints
|
|
540
|
+
a report-only graph lint and auto-applies only deterministic cleanup: exact
|
|
541
|
+
duplicates are merged through the supersede chain, empty bodies are
|
|
542
|
+
archived, and ragged first-line titles are normalized. Near-duplicates stay
|
|
543
|
+
report-only; semantic merge/split needs a human. Every change prints its
|
|
544
|
+
undo command, and `--no-curate` skips the cleanup while keeping the lint
|
|
545
|
+
report. open-memex never pushes on its own; it prints the push + PR
|
|
546
|
+
commands, and an agent holding your explicit yes can carry them out.
|
|
537
547
|
4. **PR review** — memories are plain Markdown; reviewers approve, request
|
|
538
548
|
changes, or reject through the normal branch/PR process.
|
|
539
549
|
5. **Recall** — published memories are injected at session start and searchable
|
|
@@ -567,6 +577,46 @@ time for the rest. Both top-N counts are configurable (see [Config](#config)).
|
|
|
567
577
|
For MCP clients this block is delivered as handshake guidance the agent follows;
|
|
568
578
|
the opencode plugin injects it directly on the first turn.
|
|
569
579
|
|
|
580
|
+
### The session-start ritual (wake)
|
|
581
|
+
|
|
582
|
+
open-memex sessions start from what is already in context, not from questions:
|
|
583
|
+
|
|
584
|
+
1. Read the `[OPEN-MEMEX]` block injected at session start (opencode) — or the
|
|
585
|
+
equivalent guidance in the MCP handshake instructions. It carries the top
|
|
586
|
+
project memories, your preferences, the working-state note from a previous
|
|
587
|
+
session (if any), and the compiled memory map.
|
|
588
|
+
2. If the block is empty or doesn't cover the current task, call `memory_search`
|
|
589
|
+
**once** with the task's keywords (try 2–3 phrasings, both scopes) before
|
|
590
|
+
concluding anything is missing.
|
|
591
|
+
3. Don't ask the user to re-explain what memory already holds — repeated
|
|
592
|
+
"didn't we decide X?" questions are the failure mode open-memex exists to
|
|
593
|
+
prevent. Ask only about what neither the block nor search can answer.
|
|
594
|
+
|
|
595
|
+
The block is injected **once per session, not once per turn** — mid-session,
|
|
596
|
+
open-memex adds nothing to the context unless a tool is called. The same
|
|
597
|
+
ritual is written into the bundled `open-memex` Agent Skill and the MCP
|
|
598
|
+
handshake instructions, so an agent that reads only one of the three still
|
|
599
|
+
behaves the same way.
|
|
600
|
+
|
|
601
|
+
### What this costs in context (tokens)
|
|
602
|
+
|
|
603
|
+
Measured, not asserted (D94, inspired by OptMem's published "426-token
|
|
604
|
+
prompt"). On the checked-in fixture in `scripts/token-cost.ts` — 8 project
|
|
605
|
+
memories + 5 personal + the compiled graph outline, default config — with
|
|
606
|
+
tokens estimated as characters ÷ 4 (the rough ratio for English prose; a
|
|
607
|
+
deliberately tokenizer-free method, no new dependency):
|
|
608
|
+
|
|
609
|
+
| Surface | Characters | ≈ Tokens | When |
|
|
610
|
+
|---|---|---|---|
|
|
611
|
+
| Session-start injection block | 2,125 | ~530 | once per session (not per turn) |
|
|
612
|
+
| All 13 MCP tool descriptions | 8,814 | ~2,200 | once per session, at the MCP handshake |
|
|
613
|
+
| Total | 10,939 | ~2,700 | |
|
|
614
|
+
|
|
615
|
+
These are approximations and they move with your memory sizes and config —
|
|
616
|
+
re-run `node --experimental-strip-types scripts/token-cost.ts` to measure
|
|
617
|
+
your own numbers and to regenerate the fixture's. (The script's output and
|
|
618
|
+
this table must agree; update both together, never by hand.)
|
|
619
|
+
|
|
570
620
|
### Retrieval evaluation
|
|
571
621
|
|
|
572
622
|
We measure recall on a checked-in synthetic fixture instead of asserting it:
|
|
@@ -798,11 +848,17 @@ open-memex sync-status
|
|
|
798
848
|
# (draft / proposed / approved / published / rejected),
|
|
799
849
|
# and any uncommitted repo memory files.
|
|
800
850
|
|
|
801
|
-
open-memex submit <id...> [--branch <name>] [--base <branch>]
|
|
851
|
+
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
802
852
|
# move your named drafts into .ai/open-memex/ as "proposed":
|
|
803
853
|
# copies, flips review_state, local git commit ON THE CURRENT BRANCH.
|
|
804
854
|
# Never creates a branch on its own — branch creation is your call
|
|
805
855
|
# (or the agent's, only with your explicit approval for the full chain).
|
|
856
|
+
# Before copying: report-only graph lint + deterministic curation
|
|
857
|
+
# (exact-duplicate merge, empty-body archive, first-line title cleanup).
|
|
858
|
+
# --no-curate skips the cleanup but still prints lint. Near-duplicates are
|
|
859
|
+
# reported, never merged. Every applied action prints its undo command.
|
|
860
|
+
# The generated gh pr create body carries the lint + curation summary and
|
|
861
|
+
# counts only the ids actually submitted (not the pre-curation batch).
|
|
806
862
|
# All-or-nothing; conflicts (same id, different content) abort cleanly.
|
|
807
863
|
# Prints the push + gh pr commands; an agent holding your Yes carries
|
|
808
864
|
# through push/PR itself. --branch <name> creates the branch first
|
|
@@ -810,6 +866,12 @@ open-memex submit <id...> [--branch <name>] [--base <branch>]
|
|
|
810
866
|
# PRs stack onto your working branch); --base redirects it to main or
|
|
811
867
|
# wherever you review.
|
|
812
868
|
|
|
869
|
+
open-memex curate undo <id>
|
|
870
|
+
# reverse the latest automatic curation on one memory (merge or title fix).
|
|
871
|
+
# The receipt lives in the file's review_history, so this works across
|
|
872
|
+
# branches and machines; an empty-body archive is restored with
|
|
873
|
+
# `open-memex status <id> active`.
|
|
874
|
+
|
|
813
875
|
open-memex pr-status [--apply]
|
|
814
876
|
# read the branch's GitHub PR and map its state onto each in-repo memory:
|
|
815
877
|
# merged PR → published, PR approval → approved (approved_by = reviewer),
|
|
@@ -932,8 +994,9 @@ open-memex graph lint [--json] # orphans, dangling edges, near-stale pai
|
|
|
932
994
|
```
|
|
933
995
|
|
|
934
996
|
`lint` reports only — nothing is auto-resolved; a human decides. The same report
|
|
935
|
-
is the
|
|
936
|
-
the MCP surface stays at
|
|
997
|
+
is the input for D78's pre-submit curation (D93): `submit` prints it before the
|
|
998
|
+
deterministic cleanup. The graph interface is CLI-only; the MCP surface stays at
|
|
999
|
+
its thirteen memory tools.
|
|
937
1000
|
|
|
938
1001
|
## MCP server
|
|
939
1002
|
|
package/README.zh-CN.md
CHANGED
|
@@ -269,8 +269,8 @@ open-memex uninstall --yes
|
|
|
269
269
|
|
|
270
270
|
三种存入方式:
|
|
271
271
|
|
|
272
|
-
- **关键词触发**(仅 opencode 原生插件):说 `remember …`、`note that …`、`don't forget: …`、`TIL …`、`save this …`——中文 `记住…` / `记一下…` / `记录一下…` / `别忘了:…`——这句话就被存下来,不需要任何工具调用。捕获默认进当前 **project**;`remember for me …`、`help me remember: …`、`记住我…`、`替我记…`、`帮我记…`、`我觉得…`、`我喜欢…` 这类"这是关于我"的信号会改为进 **personal**;`我们决定…`、`帮我们记住…` 等团队语境仍留在项目里。两条降噪规则(D67):触发词必须是**对存储说的话**,所以叙述型的 `记得…` / `remind me to…` / `别忘了带伞` / `don't forget the wifi password` 一律不触发(加一个分隔符——`别忘了:…`、`don't forget: …`——或用 `that`,才算指令);捕获内容不足 3 个字符按碎片丢弃,不会存下来——`capture --dry-run` 会明确说明,不再悄悄吞掉。另外,一句触发捕获的话只归一条记忆:插件会把它刚存下的内容告诉助手,几分钟内再用 `memory_add` 重复存同样的字眼会被拒绝(并给出已存的 id,D73
|
|
273
|
-
- **助手主动保存**:在任何编辑器里,你让助手记住某件事(或者你陈述了一个值得记的事实、它自己判断该保存),它会调用 `memory_add`。上面的路由是启发式规则;你可以明说"存到我的个人记忆",或用 CLI 加 `--scope`
|
|
272
|
+
- **关键词触发**(仅 opencode 原生插件):说 `remember …`、`note that …`、`don't forget: …`、`TIL …`、`save this …`——中文 `记住…` / `记一下…` / `记录一下…` / `别忘了:…`——这句话就被存下来,不需要任何工具调用。捕获默认进当前 **project**;`remember for me …`、`help me remember: …`、`记住我…`、`替我记…`、`帮我记…`、`我觉得…`、`我喜欢…` 这类"这是关于我"的信号会改为进 **personal**;`我们决定…`、`帮我们记住…` 等团队语境仍留在项目里。两条降噪规则(D67):触发词必须是**对存储说的话**,所以叙述型的 `记得…` / `remind me to…` / `别忘了带伞` / `don't forget the wifi password` 一律不触发(加一个分隔符——`别忘了:…`、`don't forget: …`——或用 `that`,才算指令);捕获内容不足 3 个字符按碎片丢弃,不会存下来——`capture --dry-run` 会明确说明,不再悄悄吞掉。另外,一句触发捕获的话只归一条记忆:插件会把它刚存下的内容告诉助手,几分钟内再用 `memory_add` 重复存同样的字眼会被拒绝(并给出已存的 id,D73)——你说的一件事就是一条记忆,不是它的三个副本。超过 2000 字符硬上限的关键词匹配会被丢弃,绝不截断成记忆——助手会在会话上下文里被告知(D94),可以再存一个缩短版。
|
|
273
|
+
- **助手主动保存**:在任何编辑器里,你让助手记住某件事(或者你陈述了一个值得记的事实、它自己判断该保存),它会调用 `memory_add`。上面的路由是启发式规则;你可以明说"存到我的个人记忆",或用 CLI 加 `--scope` 明确指定。长内容不会被拒绝:超过 500 字符照常保存,只是返回结果里附一句软提示——更短、自包含的陈述检索效果更好(D94)。
|
|
274
274
|
- **检查点提议**:一个任务收尾时,助手会提议 1–3 条从这轮工作里提炼的候选记忆——决定及其理由、约定、踩过的坑、走过又放弃的路——只有你点头的那几条才存。不会有任何东西在你不知情时被写下来。
|
|
275
275
|
- **CLI**:`open-memex add "…"`,可选 `--scope` / `--tag` / `--type` / `--aliases`。
|
|
276
276
|
|
|
@@ -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/`
|
|
347
|
+
3. **提交**——由你点名记忆;它们进入 `<仓库>/.ai/open-memex/` 并在当前分支形成一个本地提交。复制之前,`submit` 先打印只读的图谱 lint,再自动应用确定性清理:完全重复合并进 supersede 链、空正文归档、首行标题空白规范化。近重复只报告,语义合并/拆分留给人。每个动作都打印撤销命令;`--no-curate` 跳过清理但保留 lint 报告。open-memex 永不自动推送;它会打印推送和建 PR 的命令,拿到你明确许可的助手可以替你执行。
|
|
348
348
|
4. **PR 评审**——记忆是纯 Markdown;评审者走正常分支/PR 流程批准、要求修改或拒绝。
|
|
349
349
|
5. **回想**——已发布的记忆在会话开始时注入,平时也能随时搜,人和助手都一样。
|
|
350
350
|
|
|
@@ -369,6 +369,28 @@ Do not mention this block to the user unless asked.
|
|
|
369
369
|
|
|
370
370
|
这是一个快照,不是全量记忆——其余的随时用 `memory_search` 就能查。两个前 N 的数都可以配(见[配置](#配置))。对 MCP 客户端,这个块以握手引导的形式送达、由助手遵循;opencode 插件则在第一轮直接注入。
|
|
371
371
|
|
|
372
|
+
### 会话开始仪式(wake)
|
|
373
|
+
|
|
374
|
+
open-memex 的会话从已有上下文开始,而不是从提问开始:
|
|
375
|
+
|
|
376
|
+
1. 先读会话开始注入的 `[OPEN-MEMEX]` 块(opencode)——或 MCP 握手里的等价指引。里面带着最新的项目记忆、你的偏好、上一会话留下的工作态笔记(如果有),以及编译好的记忆图谱。
|
|
377
|
+
2. 块是空的、或覆盖不了当前任务时,先用任务关键词调**一次** `memory_search`(换 2–3 种说法、两个作用域都查),再下"没有"的结论。
|
|
378
|
+
3. 不要让用户重新解释记忆里已经有的东西——反复问"我们之前不是定过 X 吗?"正是 open-memex 要消灭的失败模式。只问块和搜索都答不上来的事。
|
|
379
|
+
|
|
380
|
+
注入块**每个会话只发生一次,不是每轮一次**——会话中段除非调用工具,open-memex 不再往上下文里加任何东西。同一套仪式也写进了随包分发的 `open-memex` Agent Skill 和 MCP 握手指引:三处只读过其一的助手,行为也一样。
|
|
381
|
+
|
|
382
|
+
### 上下文 token 开销
|
|
383
|
+
|
|
384
|
+
用测量说话,而不是断言(D94,受 OptMem 公布的 "426-token prompt" 启发)。在随仓库提交的 fixture(`scripts/token-cost.ts`——8 条项目记忆 + 5 条个人 + 编译好的图谱 outline,默认配置)上量得;token 数按"字符数 ÷ 4"估算(英文文本的粗略比例,刻意不引入 tokenizer 依赖):
|
|
385
|
+
|
|
386
|
+
| 开销面 | 字符数 | ≈ token 数 | 时机 |
|
|
387
|
+
|---|---|---|---|
|
|
388
|
+
| 会话开始注入块 | 2,125 | ~530 | 每会话一次(不是每轮) |
|
|
389
|
+
| 全部 13 个 MCP 工具描述 | 8,814 | ~2,200 | 每会话一次(MCP 握手时) |
|
|
390
|
+
| 合计 | 10,939 | ~2,700 | |
|
|
391
|
+
|
|
392
|
+
这些是约数,会随你的记忆大小和配置变化——跑 `node --experimental-strip-types scripts/token-cost.ts` 量你自己的数字,也用它重新生成 fixture 的数字。(脚本输出和这张表必须一致;两者一起改,绝不手改。)
|
|
393
|
+
|
|
372
394
|
### 检索效果评估
|
|
373
395
|
|
|
374
396
|
我们用一份随仓库提交的 synthetic fixture 来度量召回率,而不是空口断言:60 条记忆 + 47 个查询(精确词、改写、同义词、中文、跨语言 hard case、纯同义词查询、D81 用户别名查询,以及 D79 复用信号切片),运行 `node --experimental-strip-types scripts/retrieval-eval.ts` 即可复现。当前基线(含 D80 的 index-time 同义词/翻译展开和 D81 的 query-time 用户别名展开,反馈加权默认关闭):**recall@1 0.66、recall@5 0.98、MRR 0.80**。语料小且是合成的,请把它当回归守卫和起点,而不是真实场景的承诺。
|
|
@@ -508,15 +530,25 @@ open-memex sync-status
|
|
|
508
530
|
# (draft / proposed / approved / published / rejected)、
|
|
509
531
|
# 以及任何未提交的仓库记忆文件。
|
|
510
532
|
|
|
511
|
-
open-memex submit <id...> [--branch <name>] [--base <branch>]
|
|
533
|
+
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
512
534
|
# 把你点名的草稿移进 .ai/open-memex/,标为 "proposed":
|
|
513
535
|
# 复制、翻转 review_state、在当前分支本地 git 提交。
|
|
514
536
|
# 永不自己建分支——建分支是你(或拿到完整链路明确许可的助手)的事。
|
|
537
|
+
# 复制前:只读图谱 lint + 确定性策展(完全重复合并、空正文归档、
|
|
538
|
+
# 首行标题清理)。--no-curate 跳过清理但仍打印 lint;近重复只报告,
|
|
539
|
+
# 永不自动合并。每个已应用动作都会打印撤销命令。
|
|
540
|
+
# 生成的 gh pr create body 带 lint + 策展摘要,人数只算实际提交的 id
|
|
541
|
+
#(不是提交前的批次)。
|
|
515
542
|
# 全有全无;冲突(同 id 不同内容)干净地中止。
|
|
516
543
|
# 打印 push + gh pr 命令;持有你 Yes 的助手可以一并执行 push/PR。
|
|
517
544
|
# --branch <name> 先建分支(助手全链路路径)。PR base 默认是当前分支
|
|
518
545
|
# (记忆 PR 叠在你的工作分支上);--base 可改指到 main 或你的评审分支。
|
|
519
546
|
|
|
547
|
+
open-memex curate undo <id>
|
|
548
|
+
# 撤销某条记忆上最近一次自动策展(合并或标题修正)。
|
|
549
|
+
# 凭据写在文件 review_history 里,所以跨分支/跨机器都能撤销;
|
|
550
|
+
# 空正文归档用 `open-memex status <id> active` 恢复。
|
|
551
|
+
|
|
520
552
|
open-memex pr-status [--apply]
|
|
521
553
|
# 读分支的 GitHub PR,把状态映射到每条仓库内记忆:
|
|
522
554
|
# PR 合并 → published,PR 批准 → approved(approved_by = 评审者),
|
|
@@ -605,7 +637,7 @@ open-memex graph path <a> <b> # 最短跳链,带凭据
|
|
|
605
637
|
open-memex graph lint [--json] # 孤立节点、悬空边、近陈旧对
|
|
606
638
|
```
|
|
607
639
|
|
|
608
|
-
`lint` 只报告——不自动处理,由人决定。同一份报告就是 D78
|
|
640
|
+
`lint` 只报告——不自动处理,由人决定。同一份报告就是 D78 提交前策展(D93)的输入:`submit` 在确定性清理前先打印它。图谱接口仅限 CLI;MCP 表面保持十三个记忆工具不变。
|
|
609
641
|
|
|
610
642
|
## MCP 服务器
|
|
611
643
|
|
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
d15bb866b9ff6cb250556f01a9b29ce9eec085641e31a2b7db2ba3b482bbedee
|
package/dist/capture/handoff.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* Pure module: no db, no fs, no config, so the threshold behavior is testable
|
|
18
18
|
* in scripts/smoke-pure.ts.
|
|
19
19
|
*/
|
|
20
|
+
import { MAX_CAPTURE_CHARS } from "./keywords.js";
|
|
20
21
|
/**
|
|
21
22
|
* Overlap bar for refusing a re-save of a just-captured user statement.
|
|
22
23
|
*
|
|
@@ -53,7 +54,27 @@ export function formatHandoffBlock(records) {
|
|
|
53
54
|
return [
|
|
54
55
|
"[open-memex] The user's own wording in this turn was ALREADY stored verbatim, before you saw it. It is not unsaved.",
|
|
55
56
|
...lines,
|
|
56
|
-
"Do not call memory_add to save that text again in any rewording
|
|
57
|
+
"Do not call memory_add to save that text again in any rewording - one statement is already one memory, and a rewording only adds a second copy that retrieval will return alongside the first.",
|
|
57
58
|
"Save a memory only for information those lines do NOT contain, as its own self-contained statement. If your version is meant to replace one of them, call memory_supersede with that id instead of memory_add.",
|
|
58
59
|
].join("\n");
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* D94: the over-cap drop note. Tells the agent a keyword match was dropped
|
|
63
|
+
* for exceeding MAX_CAPTURE_CHARS (imported, not hardcoded) so it can
|
|
64
|
+
* re-save a shortened version. Empty string when there is nothing to
|
|
65
|
+
* report; never mentions too-short drops.
|
|
66
|
+
*/
|
|
67
|
+
export function formatCaptureDropBlock(drops) {
|
|
68
|
+
if (drops.length === 0)
|
|
69
|
+
return "";
|
|
70
|
+
const lines = drops.map((d) => {
|
|
71
|
+
const one = d.content.replace(/\s+/g, " ").trim();
|
|
72
|
+
const preview = one.length > 120 ? `${one.slice(0, 120)}...` : one;
|
|
73
|
+
return `- "${preview}" (${d.content.length} chars)`;
|
|
74
|
+
});
|
|
75
|
+
return [
|
|
76
|
+
`[open-memex] A keyword capture in this turn matched but was NOT saved: the body is over the ${MAX_CAPTURE_CHARS}-character hard cap, so it was dropped.`,
|
|
77
|
+
...lines,
|
|
78
|
+
"Long matches are never truncated into a memory - the cap is unchanged. If any of the dropped text is worth keeping, save a shortened, self-contained version with memory_add.",
|
|
79
|
+
].join("\n");
|
|
80
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture length nudge (D94, OptMem small item 3): a soft length hint at
|
|
3
|
+
* capture time. Inspired by OptMem's 280-byte hard cap, but deliberately
|
|
4
|
+
* softer: a long body is saved normally and the caller just gets a hint
|
|
5
|
+
* appended to the result. Nothing is ever refused for length - the only
|
|
6
|
+
* hard ceiling is the keyword-capture `MAX_CAPTURE_CHARS` (2000, D67),
|
|
7
|
+
* which stays untouched.
|
|
8
|
+
*
|
|
9
|
+
* Pure module: no db, no fs, no config, so the threshold behavior is
|
|
10
|
+
* testable in scripts/smoke-pure.ts.
|
|
11
|
+
*/
|
|
12
|
+
/** Over this many characters a save proceeds but its result carries a hint. */
|
|
13
|
+
export const LENGTH_NUDGE_CHARS = 500;
|
|
14
|
+
/**
|
|
15
|
+
* One-line hint appended to the save result when the body is long.
|
|
16
|
+
* Returns null at or under the threshold - the boundary is inclusive:
|
|
17
|
+
* 500 chars = no hint, 501 = hint. The wording says the save happened, so
|
|
18
|
+
* an agent reading only the hint never mistakes it for a refusal.
|
|
19
|
+
*/
|
|
20
|
+
export function lengthNudge(content) {
|
|
21
|
+
if (content.length <= LENGTH_NUDGE_CHARS)
|
|
22
|
+
return null;
|
|
23
|
+
return (`Note: this memory is ${content.length} characters, over the ${LENGTH_NUDGE_CHARS}-character soft limit. ` +
|
|
24
|
+
`It saved fine - nothing was refused. Short, self-contained statements retrieve better; ` +
|
|
25
|
+
`consider replacing it with a tighter version (supersede) if one exists.`);
|
|
26
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { syncScope, upsertFromFile, deleteFromIndex } from "./store/sync.js";
|
|
|
6
6
|
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
|
-
import { proposeMemories, promoteMemory, listConflicts, resolveConflict, formatReviewHistory } from "./review.js";
|
|
9
|
+
import { proposeMemories, promoteMemory, listConflicts, resolveConflict, formatReviewHistory, currentAuthor } from "./review.js";
|
|
10
10
|
import { getSyncStatus, formatSyncStatus, submitMemories } from "./submit.js";
|
|
11
11
|
import { getPrStatus, formatPrStatus, applyPrStatus } from "./github.js";
|
|
12
12
|
import { search, list, countList, hitStateLabel } from "./retrieve/search.js";
|
|
@@ -18,10 +18,13 @@ import { writeMemoryFile, readMemoryFile, ulid, msToRfc3339, normalizeAliases, }
|
|
|
18
18
|
import { loadConfig, configSource } from "./config.js";
|
|
19
19
|
import { paths, projectRoot, isInRepoMemoryFile } from "./paths.js";
|
|
20
20
|
import { redact } from "./redact.js";
|
|
21
|
+
import { lengthNudge } from "./capture/length.js";
|
|
21
22
|
import { readWorkingState, clearWorkingState, workingStatePath } from "./working-state.js";
|
|
22
23
|
import { refreshGraph, refreshGraphQuiet, ensureGraph, loadGraphEdges, loadGraphNodes, loadAllMemoryIds } from "./store/graph.js";
|
|
23
24
|
import { graphNeighbours, shortestPath } from "./graph/queries.js";
|
|
24
25
|
import { lintGraph } from "./graph/lint.js";
|
|
26
|
+
import { formatCurationAction } from "./curate.js";
|
|
27
|
+
import { undoCuration } from "./store/curate.js";
|
|
25
28
|
import { resolveMcpCommand } from "./init.js";
|
|
26
29
|
import fs from "node:fs";
|
|
27
30
|
import path from "node:path";
|
|
@@ -290,15 +293,33 @@ the repo memory dir as proposed (a local-approved copy keeps its approval),
|
|
|
290
293
|
commits locally on the CURRENT branch, and moves the outbox originals out.
|
|
291
294
|
Never creates a branch on its own — branch creation is your call.
|
|
292
295
|
|
|
293
|
-
Usage: open-memex submit <id...> [--branch <name>] [--base <branch>]
|
|
296
|
+
Usage: open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
297
|
+
|
|
298
|
+
D78: submit reports graph lint (report-only, never blocks) and auto-applies
|
|
299
|
+
only deterministic curation: exact duplicate merges, empty-body archives, and
|
|
300
|
+
first-line title whitespace normalization. Every change is listed with its
|
|
301
|
+
undo command. Near-duplicates stay report-only - a human decides.
|
|
294
302
|
|
|
295
303
|
Flags:
|
|
296
|
-
--branch
|
|
297
|
-
|
|
298
|
-
--base
|
|
304
|
+
--branch create this branch and submit onto it (only with your explicit
|
|
305
|
+
approval for the full chain); default: stay on current branch
|
|
306
|
+
--base PR base override (default: the branch you're on)
|
|
307
|
+
--no-curate skip the deterministic auto-apply tier; lint still reports
|
|
299
308
|
|
|
300
309
|
Example:
|
|
301
|
-
open-memex submit 01ABC 01DEF
|
|
310
|
+
open-memex submit 01ABC 01DEF
|
|
311
|
+
open-memex submit 01ABC --no-curate`,
|
|
312
|
+
curate: `Undo one deterministic curation action applied by submit.
|
|
313
|
+
|
|
314
|
+
Every action is recorded in the memory file's review_history, so undo works
|
|
315
|
+
across branches and machines. Only the most recent curation action on an id is
|
|
316
|
+
undoable: an undo appends its own receipt, so a second run refuses. Inspect the
|
|
317
|
+
file's review_history for the older trail.
|
|
318
|
+
|
|
319
|
+
Usage: open-memex curate undo <id>
|
|
320
|
+
|
|
321
|
+
Example:
|
|
322
|
+
open-memex curate undo 01ABC`,
|
|
302
323
|
"pr-status": `Map the current branch's GitHub PR state back onto review_state:
|
|
303
324
|
merged → published, approval → approved (approved_by = the reviewer),
|
|
304
325
|
changes-requested → suggestion only (never auto-rejects).
|
|
@@ -485,7 +506,8 @@ Usage:
|
|
|
485
506
|
open-memex export [--scope project|personal|both] [--type T] [--tag t] [--all] [-o <file>]
|
|
486
507
|
open-memex import <bundle.tar.gz> [--dry-run]
|
|
487
508
|
open-memex distill-agents [--scope project|personal] [--type t1,t2] [--limit N] [-o <file>]
|
|
488
|
-
open-memex submit <id...> [--branch <name>] [--base <branch>]
|
|
509
|
+
open-memex submit <id...> [--branch <name>] [--base <branch>] [--no-curate]
|
|
510
|
+
open-memex curate undo <id>
|
|
489
511
|
open-memex pr-status [--apply]
|
|
490
512
|
open-memex reindex
|
|
491
513
|
open-memex audit [--scope project|personal|both]
|
|
@@ -565,7 +587,7 @@ function setConfigPath(key, value) {
|
|
|
565
587
|
node[parts[parts.length - 1]] = value;
|
|
566
588
|
return { [top]: cur };
|
|
567
589
|
}
|
|
568
|
-
function parseFlags(argv) {
|
|
590
|
+
function parseFlags(argv, booleans = new Set()) {
|
|
569
591
|
const out = {};
|
|
570
592
|
for (let i = 0; i < argv.length; i++) {
|
|
571
593
|
const a = argv[i];
|
|
@@ -578,6 +600,10 @@ function parseFlags(argv) {
|
|
|
578
600
|
out[raw.slice(0, eq)] = raw.slice(eq + 1);
|
|
579
601
|
continue;
|
|
580
602
|
}
|
|
603
|
+
if (booleans.has(raw)) {
|
|
604
|
+
out[raw] = "true";
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
581
607
|
const val = argv[i + 1];
|
|
582
608
|
if (val !== undefined && !val.startsWith("--")) {
|
|
583
609
|
out[raw] = val;
|
|
@@ -1270,6 +1296,10 @@ async function main() {
|
|
|
1270
1296
|
for (const n of dups.near) {
|
|
1271
1297
|
console.log(`warning: similar memory exists (score ${n.score.toFixed(2)}): id=${n.id}\n ${n.snippet}\n use \`open-memex supersede ${n.id} "new content"\` if this replaces it.`);
|
|
1272
1298
|
}
|
|
1299
|
+
// D94: soft length hint - the save already happened; this is advisory only.
|
|
1300
|
+
const nudge = lengthNudge(red);
|
|
1301
|
+
if (nudge)
|
|
1302
|
+
console.log(nudge);
|
|
1273
1303
|
return;
|
|
1274
1304
|
}
|
|
1275
1305
|
if (cmd === "supersede") {
|
|
@@ -1411,11 +1441,14 @@ async function main() {
|
|
|
1411
1441
|
return;
|
|
1412
1442
|
}
|
|
1413
1443
|
/** Positional args with flags (and their values) skipped. */
|
|
1414
|
-
function positionalArgs(argv) {
|
|
1444
|
+
function positionalArgs(argv, booleans = new Set()) {
|
|
1415
1445
|
const out = [];
|
|
1416
1446
|
for (let i = 0; i < argv.length; i++) {
|
|
1417
1447
|
const a = argv[i];
|
|
1418
1448
|
if (a.startsWith("--")) {
|
|
1449
|
+
const raw = a.slice(2);
|
|
1450
|
+
if (raw.includes("=") || booleans.has(raw))
|
|
1451
|
+
continue;
|
|
1419
1452
|
const val = argv[i + 1];
|
|
1420
1453
|
if (val !== undefined && !val.startsWith("--"))
|
|
1421
1454
|
i++; // skip the flag's value
|
|
@@ -1761,13 +1794,42 @@ async function main() {
|
|
|
1761
1794
|
return;
|
|
1762
1795
|
}
|
|
1763
1796
|
if (cmd === "submit") {
|
|
1764
|
-
const
|
|
1765
|
-
const
|
|
1797
|
+
const booleans = new Set(["no-curate"]);
|
|
1798
|
+
const flags = parseFlags(rest, booleans);
|
|
1799
|
+
const ids = positionalArgs(rest, booleans);
|
|
1766
1800
|
if (ids.length === 0)
|
|
1767
1801
|
usage();
|
|
1768
1802
|
syncScope(project.key, "submit");
|
|
1769
1803
|
try {
|
|
1770
|
-
const r = submitMemories(ids, {
|
|
1804
|
+
const r = submitMemories(ids, {
|
|
1805
|
+
branch: flags.branch,
|
|
1806
|
+
base: flags.base,
|
|
1807
|
+
noCurate: flags["no-curate"] === "true",
|
|
1808
|
+
});
|
|
1809
|
+
const c = r.curation;
|
|
1810
|
+
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.`);
|
|
1811
|
+
for (const f of c.lintFindings.slice(0, 5)) {
|
|
1812
|
+
console.log(` [${f.kind}] ${f.id}${f.other ? ` ${f.other}` : ""}: ${f.detail}`);
|
|
1813
|
+
}
|
|
1814
|
+
if (c.lintFindings.length > 5) {
|
|
1815
|
+
console.log(` ... and ${c.lintFindings.length - 5} more (full list: open-memex graph lint)`);
|
|
1816
|
+
}
|
|
1817
|
+
if (c.disabled) {
|
|
1818
|
+
console.log("curation auto-apply skipped (--no-curate); no files were changed by curation.");
|
|
1819
|
+
}
|
|
1820
|
+
else if (c.applied.length === 0) {
|
|
1821
|
+
console.log("curation auto-applied: 0 (nothing deterministic to fix)");
|
|
1822
|
+
}
|
|
1823
|
+
else {
|
|
1824
|
+
console.log(`curation auto-applied: ${c.applied.length}`);
|
|
1825
|
+
for (const a of c.applied)
|
|
1826
|
+
console.log(` ${formatCurationAction(a.action)}`);
|
|
1827
|
+
}
|
|
1828
|
+
for (const s of c.skipped) {
|
|
1829
|
+
console.log(` curation skipped ${s.id}: ${s.reason}`);
|
|
1830
|
+
}
|
|
1831
|
+
for (const w of c.warnings)
|
|
1832
|
+
console.log(` curation note: ${w}`);
|
|
1771
1833
|
for (const s of r.submitted) {
|
|
1772
1834
|
console.log(`submitted ${s.id} → ${path.relative(process.cwd(), s.filePath)} [${s.reviewState}]`);
|
|
1773
1835
|
}
|
|
@@ -1790,6 +1852,26 @@ async function main() {
|
|
|
1790
1852
|
}
|
|
1791
1853
|
return;
|
|
1792
1854
|
}
|
|
1855
|
+
if (cmd === "curate") {
|
|
1856
|
+
const sub = rest[0];
|
|
1857
|
+
const id = rest[1];
|
|
1858
|
+
if (sub !== "undo" || !id)
|
|
1859
|
+
usage();
|
|
1860
|
+
syncScope(project.key, "cli");
|
|
1861
|
+
try {
|
|
1862
|
+
const r = undoCuration(id, { by: currentAuthor() });
|
|
1863
|
+
refreshGraphQuiet(project.key, cfg);
|
|
1864
|
+
console.log(`curation undone: ${r.kind} ${id}`);
|
|
1865
|
+
for (const p of r.filePaths) {
|
|
1866
|
+
console.log(` ${path.relative(process.cwd(), p)}`);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
catch (e) {
|
|
1870
|
+
console.error(`curate undo failed: ${e.message}`);
|
|
1871
|
+
process.exit(2);
|
|
1872
|
+
}
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1793
1875
|
if (cmd === "scopes") {
|
|
1794
1876
|
const { memories } = paths();
|
|
1795
1877
|
if (!fs.existsSync(memories)) {
|