@cerefox/memory 1.4.0 → 1.6.0
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/AGENT_GUIDE.md +90 -2
- package/AGENT_QUICK_REFERENCE.md +91 -1
- package/README.md +3 -2
- package/dist/bin/cerefox.js +843 -489
- package/dist/frontend/assets/{index-B1pgikxA.js → index-DcWOeGAh.js} +30 -30
- package/dist/frontend/assets/index-DcWOeGAh.js.map +1 -0
- package/dist/frontend/assets/{index-C1JXZA9m.css → index-DiDeaiM6.css} +1 -1
- package/dist/frontend/index.html +2 -2
- package/dist/server-assets/_shared/ef-meta/index.ts +20 -2
- package/dist/server-assets/_shared/mcp-tools/audit-log.ts +14 -1
- package/dist/server-assets/_shared/mcp-tools/get-help-content.ts +6 -4
- package/dist/server-assets/_shared/mcp-tools/get-help.ts +71 -1
- package/dist/server-assets/_shared/mcp-tools/index.ts +3 -0
- package/dist/server-assets/_shared/mcp-tools/list-versions.ts +12 -1
- package/dist/server-assets/_shared/mcp-tools/set-document-metadata.ts +133 -0
- package/dist/server-assets/_shared/partial-edits/index.ts +49 -0
- package/dist/server-assets/db/migrations/0022_rls_on_document_relations.sql +38 -0
- package/dist/server-assets/db/migrations/0023_set_document_metadata.sql +16 -0
- package/dist/server-assets/db/rpcs.sql +118 -1
- package/dist/server-assets/db/schema.sql +8 -1
- package/docs/guides/cli.md +54 -1
- package/docs/guides/connect-agents.md +11 -8
- package/docs/guides/operational-cost.md +1 -1
- package/package.json +1 -1
- package/dist/frontend/assets/index-B1pgikxA.js.map +0 -1
package/AGENT_GUIDE.md
CHANGED
|
@@ -15,7 +15,7 @@ It is not a message bus -- it is curated, versioned, searchable memory backed by
|
|
|
15
15
|
|
|
16
16
|
You'll be using **one** of these — whichever your user (or the harness) has configured:
|
|
17
17
|
|
|
18
|
-
1. **MCP tools (default)** — 12 named tools (`cerefox_search`, `cerefox_ingest`, …, `cerefox_get_help`) exposed by either a local MCP server (`@cerefox/memory` via npm, run as `cerefox mcp`) or the remote `cerefox-mcp` Edge Function. Tool names and parameters are documented in **The
|
|
18
|
+
1. **MCP tools (default)** — 12 named tools (`cerefox_search`, `cerefox_ingest`, …, `cerefox_get_help`) exposed by either a local MCP server (`@cerefox/memory` via npm, run as `cerefox mcp`) or the remote `cerefox-mcp` Edge Function. Tool names and parameters are documented in **The 13 Tools** below. This is the recommended path for purpose-built agent clients.
|
|
19
19
|
2. **Shell CLI (Bash tool)** — the same operations exposed as a local `cerefox …` command (the TypeScript CLI from `@cerefox/memory`, resource-verb shape — e.g. `cerefox document get`, `cerefox project list`), invoked via your Bash tool. Used when your user prefers not to install/configure an MCP server. The semantics are identical; only the surface differs. See **Using Cerefox via the CLI** near the bottom of this guide for the MCP-tool → CLI-command mapping and the small list of behavioural differences.
|
|
20
20
|
|
|
21
21
|
If you're not sure which mode you're in: check whether `cerefox_search` shows up in your tool list. If yes, use MCP. If no, ask your user where the Cerefox checkout lives — they'll have told you, typically in `CLAUDE.md`, `AGENTS.md`, or an equivalent project memory file.
|
|
@@ -34,7 +34,7 @@ The tool is intentionally MCP-only so an agent that has been dropped into Cerefo
|
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
|
-
## The
|
|
37
|
+
## The 13 Tools
|
|
38
38
|
|
|
39
39
|
### cerefox_search
|
|
40
40
|
|
|
@@ -603,3 +603,91 @@ printf '...new content...' \
|
|
|
603
603
|
cerefox audit list --json --limit 1000 --requestor "claude-code" \
|
|
604
604
|
| jq 'select(.author_type == "agent")'
|
|
605
605
|
```
|
|
606
|
+
|
|
607
|
+
## Timestamps are UTC
|
|
608
|
+
|
|
609
|
+
Every timestamp Cerefox returns — `created_at` on audit entries, version
|
|
610
|
+
history, document metadata — is **UTC**, and now carries its `Z` marker so it
|
|
611
|
+
cannot be mistaken for local time.
|
|
612
|
+
|
|
613
|
+
**When you write a date into a document's CONTENT, use your own clock, not a
|
|
614
|
+
Cerefox timestamp.** These are different things: a timestamp records when the
|
|
615
|
+
server stored something; a date in a log entry or a heading is authored content
|
|
616
|
+
and belongs to your timezone. An agent working a Pacific afternoon read
|
|
617
|
+
`2026-08-11` from version history, wrote "8/11" into its entries, and put a
|
|
618
|
+
day's work in the future — the timestamp was correct, and copying it into
|
|
619
|
+
content was not.
|
|
620
|
+
|
|
621
|
+
Cerefox deliberately does not convert to local time on the API or MCP paths.
|
|
622
|
+
"Local" has no server-side meaning: the remote MCP server runs in a cloud
|
|
623
|
+
function whose local time *is* UTC, while a local MCP server runs in yours, so
|
|
624
|
+
the same document would report two different times depending on transport. The
|
|
625
|
+
web UI converts because a browser knows the viewer's timezone; nothing
|
|
626
|
+
server-side does.
|
|
627
|
+
|
|
628
|
+
## Mistakes that have actually happened
|
|
629
|
+
|
|
630
|
+
Each of these comes from a real agent session, and each is easy to make.
|
|
631
|
+
|
|
632
|
+
- **`cerefox_ingest` always replaces the ENTIRE document.** Never a section.
|
|
633
|
+
Before sending, check that the tool name matches the intent: if the intent is
|
|
634
|
+
"change one section", the call is `cerefox_edit` with `replace_section`. A
|
|
635
|
+
section-sized edit sent as a full ingest truncated a 13,000-character index to
|
|
636
|
+
a single word. It was recovered from version history within the minute, but
|
|
637
|
+
only because it was noticed immediately.
|
|
638
|
+
|
|
639
|
+
- **Do not include the anchor's own heading in your text.** `replace_section`
|
|
640
|
+
keeps the heading and `insert` places your text inside the section, so
|
|
641
|
+
including it produces two. This is now refused rather than silently applied,
|
|
642
|
+
but the shape is worth knowing: it happened twice in one session, the second
|
|
643
|
+
time while trying to repair the first. A *deeper* sub-heading inside your text
|
|
644
|
+
is fine.
|
|
645
|
+
|
|
646
|
+
- **Content between sections belongs to the section ABOVE it.** A section runs
|
|
647
|
+
to the next heading of the same or higher level, so a `---` rule, a note, or
|
|
648
|
+
any trailing text sitting just above the next heading is part of the section
|
|
649
|
+
before it — even when it visually reads as belonging below. Replacing that
|
|
650
|
+
section takes it too. An agent hit exactly this: a `---` that separated two
|
|
651
|
+
major sections disappeared when the section above it was replaced. The write
|
|
652
|
+
was correct by the addressing rules; the surprise is that "the end of this
|
|
653
|
+
section" is further down the page than it looks. Note the loss warning will
|
|
654
|
+
not catch it if your replacement text is longer than what it replaced, since
|
|
655
|
+
there is then no net loss to report.
|
|
656
|
+
|
|
657
|
+
- **To change only tags, use `cerefox_set_document_metadata`, never `cerefox_ingest`.**
|
|
658
|
+
Ingest replaces the whole document, so re-sending it to set one tag carries the
|
|
659
|
+
full transcription risk for no reason. The metadata tool merges: the keys you
|
|
660
|
+
pass are set, everything else is left alone, so you do not need to read the
|
|
661
|
+
document first and cannot drop a tag another agent set. Pass `null` as a value
|
|
662
|
+
to remove a key.
|
|
663
|
+
|
|
664
|
+
- **Never partial-edit to fix a partial edit.** If a write leaves unexpected
|
|
665
|
+
structure, stop. Use `cerefox_list_versions`, retrieve the last good version,
|
|
666
|
+
and re-ingest cleanly. Repairing edits with more edits compounds the damage.
|
|
667
|
+
|
|
668
|
+
- **A rejected batch is safe.** Operations in one `cerefox_edit` are
|
|
669
|
+
all-or-nothing: if any is invalid, nothing is written. A refusal costs you a
|
|
670
|
+
retry, not data — so prefer one call for changes that belong together, and do
|
|
671
|
+
not split a batch to "make it more likely to succeed".
|
|
672
|
+
|
|
673
|
+
- **Read before replacing.** `cerefox_get_document(section: "## Heading")`
|
|
674
|
+
returns exactly what a `replace_section` on that anchor would overwrite. Use it
|
|
675
|
+
for any section you did not write in this session. The outline gives a
|
|
676
|
+
section's *size*, never its *text*.
|
|
677
|
+
|
|
678
|
+
- **Verify after writing** — read the result back before reporting success, and
|
|
679
|
+
report what the read actually shows.
|
|
680
|
+
|
|
681
|
+
- **Partial edits cannot change a document's stored TITLE.** `rename_section`
|
|
682
|
+
changes a heading inside the content; the title is a separate field and still
|
|
683
|
+
needs `cerefox_ingest`.
|
|
684
|
+
|
|
685
|
+
- **If a capability seems missing from one server, suspect your client first.**
|
|
686
|
+
Local and remote run the same code. **Every `cerefox_get_help()` response
|
|
687
|
+
begins with the server's version and the operations it registers** — you do
|
|
688
|
+
not need a special topic, and the *absence* of that block is itself an answer:
|
|
689
|
+
a server that does not print it predates v1.5.0. If that
|
|
690
|
+
disagrees with your tool list, the client is holding a list it fetched before
|
|
691
|
+
an upgrade — clients cache it at connect time. Ask the user to restart the
|
|
692
|
+
client. Do not record a capability difference between servers as a fact; every
|
|
693
|
+
such report so far has been a stale client.
|
package/AGENT_QUICK_REFERENCE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Cerefox Knowledge Base -- Agent Quick Reference
|
|
2
2
|
|
|
3
|
-
Cerefox is a persistent, shared knowledge base. You have **
|
|
3
|
+
Cerefox is a persistent, shared knowledge base. You have **17 MCP tools** (16 of them have CLI equivalents — `cerefox_get_help` is MCP-only). For the full guide, search Cerefox for "How AI Agents Use Cerefox" or call `cerefox_get_help` to retrieve this content over MCP.
|
|
4
4
|
|
|
5
5
|
## Tools
|
|
6
6
|
|
|
@@ -19,6 +19,7 @@ Cerefox is a persistent, shared knowledge base. You have **16 MCP tools** (15 of
|
|
|
19
19
|
| `cerefox_metadata_search` | Find or list docs by metadata, project, or time (no text query) | `metadata_filter`, `project_name` (list a project's docs), `updated_since`, `include_content` — **at least one** of metadata_filter/project_name/updated_since/created_since |
|
|
20
20
|
| `cerefox_list_metadata_keys` | Discover available metadata keys | (none required) |
|
|
21
21
|
| `cerefox_list_projects` | List all projects | (none required) |
|
|
22
|
+
| `cerefox_set_document_metadata` | Change tags WITHOUT resending content. **Merges** by default; a `null` value removes a key | `document_id`, `metadata` (required), `replace` (rare: set exactly this object), `author` |
|
|
22
23
|
| `cerefox_set_document_projects` | Set doc's project memberships to exactly the given list (destructive replace; metadata-only, no content change) | `document_id`, `project_names` (required) |
|
|
23
24
|
| `cerefox_get_audit_log` | Query write operation history | `document_id`, `author`, `operation`, `since` |
|
|
24
25
|
| `cerefox_get_help` | Retrieve Cerefox conventions (this reference) over MCP. **Call this whenever uncertain.** | `topic` (optional, case-insensitive H2 substring match) |
|
|
@@ -126,6 +127,7 @@ Same operations, same conventions. Full reference: [`docs/guides/cli.md`](docs/g
|
|
|
126
127
|
| `cerefox_get_relations` ⚑ | All relations touching a document, both directions | `document_id` |
|
|
127
128
|
| `cerefox_get_neighbors` ⚑ | Walk the graph along ONE relation type | `document_id`, `rel_type` (required), `depth`, `from_time`, `to_time`, `limit` |
|
|
128
129
|
| `cerefox_metadata_search` | `cerefox metadata search --metadata-filter '<json>' --requestor "<your-name>"` (list a project: `cerefox document list --project <name>`) |
|
|
130
|
+
| `cerefox_set_document_metadata` | `cerefox document set-metadata <id> --set key=value` (also `--remove key`, `--json '{...}'`, `--replace`) |
|
|
129
131
|
| `cerefox_set_document_projects` | `cerefox document set-projects <id> <name...> --author "<your-name>" --author-type agent` (or `--clear` to remove all) |
|
|
130
132
|
| `cerefox_get_audit_log` | `cerefox audit list --requestor "<your-name>"` (add `--json` for scripted access) |
|
|
131
133
|
| `cerefox_get_help` | `cerefox guides show agent-quick-reference` (or `cerefox guides list` for the full bundled-docs index) |
|
|
@@ -135,3 +137,91 @@ Same operations, same conventions. Full reference: [`docs/guides/cli.md`](docs/g
|
|
|
135
137
|
- Reads: `--requestor "<your-name>"`
|
|
136
138
|
|
|
137
139
|
Or have your user set `CEREFOX_AUTHOR_NAME` / `CEREFOX_AUTHOR_TYPE` / `CEREFOX_REQUESTOR_NAME` in their `.env` to apply defaults once.
|
|
140
|
+
|
|
141
|
+
## Timestamps are UTC
|
|
142
|
+
|
|
143
|
+
Every timestamp Cerefox returns — `created_at` on audit entries, version
|
|
144
|
+
history, document metadata — is **UTC**, and now carries its `Z` marker so it
|
|
145
|
+
cannot be mistaken for local time.
|
|
146
|
+
|
|
147
|
+
**When you write a date into a document's CONTENT, use your own clock, not a
|
|
148
|
+
Cerefox timestamp.** These are different things: a timestamp records when the
|
|
149
|
+
server stored something; a date in a log entry or a heading is authored content
|
|
150
|
+
and belongs to your timezone. An agent working a Pacific afternoon read
|
|
151
|
+
`2026-08-11` from version history, wrote "8/11" into its entries, and put a
|
|
152
|
+
day's work in the future — the timestamp was correct, and copying it into
|
|
153
|
+
content was not.
|
|
154
|
+
|
|
155
|
+
Cerefox deliberately does not convert to local time on the API or MCP paths.
|
|
156
|
+
"Local" has no server-side meaning: the remote MCP server runs in a cloud
|
|
157
|
+
function whose local time *is* UTC, while a local MCP server runs in yours, so
|
|
158
|
+
the same document would report two different times depending on transport. The
|
|
159
|
+
web UI converts because a browser knows the viewer's timezone; nothing
|
|
160
|
+
server-side does.
|
|
161
|
+
|
|
162
|
+
## Mistakes that have actually happened
|
|
163
|
+
|
|
164
|
+
Each of these comes from a real agent session, and each is easy to make.
|
|
165
|
+
|
|
166
|
+
- **`cerefox_ingest` always replaces the ENTIRE document.** Never a section.
|
|
167
|
+
Before sending, check that the tool name matches the intent: if the intent is
|
|
168
|
+
"change one section", the call is `cerefox_edit` with `replace_section`. A
|
|
169
|
+
section-sized edit sent as a full ingest truncated a 13,000-character index to
|
|
170
|
+
a single word. It was recovered from version history within the minute, but
|
|
171
|
+
only because it was noticed immediately.
|
|
172
|
+
|
|
173
|
+
- **Do not include the anchor's own heading in your text.** `replace_section`
|
|
174
|
+
keeps the heading and `insert` places your text inside the section, so
|
|
175
|
+
including it produces two. This is now refused rather than silently applied,
|
|
176
|
+
but the shape is worth knowing: it happened twice in one session, the second
|
|
177
|
+
time while trying to repair the first. A *deeper* sub-heading inside your text
|
|
178
|
+
is fine.
|
|
179
|
+
|
|
180
|
+
- **Content between sections belongs to the section ABOVE it.** A section runs
|
|
181
|
+
to the next heading of the same or higher level, so a `---` rule, a note, or
|
|
182
|
+
any trailing text sitting just above the next heading is part of the section
|
|
183
|
+
before it — even when it visually reads as belonging below. Replacing that
|
|
184
|
+
section takes it too. An agent hit exactly this: a `---` that separated two
|
|
185
|
+
major sections disappeared when the section above it was replaced. The write
|
|
186
|
+
was correct by the addressing rules; the surprise is that "the end of this
|
|
187
|
+
section" is further down the page than it looks. Note the loss warning will
|
|
188
|
+
not catch it if your replacement text is longer than what it replaced, since
|
|
189
|
+
there is then no net loss to report.
|
|
190
|
+
|
|
191
|
+
- **To change only tags, use `cerefox_set_document_metadata`, never `cerefox_ingest`.**
|
|
192
|
+
Ingest replaces the whole document, so re-sending it to set one tag carries the
|
|
193
|
+
full transcription risk for no reason. The metadata tool merges: the keys you
|
|
194
|
+
pass are set, everything else is left alone, so you do not need to read the
|
|
195
|
+
document first and cannot drop a tag another agent set. Pass `null` as a value
|
|
196
|
+
to remove a key.
|
|
197
|
+
|
|
198
|
+
- **Never partial-edit to fix a partial edit.** If a write leaves unexpected
|
|
199
|
+
structure, stop. Use `cerefox_list_versions`, retrieve the last good version,
|
|
200
|
+
and re-ingest cleanly. Repairing edits with more edits compounds the damage.
|
|
201
|
+
|
|
202
|
+
- **A rejected batch is safe.** Operations in one `cerefox_edit` are
|
|
203
|
+
all-or-nothing: if any is invalid, nothing is written. A refusal costs you a
|
|
204
|
+
retry, not data — so prefer one call for changes that belong together, and do
|
|
205
|
+
not split a batch to "make it more likely to succeed".
|
|
206
|
+
|
|
207
|
+
- **Read before replacing.** `cerefox_get_document(section: "## Heading")`
|
|
208
|
+
returns exactly what a `replace_section` on that anchor would overwrite. Use it
|
|
209
|
+
for any section you did not write in this session. The outline gives a
|
|
210
|
+
section's *size*, never its *text*.
|
|
211
|
+
|
|
212
|
+
- **Verify after writing** — read the result back before reporting success, and
|
|
213
|
+
report what the read actually shows.
|
|
214
|
+
|
|
215
|
+
- **Partial edits cannot change a document's stored TITLE.** `rename_section`
|
|
216
|
+
changes a heading inside the content; the title is a separate field and still
|
|
217
|
+
needs `cerefox_ingest`.
|
|
218
|
+
|
|
219
|
+
- **If a capability seems missing from one server, suspect your client first.**
|
|
220
|
+
Local and remote run the same code. **Every `cerefox_get_help()` response
|
|
221
|
+
begins with the server's version and the operations it registers** — you do
|
|
222
|
+
not need a special topic, and the *absence* of that block is itself an answer:
|
|
223
|
+
a server that does not print it predates v1.5.0. If that
|
|
224
|
+
disagrees with your tool list, the client is holding a list it fetched before
|
|
225
|
+
an upgrade — clients cache it at connect time. Ask the user to restart the
|
|
226
|
+
client. Do not record a capability difference between servers as a fact; every
|
|
227
|
+
such report so far has been a stale client.
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ This package contains a single binary, **`cerefox`**:
|
|
|
29
29
|
| Subcommand | What it does |
|
|
30
30
|
|---|---|
|
|
31
31
|
| `cerefox <command>` | CLI — search, ingest, list, version-history, audit-log, lifecycle (`init`, `doctor`, `configure-agent`, `self-update`). Callable from any directory. |
|
|
32
|
-
| `cerefox mcp` | Local stdio MCP server. Drop-in for Claude Code, Cursor, Claude Desktop, Codex CLI, Gemini CLI. Exposes the same
|
|
32
|
+
| `cerefox mcp` | Local stdio MCP server. Drop-in for Claude Code, Cursor, Claude Desktop, Codex CLI, Gemini CLI. Exposes the same 13 core MCP tools as the remote `cerefox-mcp` Edge Function, plus 4 document-relation tools that stay hidden until enabled. |
|
|
33
33
|
| `cerefox web` | Local web app at `http://localhost:8000` — React UI for browsing, searching, editing, and ingesting documents. Backed by an in-process Hono server that exposes the same `/api/v1/*` REST surface as the bundled Edge Functions. |
|
|
34
34
|
|
|
35
35
|
> **What this package isn't:** the source of truth for Cerefox's architecture
|
|
@@ -148,10 +148,11 @@ For manual configuration (any other MCP client), the canonical entry is:
|
|
|
148
148
|
```
|
|
149
149
|
|
|
150
150
|
Once configured, any of these clients can search + write your Cerefox KB via
|
|
151
|
-
the
|
|
151
|
+
the 13 core MCP tools (`cerefox_search`, `cerefox_ingest`, `cerefox_insert`,
|
|
152
152
|
`cerefox_edit`, `cerefox_get_document`, `cerefox_list_versions`,
|
|
153
153
|
`cerefox_list_projects`, `cerefox_list_metadata_keys`,
|
|
154
154
|
`cerefox_metadata_search`, `cerefox_set_document_projects`,
|
|
155
|
+
`cerefox_set_document_metadata`,
|
|
155
156
|
`cerefox_get_audit_log`, `cerefox_get_help`).
|
|
156
157
|
|
|
157
158
|
`cerefox_insert` and `cerefox_edit` change part of a document without resending
|