cogpit-memory 0.1.10 → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gentrit Biba
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,27 +1,24 @@
1
1
  # cogpit-memory
2
2
 
3
- CLI tool that gives any AI assistant memory of past Claude Code and Codex
4
- sessions. Browse either provider's conversation history, tool usage, thinking
5
- blocks, and sub-agent activity. Cross-session FTS search currently indexes
6
- Claude Code history.
3
+ CLI tool that gives any AI assistant memory of past Claude Code, Codex, and
4
+ GitHub Copilot CLI sessions. Browse normalized conversation history, tool
5
+ usage, thinking blocks, and inline sub-agent activity. Cross-session FTS search
6
+ indexes Claude Code, Codex, and GitHub Copilot CLI history.
7
7
 
8
8
  All output is JSON to stdout — designed for programmatic consumption by AI agents.
9
9
 
10
10
  Session compatibility is validated against Claude Code 2.1.217 and Codex CLI
11
11
  0.145.0. The parser also retains backward compatibility with older rollout
12
- formats covered by the test suite.
12
+ formats covered by the test suite. Copilot support follows the documented SDK
13
+ event schema and `~/.copilot/session-state/` layout.
13
14
 
14
15
  ## Install
15
16
 
16
17
  ```bash
17
- npm install -g cogpit-memory
18
+ bun install --global cogpit-memory
18
19
  ```
19
20
 
20
- Or run directly:
21
-
22
- ```bash
23
- npx cogpit-memory sessions
24
- ```
21
+ Use the installed `cogpit-memory` command for repeated or concurrent work. Installing once avoids races between transient `bunx` installs of the native SQLite dependency. Keep stderr separate from stdout when parsing JSON.
25
22
 
26
23
  ## Quick Start
27
24
 
@@ -35,7 +32,7 @@ cogpit-memory context <sessionId>
35
32
  # Drill into a specific turn
36
33
  cogpit-memory context <sessionId> --turn 3
37
34
 
38
- # Search across all sessions
35
+ # Search indexed sessions from all supported CLIs
39
36
  cogpit-memory search "authentication"
40
37
  ```
41
38
 
@@ -68,14 +65,22 @@ Three layers of detail. Start at L1, drill down only as needed.
68
65
  | **L3** — Sub-agent | `cogpit-memory context <sessionId> --agent <agentId>` | Full sub-agent conversation (same shape as L1) |
69
66
  | **L3** — Sub-agent turn | `cogpit-memory context <sessionId> --agent <agentId> --turn 0` | Sub-agent turn detail (same shape as L2) |
70
67
 
71
- **Discovery flow:** L1 gives you `turnIndex` and `agentId` values → use those to drill into L2/L3.
68
+ **Discovery flow:** L1 gives you `turnIndex` and `agentId` values. Use those to
69
+ drill into L2 and, when a separate sub-agent transcript exists, L3.
70
+
71
+ Copilot CLI keeps nested agent events in the root `events.jsonl`, so L1 and L2
72
+ include that activity inline. L3 needs a separate sub-agent transcript file and
73
+ is not available for Copilot sessions.
72
74
 
73
75
  ### `search` — Full-text search with FTS5
74
76
 
75
- Searches everything: user messages, assistant responses, thinking blocks, tool call inputs/outputs, sub-agent content, and compaction summaries.
77
+ Cross-session search indexes Claude Code, Codex, and Copilot CLI history. With
78
+ `--session`, all three are supported too,
79
+ including user and assistant messages, thinking, tool I/O, inline sub-agent
80
+ content, and compaction summaries when the provider records them.
76
81
 
77
82
  ```bash
78
- cogpit-memory search "authentication" # Cross-session search
83
+ cogpit-memory search "authentication" # Cross-session index, every agent
79
84
  cogpit-memory search "auth" --session <sessionId> # Single session
80
85
  cogpit-memory search "bug" --max-age 30d --limit 50 # Custom window
81
86
  cogpit-memory search "AuthProvider" --case-sensitive # Case-sensitive
@@ -86,12 +91,15 @@ cogpit-memory search "bug" --session-limit 20 --hits-per-session 2 # Compact re
86
91
  | Flag | Default | Description |
87
92
  |------|---------|-------------|
88
93
  | `--session` | all | Scope to single session |
