From f88e78a524ad52b90f3d837abfddc53e122f3801 Mon Sep 17 00:00:00 2001 From: KT <677465+kevintseng@users.noreply.github.com> Date: Fri, 4 Dec 2026 20:03:08 +0800 Subject: [PATCH 1/2] Sync documentation with the 4.13.2 behavior --- AGENTS.md | 9 ++++----- CODEMAP.md | 9 ++++++++- README.md | 4 +--- README.vi.md | 2 +- README.zh-TW.md | 2 +- docs/ARCHITECTURE.md | 30 +++++++++++------------------- docs/api/API_REFERENCE.md | 16 ++++++++-------- docs/platforms/README.md | 3 +-- docs/platforms/agent-messaging.md | 11 ++++++++--- docs/platforms/chatgpt.md | 2 +- docs/platforms/deepseek-worker.md | 3 +-- docs/platforms/gemini.md | 2 +- docs/platforms/hermes-agent.md | 3 +-- docs/platforms/universal.md | 2 +- llms-install.md | 2 +- scripts/mcp-doc-contract.json | 4 ++-- skills/memesh-review/SKILL.md | 6 +++--- skills/memesh/SKILL.md | 20 ++++++++------------ 18 files changed, 62 insertions(+), 68 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b1271e97b..252b8ccf0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -73,10 +73,9 @@ creates one undelivered notice after a day. Bodies are untrusted data. Both plugin manifests declare the SessionStart/UserPromptSubmit conversation hook. Claude Stop can block with complete pending messages; Codex also receives them after Bash tool calls. Delivery is recorded only after successful output. -Memory hooks no longer publish legacy principal addresses or old inbox-action -instructions. Private hook/MCP checks do not establish native-host, wakeup or -model-visible acceptance. The retired HTTP message endpoint returns `410 Gone`; -use the conversation MCP/CLI interface above. +Use recipient read and reply events to verify the handoff. For a request that +needs a response, use `reply_to` to acknowledge it, return the result, or explain +a blocker within the user's authorization. ## All 12 MCP tools @@ -90,7 +89,7 @@ use the conversation MCP/CLI interface above. | `import` | Import a JSON export; `merge_strategy` (required): skip / append / overwrite | | `learn` | Record a structured lesson: error, root cause, fix, prevention | | `task_state` | Read or update where the work stands: goal / next / blocked / done | -| `briefing` | The assembled work topology — task state and up to three session tails precede ranked memories at every level, after optional repository facts; `minimal` then shows this project's decisions, lessons, knowledge and recent activity plus memories with no project and a few preferences of other projects, closing with the recent index (titles of the 30 most recently written memories in scope) at every level, and `full` adds other projects and global memory; legacy exact `project` + `recipient` can surface only that recipient's unfetched graph deliveries; these are separate from conversation messages | +| `briefing` | Load task state, up to three session tails, ranked memories, and the recent index. All levels include project and unfiled memories. `full` adds global and other-project activity. | | `user_patterns` | Analyze work schedule, focus areas, and commit workflow from memory | | `improvement` | Propose an evidence-linked product improvement or read its status; only a human may accept/reject it | | `message` | Discover a conversation address, send/read/status typed untrusted messages; host identity, 8,000-byte rendered envelope, queue/audit semantics and 14-day store maintenance apply | diff --git a/CODEMAP.md b/CODEMAP.md index 524c33518..474d91713 100644 --- a/CODEMAP.md +++ b/CODEMAP.md @@ -109,7 +109,7 @@ docs/ # ARCHITECTURE.md, api/API_REFERENCE.md | `session-summary.js` | Stop | captures the last assistant reply for later conversation tails; note ingestion (`_stop-notes`) | | `stop-message-gate.js` | Stop | Claude-Code-only: block the stop once per waiting agent-message id (#468) | | `post-commit.js` | PostToolUse Bash | git commit tracking | -| `user-prompt-intent.js` | UserPromptSubmit | waiting-message reminder, private marker renewal | +| `user-prompt-intent.js` | UserPromptSubmit | captures redacted user prompts when automatic capture is on | | `prompt-recall.js` | UserPromptSubmit | inject up to two eligible keyword-search results with titles, content and `[mem:id]`, within a shared 4096 UTF-8 byte rendered block | `scripts/hooks/_shared.js`, `_claude-channel.js`, `_clear-alias.js` and `_stop-notes.js` @@ -118,6 +118,13 @@ automatic updates are off, and by `memesh update` when asked by hand; there is n --- +### Codex hooks + +The [Codex manifest](.codex-plugin/plugin.json) also runs: + +- `codex-plan-activity.js` before and after Bash and after `update_plan`. It records plan activity and shell checkpoints for [continuation](src/core/continuation.ts). +- `codex-busy-message-notice.js` after Bash to surface pending messages during a busy turn. + ## Core modules (navigation map) | File | One line | diff --git a/README.md b/README.md index 5e35c2cbc..8cf95ba49 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,7 @@ memesh doctor If `memesh doctor` reports database damage, stop your AI tools and run `memesh repair`. It preserves a verified damaged copy, salvages readable memories, and checks the replacement first. A built-in Node recovery path works without a usable system `sqlite3`; `memesh repair --from-backup` uses the newest verified memory backup instead. Restart your AI tools afterwards. -**Updates are automatic.** MeMesh installs new releases by itself (every version) after checking the release's provenance and backing up your database. It waits up to three days for running sessions to end; after that it may update while they are still running. It is on by default when HOME matches the system account home (or no account-home entry exists), including containers and other database locations. CI and a different test/sandbox HOME default to off; an explicit setting in that environment can enable it, while an account-level off always wins. Turn it off with `memesh config set autoUpdate off`; update right now with `memesh update`; repair a damaged plugin with `memesh update --reinstall`; `memesh doctor` shows what it did. - -**Windows npm-global 4.12.0:** Install 4.13.0 once with npm, then use `memesh update` for later releases. [Upgrade instructions](llms-install.md#updates) +MeMesh checks and installs updates automatically by default. Run `memesh update` to update now. The [update guide](llms-install.md#updates) covers controls, repair, and the one-time upgrade from Windows npm-global 4.12.0. `PCIRCLE-AI/memesh` is the GitHub repository that supplies the marketplace. `memesh@pcircle-memesh` selects the `memesh` plugin from the `pcircle-memesh` marketplace. diff --git a/README.vi.md b/README.vi.md index 3ca358cec..feb3f551d 100644 --- a/README.vi.md +++ b/README.vi.md @@ -42,7 +42,7 @@ memesh doctor [Hướng dẫn cài đặt và cập nhật](llms-install.md) · [Các tích hợp khác](docs/platforms/README.md) -**Windows với 4.12.0 cài toàn cục bằng npm:** Sau khi 4.13.0 có trên npm, cập nhật một lần bằng npm. [Hướng dẫn cập nhật](llms-install.md#updates) +MeMesh mặc định tự kiểm tra và cài đặt bản cập nhật. Chạy `memesh update` để cập nhật ngay. [Hướng dẫn cập nhật](llms-install.md#updates) giải thích cách cấu hình, sửa lỗi và nâng cấp một lần từ bản 4.12.0 cài toàn cục bằng npm trên Windows. `PCIRCLE-AI/memesh` là kho GitHub cung cấp marketplace. `memesh@pcircle-memesh` chọn plugin `memesh` từ marketplace `pcircle-memesh`. diff --git a/README.zh-TW.md b/README.zh-TW.md index 0c2861c33..c21685321 100644 --- a/README.zh-TW.md +++ b/README.zh-TW.md @@ -44,7 +44,7 @@ memesh doctor 若 `memesh doctor` 回報資料庫損毀,先關閉 AI 工具,再執行 `memesh repair`。它會保存核對過的損毀副本、救援可讀記憶,檢查新檔後才替換;系統 `sqlite3` 無法使用時會改用內建 Node 救援。也可用 `memesh repair --from-backup` 還原最新且通過檢查的記憶備份。完成後重新開啟 AI 工具。 -**Windows 上透過 npm 全域安裝的 4.12.0** 請等 4.13.0 上架後,用 npm 升級一次。[更新指南](llms-install.md#updates) +MeMesh 預設會自動檢查並安裝更新。可執行 `memesh update` 立即更新。[更新指南](llms-install.md#updates)說明設定、修復和 Windows npm 全域安裝 4.12.0 的一次性升級步驟。 `PCIRCLE-AI/memesh` 是提供 marketplace 的 GitHub 儲存庫;`memesh@pcircle-memesh` 表示從 `pcircle-memesh` marketplace 安裝 `memesh` 插件。 diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index f2713c650..2f257b20b 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -136,7 +136,6 @@ src/ ├── db.ts # SQLite + FTS5 + migrations ├── knowledge-graph.ts # Entity CRUD, relations, FTS5 search, findConflicts ├── index.ts # Package exports -├── cli/ ├── host-adapters/ # Native Claude/Codex adapters; ACP remains experimental and not release-gated ├── host-runtime/ # Claude conversation Channel entry and lifecycle ├── mcp/ @@ -478,21 +477,14 @@ exhausted matching budget, the hook records a diagnostic and lets the tool proce - **Trigger**: `PreToolUse` event on `Edit` and `Write` tools - **Matcher**: `Edit|Write` - **What is printed**: ordinary memories keep their name, type and first observation. Lessons use the briefing's shared renderer: newest `Fix:` first, then the first non-empty observation; with no fix they show that observation, and with no observation only their name and handle. Names and text are redacted before the text is cut to 120 characters; each lesson's `[mem:id]` handle is appended after the cut (#602, #554, #523). -- **Behavior**: A memory is injected for the edited file only if (a) it carries the exact tag `file:`, or (b) its `entities.name` or one of its `observations.content` literally names the file — for every script, ASCII or not — and it is not an auto-captured session snapshot. A memory that refers to a file only by its stem ("the `auth` module …"), only loosely in prose ("the Claude MD file"), or by a DIFFERENT file's basename does NOT match; this is deliberately narrower than an earlier version of this hook (see CHANGELOG `[4.10.2]`). - - An exact `file:` TAG match — the full basename with its extension, never the extension-less stem alone (a `file:` tag, also written by the capture producer, is not unique to one file: `file:auth` is on both `auth.ts` and `auth.py`). - - An FTS5 search used only as a CANDIDATE GENERATOR — the ASCII basename's own words, extension included, adjacent and in order (not merely any one of them; a non-ASCII basename's candidate search is on its stem, bigram-OR'd, ranked by relevance) — over a bounded window of up to 50 candidates, followed by a LITERAL CONFIRMATION in JS over every fetched candidate: the FULL basename, extension included, must occur literally — for every script, never only the stem, even on the non-ASCII path — NFC-normalised, in the entity's name or one of its observations. Case folding is ASCII-only and applied PER CHARACTER (`A-Z`→`a-z`, everything else including every non-ASCII script passes through unchanged) — not gated on the whole basename being ASCII, so a mixed-script basename's own ASCII extension still folds (`設定配置.TS` confirms `設定配置.ts`). The candidate query alone is not sufficient: a token-adjacency hit is not proof the literal name appears (`05-CLAUDE-md.md` tokenizes to "claude" immediately followed by "md" too). - - A literal hit must also sit on a filename boundary: not embedded in a longer identifier (`xCLAUDE.md`, `my-CLAUDE.md`; a combining mark or an invisible format character directly after the name counts as part of a longer name too; bidi marks, embeddings and isolates are skipped wherever this boundary looks — directly after the name and again after a `.` — because right-to-left prose puts them around a Latin filename, and the character after them decides (`CLAUDE.md.` + RLM + space is a sentence end, `CLAUDE.md.` + LRM + `bak` is an extension); the two bidi overrides are never skipped and reject) or extension chain (`CLAUDE.mdx`, `CLAUDE.md~`, or a `.` followed by a letter, digit, combining mark or invisible format character in any script — `CLAUDE.md.bak`, `CLAUDE.md.備份`; a `.` followed by anything else, such as an emoji, is read as a sentence end), and not immediately followed by another path separator (`notes/CLAUDE.md/`, `notes/CLAUDE.md/subfile` — that names a DIRECTORY called CLAUDE.md, or a file inside it, not the edited file itself); a bare mention bounded by whitespace or punctuation (quotes, parens, a line-number suffix, a trailing sentence period, a URL fragment or query string such as `notes/CLAUDE.md#section` or `notes/CLAUDE.md?x=1` — a fragment/query does not change which file a path points at, so it still confirms) passes. A non-ASCII letter with no separator directly before an ASCII basename (`設定CLAUDE.md`) is a deliberate exception: the boundary check is ASCII-only, so this is NOT treated as embedding and IS accepted as a bare mention. - - The NFC normalisation on both sides is a CANONICAL-equivalence rule, pinned as by-design rather than a defect (#358): two spellings are the same name after NFC exactly when Unicode treats them as canonically equivalent — composed vs. decomposed accents ("café" vs. "cafe" + combining acute), and also the handful of singleton canonical mappings such as KELVIN SIGN U+212A → ASCII "K" and ANGSTROM SIGN U+212B → "Å" (U+00C5). A memory naming a file with the Kelvin sign confirming an edit to the ASCII-K file is this rule working as intended, the same relationship that unifies composed and decomposed "é" — it is deliberately not special-cased, since a carve-out for one singleton mapping would need a per-character exception table on this hot path. COMPATIBILITY equivalents are NOT folded together: fullwidth "A" (U+FF21) stays distinct from ASCII "A", and ligatures stay distinct from their expansions, because NFC is used here, not NFKC (NFKC would erase exactly those distinctions). The ASCII-only case fold described above runs after normalisation and only touches `A-Z`, so it does not reach Turkish İ (U+0130) / ı (U+0131) or German ß (U+00DF) — none of those fold to their naive ASCII lookalikes. - - A mention preceded by a path separator (e.g. "notes/CLAUDE.md", "文件/CLAUDE.md", `C:\repo\docs\CLAUDE.md`) is checked as a PATH: the backward scan for the path token includes letters, marks and digits from the Basic Multilingual Plane and retains `@ + = % $` inside path components. It keeps a `~` inside a directory name (a Windows 8.3 short name such as `RUNNER~1`; by the same rule a `~` glued to the front of a mention belongs to it, so "x~notes/CLAUDE.md" is not read as "notes/CLAUDE.md") and recognises a single ASCII drive letter followed by `:` as the start of the token. The extracted path is accepted only if it equals, or is a directory-aligned suffix of, one of the edited file's own path forms: its path relative to its repository root (when known), its canonical absolute path (through any symlink resolved to its real target), or the absolute path exactly as the edit payload itself named it (unresolved). A directory that does not exist yet stays part of all three: a `Write` into `notes/new/` is checked as `notes/new/CLAUDE.md`, never as the nearest existing ancestor's `notes/CLAUDE.md`. Only the FINAL path segment — the basename — and a leading Windows drive letter are ASCII case-folded; every directory component in between is compared exactly, on every platform (#358). This is a deliberate decision, not an oversight: a directory's real case sensitivity depends on the volume, which this check cannot ask without a filesystem call, and this is a hot path that makes none — `NOTES/CLAUDE.md` mentioned in a memory does NOT match an edit to `notes/CLAUDE.md` (a directory-case mismatch is a deliberate false negative; the memory is still reachable by a relative or bare mention), while `notes/claude.MD` still does (the basename stays case-insensitive). An ABSOLUTE mention matches when it equals the edited file's path either exactly as the editor supplied it (its own alias, if any) or in its canonical (realpath-resolved) form; an alias that appears ONLY in the memory text — never in the edit payload itself — does NOT match, because resolving it would need a filesystem call per mention (#358). A memory can still name either the symlinked or canonical spelling of the file THE EDIT PAYLOAD ITSELF USED, and both match; a spelling the payload never used is out of reach through this path only, not through a bare or relative mention. The drive-letter comparison is case-insensitive on the letter and still rejects a different drive or a different repository path. Editing the repository root's `CLAUDE.md`, a mention prefixed with an unrelated subdirectory does not count; editing a `CLAUDE.md` that actually lives under that subdirectory, it does, and so does a bare `CLAUDE.md` mention. A path-shaped mention requires a non-path character (or start of text) immediately before it — a delimiter such as whitespace, punctuation, or an emoji; CJK prose with no delimiter directly before the path is consumed into the path token itself and does not match (`請看文件/CLAUDE.md` misses; `📁文件/CLAUDE.md` matches) — a deliberate decision, not an oversight: the same memory remains reachable through any other bare or delimited mention it also contains (#358). - - Bidi marks between a path separator and the basename are transparent to literal confirmation. The complete preceding path still has to match, and bidi overrides at the basename boundary are rejected. The path scan can miss exact paths that contain spaces, quotes, parentheses, brackets, commas, semicolons, or letters outside the Basic Multilingual Plane. A path that fails comparison is never retried with its leading segments removed. - - When the FTS candidate window fills AND fewer than the maximum number of memories were confirmed, the outcome records that the search was truncated — whether that means an empty injection (recorded as `skipped`, not falsely claiming there was nothing to find) or a partial one (recorded as `notified` with the same truncation reason attached, so 1 or 2 genuinely-confirmed memories are not reported as if the search had covered everything). A full set of confirmed memories, or a window that did not fill, carries no such reason. - - Auto-captured session-snapshot rows (`session-insight`, `session-summary`) never qualify as a match either way — they carry a `file:` tag for every file a session touched, which is not evidence the memory is about this edit. The project scope is derived from the edited file's own directory (nearest git repository, resolved through any symlink), and a memory is matched under every project id that repository has been filed under (`getProjectIds`), falling back to the session's `cwd` project when the file's own repository cannot be determined — the file is not inside one, or git cannot answer for its directory (an ancestor git may not enter). In that case only a bare mention or an absolute path can confirm, since there is no repository-relative path to compare. Each git call is capped at 2 seconds and up to four run in sequence, so where git itself stalls the fallback may not be reached before the hook's timeout ends the run (#366). A recall or database close failure is recorded as an `error`, and the file remains eligible for recall. A lesson guard already matched to the edit still appears. Both guard hooks flush the complete JSON response before recording the warning and writing the fire counter. The counter waits up to 200 ms for the write lock and reports a missed count on stderr. Returns relevant memories as additional context, or nothing when no candidate clears these bars. Throttled to max 1 recall per file per session: each session keeps its own list in `~/.memesh/pre-edit-recall/` (cleared whenever that session starts again; lists idle for 30 days are removed), and a subagent, whose payload carries its parent's `session_id` plus its own `agent_id`, keeps a list of its own, so another session, or the parent, editing the same file still gets its recall. A list's file name is a hash of the ids (`recallListName` in `_stop-notes.js`, used by both this hook and SessionStart), so it has a fixed length and ids that differ only in case stay separate on a case-insensitive disk. A payload without a usable session id (or with an unusable `agent_id`) is not throttled. A throttled repeat is recorded as throttled ("this session already looked at it"), never as "nothing to recall", and says nothing about whether memories were shown. A list that cannot be written or pruned leaves an `error` outcome (`pre-edit list: …`) as well as a stderr line (#521). Timeout: 5 seconds. +- **Matching**: a memory must carry the exact `file:` tag or mention + the full filename. FTS finds up to 50 candidates before literal confirmation. + Filename matching uses NFC and ASCII-only case folding. Path mentions must + match the edited path or a directory-aligned suffix, using exact directory + case. Scope follows the edited file's repository and aliases, with the host's + working directory as fallback. The hook excludes auto-captured snapshots + and recalls each file once per session or subagent. See the + [matching tests](../tests/hooks/pre-edit-recall.test.ts). ### Session Start (`scripts/hooks/session-start.js`) @@ -505,7 +497,7 @@ exhausted matching budget, the hook records a diagnostic and lets the tool proce Splitting the channels is load-bearing, not cosmetic. Before v4.2.7 the hook emitted **only** `systemMessage`, so nothing it recalled ever reached the model even though the banner reported a memory count — and the Stop hook then charged each of those entities a `recall_miss` for not appearing in a transcript they were never shown in, permanently depressing their `impactScore`. Regression tests in `tests/hooks/session-start.test.ts` assert the model-facing payload directly. - **Briefing levels (#360).** What the model-facing payload contains is controlled by the `briefing` setting (`minimal` (default) | `standard` | `full` — see **briefing-level.ts** above and the `briefing` MCP tool in [API_REFERENCE.md](api/API_REFERENCE.md)). The contract, stated identically everywhere it is documented (see the current policy in `briefing-level.ts`): **`minimal`** is only this project — its decisions, lessons, known facts and recent activity, with the live repository state in front of them whenever anything else is injected (the repository state alone is never injected), then the recent index (the titles of the 30 memories most recently written in this project or with no project, never another project's); task state and session tails are included; nothing else from outside the project's own detail; a few preferences of other projects (`preference`, `user_preference`, `feedback`, only those the note importer stored from the user's own memory folder, by their provenance; at most three, labelled with their project, in a section after the project's own that takes only the room left) follow the project's own. A project's curated decisions and lessons are included at `minimal` because they are the one thing a host's own built-in memory does not already have. **`standard`** uses the same memory selection as `minimal`. **`full`** is `standard` plus memories from your other projects (of their memory-folder notes, only preferences and feedback, as at every level) plus global memory. The hook, `briefing` MCP tool and CLI use the same saved-memory assembly rules; their query windows differ, so their selected rows need not be identical. The SessionStart hook additionally appends the hook-only work-package notice at `full` (never part of `assembleBriefing()`'s result, so never part of the `briefing` tool/CLI output, at any level — see the field comment on `BriefingLevelPolicy.workPackageNotice` in briefing-level.ts). The `full`-equivalent block (hook, including the notice) was every session's only behaviour before this change, and was measured, on one real session, to be dominated by content not about the project the agent was actually in (see `CHANGELOG.md`'s `[4.10.2]` entry for the exact figures). Each task-state field is aged from its own stated date: changing the goal does not refresh untouched next, blocked or done text. Fields remain visible regardless of age, attributed to each stated date or labelled unknown when its date is missing, malformed or more than `CLOCK_SKEW_ALLOWANCE_MINUTES` (5) minutes in the future. Legacy values retain their source timestamp as provenance without guessing their individual stated dates. Legacy records without a field-date map retain the shared `updated_at` compatibility rule until their first changed write; thereafter untouched fields remain unknown, while `legacy_updated_at` preserves the original shared timestamp only as provenance. `MEMESH_BRIEFING` overrides the configured level; an unrecognised env or config value is traced to stderr and recorded on the outcome channel below (with the offending source and value) rather than silently defaulting. On an initialised project with nothing in scope the recent index has no section, so `minimal` and `standard` inject no memory and record why (`hook-outcomes.jsonl`) instead of injecting a preamble wrapped around an empty fence (the session's project line above is still injected when the host reported a usable working directory); `full` injects only its work-package notice. `core/briefing.ts`'s `assembleBriefing` makes the identical decision on its own assembled block via the same `hasBriefingContent` rule (`work-topology.ts`), so the `briefing` MCP tool and CLI (`BriefingResult.empty`; the CLI prints one line instead of `text` when true) cannot disagree with the hook about what "nothing to show" means, even though neither can call the other's code (A1a). + **Briefing levels.** `minimal` and `standard` use the same saved-memory selection: project memories, unfiled memories, eligible preferences from other projects, and a recent index. `full` adds cross-project activity and global memories. SessionStart alone can append a work-package notice at `full`. The hook, CLI and MCP share assembly rules and may use different candidate windows. Task-state fields remain visible with their own stated date or an unknown-date label. See the [briefing API](api/API_REFERENCE.md#briefing). - Records the injected entity IDs, names, and the **exact injected text** to `~/.memesh/sessions/-.json` for recall-effectiveness tracking. `session-summary.js` subtracts that text from the transcript before hit/miss matching so memesh's own injection is never mistaken for the user referencing a memory. Files older than 24h are pruned on each run. - After output, runs `compressWeeklyNoise()` (throttled to once per 24h) to archive old auto-tracked noise into weekly summaries, then `archiveUnusedAutoCaptured()` (same throttle): auto-captured commits and session rollups (rows carrying the `source:auto-capture` tag) that no session cited, nothing recalled and nothing was added to for 14 days are archived. A memory an agent wrote is never touched, whatever its type or age. The row and its text stay (`memesh recall --include-archived` reads it; `remember` with the same name brings it back), carrying `metadata.auto_archive`. Every run, including one that archived nothing, is recorded in `memesh_metadata` (`last_auto_archive_run`) and shown by `memesh doctor` as "Automatic archive". @@ -629,7 +621,7 @@ MeMesh supports three integration tiers: | Tier | Client | Integration Method | |------|--------|--------------------| -| **Native plugin** | Claude Code | Plugin (`.claude-plugin/plugin.json` + 10 lifecycle hooks) | +| **Native plugin** | Claude Code | [Plugin manifest](../.claude-plugin/plugin.json) and [hooks](../hooks/hooks.json) | | | Hermes Agent | Native `MemoryProvider` plugin (Python ABC, convention-based discovery) | | **MCP server** | Claude Managed Agents | MCP connector (beta, via session config) | | | Claude Desktop | MCP server config | @@ -684,7 +676,7 @@ For release safety, `npm run test:packaged` creates a real npm tarball, extracts ### Smart Session-Start - Session-start hook loads top-N entities through the shared selection (`src/core/briefing-pools.ts`): each pool reads its newest candidates (up to 400), ranks them with `rankEntities` (recency, frequency, confidence and recall impact; no search term), gates and caps them. Older ordinary memories can fall outside that window; `recall` reaches them -- Default N=10, configurable via MEMESH_SESSION_LIMIT or `sessionLimit`; `briefing` resolves the same value, so the hook and `briefing` return the same selection. Recent commits (up to three) and the recent index sit outside that limit +- Default N=10, configurable via `MEMESH_SESSION_LIMIT` or `sessionLimit`. The hook and `briefing` share that limit. Recent commits (up to three) and the recent index sit outside it. - The block closes with the recent index (`src/core/recent-index.ts`, hook copy `scripts/hooks/_generated/recent-index.js`, the same section `briefing` closes with): the titles of the 30 memories most recently written in the prompt-recall scope (this project's proven ids and no project, never another project's even when global; trusted; no bookkeeping types, no feedback, no automatic captures), at every level (at most 30 lines of at most 139 characters (4,199 with line breaks), plus its heading), without a title-based stale or replacement filter. It is selected on its own, so a memory can appear both in a ranked section and in the index. - Memories with no project tag (preferences and general lessons stored with `project: false`, or older untagged rows) get their own pool of up to five at every level, shown under their own heading after the project's sections; global rows keep their own pool, and at `full` the other-projects pool takes only rows that carry a project tag - Equal scores resolve newest first: candidates arrive newest first and the sort is stable (#401). The daily decay multiplies the confidence of never-accessed memories by 0.9, so the memories captured since its last run all score alike, and without this the oldest of them would fill the window. The lesson query orders newest first too diff --git a/docs/api/API_REFERENCE.md b/docs/api/API_REFERENCE.md index d62992e42..d4ebd4710 100644 --- a/docs/api/API_REFERENCE.md +++ b/docs/api/API_REFERENCE.md @@ -165,7 +165,7 @@ Five more fields are conditional. `retagged` appears when a `project:` tag --- -#### Native human editing (unreleased source builds) +#### Native human editing To open the native editor for an existing memory, call `remember` with only `name`, `interactive: true`, and optional `project` (same binding rules as ordinary @@ -838,7 +838,7 @@ Passing an **empty string** clears a field — that is how a blocker is removed ### briefing -The `briefing` tool returns task state and up to three project session tails ahead of ranked memories, together with project decisions, lessons, knowledge, recent activity, up to five memories that belong to no project (preferences, general lessons; every level), up to three preferences of your other projects (`preference`, `user_preference` or `feedback`, only those MeMesh imported from your own memory folder; labelled with the project they came from, filled after everything of this project's, newest first), at every level the recent index (the titles of the 30 memories most recently written in this project's scope) with `[mem:id]` handles. Repository facts can prefix the block. The Claude Code SessionStart hook injects a memory block through the same selection and assembly; both use `MEMESH_SESSION_LIMIT`, then the configured session limit, then the default of 10. The ranked pools (this project's memories, memories with no project, global memory and other projects' recent memory) each rank only their newest 400 candidates, so older ordinary memories are reached with `recall`, not automatically; decisions (newest valid activity first), lessons (newest 50, up to five shown) and session tails keep their own selection. At `full` the hook adds a separate work-package notice that the tool and CLI do not include. When Codex allows the plugin's hooks, SessionStart injects the same memory block and the message hook registers eligible CLI conversations. At startup, Codex can show an earlier shell request from the same worktree. The return and candidate match are reported only when observed. Use `briefing` at startup when the block is missing, including with MCP-only clients. MCP can include a shell checkpoint when the client reports one workspace root that matches its project binding. +`briefing` returns task state, up to three project session tails, ranked memories, and the recent index. Repository facts can prefix the block. Hook, CLI, and MCP share assembly rules. The message hook registers eligible Codex CLI conversations. SessionStart can show a `full`-level work-package notice. Call `briefing` at startup when the host did not inject it. A shell checkpoint can appear when MCP has one unambiguous local workspace matching its bound project, from `MEMESH_PROJECT_ROOT` or client workspace roots. A checkpoint reports observed events and candidate information. Verify the operation's actual effects before continuing. The returned text is fenced as untrusted background data; stored memory content must not be treated as instructions. @@ -846,13 +846,13 @@ The returned text is fenced as untrusted background data; stored memory content **Briefing levels.** Set `memesh config set briefing ` or `MEMESH_BRIEFING` (environment overrides config); the default is `minimal`. The level applies to Claude Code's hook, the MCP tool, and `memesh briefing`, with no per-call override. `memesh config list` shows the effective level and its source; `memesh config get briefing` shows only the stored value. Invalid stored or environment values fall back to `minimal` and are reported as invalid. -| Level | Project session tails | This project's decisions/lessons/knowledge/recent activity | Memories with no project (up to five), and preferences of other projects (up to three) | Task state (fresh) | Recent index | Global memory | Other projects' recent memory | Work-package notice (hook only) | +| Level | Project session tails | This project's decisions/lessons/knowledge/recent activity | Memories with no project (up to five), and preferences of other projects (up to three) | Task state | Recent index | Global memory | Other projects' recent memory | Work-package notice (hook only) | |---|---|---|---|---|---|---|---|---| | `minimal` (default) | yes | yes | yes | yes | yes | no | no | no | | `standard` | yes | yes | yes | yes | yes | no | no | no | | `full` | yes | yes | yes | yes | yes | yes | yes | yes | -Task state precedes session tails at every level; repository facts, when present, prefix the block. `minimal` otherwise includes this project's decisions, lessons, knowledge, and recent activity, and up to five memories that belong to no project (every level, under their own heading; never global ones, which have their own pool at `full`), and your preferences from other projects: at most three (`preference`, `user_preference` and `feedback`, only those MeMesh imported from your own memory folder), newest first, each labelled `(from )`, in their own section after everything of this project's, so they take only what is left. Only notes of a memory folder are shown unasked, and only what MeMesh itself vouches for: that a note came from such a folder is set by the note importer alone (a tag or a type an agent writes proves nothing, and an agent that rewrites an imported note, with `remember` or the memory tool, loses that mark). The folder holds what you and the agent wrote there; a note whose file was deleted is not shown. Another project's decisions and lessons, and any preference an agent wrote, would let one project's captured text steer another if they were put in front of it unasked (a preference that applies everywhere is stored with no project, which has its own pool); they stay one `recall` away. At `minimal` and `standard`, another project's detail does not appear in the ranked sections. The project's own memories are read under every id its checkout has been filed under, and session tails select the latest trusted assistant conversation per session across those ids (an untrusted one, such as an import, never hides a trusted one). The recent index (the titles of the 30 memories most recently written in this project's scope) closes the block at every level. `standard` uses the same memory selection as `minimal`. `full` also adds global memory and other projects' recent activity; of another project's memory-folder notes it too shows only the preferences and feedback. The work-package notice at `full` belongs only to the Claude Code SessionStart hook, not to the MCP tool or CLI. +Task state precedes session tails at every level; repository facts, when present, prefix the block. `minimal` otherwise includes this project's decisions, lessons, knowledge, and recent activity, and up to five memories that belong to no project (every level, under their own heading; never global ones, which have their own pool at `full`), and your preferences from other projects: at most three (`preference`, `user_preference` and `feedback`, only those MeMesh imported from your own memory folder), newest first, each labelled `(from )`, in their own section after everything of this project's, so they take only what is left. Only notes of a memory folder are shown unasked, and only what MeMesh itself vouches for: that a note came from such a folder is set by the note importer alone (a tag or a type an agent writes proves nothing, and an agent that rewrites an imported note, with `remember` or the memory tool, loses that mark). The folder holds what you and the agent wrote there; a note whose file was deleted is not shown. Another project's decisions and lessons, and any preference an agent wrote, would let one project's captured text steer another if they were put in front of it unasked (a preference that applies everywhere is stored with no project, which has its own pool); they stay one `recall` away. At `minimal` and `standard`, another project's detail does not appear in the ranked sections. The project's own memories are read under every id its checkout has been filed under, and session tails select the latest trusted assistant conversation per session across those ids (an untrusted one, such as an import, never hides a trusted one). The recent index (the titles of the 30 memories most recently written in this project's scope) closes the block at every level. `standard` uses the same memory selection as `minimal`. `full` also adds global memory and other projects' recent activity; of another project's memory-folder notes it too shows only the preferences and feedback. The work-package notice at `full` belongs to the SessionStart hook, not to the MCP tool or CLI. A decision (`decision`, `architecture_decision`, `design_decision`) is shown with its latest `Why:` observation after the title — `- [decision] SQLite for local-first storage — Why: PostgreSQL is too heavy to deploy for one user; revisit if we add a hosted tier [mem:12]` — or with `(no reason recorded)` when it has none; a decision whose only observation is its reason shows that reason once. When nobody has read it (`recall` stamps it) or added to it (its newest observation, whatever the decision type) for 30 days, the line also says `(unconfirmed N days: re-check before relying)`; a `recall` that returns it clears that. The durable-memory catalog (`briefing --index`) marks its decision lines the same way; the recent index shows titles only. The markers and the `[mem:id]` handle are never cut. When a decision line is longer than its budget (160 characters in the ranked block, 120 in the catalog, counted after the `- [type] ` prefix and including the markers and handle) the title is clipped first, down to 40 characters, and only then the reason, so the reason gets room before the title does (it is still cut when it is very long, and in the index's 120 characters little room is left for it once the unconfirmed note is shown). @@ -888,13 +888,13 @@ Task-state fields remain visible regardless of age. Each is attributed to its st } ``` -At `minimal` on a project with nothing to show, the response has `text: ""` and `empty: true`; `index` is still returned as structured data but is not included in `text`. The CLI prints one line, `Nothing to brief at level minimal — no project memories yet. To add the first one to this project, change the quoted text and run: memesh remember --name first-memory --type note --obs "what to remember" --tags project:` (`` is the briefed project's id, filled in), and exits `0`. The command runs as printed and stores the memory in that project; without `--tags project:` a memory belongs to no project and appears in every project's briefing. `memesh briefing` only reads: on a machine with no database yet it answers as it would on an empty one and does not create the database file. +At `minimal` on a project with nothing to show, the response has `text: ""` and `empty: true`; `index` is still returned as structured data but is not included in `text`. The CLI prints one line, `Nothing to brief at level minimal — no project memories yet. To add the first one to this project, change the quoted text and run: memesh remember --name first-memory --type note --obs "what to remember" --tags project:` (`` is the briefed project's id, filled in), and exits `0`. The command stores the memory in the specified project. Omit the project tag to use the current directory’s project, or pass `--no-project` to leave it unfiled. `memesh briefing` only reads: on a machine with no database yet it answers as it would on an empty one and does not create the database file. `bytes`/`tokens` above are shown as `"…"` because the `lines` they measure are abbreviated in this example — they are only reproducible for a fully spelled-out set of lines (see the `GET /v1/briefing-index` response below for one). -`hasTaskState` is `true` exactly when a task-state line is included: a dated or unknown-date state at any level, or the unreadable-record line. `hasHandoff` is `true` exactly when a session tail is displayed. The unread-message reminder that `recipient` adds rides beside them but is not a task state and does not count. +`hasTaskState` is `true` exactly when a task-state line is included: a dated or unknown-date state at any level, or the unreadable-record line. `hasHandoff` is `true` exactly when a session tail is displayed. -**Project names in the text.** `project` returns the full project ID (`