@tznthou/ccrecall 0.7.2 → 0.8.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/README.md +31 -16
- package/README_ZH.md +29 -16
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +25 -10
- package/dist/api/routes.js.map +1 -1
- package/dist/core/database.d.ts +52 -0
- package/dist/core/database.d.ts.map +1 -1
- package/dist/core/database.js +173 -23
- package/dist/core/database.js.map +1 -1
- package/dist/core/integrity-monitor.d.ts.map +1 -1
- package/dist/core/integrity-monitor.js +7 -3
- package/dist/core/integrity-monitor.js.map +1 -1
- package/dist/core/recall-telemetry.d.ts.map +1 -1
- package/dist/core/recall-telemetry.js +9 -3
- package/dist/core/recall-telemetry.js.map +1 -1
- package/dist/core/secure-dir.d.ts +7 -0
- package/dist/core/secure-dir.d.ts.map +1 -0
- package/dist/core/secure-dir.js +64 -0
- package/dist/core/secure-dir.js.map +1 -0
- package/dist/core/token-budget.d.ts +59 -3
- package/dist/core/token-budget.d.ts.map +1 -1
- package/dist/core/token-budget.js +115 -11
- package/dist/core/token-budget.js.map +1 -1
- package/dist/mcp/tools.d.ts +2 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +51 -3
- package/dist/mcp/tools.js.map +1 -1
- package/hooks/lib/secure-dir.mjs +52 -0
- package/hooks/session-start.mjs +20 -3
- package/package.json +3 -2
- package/scripts/extraction-prompt.md +52 -1
- package/scripts/l3-prescription-position.py +835 -0
- package/scripts/post-session-extract.sh +36 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tznthou/ccrecall",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "AI memory service for Claude Code — on-demand context injection with metacognition",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"start": "node dist/index.js",
|
|
59
59
|
"test": "vitest run",
|
|
60
60
|
"lint": "eslint . --fix",
|
|
61
|
-
"typecheck": "tsc --noEmit"
|
|
61
|
+
"typecheck": "tsc --noEmit",
|
|
62
|
+
"eval:demo": "tsx evaluation/demo.ts"
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -21,13 +21,37 @@ NOT worth saving (noise):
|
|
|
21
21
|
- Anything already stored in auto-memory or CLAUDE.md
|
|
22
22
|
- Credentials, API keys, tokens, passwords
|
|
23
23
|
|
|
24
|
+
## Lead with the prescription (most important rule)
|
|
25
|
+
|
|
26
|
+
When this memory is injected into a future session, **only its first 149
|
|
27
|
+
characters survive** — the rest is truncated away. The reader sees the opening
|
|
28
|
+
and nothing else, and has to decide what to do from that alone.
|
|
29
|
+
|
|
30
|
+
So open with the thing a future reader should DO. Put the evidence, the war
|
|
31
|
+
story and the file names after it.
|
|
32
|
+
|
|
33
|
+
- BAD — the actionable half never arrives:
|
|
34
|
+
"Three file-cut attempts failed (M8 missing quote, M18 punctuation style, M20
|
|
35
|
+
paragraph detection) before realizing the patterns were wrong, not the data
|
|
36
|
+
missing. Mitigation: pre-verify patterns by running grep first."
|
|
37
|
+
- GOOD — survives the cut intact:
|
|
38
|
+
"Pre-verify a grep pattern against the live file (confirm >= 1 hit) before
|
|
39
|
+
encoding it into an assertion: zero-hits reads the same whether the pattern is
|
|
40
|
+
wrong or the data is absent. Hit three times — M8, M18, M20."
|
|
41
|
+
|
|
42
|
+
This is not a length limit. Write the full memory; just order it so the first
|
|
43
|
+
sentence carries the instruction rather than the narrative that produced it.
|
|
44
|
+
|
|
45
|
+
If a memory has no action attached — a pure fact, a decision record, a version
|
|
46
|
+
quirk — lead with the conclusion instead. Never lead with the investigation.
|
|
47
|
+
|
|
24
48
|
## How to write each memory
|
|
25
49
|
|
|
26
50
|
Every memory must be **self-contained** — a future reader in a different project
|
|
27
51
|
has zero context about this session.
|
|
28
52
|
|
|
29
53
|
Rules:
|
|
30
|
-
1. Include the WHY, not just the WHAT
|
|
54
|
+
1. Include the WHY, not just the WHAT — but after the prescription, not before it
|
|
31
55
|
2. Use concrete details: file paths (relative, not absolute), command names,
|
|
32
56
|
version numbers, error messages
|
|
33
57
|
3. Replace pronouns ("we", "it", "this") with specific nouns
|
|
@@ -72,6 +96,26 @@ memory is updated instead of duplicated. Choose keys that are:
|
|
|
72
96
|
- Stable enough that the same insight would get the same key next time
|
|
73
97
|
- Lowercase, hyphenated, no special characters
|
|
74
98
|
|
|
99
|
+
## Message provenance (messageId)
|
|
100
|
+
|
|
101
|
+
Every turn in the transcript is headed `--- human [<uuid>] ---` or
|
|
102
|
+
`--- assistant [<uuid>] ---`. That uuid identifies the message.
|
|
103
|
+
|
|
104
|
+
For each memory, pass the uuid of the ONE message that most directly produced
|
|
105
|
+
it — where the decision was stated, the root cause named, the preference
|
|
106
|
+
expressed. Copy it verbatim out of the header.
|
|
107
|
+
|
|
108
|
+
- **Never invent, reconstruct, or guess a uuid.** If no single message stands
|
|
109
|
+
out, omit `messageId` entirely. A missing citation costs nothing; a wrong one
|
|
110
|
+
makes a memory look sourced when it is not, which is worse than unsourced.
|
|
111
|
+
- A header printed without a uuid (`--- human ---`) cannot be cited. Omit.
|
|
112
|
+
- Citing a message is **not** a claim that the message proves the memory. It
|
|
113
|
+
records where you drew it from, so a human can go read that turn later. Pick
|
|
114
|
+
the most direct source; do not stretch to manufacture one.
|
|
115
|
+
- The save path checks the uuid against this session's real messages. One it
|
|
116
|
+
cannot find is dropped, the memory is saved without it, and the result says
|
|
117
|
+
so. Do not retry — the turn budget is better spent on saves not yet made.
|
|
118
|
+
|
|
75
119
|
## recall_save parameters
|
|
76
120
|
|
|
77
121
|
For each memory, call `recall_save` with:
|
|
@@ -82,6 +126,13 @@ For each memory, call `recall_save` with:
|
|
|
82
126
|
- `projectId`: include for project-specific, omit for cross-project
|
|
83
127
|
- `sessionId`: the Origin session ID given in the transcript header above —
|
|
84
128
|
pass it verbatim so each memory can be traced back to its origin session
|
|
129
|
+
- `messageId`: the uuid of the single message this memory came from, copied
|
|
130
|
+
from its `--- human [<uuid>] ---` header (see above). Omit when no one
|
|
131
|
+
message is the source — never guess one
|
|
132
|
+
- `origin`: always `"agent-inferred"`. You are reading a finished transcript
|
|
133
|
+
with nobody watching, so your saves must not overwrite a memory the user
|
|
134
|
+
wrote by hand under the same key. Omitting this marks your save as the
|
|
135
|
+
user's own and removes that protection.
|
|
85
136
|
|
|
86
137
|
## Output
|
|
87
138
|
|