cogpit-memory 0.2.1 → 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 +36 -27
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3669 -1929
- 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 +3247 -1579
- package/dist/lib/agent-descriptors.d.ts +425 -0
- package/dist/lib/agents.d.ts +123 -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 +40 -1
- package/dist/lib/copilot.d.ts +51 -0
- package/dist/lib/dirs.d.ts +10 -0
- package/dist/lib/helpers.d.ts +0 -20
- package/dist/lib/instances.d.ts +12 -0
- 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/read-session.d.ts +1 -0
- 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 +48 -0
- package/dist/lib/toolResults.d.ts +12 -0
- package/dist/lib/turnBuilder.d.ts +22 -0
- package/dist/lib/turnContent.d.ts +2 -0
- package/dist/lib/types.d.ts +85 -7
- package/package.json +3 -2
- package/skill/SKILL.md +67 -49
- package/dist/lib/token-costs.d.ts +0 -27
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/** The agent CLIs Cogpit can drive. */
|
|
2
|
+
export type AgentKind = "claude" | "codex" | "copilot" | "acp";
|
|
3
|
+
/**
|
|
4
|
+
* Every agent kind, in transcript-detection order. Codex and Copilot carry
|
|
5
|
+
* positive discriminators in their records; Claude is the terminal fallback and
|
|
6
|
+
* must stay last.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AGENT_KINDS: readonly AgentKind[];
|
|
9
|
+
export type SessionStatus = "idle" | "thinking" | "tool_use" | "processing" | "completed" | "compacting" | "deferred" | "awaiting_agents";
|
|
10
|
+
export interface SessionStatusInfo {
|
|
11
|
+
status: SessionStatus;
|
|
12
|
+
/** Name of the tool currently being used (if status is tool_use) */
|
|
13
|
+
toolName?: string;
|
|
14
|
+
/** Number of pending queue items (user messages waiting to be processed) */
|
|
15
|
+
pendingQueue?: number;
|
|
16
|
+
/** Why the session terminated (from Claude Code's terminal_reason). Only set for non-normal endings. */
|
|
17
|
+
terminalReason?: string;
|
|
18
|
+
/** Number of background agents/workflows still running (status awaiting_agents) */
|
|
19
|
+
pendingAgents?: number;
|
|
20
|
+
/** Short descriptions of the pending background agents, oldest first */
|
|
21
|
+
pendingAgentDescriptions?: string[];
|
|
22
|
+
}
|
|
23
|
+
/** A raw transcript record, before any agent-specific interpretation. */
|
|
24
|
+
export type RawRecord = {
|
|
25
|
+
type: string;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
1
28
|
export interface TextBlock {
|
|
2
29
|
type: "text";
|
|
3
30
|
text: string;
|
|
@@ -99,7 +126,10 @@ export interface UserMessage extends BaseMessage {
|
|
|
99
126
|
thinkingMetadata?: {
|
|
100
127
|
maxThinkingTokens: number;
|
|
101
128
|
};
|
|
102
|
-
toolUseResult?: AgentToolUseResult
|
|
129
|
+
toolUseResult?: Partial<AgentToolUseResult> & {
|
|
130
|
+
staged?: boolean;
|
|
131
|
+
bashEditDiff?: unknown;
|
|
132
|
+
};
|
|
103
133
|
sourceToolAssistantUUID?: string;
|
|
104
134
|
}
|
|
105
135
|
export interface TokenUsage {
|
|
@@ -173,7 +203,7 @@ export interface AgentProgressData {
|
|
|
173
203
|
prompt: string;
|
|
174
204
|
agentId: string;
|
|
175
205
|
}
|
|
176
|
-
export type HookEventName = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStop" | "PreCompact" | "PostCompact" | "PermissionDenied" | "TaskCreated" | "WorktreeCreate" | "CwdChanged" | "FileChanged" | "Elicitation" | "ElicitationResult" | "Notification";
|
|
206
|
+
export type HookEventName = "PreToolUse" | "PostToolUse" | "PostToolUseFailure" | "UserPromptSubmit" | "SessionStart" | "SessionEnd" | "Stop" | "StopFailure" | "SubagentStop" | "PreCompact" | "PostCompact" | "PreModelSwitch" | "PostModelSwitch" | "PermissionDenied" | "TaskCreated" | "WorktreeCreate" | "CwdChanged" | "FileChanged" | "Elicitation" | "ElicitationResult" | "Notification";
|
|
177
207
|
export interface HookProgressData {
|
|
178
208
|
type: "hook_progress";
|
|
179
209
|
/** Event name (newer SDK: hook_event_name; older SDK: hookEvent) */
|
|
@@ -319,13 +349,41 @@ export interface AgentSettingMessage extends BaseMessage {
|
|
|
319
349
|
agentSetting?: string;
|
|
320
350
|
}
|
|
321
351
|
export type RawMessage = UserMessage | AssistantMessage | ProgressMessage | SystemMessage | FileHistorySnapshotMessage | SummaryMessage | QueueOperationMessage | AttachmentMessage;
|
|
352
|
+
export interface ToolFileDiff {
|
|
353
|
+
filePath: string;
|
|
354
|
+
hunks: Array<{
|
|
355
|
+
oldStart: number;
|
|
356
|
+
oldLines: number;
|
|
357
|
+
newStart: number;
|
|
358
|
+
newLines: number;
|
|
359
|
+
lines: string[];
|
|
360
|
+
}>;
|
|
361
|
+
}
|
|
322
362
|
export interface ToolCall {
|
|
323
363
|
id: string;
|
|
324
364
|
name: string;
|
|
325
365
|
input: Record<string, unknown>;
|
|
326
366
|
result: string | null;
|
|
367
|
+
/** Binary images returned by a tool, when the provider persists them. */
|
|
368
|
+
resultImages?: ImageBlock[];
|
|
327
369
|
isError: boolean;
|
|
370
|
+
awaitingReview?: boolean;
|
|
371
|
+
fileDiffs?: ToolFileDiff[];
|
|
372
|
+
additionalFileDiffs?: number;
|
|
373
|
+
/** Counts from one structured file diff, before combining it with later edits. */
|
|
374
|
+
diffLineCounts?: {
|
|
375
|
+
add: number;
|
|
376
|
+
del: number;
|
|
377
|
+
};
|
|
328
378
|
timestamp: string;
|
|
379
|
+
/**
|
|
380
|
+
* A question whose tool result is only an acceptance receipt. Codex's
|
|
381
|
+
* `request_user_input_async` returns `{"accepted":true}` at once and the
|
|
382
|
+
* agent keeps working, so the answer arrives later as an ordinary message
|
|
383
|
+
* rather than as this call's result — `result !== null` does not mean
|
|
384
|
+
* answered here.
|
|
385
|
+
*/
|
|
386
|
+
asyncQuestion?: boolean;
|
|
329
387
|
/** Set by parser when a PostToolUse hook replaced this tool's output */
|
|
330
388
|
outputReplacedByHook?: boolean;
|
|
331
389
|
/** Total duration of PostToolUse hooks attached to this call, summed in ms */
|
|
@@ -431,6 +489,17 @@ export type TurnContentBlock = {
|
|
|
431
489
|
kind: "task_notification";
|
|
432
490
|
content: string;
|
|
433
491
|
timestamp?: string;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Output of a slash command that ran locally and answered the user directly
|
|
495
|
+
* (`/usage`, `/context`, `/recap`), recorded as a `local_command` system
|
|
496
|
+
* record. `content` is the raw record text, `<local-command-stdout>` tags
|
|
497
|
+
* included, left for the renderers like `task_notification`.
|
|
498
|
+
*/
|
|
499
|
+
| {
|
|
500
|
+
kind: "local_command";
|
|
501
|
+
content: string;
|
|
502
|
+
timestamp?: string;
|
|
434
503
|
};
|
|
435
504
|
export interface Turn {
|
|
436
505
|
id: string;
|
|
@@ -511,10 +580,12 @@ export interface ParsedSession {
|
|
|
511
580
|
turnIndex?: number | null;
|
|
512
581
|
};
|
|
513
582
|
/**
|
|
514
|
-
* The
|
|
515
|
-
*
|
|
583
|
+
* The agent that produced this session, as determined by the parser from the
|
|
584
|
+
* transcript's own bytes. This is the parser's finding, not the app's source
|
|
585
|
+
* of truth — the session's dirName is (see `shared/session/agents.ts`).
|
|
516
586
|
*/
|
|
517
|
-
agentKind?:
|
|
587
|
+
agentKind?: AgentKind;
|
|
588
|
+
instanceId?: string;
|
|
518
589
|
}
|
|
519
590
|
export interface ArchivedToolCall {
|
|
520
591
|
type: "Edit" | "Write";
|
|
@@ -526,6 +597,8 @@ export interface ArchivedToolCall {
|
|
|
526
597
|
}
|
|
527
598
|
export interface ArchivedTurn {
|
|
528
599
|
index: number;
|
|
600
|
+
/** The archived turn's `Turn.id`. Absent on archives written before ids were kept. */
|
|
601
|
+
id?: string;
|
|
529
602
|
userMessage: string | null;
|
|
530
603
|
toolCalls: ArchivedToolCall[];
|
|
531
604
|
thinkingBlocks: string[];
|
|
@@ -536,7 +609,14 @@ export interface ArchivedTurn {
|
|
|
536
609
|
export interface Branch {
|
|
537
610
|
id: string;
|
|
538
611
|
createdAt: string;
|
|
612
|
+
/**
|
|
613
|
+
* Position of the fork turn among the turns loaded when this was written.
|
|
614
|
+
* Only a long session's tail is loaded, so it is re-resolved from
|
|
615
|
+
* `branchPointTurnId` on every read and trusted as stored only without one.
|
|
616
|
+
*/
|
|
539
617
|
branchPointTurnIndex: number;
|
|
618
|
+
/** `Turn.id` of the last turn kept before the fork; null when none was kept. */
|
|
619
|
+
branchPointTurnId?: string | null;
|
|
540
620
|
label: string;
|
|
541
621
|
turns: ArchivedTurn[];
|
|
542
622
|
jsonlLines: string[];
|
|
@@ -545,8 +625,6 @@ export interface Branch {
|
|
|
545
625
|
}
|
|
546
626
|
export interface UndoState {
|
|
547
627
|
sessionId: string;
|
|
548
|
-
currentTurnIndex: number;
|
|
549
|
-
totalTurns: number;
|
|
550
628
|
branches: Branch[];
|
|
551
629
|
activeBranchId: string | null;
|
|
552
630
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cogpit-memory",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "CLI tool for Claude Code and
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "CLI tool for Claude Code, Codex, and GitHub Copilot CLI session introspection",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"keywords": [
|
|
14
14
|
"claude-code",
|
|
15
15
|
"codex",
|
|
16
|
+
"github-copilot",
|
|
16
17
|
"session",
|
|
17
18
|
"memory",
|
|
18
19
|
"cli",
|
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:
|
|
@@ -151,10 +153,10 @@ Response shape:
|
|
|
151
153
|
```
|
|
152
154
|
|
|
153
155
|
Key details:
|
|
154
|
-
- `contentBlocks` kinds: `thinking`, `text`, `tool_calls`, `sub_agent`, `background_agent`, `queued_prompt`, `hook_event`, `plan_mode`, `recap`, `agent_message`
|
|
156
|
+
- `contentBlocks` kinds: `thinking`, `text`, `tool_calls`, `sub_agent`, `background_agent`, `queued_prompt`, `hook_event`, `plan_mode`, `recap`, `agent_message`, `task_notification`, `local_command`
|
|
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,53 @@ 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.**
|
|
356
|
+
|
|
357
|
+
## Provider account identities
|
|
358
|
+
|
|
359
|
+
Sessions from configured Cogpit provider accounts use account-qualified IDs. Pass
|
|
360
|
+
the full ID to context and search commands. Cogpit supplies
|
|
361
|
+
`COGPIT_ORCHESTRATION_ROOT` to discover these profiles; set it to the app data root
|
|
362
|
+
when running the memory CLI independently. Inside a provider worker, introspection
|
|
363
|
+
uses that account’s own transcript store. ACP transcripts are supported.
|
|
@@ -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;
|