94
+ | `--exclude-session` | none | Exclude one session and its subagents |
89
95
  | `--max-age` | `5d` | Time window — any duration (`5d`, `30d`, `365d`) |
90
96
  | `--limit` | `20` | Max total hits returned |
91
97
  | `--session-limit` | all | Cap unique sessions in results |
92
98
  | `--hits-per-session` | all | Max hits kept per session |
93
99
  | `--case-sensitive` | `false` | Case sensitivity |
94
100
 
101
+ Use `--exclude-session <current-session-id>` when recalling earlier work to omit your own search commands and results. Missing transcript files are removed from the index before searching. If a transcript is deleted between search and drill-down, `context` returns a JSON error and exits nonzero.
102
+
95
103
  Each result includes the `cwd` (working directory where the session ran) and an array of hits. Each hit includes a `location` string (e.g. `turn/3/assistantMessage`, `agent/a7f3bc2/toolCall/tc1/result`) that maps directly to L2/L3 drill-down commands.
96
104
 
97
105
  ### `index` — Manage the FTS5 search index
@@ -110,7 +118,7 @@ Benchmarked against a real Claude Code history: **765 sessions, 1,745 sub-agents
110
118
  | `sessions --limit 20` | **38ms** | File-system scan, no DB needed |
111
119
  | `context <sessionId>` (L1) | **34ms** | Single JSONL file parse |
112
120
  | `context <sessionId> --turn N` (L2) | **35ms** | Same file, filtered to one turn |
113
- | `search "keyword"` (cross-session) | **56–200ms** | FTS5 trigram across 210K rows |
121
+ | `search "keyword"` (cross-session) | **56–200ms** | FTS5 across 210K rows |
114
122
  | `search "keyword" --session <id>` | **30ms** | Scoped to single session |
115
123
  | `index stats` | **50ms** | Single DB query |
116
124
 
@@ -123,19 +131,20 @@ Benchmarked against a real Claude Code history: **765 sessions, 1,745 sub-agents
123
131
  | Heavy (1 year) | ~2,000 | ~500K | ~3.5 GB | 100–400ms |
124
132
  | Power user (2+ years) | ~5,000 | ~1.2M | ~8 GB | 200–800ms |
125
133
 
126
- FTS5 trigram search is sublinear — doubling the index size does not double query time. The index uses SQLite WAL mode for concurrent reads and is incrementally updated.
134
+ FTS5 search is sublinear — doubling the index size does not double query time. The index uses SQLite WAL mode for concurrent reads and is incrementally updated.
127
135
 
128
136
  ## How It Works
129
137
 
130
138
  Session discovery and context commands read Claude Code JSONL history from
131
- `~/.claude/projects/` and Codex JSONL history from `~/.codex/sessions/`. The
132
- shared parser normalizes each provider into the same conversation structure
133
- (turns, tool calls, thinking blocks, and sub-agents) for layered drill-down.
134
-
135
- Cross-session search currently builds its FTS5 trigram index from the Claude
136
- project tree and stores it at `~/.claude/cogpit-memory/search-index.db`. The
137
- trigram tokenizer enables substring matching (not just whole-word) — searching
138
- for `"auth"` matches `"authentication"`, `"OAuth"`, and `"AuthProvider"`.
139
+ `~/.claude/projects/`, Codex history from `~/.codex/sessions/`, and GitHub
140
+ Copilot CLI history from `~/.copilot/session-state/`. The shared parser
141
+ normalizes each provider into the same conversation structure for layered
142
+ drill-down.
143
+
144
+ Cross-session search builds its FTS5 index from every agent's history root, then
145
+ stores it at `~/.claude/cogpit-memory/search-index.db`. It uses SQLite's
146
+ `unicode61` tokenizer, so a query matches whole tokens: searching for `"auth"`
147
+ finds `"auth"`, not `"authentication"`.
139
148
 
140
149
  ## Development
141
150
 
package/dist/cli.d.ts CHANGED
@@ -14,6 +14,7 @@ export interface CLICommand {
14
14
  export interface CLIArguments {
15
15
  query?: string;
16
16
  session?: string;
17
+ excludeSession?: string;
17
18
  maxAge?: string;
18
19
  limit?: number;
19
20
  sessionLimit?: number;