cogpit-memory 0.1.9 → 0.2.1

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,9 +1,16 @@
1
1
  # cogpit-memory
2
2
 
3
- CLI tool that gives any AI assistant memory of past [Claude Code](https://docs.anthropic.com/en/docs/claude-code) sessions. Retrieve conversation history, tool usage, thinking blocks, sub-agent activity, and full-text search across all sessions.
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.
4
7
 
5
8
  All output is JSON to stdout — designed for programmatic consumption by AI agents.
6
9
 
10
+ Session compatibility is validated against Claude Code 2.1.217 and Codex CLI
11
+ 0.145.0. The parser also retains backward compatibility with older rollout
12
+ formats covered by the test suite.
13
+
7
14
  ## Install
8
15
 
9
16
  ```bash
@@ -120,16 +127,27 @@ FTS5 trigram search is sublinear — doubling the index size does not double que
120
127
 
121
128
  ## How It Works
122
129
 
123
- cogpit-memory reads Claude Code's JSONL session files from `~/.claude/projects/`. It parses the conversation structure (turns, tool calls, thinking blocks, sub-agents) and provides a layered drill-down interface.
130
+ 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.
124
134
 
125
- For search, it maintains an FTS5 trigram index at `~/.claude/cogpit-memory/search-index.db`. The trigram tokenizer enables substring matching (not just whole-word) — searching for `"auth"` matches `"authentication"`, `"OAuth"`, and `"AuthProvider"`.
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"`.
126
139
 
127
140
  ## Development
128
141
 
129
- Requires [Bun](https://bun.sh) for development (source uses `bun:sqlite`). The npm build uses `better-sqlite3` for Node.js compatibility via an esbuild alias.
142
+ The npm package requires Node.js 20 or newer. Development requires [Bun](https://bun.sh) because the source uses `bun:sqlite`; the npm build substitutes `better-sqlite3` through an esbuild alias.
143
+
144
+ The session parser under `src/lib/` is generated from Cogpit's canonical
145
+ `shared/session/` implementation. Edit the shared copy, then run
146
+ `bun run sync-cogpit-memory` from the Cogpit repository root. CI runs
147
+ `bun run check:cogpit-memory-sync` and rejects drift.
130
148
 
131
149
  ```bash
132
- # Run tests (82 tests)
150
+ # Run tests
133
151
  bun test
134
152
 
135
153
  # Build compiled binary (Bun, uses bun:sqlite)
@@ -137,6 +155,9 @@ bun run build
137
155
 
138
156
  # Build for npm (Node.js, uses better-sqlite3)
139
157
  bun run build:npm
158
+
159
+ # Verify built CommonJS, declarations, public exports, CLI, and npm tarball
160
+ bun run test:contracts
140
161
  ```
141
162
 
142
163
  ## Agent Skill
package/dist/cli.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ * cogpit-memory CLI — query Claude Code session history.
3
+ *
4
+ * Usage:
5
+ * cogpit-memory search <query> [options]
6
+ * cogpit-memory context <sessionId> [--turn N] [--agent ID]
7
+ * cogpit-memory sessions [--cwd path] [--current] [--limit N] [--max-age 7d]
8
+ * cogpit-memory index stats|rebuild
9
+ */
10
+ export interface CLICommand {
11
+ command: string;
12
+ args: CLIArguments;
13
+ }
14
+ export interface CLIArguments {
15
+ query?: string;
16
+ session?: string;
17
+ maxAge?: string;
18
+ limit?: number;
19
+ sessionLimit?: number;
20
+ hitsPerSession?: number;
21
+ caseSensitive?: boolean;
22
+ sessionId?: string;
23
+ turnIndex?: number;
24
+ agentId?: string;
25
+ cwd?: string;
26
+ current?: boolean;
27
+ subcommand?: string;
28
+ global?: boolean;
29
+ }
30
+ export declare function parseArgs(argv: string[]): CLICommand;