@tznthou/ccrecall 0.1.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/LICENSE +202 -0
- package/README.md +290 -0
- package/README_ZH.md +288 -0
- package/dist/api/routes.d.ts +13 -0
- package/dist/api/routes.d.ts.map +1 -0
- package/dist/api/routes.js +428 -0
- package/dist/api/routes.js.map +1 -0
- package/dist/api/server.d.ts +7 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +44 -0
- package/dist/api/server.js.map +1 -0
- package/dist/cli/daemon.d.ts +35 -0
- package/dist/cli/daemon.d.ts.map +1 -0
- package/dist/cli/daemon.js +163 -0
- package/dist/cli/daemon.js.map +1 -0
- package/dist/core/compression.d.ts +37 -0
- package/dist/core/compression.d.ts.map +1 -0
- package/dist/core/compression.js +129 -0
- package/dist/core/compression.js.map +1 -0
- package/dist/core/database.d.ts +219 -0
- package/dist/core/database.d.ts.map +1 -0
- package/dist/core/database.js +1513 -0
- package/dist/core/database.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/indexer.d.ts +15 -0
- package/dist/core/indexer.d.ts.map +1 -0
- package/dist/core/indexer.js +224 -0
- package/dist/core/indexer.js.map +1 -0
- package/dist/core/lint.d.ts +17 -0
- package/dist/core/lint.d.ts.map +1 -0
- package/dist/core/lint.js +51 -0
- package/dist/core/lint.js.map +1 -0
- package/dist/core/log-safe.d.ts +6 -0
- package/dist/core/log-safe.d.ts.map +1 -0
- package/dist/core/log-safe.js +11 -0
- package/dist/core/log-safe.js.map +1 -0
- package/dist/core/maintenance-coordinator.d.ts +26 -0
- package/dist/core/maintenance-coordinator.d.ts.map +1 -0
- package/dist/core/maintenance-coordinator.js +67 -0
- package/dist/core/maintenance-coordinator.js.map +1 -0
- package/dist/core/memory-service.d.ts +31 -0
- package/dist/core/memory-service.d.ts.map +1 -0
- package/dist/core/memory-service.js +47 -0
- package/dist/core/memory-service.js.map +1 -0
- package/dist/core/parser.d.ts +17 -0
- package/dist/core/parser.d.ts.map +1 -0
- package/dist/core/parser.js +205 -0
- package/dist/core/parser.js.map +1 -0
- package/dist/core/scanner.d.ts +8 -0
- package/dist/core/scanner.d.ts.map +1 -0
- package/dist/core/scanner.js +123 -0
- package/dist/core/scanner.js.map +1 -0
- package/dist/core/summarizer.d.ts +12 -0
- package/dist/core/summarizer.d.ts.map +1 -0
- package/dist/core/summarizer.js +430 -0
- package/dist/core/summarizer.js.map +1 -0
- package/dist/core/topic-extractor.d.ts +11 -0
- package/dist/core/topic-extractor.d.ts.map +1 -0
- package/dist/core/topic-extractor.js +51 -0
- package/dist/core/topic-extractor.js.map +1 -0
- package/dist/core/types.d.ts +329 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +12 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/watcher.d.ts +30 -0
- package/dist/core/watcher.d.ts.map +1 -0
- package/dist/core/watcher.js +146 -0
- package/dist/core/watcher.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/server.d.ts +3 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +32 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +39 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +215 -0
- package/dist/mcp/tools.js.map +1 -0
- package/hooks/README.md +78 -0
- package/hooks/session-end.mjs +92 -0
- package/hooks/session-start.mjs +112 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# ccRecall
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
+
[](https://www.typescriptlang.org/)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://www.sqlite.org/)
|
|
7
|
+
|
|
8
|
+
[中文版](README_ZH.md)
|
|
9
|
+
|
|
10
|
+
A local memory service for Claude Code — indexes your conversation history, recalls relevant context on demand, and injects it into future sessions. Zero API cost.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Core Concept
|
|
15
|
+
|
|
16
|
+
Every time you start a new Claude Code session, the AI forgets everything. The architecture you spent 20 minutes explaining, the bug you debugged together, the decisions you made — all gone. You start over.
|
|
17
|
+
|
|
18
|
+
CLAUDE.md and RESUME.md help, but they're static files you maintain by hand. ccRecall automates this: it reads your JSONL conversation logs, builds a searchable index, and serves relevant memories back to Claude Code through hooks and MCP tools. The AI remembers what it learned — you don't have to remind it.
|
|
19
|
+
|
|
20
|
+
ccRecall is the "memory" counterpart to [ccRewind](https://github.com/tznthou/ccRewind) (a conversation replay GUI). ccRewind lets humans look back at what happened; ccRecall lets the AI remember what happened.
|
|
21
|
+
|
|
22
|
+
> **Note:** This project is unrelated to [spences10/ccrecall](https://github.com/spences10/ccrecall), an analytics-focused tool that happens to share the name. Because the npm package `ccrecall` is already taken, we publish as `@tznthou/ccrecall` and the CLI binary is named `ccmem`.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
| Feature | Description |
|
|
29
|
+
|---------|-------------|
|
|
30
|
+
| **Rule-based summarization** | Extracts intent, activity, outcome, and tags from sessions — no LLM calls, zero API cost |
|
|
31
|
+
| **FTS5 full-text search** | Sub-100ms keyword search across all conversation history, fast enough for hook injection |
|
|
32
|
+
| **Incremental indexing** | Only re-indexes sessions that changed (mtime diffing), handles resumed sessions via UUID dedup |
|
|
33
|
+
| **Metacognition** | `knowledge_map` aggregates topic mentions from sessions + memories. Depth derived from mention count (shallow / medium / deep). Exposed via `/metacognition/check` and MCP `recall_context` |
|
|
34
|
+
| **Forgetting curve** | Memories compress over time: raw → summary → one-liner → deleted. Confidence decays on unused memories. Background maintenance tick runs every 5 min |
|
|
35
|
+
| **Watch mode** | chokidar-based JSONL watcher picks up new sessions within 2 s; periodic 10 min full-resync covers missed filesystem events |
|
|
36
|
+
| **Rescue reindex** | `/session/end` retries a reindex on cache miss — no fresh-session race between the hook and the daemon |
|
|
37
|
+
| **Auto-start (macOS)** | `ccmem install-daemon` registers a LaunchAgent so the service stays up across reboots |
|
|
38
|
+
| **Read-only** | Never modifies `~/.claude/` — only reads JSONL logs |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Architecture
|
|
43
|
+
|
|
44
|
+
```mermaid
|
|
45
|
+
flowchart TB
|
|
46
|
+
subgraph Input["Data Source (read-only)"]
|
|
47
|
+
JSONL["~/.claude/projects/*/*.jsonl"]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
subgraph Core["ccRecall Service (port 7749)"]
|
|
51
|
+
Scanner["Scanner<br/>find JSONL files"]
|
|
52
|
+
Parser["Parser<br/>parse conversations"]
|
|
53
|
+
Summarizer["Summarizer<br/>rule-based extraction"]
|
|
54
|
+
DB["SQLite + FTS5<br/>index & search"]
|
|
55
|
+
API["HTTP API<br/>7 endpoints"]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
subgraph Consumers["Context Injection"]
|
|
59
|
+
Hook["Claude Code Hooks<br/>SessionStart / SessionEnd"]
|
|
60
|
+
MCP["MCP Server<br/>recall_query / recall_save"]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
JSONL --> Scanner --> Parser --> Summarizer --> DB
|
|
64
|
+
DB --> API
|
|
65
|
+
API --> Hook
|
|
66
|
+
API --> MCP
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Tech Stack
|
|
72
|
+
|
|
73
|
+
| Technology | Purpose | Notes |
|
|
74
|
+
|------------|---------|-------|
|
|
75
|
+
| Node.js 20–22 + TypeScript | Runtime | ES modules, strict mode |
|
|
76
|
+
| better-sqlite3 | Database | Synchronous API, zero external deps |
|
|
77
|
+
| FTS5 | Full-text search | Built into SQLite, unicode61 tokenizer |
|
|
78
|
+
| Native `http` | HTTP server | No Express — minimal surface, localhost only |
|
|
79
|
+
| chokidar | Filesystem watcher | Cross-platform JSONL change detection with 2 s debounce + single-flight |
|
|
80
|
+
| vitest | Testing | 396 tests across 26 files, integration-style |
|
|
81
|
+
| `@modelcontextprotocol/sdk` | MCP server | stdio transport, shared SQLite via WAL |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Quick Start
|
|
86
|
+
|
|
87
|
+
### Prerequisites
|
|
88
|
+
|
|
89
|
+
- Node.js `>=20.0.0,<23.0.0`
|
|
90
|
+
- pnpm
|
|
91
|
+
|
|
92
|
+
### Installation
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
git clone https://github.com/tznthou/ccRecall.git
|
|
96
|
+
cd ccRecall
|
|
97
|
+
|
|
98
|
+
pnpm install
|
|
99
|
+
|
|
100
|
+
# Start development server (auto-indexes on startup, watches ~/.claude/projects)
|
|
101
|
+
pnpm dev
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The service starts at `http://127.0.0.1:7749` and indexes all JSONL files in `~/.claude/projects/`.
|
|
105
|
+
|
|
106
|
+
### Verify
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Health check — should show sessionCount > 0
|
|
110
|
+
curl http://127.0.0.1:7749/health
|
|
111
|
+
|
|
112
|
+
# Search your conversation history
|
|
113
|
+
curl "http://127.0.0.1:7749/memory/query?q=authentication&limit=5"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## API Endpoints
|
|
119
|
+
|
|
120
|
+
| Endpoint | Method | Description | Status |
|
|
121
|
+
|----------|--------|-------------|--------|
|
|
122
|
+
| `/health` | GET | Service health + DB stats | Live |
|
|
123
|
+
| `/memory/query?q=...&limit=...&project=...` | GET | FTS5 search across memories with optional project filter | Live |
|
|
124
|
+
| `/memory/save` | POST | Save a memory entry (origin-checked) | Live |
|
|
125
|
+
| `/session/end` | POST | Harvest a finished session's summary into a memory (idempotent) | Live |
|
|
126
|
+
| `/memory/context?session_id=...` | GET | Session context lookup | Stub |
|
|
127
|
+
| `/metacognition/check?projectId=...[&topic=...]` | GET | Knowledge map: summary (top/recent/stale topics + counts) or topic detail (memories + related topics) | Live |
|
|
128
|
+
| `/session/checkpoint` | POST | Mid-session snapshot into dedicated `session_checkpoints` table (not harvested as memory) | Live |
|
|
129
|
+
| `/lint/warnings` | GET | Lint report: orphan (session deleted) + stale (low-confidence, long-idle) memory warnings | Live |
|
|
130
|
+
|
|
131
|
+
## MCP Tools
|
|
132
|
+
|
|
133
|
+
| Tool | Purpose |
|
|
134
|
+
|------|---------|
|
|
135
|
+
| `recall_query` | Raw FTS5 keyword search across memories |
|
|
136
|
+
| `recall_context` | Topic-clustered retrieval — normalizes keywords, groups memories by matched topic with depth signals, falls back to per-keyword FTS if no topic matches |
|
|
137
|
+
| `recall_save` | Store a new memory (type: decision / discovery / preference / pattern / feedback) |
|
|
138
|
+
|
|
139
|
+
Expose them to Claude Code. After `pnpm build`, the `ccmem-mcp` bin is on
|
|
140
|
+
the repo's `node_modules/.bin` path — point `claude mcp add` at it or at a
|
|
141
|
+
global install:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Using the built bin (after pnpm build)
|
|
145
|
+
claude mcp add ccrecall --scope user -- /absolute/path/to/ccRecall/dist/mcp/server.js
|
|
146
|
+
|
|
147
|
+
# Or using tsx for development (no build step)
|
|
148
|
+
claude mcp add ccrecall --scope user -- /absolute/path/to/ccRecall/node_modules/.bin/tsx /absolute/path/to/ccRecall/src/mcp/server.ts
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
A ready-to-copy example lives at [.mcp.json.example](.mcp.json.example).
|
|
152
|
+
|
|
153
|
+
See [hooks/README.md](hooks/README.md) for SessionStart / SessionEnd hook installation.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Running as a service (macOS)
|
|
158
|
+
|
|
159
|
+
ccRecall runs as a local HTTP daemon. To keep it up across reboots, register
|
|
160
|
+
a per-user LaunchAgent:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
pnpm build
|
|
164
|
+
node dist/index.js install-daemon # or `ccmem install-daemon` if globally linked
|
|
165
|
+
node dist/index.js install-daemon --dry-run # preview plist without writing
|
|
166
|
+
|
|
167
|
+
# verify
|
|
168
|
+
launchctl list | grep ccrecall
|
|
169
|
+
curl http://127.0.0.1:7749/health
|
|
170
|
+
|
|
171
|
+
# remove
|
|
172
|
+
node dist/index.js uninstall-daemon
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The installer:
|
|
176
|
+
- writes `~/Library/LaunchAgents/com.tznthou.ccrecall.plist`
|
|
177
|
+
- routes logs to `~/Library/Logs/ccrecall/ccrecall.{out,err}.log`
|
|
178
|
+
- propagates `CCRECALL_PORT` / `CCRECALL_DB_PATH` from the current shell into
|
|
179
|
+
the plist, so the LaunchAgent uses the same settings as your interactive run
|
|
180
|
+
- refuses to touch a plist whose `Label` isn't ccRecall's (safety check)
|
|
181
|
+
|
|
182
|
+
Full manual-install, troubleshooting, and uninstall docs:
|
|
183
|
+
[docs/launchd.md](docs/launchd.md).
|
|
184
|
+
|
|
185
|
+
Linux/Windows equivalents (systemd unit, Windows service) are planned for
|
|
186
|
+
Phase 5. For now, run under `nohup` or your process manager of choice.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Project Structure
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
ccRecall/
|
|
194
|
+
├── src/
|
|
195
|
+
│ ├── core/
|
|
196
|
+
│ │ ├── types.ts # All type definitions
|
|
197
|
+
│ │ ├── parser.ts # JSONL conversation parser
|
|
198
|
+
│ │ ├── scanner.ts # File system scanner
|
|
199
|
+
│ │ ├── summarizer.ts # Rule-based session summarizer
|
|
200
|
+
│ │ ├── topic-extractor.ts # Rule-based topic extraction
|
|
201
|
+
│ │ ├── database.ts # SQLite + FTS5 (trimmed from ccRewind)
|
|
202
|
+
│ │ ├── indexer.ts # Indexing pipeline orchestrator
|
|
203
|
+
│ │ ├── memory-service.ts # Memory lifecycle (touch / delete / update)
|
|
204
|
+
│ │ ├── compression.ts # L0→L1→L2→delete state machine
|
|
205
|
+
│ │ ├── lint.ts # Orphan / stale memory detection
|
|
206
|
+
│ │ ├── maintenance-coordinator.ts # Background compression tick
|
|
207
|
+
│ │ ├── watcher.ts # chokidar JSONL watcher (Phase 4e)
|
|
208
|
+
│ │ └── log-safe.ts # scrubErrorMessage — log-injection defence
|
|
209
|
+
│ ├── api/
|
|
210
|
+
│ │ ├── server.ts # HTTP server
|
|
211
|
+
│ │ └── routes.ts # Request routing + rescue reindex
|
|
212
|
+
│ ├── mcp/
|
|
213
|
+
│ │ ├── server.ts # MCP stdio server entry (shebang bin)
|
|
214
|
+
│ │ └── tools.ts # recall_query + recall_context + recall_save
|
|
215
|
+
│ ├── cli/
|
|
216
|
+
│ │ └── daemon.ts # install-daemon / uninstall-daemon (macOS)
|
|
217
|
+
│ └── index.ts # HTTP entry point + subcommand dispatch
|
|
218
|
+
├── hooks/
|
|
219
|
+
│ ├── session-start.mjs # Inject memories on SessionStart (stdout)
|
|
220
|
+
│ ├── session-end.mjs # POST /session/end on SessionEnd
|
|
221
|
+
│ └── README.md # Hook installation guide
|
|
222
|
+
├── docs/
|
|
223
|
+
│ └── launchd.md # macOS LaunchAgent install/troubleshoot
|
|
224
|
+
├── tests/ # 396 tests across 26 files (parser / scanner /
|
|
225
|
+
│ │ # summarizer / database / indexer / e2e /
|
|
226
|
+
│ │ # memories / mcp / session-end / compression /
|
|
227
|
+
│ │ # lint / watcher / bin-smoke / cli-daemon /
|
|
228
|
+
│ │ # migration-v18 / decay / maintenance-coordinator /
|
|
229
|
+
│ │ # memory-service / memory-project-scope / touch /
|
|
230
|
+
│ │ # hooks-session-start / hooks-session-end /
|
|
231
|
+
│ │ # knowledge-map / topic-extractor / metacognition /
|
|
232
|
+
│ │ # session-checkpoint)
|
|
233
|
+
│ └── fixtures/ # Sample JSONL + shared test helpers
|
|
234
|
+
├── .mcp.json.example # MCP client config template
|
|
235
|
+
├── NOTICE / SECURITY.md / CONTRIBUTING.md / CODE_OF_CONDUCT.md
|
|
236
|
+
└── .claude/
|
|
237
|
+
└── pi-research/ # Architecture research documents
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
## Related Projects
|
|
243
|
+
|
|
244
|
+
- **[ccRewind](https://github.com/user/ccRewind)** — Session replay GUI for Claude Code. ccRecall's core modules (parser, scanner, summarizer, database, indexer) were extracted from ccRewind.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Reflections
|
|
249
|
+
|
|
250
|
+
### Why This Exists
|
|
251
|
+
|
|
252
|
+
Thariq from Anthropic's Claude Code team [wrote about context management](https://x.com/trq212) in April 2026 — 11,908 bookmarks, because everyone saved it to re-read but nobody had the tools to actually do it. He described the problem perfectly: context rot degrades model performance in long sessions, and autocompact fires at the worst possible moment.
|
|
253
|
+
|
|
254
|
+
But he gave methodology, not tools. ccRecall is the tool.
|
|
255
|
+
|
|
256
|
+
The real trigger was simpler: I kept re-explaining the same architecture to Claude Code across sessions. Not because the AI is bad at remembering — it literally can't. Every session starts from zero. CLAUDE.md helps, but it's a static file I maintain by hand. The maintenance cost grows faster than the value. Sound familiar? That's exactly why humans abandon wikis too (Karpathy's LLM Wiki insight).
|
|
257
|
+
|
|
258
|
+
### Design Decisions
|
|
259
|
+
|
|
260
|
+
**Rule-based summarizer instead of LLM calls.** claude-mem uses the Claude API for summarization — you're paying AI money to help AI remember. ccRecall uses heuristic extraction (regex patterns, tool usage analysis, outcome inference). It's less sophisticated but costs exactly zero. For session summaries, "Edit x8, 5 files, committed" is more useful than a paragraph of prose anyway.
|
|
261
|
+
|
|
262
|
+
**FTS5 instead of vector database.** Semantic search sounds better on paper, but for conversation logs — where you're searching for specific tools, file paths, error messages — keyword matching wins. FTS5 queries run in <10ms locally. No embedding model, no Chroma, no Docker container. At the scale we're operating (hundreds of sessions, not millions of documents), Karpathy's own analysis confirms: "plain index + keyword search is already sufficient under 500 sources."
|
|
263
|
+
|
|
264
|
+
**HTTP + MCP dual interface.** Research showed that MCP server tools are the most stable way to inject context into Claude (pull-based, Claude decides when to fetch). But SessionStart hooks (push-based, automatic) are also stable. So ccRecall runs both: HTTP for hooks, MCP for on-demand queries. Same SQLite backend, two access patterns.
|
|
265
|
+
|
|
266
|
+
**Read-only constraint.** ccRecall never modifies `~/.claude/`. This isn't just politeness — it's a trust boundary. If a background service can write to your Claude Code config, one bug could corrupt your sessions. Read-only means the worst case is "ccRecall gives bad search results," not "ccRecall broke my setup."
|
|
267
|
+
|
|
268
|
+
### Non-goals
|
|
269
|
+
|
|
270
|
+
**No Docker, no Electron, no vector database.** These are deliberate exclusions, not missing features. Docker adds deployment friction for what should be a `pnpm dev` experience. Electron is for GUIs — ccRecall has no UI (that's ccRewind's job). Vector databases solve a problem we don't have at this scale.
|
|
271
|
+
|
|
272
|
+
**No LLM dependency for any operation.** If ccRecall needs an API key to function, it has failed. The whole point is zero-cost memory that runs locally. Summarization is rule-based. Search is FTS5. The day we need LLM calls is the day we've overscoped.
|
|
273
|
+
|
|
274
|
+
**No "smart" memory injection.** ccRecall doesn't decide what Claude should remember. It provides a search API — the injection layer (hooks, MCP) presents results, and Claude integrates them. Opinionated memory selection is a premature optimization that would be wrong in ways we can't predict.
|
|
275
|
+
|
|
276
|
+
**No modification of user data.** ccRecall reads `~/.claude/projects/` JSONL files. It never writes to that directory, never modifies session files, never injects itself into Claude Code's config automatically. The user explicitly configures hooks and MCP — ccRecall doesn't install itself.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## License
|
|
281
|
+
|
|
282
|
+
Licensed under the Apache License, Version 2.0 — see [LICENSE](LICENSE).
|
|
283
|
+
|
|
284
|
+
Copyright 2026 tznthou
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Author
|
|
289
|
+
|
|
290
|
+
tznthou — [tznthou.com](https://tznthou.com) · [tznthou@gmail.com](mailto:tznthou@gmail.com)
|