@gamaze/hicortex 0.14.0 → 0.14.2

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/README.md CHANGED
@@ -227,7 +227,7 @@ Full docs: [hicortex.gamaze.com/docs/configuration.html](https://hicortex.gamaze
227
227
  | `/distill` | POST | Yes | Canonical capture endpoint (0.9.0+). Accepts denoised session text (`text` string or `messages` array), distills server-side, stores. Used by both server-mode and client-mode nightly jobs. |
228
228
  | `/search` | GET | Yes | Semantic memory search |
229
229
  | `/recall-index` | POST | Yes | Pushed recall index (0.14): `{session_id, prompt}` → compact one-line-per-memory block (or `null`); `{session_id, reset: true}` clears the session's dedup state. Appearing in the index marks memories *shown*, never *used* |
230
- | `/memory` | GET | Yes | Fetch one memory by `?id=` (0.14). Marks it as used (strengthens) — the lazy-load counterpart of `/recall-index` |
230
+ | `/memory` | GET | Yes | Fetch one memory by `?id=` (0.14). Marks it as used (strengthens) — the lazy-load counterpart of `/recall-index`. Response includes a server-rendered `citation` (id, date, origin agent) — agents are instructed to cite memories that shape their answers, so memory influence is always visible to the user (0.14.1) |
231
231
  | `/recent` | GET | Yes | Recent memories, queryless recall (renamed from `/context` in 0.12) |
232
232
  | `/context` | GET / PUT | Yes | Standing [context layer](#context-layer): read all sections / partial-upsert named sections. `?agent=<id>` selects a [per-agent scope](#per-agent-context-013) (server resolves override/global/off + merge); invalid id → 400. Recall-style query params on GET → 400 (use `/recent`) |
233
233
  | `/context/ui` | GET | No* | Web editor for the context layer (shell served without auth, like `/viz`; data via `/context`) |
@@ -124,7 +124,7 @@ function createMcpServer() {
124
124
  }
125
125
  });
126
126
  // -- hicortex_get --
127
- server.tool("hicortex_get", "Fetch ONE memory's full content by id — use this to lazy-load entries from the '## Memory recall (auto)' index or from search results whose snippet was not enough. Fetching a memory marks it as used (strengthens it), so only fetch what you actually need.", {
127
+ server.tool("hicortex_get", "Fetch ONE memory's full content by id — use this to lazy-load entries from the '## Memory recall (auto)' index or from search results whose snippet was not enough. Fetching a memory marks it as used (strengthens it), so only fetch what you actually need. When the memory shapes your answer, cite it to the user (id + date + origin agent).", {
128
128
  id: zod_1.z.string().describe("Memory id (as shown in recall index/search results)"),
129
129
  }, async ({ id }) => {
130
130
  if (!db)
@@ -135,7 +135,12 @@ function createMcpServer() {
135
135
  return { content: [{ type: "text", text: `No memory with id ${id}` }], isError: true };
136
136
  // Real use → full strengthen (access_count + hardening + prune shield).
137
137
  storage.strengthenMemory(db, id, new Date().toISOString());
138
- const header = `[${mem.memory_type ?? "episode"}] ${mem.project ?? ""} ${mem.created_at ?? ""}`.trim();
138
+ // Provenance header (built-in citing norm, 0.14.1): id, type, project,
139
+ // ORIGIN AGENT (shared brain — the memory may come from another
140
+ // agent's session), and date, plus the explicit citation instruction.
141
+ const date = (mem.created_at ?? "").slice(0, 10);
142
+ const header = `[memory ${mem.id} | ${mem.memory_type ?? "episode"} | ${mem.project ?? "-"} | from ${mem.source_agent ?? "unknown"} | ${date}]\n` +
143
+ `Cite as (memory ${String(mem.id).slice(0, 8)}, ${date}) where this shapes your answer; it may be stale — newer memories supersede older.`;
139
144
  return { content: [{ type: "text", text: `${header}\n\n${mem.content ?? ""}` }] };
140
145
  }
141
146
  catch (err) {
@@ -673,7 +678,13 @@ async function startServer(options = {}) {
673
678
  return;
674
679
  }
675
680
  storage.strengthenMemory(db, id, new Date().toISOString());
676
- res.json({ memory: mem });
681
+ // `citation` is server-rendered so every plugin surfaces the same
682
+ // built-in provenance norm (owner directive 27.07) — see #193.
683
+ const date = (mem.created_at ?? "").slice(0, 10);
684
+ res.json({
685
+ memory: mem,
686
+ citation: `(memory ${String(mem.id).slice(0, 8)}, ${date}, from ${mem.source_agent ?? "unknown"})`,
687
+ });
677
688
  }
678
689
  catch (err) {
679
690
  res.status(500).json({ error: err instanceof Error ? err.message : String(err) });
@@ -1260,7 +1271,10 @@ function fixDaemonVersionPin() {
1260
1271
  function formatResults(results) {
1261
1272
  if (results.length === 0)
1262
1273
  return "No memories found.";
1274
+ // The id makes every recall surface feed the rest of the toolset: cite-on-use
1275
+ // (id + date), hicortex_get lazy-load of truncated content, hicortex_graph
1276
+ // entry points, and hicortex_update/delete self-correction (#192).
1263
1277
  return results
1264
- .map((r) => `[${r.memory_type}] (score: ${r.score.toFixed(3)}, strength: ${r.effective_strength.toFixed(3)}) ${r.content.slice(0, 500)}`)
1278
+ .map((r) => `[${r.id}] [${r.memory_type}] (${(r.created_at ?? "").slice(0, 10)}, score: ${r.score.toFixed(3)}, strength: ${r.effective_strength.toFixed(3)}) ${r.content.slice(0, 500)}`)
1265
1279
  .join("\n\n");
1266
1280
  }
@@ -144,7 +144,13 @@ async function handleRecallIndex(deps, body) {
144
144
  const lines = picked.map((r) => formatIndexLine(r));
145
145
  const block = [
146
146
  "## Memory recall (auto)",
147
- "Possibly relevant long-term memories. Fetch full content with `hicortex_get(id)` ONLY for entries relevant to the current task:",
147
+ // Provenance is BUILT IN, split by function (owner decision 27.07,
148
+ // option D): this header carries only the SELECTION-time rules —
149
+ // supersession (the one moment competing dates are visible side by side)
150
+ // and cite-what-you-rely-on (covers snippet-only use, the common case per
151
+ // the 0.14.0 field test). The full citation format + origin agent ride on
152
+ // the hicortex_get response / GET /memory `citation` field (use-time).
153
+ "Possibly relevant memories — dates matter, newer supersedes older. Fetch full content with `hicortex_get(id)` only when relevant; cite any memory you rely on (id, date):",
148
154
  ...lines,
149
155
  ].join("\n");
150
156
  return { status: 200, body: { block, shown: ids, turn } };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gamaze/hicortex",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "Self-learning memory for AI agents \u2014 experience captured automatically, distilled into lessons overnight, shared across your whole fleet. Works with Hermes, OpenClaw, Claude Code, and Pi.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {