@lh8ppl/claude-memory-kit 0.2.1 → 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.
- package/README.md +7 -6
- package/bin/cmk-capture-prompt.mjs +17 -17
- package/bin/cmk-capture-turn.mjs +22 -21
- package/bin/cmk-compress-session.mjs +2 -2
- package/bin/cmk-inject-context.mjs +11 -11
- package/bin/cmk-observe-edit.mjs +17 -16
- package/package.json +1 -1
- package/src/audit-log.mjs +1 -0
- package/src/auto-extract.mjs +258 -6
- package/src/auto-persona.mjs +40 -8
- package/src/capture-turn.mjs +48 -1
- package/src/compress-session.mjs +89 -26
- package/src/compressor.mjs +1 -1
- package/src/conflict-queue.mjs +14 -0
- package/src/doctor.mjs +3 -3
- package/src/forget.mjs +29 -0
- package/src/graduation.mjs +1 -1
- package/src/index-rebuild.mjs +42 -0
- package/src/inject-context.mjs +5 -1
- package/src/install.mjs +29 -6
- package/src/lazy-compress.mjs +58 -9
- package/src/mcp-server.mjs +353 -124
- package/src/merge-facts.mjs +4 -0
- package/src/persona-portability.mjs +24 -1
- package/src/read-core.mjs +87 -0
- package/src/register-crons.mjs +64 -33
- package/src/remember-core.mjs +91 -0
- package/src/review-queue.mjs +13 -0
- package/src/rich-fact.mjs +46 -0
- package/src/settings-hooks.mjs +56 -2
- package/src/subcommands.mjs +419 -182
- package/src/weekly-curate.mjs +5 -0
- package/src/write-fact.mjs +25 -1
- package/template/.claude/skills/memory-write/SKILL.md +52 -35
- package/template/.gitignore.fragment +9 -3
- package/template/CLAUDE.md.template +2 -2
- package/template/docs/journey/journey-log.md.template +1 -1
package/src/weekly-curate.mjs
CHANGED
|
@@ -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
|
|
package/src/write-fact.mjs
CHANGED
|
@@ -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;
|
|
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
|
|
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
|
|
10
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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").
|
|
@@ -12,7 +12,13 @@ context/.index/
|
|
|
12
12
|
context/.locks/
|
|
13
13
|
|
|
14
14
|
# Diagnostic NDJSON logs (observability only; carry raw turn excerpts —
|
|
15
|
-
# e.g.
|
|
16
|
-
#
|
|
17
|
-
#
|
|
15
|
+
# e.g. discarded-low-trust traces — that are NOT secret-screened, so they
|
|
16
|
+
# must never be committed). The durable memory lives in the scratchpads +
|
|
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
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
This project uses **claude-memory-kit** for per-project, in-repo memory that survives session boundaries. Memory lives in `context/` (committed) and `context.local/` (gitignored). Cross-project memory lives at `~/.claude-memory-kit/` (or `$MEMORY_KIT_USER_DIR`).
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> This block is the runtime contract for the kit. `cmk doctor` reports which layers are active in your install. Docs: <https://github.com/LH8PPL/claude-memory-kit>
|
|
6
6
|
|
|
7
7
|
### Where memory lives
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ Precedence at session start: local > project > user (most-specific wins, others
|
|
|
22
22
|
|
|
23
23
|
### Health checks (when `cmk doctor` is live)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The `cmk doctor` health checks verify each layer is wired correctly: install integrity, hook registration, transcript capture freshness, INDEX accuracy, cron registration, semantic search backend, native Auto Memory coexistence, and stale locks. Full design + decision records: <https://github.com/LH8PPL/claude-memory-kit>.
|
|
26
26
|
|
|
27
27
|
### Recalling memory (for Claude)
|
|
28
28
|
|
|
@@ -23,7 +23,7 @@ How to update it:
|
|
|
23
23
|
|
|
24
24
|
For inspiration:
|
|
25
25
|
See claude-memory-kit's own journey log as a worked example:
|
|
26
|
-
https://github.com/LH8PPL/claude-memory-kit/
|
|
26
|
+
https://github.com/LH8PPL/claude-memory-kit/tree/main/docs/journey
|
|
27
27
|
|
|
28
28
|
This template uses HTML comments (like this one) to coach the
|
|
29
29
|
user through each section. The comments are stripped from
|