cogpit-memory 0.2.1 → 0.3.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 +34 -25
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3261 -1726
- package/dist/commands/search.d.ts +1 -1
- package/dist/commands/sessions.d.ts +2 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2762 -1300
- package/dist/lib/agent-descriptors.d.ts +387 -0
- package/dist/lib/agents.d.ts +112 -0
- package/dist/lib/claude.d.ts +49 -0
- package/dist/lib/codex-exec.d.ts +12 -0
- package/dist/lib/codex-tool-normalization.d.ts +25 -4
- package/dist/lib/codex.d.ts +29 -1
- package/dist/lib/copilot.d.ts +51 -0
- package/dist/lib/dirs.d.ts +9 -0
- package/dist/lib/helpers.d.ts +0 -20
- package/dist/lib/interactiveState.d.ts +9 -0
- package/dist/lib/metadata.d.ts +16 -14
- package/dist/lib/parser.d.ts +6 -4
- package/dist/lib/search-index.d.ts +7 -67
- package/dist/lib/sessionStats.d.ts +2 -1
- package/dist/lib/sessionStatus.d.ts +11 -32
- package/dist/lib/stores.d.ts +47 -0
- package/dist/lib/turnBuilder.d.ts +22 -0
- package/dist/lib/turnContent.d.ts +2 -0
- package/dist/lib/types.d.ts +41 -3
- package/package.json +3 -2
- package/skill/SKILL.md +58 -48
- package/dist/lib/token-costs.d.ts +0 -27
package/skill/SKILL.md
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cogpit-memory
|
|
3
|
-
description: CLI tool for Claude Code and
|
|
3
|
+
description: CLI tool for Claude Code, Codex, and GitHub Copilot CLI session introspection -- retrieves conversation history, tool calls, thinking, full-text search, session discovery, and supported sub-agent/team activity. All output is JSON to stdout.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Cogpit Memory -- Session Context CLI
|
|
7
7
|
|
|
8
|
-
CLI tool that gives any AI assistant memory of past Claude Code and
|
|
8
|
+
CLI tool that gives any AI assistant memory of past Claude Code, Codex, and GitHub Copilot CLI sessions. Retrieve conversation history, tool usage, thinking, and supported sub-agent activity via a layered command structure. Session discovery, root context and cross-session full-text indexing all cover every provider. Copilot nested activity is included inline in the root session, but `context --agent` is unavailable because Copilot CLI does not write separate sub-agent transcript files.
|
|
9
9
|
|
|
10
10
|
Always start with session discovery or the overview (Layer 1), and drill into specific turns or sub-agents only as needed. Use search when you need to **find** content rather than browse known sessions.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## Step 1 -- Verify the tool works
|
|
12
|
+
## Step 1 -- Use the installed CLI
|
|
15
13
|
|
|
16
14
|
```bash
|
|
17
|
-
|
|
15
|
+
command -v cogpit-memory
|
|
16
|
+
cogpit-memory --help
|
|
18
17
|
```
|
|
19
18
|
|
|
20
|
-
If
|
|
19
|
+
If missing, install it once, wait for installation to finish, then use the installed command:
|
|
21
20
|
|
|
22
21
|
```bash
|
|
23
|
-
|
|
22
|
+
bun install --global cogpit-memory
|
|
23
|
+
cogpit-memory --help
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
The npm package requires Node.js 20 or newer. If Bun's global bin directory is not on PATH, resolve it with `bun pm bin --global` and invoke `cogpit-memory` there. Do not run parallel `bunx cogpit-memory` installs: transient native-dependency installation can race. Parallel calls to the installed CLI do not reinstall anything.
|
|
27
|
+
|
|
28
|
+
JSON goes to stdout. Keep stderr separate when piping to `jq` or Python; never merge it with `2>&1` before a JSON parser. A JSON `{ "error": ... }` response exits nonzero and is a failed lookup, not an empty successful result. Use complete session IDs from discovery or search, not abbreviated IDs.
|
|
27
29
|
|
|
28
30
|
## Step 2 -- Find sessions
|
|
29
31
|
|
|
@@ -31,13 +33,13 @@ Then use `cogpit-memory` directly instead of `bunx cogpit-memory`.
|
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
35
|
# List recent sessions (default: last 7 days, up to 20 results)
|
|
34
|
-
|
|
36
|
+
cogpit-memory sessions
|
|
35
37
|
|
|
36
38
|
# Filter by working directory
|
|
37
|
-
|
|
39
|
+
cogpit-memory sessions --cwd /path/to/project
|
|
38
40
|
|
|
39
41
|
# Customize limit and time window
|
|
40
|
-
|
|
42
|
+
cogpit-memory sessions --limit 50 --max-age 30d
|
|
41
43
|
```
|
|
42
44
|
|
|
43
45
|
Options:
|
|
@@ -53,7 +55,7 @@ Response: array of session summaries with `sessionId`, `cwd`, `model`, `firstMes
|
|
|
53
55
|
### Get current session for a directory
|
|
54
56
|
|
|
55
57
|
```bash
|
|
56
|
-
|
|
58
|
+
cogpit-memory sessions --current --cwd /path/to/project
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
Returns the most recently active session for the given working directory. The `--cwd` flag is required when using `--current` (defaults to the current working directory if omitted).
|
|
@@ -63,7 +65,7 @@ Returns the most recently active session for the given working directory. The `-
|
|
|
63
65
|
This gives you every user prompt and AI reply, plus a tool usage summary per turn. **You must call this before Layer 2 or Layer 3** -- it provides the `turnIndex` and `agentId` values you need for drill-downs.
|
|
64
66
|
|
|
65
67
|
```bash
|
|
66
|
-
|
|
68
|
+
cogpit-memory context <SESSION_ID>
|
|
67
69
|
```
|
|
68
70
|
|
|
69
71
|
Response shape:
|
|
@@ -117,7 +119,7 @@ Key fields:
|
|
|
117
119
|
Use this to drill into a specific turn. Get thinking, full tool call inputs/outputs, and sub-agent summaries in chronological order.
|
|
118
120
|
|
|
119
121
|
```bash
|
|
120
|
-
|
|
122
|
+
cogpit-memory context <SESSION_ID> --turn <TURN_INDEX>
|
|
121
123
|
```
|
|
122
124
|
|
|
123
125
|
Response shape:
|
|
@@ -154,7 +156,7 @@ Key details:
|
|
|
154
156
|
- `contentBlocks` kinds: `thinking`, `text`, `tool_calls`, `sub_agent`, `background_agent`, `queued_prompt`, `hook_event`, `plan_mode`, `recap`, `agent_message`
|
|
155
157
|
- Tool call `result` is truncated at 10,000 chars -- check `resultTruncated: true`
|
|
156
158
|
- Tool call `result` may be `null` if the tool hasn't returned yet
|
|
157
|
-
- Sub-agent blocks show prompt + result text.
|
|
159
|
+
- Sub-agent blocks show prompt + result text. When the provider writes a separate sub-agent transcript, use Layer 3 for the full conversation
|
|
158
160
|
|
|
159
161
|
**Make separate requests per turn** -- do not try to batch multiple turns in one call.
|
|
160
162
|
|
|
@@ -163,7 +165,7 @@ Key details:
|
|
|
163
165
|
Drill into a specific sub-agent's full conversation. Returns the same shape as Layer 1 (an overview of the sub-agent's own turns).
|
|
164
166
|
|
|
165
167
|
```bash
|
|
166
|
-
|
|
168
|
+
cogpit-memory context <SESSION_ID> --agent <AGENT_ID>
|
|
167
169
|
```
|
|
168
170
|
|
|
169
171
|
Get the `AGENT_ID` from Layer 1's `subAgents[].agentId` field.
|
|
@@ -188,7 +190,7 @@ Response shape:
|
|
|
188
190
|
The `overview` field has the exact same shape as Layer 1. You can then drill into specific sub-agent turns:
|
|
189
191
|
|
|
190
192
|
```bash
|
|
191
|
-
|
|
193
|
+
cogpit-memory context <SESSION_ID> --agent <AGENT_ID> --turn <TURN_INDEX>
|
|
192
194
|
```
|
|
193
195
|
|
|
194
196
|
This returns the same shape as Layer 2.
|
|
@@ -214,32 +216,42 @@ The typical workflow for drilling into sub-agent activity:
|
|
|
214
216
|
|
|
215
217
|
1. Call Layer 1 to get the session overview
|
|
216
218
|
2. Look at `turns[].subAgents[]` to find agent IDs
|
|
217
|
-
3.
|
|
219
|
+
3. If the provider writes a separate sub-agent transcript, call Layer 3 with the `--agent` flag to get that sub-agent's overview
|
|
218
220
|
4. Call Layer 3 + `--turn` to drill into a specific sub-agent turn
|
|
219
221
|
5. If the sub-agent itself had sub-agents, repeat from step 2 using the sub-agent's overview
|
|
220
222
|
|
|
221
223
|
## Session Search -- Find keywords across sessions
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
Cross-session search indexes every provider's history. With `--session`, Claude Code, Codex, and Copilot CLI sessions are all supported, including user and assistant messages, thinking, tool I/O, inline sub-agent content, and compaction summaries when the provider records them.
|
|
224
226
|
|
|
225
227
|
**When to use search vs Layer 1:**
|
|
226
228
|
- You know the session -> Use Layer 1 overview, then drill with Layer 2/3
|
|
227
229
|
- You need to **find** which session discussed something -> Use search first, then drill into hits
|
|
228
230
|
|
|
231
|
+
When recalling earlier work, exclude this session if its ID is known, so your search commands and copied results do not crowd out history:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
cogpit-memory search "authentication" --max-age 90d --exclude-session "$COGPIT_SESSION_ID"
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Only pass that flag when the environment variable is set, or supply a known full session ID. Do not guess that the most recently modified session is yours when agents share a project. Omit the flag when searching this session itself. The exclusion also covers its indexed subagents.
|
|
238
|
+
|
|
239
|
+
Search automatically removes index entries for transcript files that no longer exist. It cannot recover deleted transcripts. If a file disappears between search and `context`, report that the source is unavailable and continue with other hits.
|
|
240
|
+
|
|
229
241
|
### Basic usage
|
|
230
242
|
|
|
231
243
|
```bash
|
|
232
|
-
# Search
|
|
233
|
-
|
|
244
|
+
# Search recent indexed sessions from all supported CLIs (last 5 days)
|
|
245
|
+
cogpit-memory search "authentication"
|
|
234
246
|
|
|
235
247
|
# Search within a specific session
|
|
236
|
-
|
|
248
|
+
cogpit-memory search "authentication" --session <SESSION_ID>
|
|
237
249
|
|
|
238
250
|
# Search with custom time window and more results
|
|
239
|
-
|
|
251
|
+
cogpit-memory search "authentication" --max-age 30d --limit 50
|
|
240
252
|
|
|
241
253
|
# Case-sensitive search
|
|
242
|
-
|
|
254
|
+
cogpit-memory search "AuthProvider" --case-sensitive
|
|
243
255
|
```
|
|
244
256
|
|
|
245
257
|
### Options
|
|
@@ -247,6 +259,7 @@ bunx cogpit-memory search "AuthProvider" --case-sensitive
|
|
|
247
259
|
| Flag | Default | Description |
|
|
248
260
|
|------|---------|-------------|
|
|
249
261
|
| `--session` | all sessions | Scope to single session |
|
|
262
|
+
| `--exclude-session` | none | Omit one session and its subagents |
|
|
250
263
|
| `--max-age` | `5d` | Time window: `5d`, `12h`, `30d` |
|
|
251
264
|
| `--limit` | `20` | Max total hits returned |
|
|
252
265
|
| `--session-limit` | all | Cap unique sessions in results |
|
|
@@ -298,48 +311,45 @@ Locations map directly to Layer 2/3 drill-down commands -- use them to fetch ful
|
|
|
298
311
|
- `turn/{i}/toolCall/{id}/input` -- tool call input -> drill with `--turn {i}`
|
|
299
312
|
- `turn/{i}/toolCall/{id}/result` -- tool call result -> drill with `--turn {i}`
|
|
300
313
|
- `turn/{i}/compactionSummary` -- compaction summary -> drill with `--turn {i}`
|
|
301
|
-
- `agent/{agentId}/...` -- sub-agent content
|
|
314
|
+
- `agent/{agentId}/...` -- sub-agent content; drill with `--agent {agentId}` only when the provider writes a separate transcript
|
|
302
315
|
|
|
303
316
|
### Typical workflow
|
|
304
317
|
|
|
305
|
-
1. Search for keyword: `
|
|
318
|
+
1. Search for keyword: `cogpit-memory search "auth"`
|
|
306
319
|
2. Pick a hit from results (e.g., `sessionId: "abc-123"`, `location: "turn/3/assistantMessage"`)
|
|
307
|
-
3. Get full turn context: `
|
|
308
|
-
4. If hit is in a sub-agent, get
|
|
320
|
+
3. Get full turn context: `cogpit-memory context abc-123 --turn 3`
|
|
321
|
+
4. If a hit is in a sub-agent with a separate transcript, get its overview: `cogpit-memory context abc-123 --agent a7f3bc2`
|
|
309
322
|
|
|
310
|
-
###
|
|
323
|
+
### Search behavior
|
|
311
324
|
|
|
312
|
-
|
|
313
|
-
- Default 5-day window keeps search fast; increase `--max-age` only if needed
|
|
314
|
-
- Single-session search (`--session` flag) is much faster than cross-session
|
|
315
|
-
- Typical cross-session search: ~150 sessions in ~1-2 seconds
|
|
325
|
+
Cross-session search uses an incrementally updated SQLite FTS5 index, with a raw-file fallback if the index is unavailable. The default window is 5 days. Increase `--max-age` for older work. FTS matches whole tokens, so `auth` does not match `authentication`. `--limit` is capped at 200; narrow a broad query or use `--session` to investigate further.
|
|
316
326
|
|
|
317
327
|
## Index management
|
|
318
328
|
|
|
319
|
-
The search index is an FTS5
|
|
329
|
+
The search index is an FTS5 database at `~/.claude/cogpit-memory/search-index.db`. Most commands work without the index (falling back to raw file scanning), but indexed search is significantly faster.
|
|
320
330
|
|
|
321
331
|
```bash
|
|
322
332
|
# Show index stats (session count, staleness, DB size)
|
|
323
|
-
|
|
333
|
+
cogpit-memory index stats
|
|
324
334
|
|
|
325
335
|
# Rebuild the full index from scratch
|
|
326
|
-
|
|
336
|
+
cogpit-memory index rebuild
|
|
327
337
|
```
|
|
328
338
|
|
|
329
339
|
## Quick reference
|
|
330
340
|
|
|
331
341
|
| Goal | Command |
|
|
332
342
|
|------|---------|
|
|
333
|
-
| List recent sessions | `
|
|
334
|
-
| Sessions for a directory | `
|
|
335
|
-
| Current session for a directory | `
|
|
336
|
-
| Session overview (always first) | `
|
|
337
|
-
| Turn detail | `
|
|
338
|
-
| Sub-agent overview | `
|
|
339
|
-
| Sub-agent turn detail | `
|
|
340
|
-
| **Search
|
|
341
|
-
| **Search single session** | `
|
|
342
|
-
| Index stats | `
|
|
343
|
-
| Index rebuild | `
|
|
343
|
+
| List recent sessions | `cogpit-memory sessions` |
|
|
344
|
+
| Sessions for a directory | `cogpit-memory sessions --cwd <path>` |
|
|
345
|
+
| Current session for a directory | `cogpit-memory sessions --current --cwd <path>` |
|
|
346
|
+
| Session overview (always first) | `cogpit-memory context <sessionId>` |
|
|
347
|
+
| Turn detail | `cogpit-memory context <sessionId> --turn <N>` |
|
|
348
|
+
| Sub-agent overview | `cogpit-memory context <sessionId> --agent <agentId>` |
|
|
349
|
+
| Sub-agent turn detail | `cogpit-memory context <sessionId> --agent <agentId> --turn <N>` |
|
|
350
|
+
| **Search indexed sessions** | `cogpit-memory search "<query>"` |
|
|
351
|
+
| **Search any single provider session** | `cogpit-memory search "<query>" --session <sessionId>` |
|
|
352
|
+
| Index stats | `cogpit-memory index stats` |
|
|
353
|
+
| Index rebuild | `cogpit-memory index rebuild` |
|
|
344
354
|
|
|
345
355
|
**Default to Layer 1 only. Drill into Layer 2/3 only when you have a specific reason.**
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Token display estimation and cost formatting.
|
|
3
|
-
*
|
|
4
|
-
* Pricing lives in shared/usageCost/pricing.ts, driven by LiteLLM's live rate
|
|
5
|
-
* table — nothing here carries hardcoded rates. What remains is display-only
|
|
6
|
-
* accounting of the thinking/visible output split.
|
|
7
|
-
*
|
|
8
|
-
* Claude Code 2.1.19x+ reports thinking tokens directly on the assistant
|
|
9
|
-
* record, so that half of the split is now exact. Older transcripts recorded
|
|
10
|
-
* only the message_start placeholder usage, so they still fall back to a
|
|
11
|
-
* content estimate at ≈4 chars/token — as does the visible-output half, which
|
|
12
|
-
* the CLI does not break out.
|
|
13
|
-
*/
|
|
14
|
-
import type { Turn } from "./types";
|
|
15
|
-
/** Approximate characters per token for content-based estimation. */
|
|
16
|
-
export declare const CHARS_PER_TOKEN = 4;
|
|
17
|
-
/**
|
|
18
|
-
* Thinking tokens for a turn: the count the model reported when it is
|
|
19
|
-
* available, falling back to a character estimate for older transcripts.
|
|
20
|
-
*
|
|
21
|
-
* A reported 0 is a fact — a turn that did no thinking — so presence is tested
|
|
22
|
-
* rather than truthiness.
|
|
23
|
-
*/
|
|
24
|
-
export declare function estimateThinkingTokens(turn: Turn): number;
|
|
25
|
-
/** Estimate non-thinking output tokens (text + tool use JSON). */
|
|
26
|
-
export declare function estimateVisibleOutputTokens(turn: Turn): number;
|
|
27
|
-
export declare function formatCost(usd: number): string;
|