@lh8ppl/claude-memory-kit 0.2.2 → 0.2.3

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.
@@ -339,6 +339,11 @@ export async function weeklyCurate({
339
339
  backend,
340
340
  now: ts,
341
341
  cooldownMs: 0,
342
+ // Task 111 (F-2): the weekly janitor sweeps the whole-project `facts`
343
+ // corpus (heavier than a session summary) and runs as a cron/lazy child
344
+ // with no 60s hook ceiling — give the classifier headroom so a large
345
+ // corpus doesn't time out. (Corpus is byte-capped at PERSONA_CORPUS_BYTES.)
346
+ timeoutMs: 120_000,
342
347
  });
343
348
  }
344
349
 
@@ -248,7 +248,7 @@ export function writeFact(opts = {}) {
248
248
  // Keep INDEX.md consistent on every create — the index is a derived view of
249
249
  // the fact files, so the writer owns keeping it current. Without this, a fresh
250
250
  // `cmk remember` left INDEX.md stale until a manual `cmk reindex`, and
251
- // `cmk doctor` HC-5 failed from the first capture (Task 85; lior-test-7
251
+ // `cmk doctor` HC-5 failed from the first capture (Task 85; live-test-7
252
252
  // 2026-06-03 — "users should get it working from the start"). Best-effort: the
253
253
  // fact is already durably on disk, so an index-rebuild hiccup must not turn a
254
254
  // successful capture into an error — the next reindex/search self-heals.
@@ -258,5 +258,29 @@ export function writeFact(opts = {}) {
258
258
  // index rebuild is best-effort; capture already succeeded
259
259
  }
260
260
 
261
+ // Default create-audit (Task 123.A / D-103). writeFact is the single boundary
262
+ // every fact create flows through, so it owns the operational audit entry —
263
+ // the prior "caller's responsibility" design left 3 of 4 create paths
264
+ // (auto-extract, explicit-remember, graduation) silently unaudited (cut-gate7:
265
+ // 6 creates → 0 audit lines). Callers that emit a richer-semantic audit for
266
+ // the same write (merge-facts → `merged`/CURATED_MERGE) pass `audit:false` to
267
+ // avoid a redundant `created` entry. Best-effort: a successful capture must
268
+ // not be turned into an error by an audit-log hiccup.
269
+ if (opts.audit !== false) {
270
+ try {
271
+ appendAuditEntry(tierRoot, {
272
+ ts: createdAt,
273
+ action: 'created',
274
+ tier: opts.tier,
275
+ id,
276
+ reasonCode: REASON_CODES.FACT_CREATED,
277
+ paths: { after: path },
278
+ extra: { writeSource: factOpts.writeSource, trust: factOpts.trust },
279
+ });
280
+ } catch {
281
+ // audit append is best-effort; the fact is already durably on disk
282
+ }
283
+ }
284
+
261
285
  return { action: 'created', id, path };
262
286
  }
@@ -1,33 +1,55 @@
1
1
  ---
2
2
  name: memory-write
3
- description: Captures a durable fact to project memory by running `cmk remember`, the kit's safe write path (Poison_Guard secret/injection screening + home-path sanitization + dedup + conflict detection). Use when the user says "remember this", "note this", "save this", "from now on", "going forward", "I prefer", "I don't like", "we decided", "we agreed", or otherwise states a durable preference, decision, or environment fact worth carrying across sessions. Also covers correcting a saved fact ("update memory: X is now Y") and removing one ("forget about X"). Skip throwaway chatter and facts that only matter to the current task.
4
- allowed-tools: Bash(cmk remember *) Bash(cmk forget *) Read
3
+ description: Captures a durable fact to project memory through the kit's safe write path (Poison_Guard secret/injection screening + home-path sanitization + dedup + conflict detection) — preferring the cmk MCP tools (mk_remember / mk_forget / mk_trust) when connected, falling back to the cmk CLI. Use when the user says "remember this", "note this", "save this", "from now on", "going forward", "I prefer", "I don't like", "we decided", "we agreed", or otherwise states a durable preference, decision, or environment fact worth carrying across sessions. Also covers correcting a saved fact ("update memory: X is now Y"), removing one ("forget about X"), and adjusting how much a saved fact is trusted ("trust this", "that's important — keep it", "that's not important / I'm not sure about that / low priority"). Skip throwaway chatter and facts that only matter to the current task.
4
+ allowed-tools: mcp__cmk__mk_remember mcp__cmk__mk_forget mcp__cmk__mk_trust Bash(cmk remember *) Bash(cmk forget *) Bash(cmk trust *) Read
5
5
  ---
6
6
 
7
7
  # Capturing durable memory
8
8
 
9
- Durable facts — preferences, decisions, environment state — are saved by running
10
- the kit's CLI. The CLI is the only safe way to write memory.
9
+ Durable facts — preferences, decisions, environment state — are saved through the
10
+ kit's safe write path (Poison_Guard secret screening + home-path sanitization +
11
+ dedup + conflict detection).
11
12
 
12
- ## MUST / NEVER
13
-
14
- - **MUST** capture every durable fact by running `cmk remember` (or `cmk forget`
15
- to remove). Run the command as shown; do not modify its shape.
16
- - **NEVER** hand-edit `context/MEMORY.md`, `context/USER.md`, or any file under
17
- `context/memory/`. Direct edits bypass secret screening and home-path
18
- sanitization and can leak a credential or a local path into a committed file.
13
+ - **NEVER hand-edit** `context/MEMORY.md`, `context/USER.md`, or any file under
14
+ `context/memory/`. Direct edits bypass screening and can leak a credential or a
15
+ local path into a committed file.
19
16
  - **Silent on success.** Do not announce "saved to memory" unless the user asked.
