code-session-memory 0.3.2 → 0.4.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 +108 -16
- package/dist/src/cli-sessions.d.ts +16 -0
- package/dist/src/cli-sessions.d.ts.map +1 -0
- package/dist/src/cli-sessions.js +482 -0
- package/dist/src/cli-sessions.js.map +1 -0
- package/dist/src/cli.d.ts +5 -3
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +68 -7
- package/dist/src/cli.js.map +1 -1
- package/dist/src/database.d.ts +31 -0
- package/dist/src/database.d.ts.map +1 -1
- package/dist/src/database.js +63 -0
- package/dist/src/database.js.map +1 -1
- package/dist/src/session-to-md.d.ts.map +1 -1
- package/dist/src/session-to-md.js +36 -0
- package/dist/src/session-to-md.js.map +1 -1
- package/dist/src/transcript-to-messages.d.ts.map +1 -1
- package/dist/src/transcript-to-messages.js +42 -8
- package/dist/src/transcript-to-messages.js.map +1 -1
- package/dist/src/types.d.ts +13 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -51,9 +51,9 @@ The `install` command sets up everything for both tools in one shot:
|
|
|
51
51
|
3. Writes the MCP server entry into `~/.config/opencode/opencode.json`
|
|
52
52
|
|
|
53
53
|
**Claude Code:**
|
|
54
|
-
1. Writes a `Stop` hook to `~/.claude
|
|
54
|
+
1. Writes a `Stop` hook to `~/.claude.json` (user-scoped global config; fires after each agent turn)
|
|
55
55
|
2. Injects the skill into `~/.claude/CLAUDE.md` (with idempotent markers)
|
|
56
|
-
3.
|
|
56
|
+
3. Writes the MCP server entry into `~/.claude.json`
|
|
57
57
|
|
|
58
58
|
**Both tools share:**
|
|
59
59
|
- The same database at `~/.local/share/code-session-memory/sessions.db`
|
|
@@ -94,7 +94,7 @@ code-session-memory status
|
|
|
94
94
|
MCP config ~/.config/opencode/opencode.json ✓
|
|
95
95
|
|
|
96
96
|
Claude Code
|
|
97
|
-
Stop hook ~/.claude
|
|
97
|
+
Stop hook ~/.claude.json ✓
|
|
98
98
|
Skill ~/.claude/CLAUDE.md ✓
|
|
99
99
|
MCP server /path/to/dist/mcp/index.js ✓
|
|
100
100
|
```
|
|
@@ -137,6 +137,57 @@ Retrieve the full ordered content of a specific session message. Use the `sessio
|
|
|
137
137
|
| `startIndex` | number | no | First chunk index (0-based) |
|
|
138
138
|
| `endIndex` | number | no | Last chunk index (0-based, inclusive) |
|
|
139
139
|
|
|
140
|
+
### Browsing sessions
|
|
141
|
+
|
|
142
|
+
You can browse, inspect, and delete indexed sessions directly from the CLI:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npx code-session-memory sessions # interactive browser
|
|
146
|
+
npx code-session-memory sessions --filter # with source/date filter step
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The interactive browser lists all sessions with their title, date, source tool, and chunk count. Select a session to:
|
|
150
|
+
- **Print** — dump all chunks to stdout (useful for piping or inspection)
|
|
151
|
+
- **Delete** — remove the session from the DB (with confirmation)
|
|
152
|
+
- **Back** — return to the session list
|
|
153
|
+
|
|
154
|
+
You can also `print` or `delete` directly. Without an ID, an interactive picker opens:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npx code-session-memory sessions print # pick interactively, then print
|
|
158
|
+
npx code-session-memory sessions print --filter # filter first, then pick and print
|
|
159
|
+
npx code-session-memory sessions print <id> # print directly by session ID
|
|
160
|
+
|
|
161
|
+
npx code-session-memory sessions delete # pick interactively, then delete
|
|
162
|
+
npx code-session-memory sessions delete --filter # filter first, then pick and delete
|
|
163
|
+
npx code-session-memory sessions delete <id> # delete directly by session ID
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Print output example:**
|
|
167
|
+
```
|
|
168
|
+
────────────────────────────────────────────────────────────────────────
|
|
169
|
+
Session: Add authentication middleware
|
|
170
|
+
Source: opencode 2026-02-18
|
|
171
|
+
Project: /Users/you/myproject
|
|
172
|
+
ID: ses_abc123
|
|
173
|
+
Chunks: 12
|
|
174
|
+
────────────────────────────────────────────────────────────────────────
|
|
175
|
+
|
|
176
|
+
## Chunk 1/12 — Section: User
|
|
177
|
+
|
|
178
|
+
How can I add JWT authentication to the Express middleware?
|
|
179
|
+
|
|
180
|
+
## Chunk 2/12 — Section: Assistant
|
|
181
|
+
|
|
182
|
+
...
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Filtering options** (with `--filter`):
|
|
186
|
+
- Source: All tools / OpenCode / Claude Code
|
|
187
|
+
- Date range: Last 7 / 30 / 90 days, last N days (custom), or older than N days (custom)
|
|
188
|
+
|
|
189
|
+
> **Note:** Deleting a session only removes it from the database. If the original session files still exist on disk, the session will be re-indexed automatically on the next agent turn.
|
|
190
|
+
|
|
140
191
|
### Asking the agent about past sessions
|
|
141
192
|
|
|
142
193
|
The installed skill teaches the agent when and how to use these tools. Example prompts:
|
|
@@ -183,7 +234,8 @@ code-session-memory/
|
|
|
183
234
|
│ ├── indexer.ts # Orchestrator: incremental indexing
|
|
184
235
|
│ ├── indexer-cli.ts # Node.js subprocess (called by OpenCode plugin)
|
|
185
236
|
│ ├── indexer-cli-claude.ts # Node.js subprocess (called by Claude Code hook)
|
|
186
|
-
│
|
|
237
|
+
│ ├── cli.ts # install / status / uninstall / reset-db commands
|
|
238
|
+
│ └── cli-sessions.ts # sessions list / print / delete (interactive TUI)
|
|
187
239
|
├── mcp/
|
|
188
240
|
│ ├── server.ts # MCP query handlers (testable, injected deps)
|
|
189
241
|
│ └── index.ts # MCP stdio server entry point
|
|
@@ -191,13 +243,18 @@ code-session-memory/
|
|
|
191
243
|
│ └── memory.ts # OpenCode plugin (session.idle hook)
|
|
192
244
|
├── skill/
|
|
193
245
|
│ └── memory.md # Skill instructions (injected into both tools)
|
|
246
|
+
├── scripts/
|
|
247
|
+
│ └── generate-fixtures.ts # Generates committed e2e test fixtures (run manually)
|
|
194
248
|
└── tests/
|
|
195
249
|
├── chunker.test.ts
|
|
196
250
|
├── database.test.ts
|
|
197
251
|
├── embedder.test.ts
|
|
198
252
|
├── indexer.test.ts
|
|
199
253
|
├── mcp-server.test.ts
|
|
200
|
-
|
|
254
|
+
├── session-to-md.test.ts
|
|
255
|
+
├── e2e-claude.test.ts # End-to-end: Claude Code pipeline
|
|
256
|
+
├── e2e-opencode.test.ts # End-to-end: OpenCode pipeline
|
|
257
|
+
└── fixtures/ # Committed session files (generated by generate-fixtures)
|
|
201
258
|
```
|
|
202
259
|
|
|
203
260
|
## Development
|
|
@@ -217,38 +274,73 @@ npm run test:watch
|
|
|
217
274
|
|
|
218
275
|
# Coverage report
|
|
219
276
|
npm run test:coverage
|
|
277
|
+
|
|
278
|
+
# Regenerate e2e fixtures (requires claude and opencode CLIs)
|
|
279
|
+
npm run generate-fixtures
|
|
220
280
|
```
|
|
221
281
|
|
|
222
282
|
### Running tests
|
|
223
283
|
|
|
224
284
|
Tests use [Vitest](https://vitest.dev) and run without any external dependencies:
|
|
225
285
|
- No real OpenAI API calls — the embedder is mocked
|
|
226
|
-
- No real DB files — SQLite uses in-memory databases (`:memory:`) for unit tests
|
|
227
|
-
-
|
|
286
|
+
- No real DB files — SQLite uses in-memory databases (`:memory:`) for unit tests, temp files for indexer/e2e tests
|
|
287
|
+
- E2e tests use committed fixture files in `tests/fixtures/` (real transcripts, no CLI calls during `npm test`)
|
|
228
288
|
|
|
229
289
|
```
|
|
230
|
-
✓ tests/chunker.test.ts
|
|
231
|
-
✓ tests/mcp-server.test.ts
|
|
232
|
-
✓ tests/session-to-md.test.ts
|
|
233
|
-
✓ tests/embedder.test.ts
|
|
234
|
-
✓ tests/database.test.ts
|
|
235
|
-
✓ tests/indexer.test.ts
|
|
236
|
-
|
|
290
|
+
✓ tests/chunker.test.ts (15 tests)
|
|
291
|
+
✓ tests/mcp-server.test.ts (13 tests)
|
|
292
|
+
✓ tests/session-to-md.test.ts (18 tests)
|
|
293
|
+
✓ tests/embedder.test.ts (9 tests)
|
|
294
|
+
✓ tests/database.test.ts (25 tests)
|
|
295
|
+
✓ tests/indexer.test.ts (8 tests)
|
|
296
|
+
✓ tests/e2e-claude.test.ts (16 tests)
|
|
297
|
+
✓ tests/e2e-opencode.test.ts (14 tests)
|
|
298
|
+
Tests 118 passed
|
|
237
299
|
```
|
|
238
300
|
|
|
301
|
+
To refresh the e2e fixtures (e.g. after changing the indexer or parsers), run:
|
|
302
|
+
```bash
|
|
303
|
+
npm run generate-fixtures
|
|
304
|
+
```
|
|
305
|
+
This invokes the real `claude` and `opencode` CLIs to generate two-turn sessions with tool use, then commits the results to `tests/fixtures/`.
|
|
306
|
+
|
|
239
307
|
## Uninstall
|
|
240
308
|
|
|
241
309
|
```bash
|
|
242
310
|
npx code-session-memory uninstall
|
|
243
311
|
```
|
|
244
312
|
|
|
245
|
-
This removes the plugin, hooks,
|
|
313
|
+
This removes the plugin, hooks, skill files, and MCP config entries for both tools. The database is **not** removed automatically.
|
|
314
|
+
|
|
315
|
+
To delete individual sessions instead of wiping everything, use the [session browser](#browsing-sessions):
|
|
316
|
+
```bash
|
|
317
|
+
npx code-session-memory sessions
|
|
318
|
+
npx code-session-memory sessions delete <id>
|
|
319
|
+
```
|
|
246
320
|
|
|
247
|
-
To
|
|
321
|
+
To wipe the entire database:
|
|
248
322
|
```bash
|
|
249
323
|
rm ~/.local/share/code-session-memory/sessions.db
|
|
250
324
|
```
|
|
251
325
|
|
|
326
|
+
Or use the built-in command, which prompts for confirmation before deleting:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
npx code-session-memory reset-db
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
code-session-memory reset-db
|
|
334
|
+
|
|
335
|
+
Database: ~/.local/share/code-session-memory/sessions.db
|
|
336
|
+
Indexed chunks: 1842
|
|
337
|
+
Sessions tracked: 47
|
|
338
|
+
|
|
339
|
+
This will permanently delete all indexed data. Confirm? [y/N] y
|
|
340
|
+
|
|
341
|
+
Done. Database reset — all indexed data removed.
|
|
342
|
+
```
|
|
343
|
+
|
|
252
344
|
## Architecture notes
|
|
253
345
|
|
|
254
346
|
### Incremental indexing
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* sessions sub-commands for code-session-memory CLI
|
|
4
|
+
*
|
|
5
|
+
* sessions [list] Browse sessions (interactive TUI)
|
|
6
|
+
* sessions list --filter Browse with filter step first
|
|
7
|
+
* sessions print [id] Print all chunks of a session to stdout
|
|
8
|
+
* sessions print --filter Pick session interactively with filter, then print
|
|
9
|
+
* sessions delete [id] Delete a session from the DB
|
|
10
|
+
* sessions delete --filter Pick session interactively with filter, then delete
|
|
11
|
+
*/
|
|
12
|
+
export declare function cmdSessionsList(args: string[]): Promise<void>;
|
|
13
|
+
export declare function cmdSessionsPrint(sessionId?: string, args?: string[]): Promise<void>;
|
|
14
|
+
export declare function cmdSessionsDelete(sessionId?: string, args?: string[]): Promise<void>;
|
|
15
|
+
export declare function cmdSessions(argv: string[]): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=cli-sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-sessions.d.ts","sourceRoot":"","sources":["../../src/cli-sessions.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAkPH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDnE;AAMD,wBAAsB,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB7F;AAmDD,wBAAsB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD9F;AAwCD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuC/D"}
|