20
17
 
21
- ## Capture a fact (default)
18
+ There are two equivalent surfaces onto the same safe path. **Prefer the MCP tools
19
+ when the `cmk` server is connected** — params are structured data, so backtick /
20
+ `$()` / quote-heavy rationale can't be mangled by a shell, and there's no
21
+ per-command approval prompt.
22
+
23
+ ## Preferred: the cmk MCP tools (when connected)
24
+
25
+ - **Capture** → call `mk_remember` with `text`. For a preference, working-style
26
+ rule, or constraint, also pass `why`, `how`, `title`, and `type` — this writes a
27
+ rich Why/How fact file, not just a bullet.
28
+ - **Remove** → call `mk_forget` with the fact `id`. Two-step: the first call
29
+ previews what would be removed and returns a `confirm_token`; call again with
30
+ that token to tombstone (audit trail preserved). Confirm with the user first.
31
+ - **Adjust trust** → call `mk_trust` with the fact `id` and a `level` of `low`,
32
+ `medium`, or `high`. Use when the user signals how much a saved fact matters:
33
+ "trust this" / "that's important — keep it" → `high`; "that's not important / I'm
34
+ not sure / low priority" → `low`. Trust drives what gets injected first and what
35
+ ages out, so this is the user steering their own memory without editing files.
36
+
37
+ `type` is one of:
38
+
39
+ - `feedback` — how the user wants you to work
40
+ - `user` — who the user is (role, expertise)
41
+ - `project` — an ongoing goal or constraint
42
+ - `reference` — a pointer to an external resource (URL, ticket, dashboard)
43
+
44
+ ## Fallback: the cmk CLI (when the MCP server isn't connected)
45
+
46
+ Capture a bullet:
22
47
 
23
48
  ```
24
49
  cmk remember "<the fact, one sentence>"
25
50
  ```
26
51
 
27
- Writes a bullet to `context/MEMORY.md`. Use it for in-flight work, decisions,
28
- tool versions, paths, and environment facts.
29
-
30
- When the fact is not active work, pick its section:
52
+ Pick a section for facts that are not active work:
31
53
 
32
54
  ```
33
55
  cmk remember "<fact>" --section "Environment Notes"
@@ -35,32 +57,21 @@ cmk remember "<fact>" --section "Environment Notes"
35
57
 
36
58
  Sections: `Active Threads` (default), `Environment Notes`, `Pending Decisions`.
37
59
 
38
- ## Capture a fact WITH rationale (preferences, working style, lasting rules)
39
-
40
- When the fact carries a reason or a how-to — a user preference, a working-style
41
- rule, a project constraint — capture it richly so the reasoning survives:
60
+ Capture WITH rationale (preference, working-style rule, project constraint):
42
61
 
43
62
  ```
44
63
  cmk remember "<headline>" --type <type> --why "<why it holds>" --how "<how to apply it>" --title "<short title>"
45
64
  ```
46
65
 
47
- `--type` is one of:
66
+ For backtick / quote-heavy rationale, pass it off-shell as a JSON object so the
67
+ shell can't corrupt it (the D-81 fix):
48
68
 
49
- - `feedback` — how the user wants you to work
50
- - `user` who the user is (role, expertise)
51
- - `project` — an ongoing goal or constraint
52
- - `reference` — a pointer to an external resource (URL, ticket, dashboard)
53
-
54
- This writes a granular fact file with the rationale attached, not just a bullet.
55
-
56
- ## Correct a fact
57
-
58
- Capture the corrected version with `cmk remember`, then remove the stale entry
59
- with `cmk forget` (below) if it is now wrong. Do not hand-edit the old bullet.
60
-
61
- ## Remove a fact
69
+ ```
70
+ cmk remember --from-file fact.json
71
+ ```
62
72
 
63
- After confirming with the user (never remove a fact they did not ask to forget):
73
+ Remove a fact (after confirming with the user never remove one they did not ask
74
+ to forget):
64
75
 
65
76
  ```
66
77
  cmk forget "<substring or citation id>" --yes --reason "<why>"
@@ -68,6 +79,12 @@ cmk forget "<substring or citation id>" --yes --reason "<why>"
68
79
 
69
80
  Tombstones the fact — it keeps an audit trail and is never a silent delete.
70
81
 
82
+ Adjust how much a saved fact is trusted (`<id>` comes from `cmk search`):
83
+
84
+ ```
85
+ cmk trust <id> <low|medium|high>
86
+ ```
87
+
71
88
  ## What NOT to capture
72
89
 
73
90
  - Throwaway chatter ("user said hi").
@@ -16,3 +16,9 @@ context/.locks/
16
16
  # must never be committed). The durable memory lives in the scratchpads +
17
17
  # fact files, not these logs.
18
18
  context/sessions/*.extract.log
19
+
20
+ # Transcript-extraction temp buffer. capture-turn writes
21
+ # context/transcripts/.extract-<ts>.tmp as the turn buffer for the detached
22
+ # auto-extract child, which consumes + deletes it. Gitignored so a crash-orphaned
23
+ # partial (raw, un-screened turn content) never travels with `git clone`.
24
+ context/transcripts/.extract-*.tmp