ctxpool 0.1.0 → 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.
Files changed (58) hide show
  1. package/README.md +95 -105
  2. package/dist/cli.js +328 -184
  3. package/dist/cli.js.map +1 -1
  4. package/dist/clipboard.js +8 -10
  5. package/dist/clipboard.js.map +1 -1
  6. package/dist/format.d.ts +32 -0
  7. package/dist/format.js +110 -0
  8. package/dist/format.js.map +1 -0
  9. package/dist/handoff.d.ts +16 -13
  10. package/dist/handoff.js +441 -706
  11. package/dist/handoff.js.map +1 -1
  12. package/dist/mcp.js +99 -221
  13. package/dist/mcp.js.map +1 -1
  14. package/dist/pack.d.ts +14 -0
  15. package/dist/pack.js +121 -0
  16. package/dist/pack.js.map +1 -0
  17. package/dist/paths.d.ts +15 -0
  18. package/dist/paths.js +35 -5
  19. package/dist/paths.js.map +1 -1
  20. package/dist/redact.d.ts +6 -0
  21. package/dist/redact.js +85 -0
  22. package/dist/redact.js.map +1 -0
  23. package/dist/repo.d.ts +6 -1
  24. package/dist/repo.js +109 -123
  25. package/dist/repo.js.map +1 -1
  26. package/dist/session.d.ts +40 -1
  27. package/dist/session.js +1295 -302
  28. package/dist/session.js.map +1 -1
  29. package/dist/store.d.ts +13 -6
  30. package/dist/store.js +88 -115
  31. package/dist/store.js.map +1 -1
  32. package/dist/text.d.ts +6 -0
  33. package/dist/text.js +25 -0
  34. package/dist/text.js.map +1 -0
  35. package/dist/types.d.ts +44 -7
  36. package/dist/ui.d.ts +10 -1
  37. package/dist/ui.js +329 -383
  38. package/dist/ui.js.map +1 -1
  39. package/dist/util.d.ts +10 -1
  40. package/dist/util.js +40 -10
  41. package/dist/util.js.map +1 -1
  42. package/dist/verify.d.ts +16 -0
  43. package/dist/verify.js +74 -0
  44. package/dist/verify.js.map +1 -0
  45. package/dist/version.d.ts +1 -0
  46. package/dist/version.js +4 -0
  47. package/dist/version.js.map +1 -0
  48. package/dist-web/assets/contextpool-mark-4vSRiUeZ.svg +1 -0
  49. package/dist-web/assets/index-BBjy_S2c.css +2 -0
  50. package/dist-web/assets/index-QwGbBEu2.js +17 -0
  51. package/dist-web/index.html +4 -3
  52. package/package.json +19 -18
  53. package/dist/logs.d.ts +0 -9
  54. package/dist/logs.js +0 -82
  55. package/dist/logs.js.map +0 -1
  56. package/dist-web/assets/contextpool-mark-Bu_00i5t.svg +0 -16
  57. package/dist-web/assets/index-BfHRocKl.js +0 -14
  58. package/dist-web/assets/index-l1QjYqDb.css +0 -2
package/README.md CHANGED
@@ -1,154 +1,144 @@
1
1
  # ContextPool
2
2
 
3
- ContextPool is a local-first context builder for AI-assisted engineering work.
3
+ Hand off AI coding sessions between agents without losing the thread.
4
4
 
5
- It captures handoff packets from Codex and Claude sessions, preserves repo state and provenance, then lets you drag reusable context blocks into agent-ready prompt packs for Codex, Claude, Cursor, or any MCP-capable tool.
6
-
7
- ## Why
8
-
9
- AI coding sessions often lose the useful parts of prior work: task intent, decisions, constraints, files changed, verification state, blockers, and the next best action. ContextPool keeps that engineering memory local, structured, and reusable.
10
-
11
- The wedge is not generic long-term memory. It is provenance-backed engineering continuity:
12
-
13
- - Capture what changed, why it changed, what was verified, what failed, and what should happen next.
14
- - Preserve local-first trust by default.
15
- - Let users curate exactly which context goes into the next agent prompt.
16
- - Export sync-ready packets only when the user chooses.
17
-
18
- ## Features
19
-
20
- - Local handoff capture from Codex and Claude JSONL sessions.
21
- - Git snapshot capture: branch, commit, dirty files, diff stats, patches, and recent commits.
22
- - Drag-and-drop context pack builder UI.
23
- - Reusable context blocks for intent, instructions, decisions, constraints, verification, risks, next actions, files, and transcript snippets.
24
- - Markdown and JSON prompt-pack export.
25
- - Local SQL.js storage under `~/.ctxpool` by default.
26
- - MCP tools for agents to read handoffs and curated context packs.
27
- - Redacted team timeline export with raw transcripts excluded by default.
28
-
29
- ## Install
30
-
31
- Requires Node.js `>=22.5.0`.
32
-
33
- ```sh
34
- npm install
35
- npm run build
36
- node dist/cli.js init
37
- ```
38
-
39
- For a global npm install after publishing:
5
+ ContextPool reads the Codex, Claude Code, Gemini CLI, or Antigravity CLI session you just worked in, pairs it with the repo's git state, and writes a short handoff the next agent can act on: what was asked, the plan, which checks passed or failed, what changed, and the next action. Everything stays on your machine.
40
6
 
41
7
  ```sh
42
8
  npm install -g ctxpool
43
- ctxpool init
9
+ ctxpool handoff
44
10
  ```
45
11
 
46
- ## Quick Start
47
-
48
- Capture a handoff from the current workspace:
49
-
50
- ```sh
51
- node dist/cli.js handoff --from codex --no-ollama
52
12
  ```
13
+ Handoff ready
53
14
 
54
- Open the local context builder UI:
15
+ Task webhook-retries
16
+ Source Claude · Webhook retries · 4m ago
17
+ Repo billing-api · feature/webhook-retries @ 3f2c1a9 · 4 files +182 -37
18
+ Phase debugging
19
+ Checks ✗ npm test
20
+ ✓ npm run typecheck
21
+ Next Fix the failing `npm test` (AssertionError: expected 2 to equal 1), then re-run it.
55
22
 
56
- ```sh
57
- node dist/cli.js ui
23
+ ✓ Copied to clipboard · ~1.4k tokens
58
24
  ```
59
25
 
60
- Then open:
26
+ Paste it into the next agent, or let the agent fetch it over MCP.
61
27
 
62
- ```text
63
- http://127.0.0.1:4377
64
- ```
28
+ ## How it works
29
+
30
+ - **Reads the agent's own records.** Plans come from the agent's to-do tools (`TodoWrite`, `update_plan`, `write_todos`). Check results come from real exit codes. Edits come from the agent's edit tools. Prose heuristics only fill gaps, and they read your messages and the agent's, never tool output.
31
+ - **Knows when checks are stale.** A pass followed by more edits is flagged as unverified. `npm test | tail` hides failures behind a 0 exit code, so piped checks are judged by their output.
32
+ - **Picks the right session.** It uses the most recent primary session started in this repo and skips subagent and reviewer threads. If more than one agent was active in the last 10 minutes, it asks which one to use.
33
+ - **Replays Gemini chats the way Gemini CLI does.** Rewound turns are dropped, and `@file` contents are left out of your prompts.
34
+ - **Redacts secrets at capture.** API keys, tokens, private keys, and credentials in URLs are redacted before anything is saved or copied. `.env` and key files never appear in diffs.
65
35
 
66
- If the default port is busy, `ctxpool ui` tries the next few ports automatically unless a fixed `--port` is provided.
36
+ ## Supported agents
67
37
 
68
- ## Context Packs
38
+ | Agent | Sessions read from |
39
+ | --- | --- |
40
+ | Codex | `~/.codex/sessions` |
41
+ | Claude Code | `~/.claude/projects` |
42
+ | Gemini CLI | `~/.gemini/tmp/<project>/chats` |
43
+ | Antigravity CLI (`agy`) | `~/.gemini/antigravity-cli/conversations` |
69
44
 
70
- The UI turns saved handoffs into draggable context blocks. Add the useful blocks to a context pack, reorder them, disable noisy entries, and copy the generated markdown or JSON into another agent.
45
+ Antigravity keeps each conversation in a SQLite database. ContextPool opens it without writing anything, and reads steps that `agy` has compacted out of context through the latest checkpoint summary. Older conversations saved as `.pb` files use an opaque format and are skipped. Cursor isn't supported yet.
71
46
 
72
- Raw transcript text is redacted by default in context packs. Enable raw transcript export only when the destination is trusted.
47
+ ## Commands
73
48
 
74
- Saved packs stay local in the ContextPool store.
49
+ | Command | What it does |
50
+ | --- | --- |
51
+ | `ctxpool handoff` | Capture the current session and copy the handoff to the clipboard |
52
+ | `ctxpool capture` | Same, without the clipboard |
53
+ | `ctxpool sessions` | List the sessions ContextPool can read here (`--all` for every folder) |
54
+ | `ctxpool tasks` | List tasks with saved handoffs |
55
+ | `ctxpool show [task]` | Print the latest handoff (for a task) |
56
+ | `ctxpool ui` | Open the context pack builder in your browser |
57
+ | `ctxpool team export` | Write a redacted, sync-ready JSON packet |
58
+ | `ctxpool mcp start` | Serve handoffs to agents over MCP (stdio) |
59
+ | `ctxpool status` | Show where data lives and which agents were found |
75
60
 
76
- ## CLI
61
+ Useful options for `handoff` and `capture`:
77
62
 
78
63
  ```sh
79
- node dist/cli.js init
80
- node dist/cli.js handoff --from codex --no-ollama
81
- node dist/cli.js capture --from claude --task billing-flow
82
- node dist/cli.js ui
83
- node dist/cli.js tasks
84
- node dist/cli.js show latest --task billing-flow
85
- node dist/cli.js team export --task billing-flow
86
- node dist/cli.js mcp start
64
+ ctxpool handoff --from gemini # choose the agent when several were active
65
+ ctxpool handoff --session 01a15320 # a specific session id, or a path to a session file
66
+ ctxpool handoff --task billing-flow # name the task (defaults to the branch or repo)
67
+ ctxpool handoff --budget 1500 # token budget for the transcript excerpt
68
+ ctxpool handoff --no-transcript # leave the transcript out entirely
69
+ ctxpool handoff --json # machine-readable output
87
70
  ```
88
71
 
89
- `ctxpool team export` writes a sync-ready JSON packet under the local ContextPool home directory. Raw transcript entries are excluded by default:
72
+ ## Connect an agent over MCP
90
73
 
91
74
  ```sh
92
- ctxpool team export --task my-task
93
- ctxpool team export --task my-task --include-transcript
75
+ claude mcp add contextpool -- npx -y ctxpool mcp start
76
+ codex mcp add contextpool -- npx -y ctxpool mcp start
77
+ gemini mcp add -s user contextpool npx -y ctxpool mcp start
94
78
  ```
95
79
 
96
- ## MCP Tools
80
+ All tools are read-only.
97
81
 
98
- ContextPool exposes local MCP tools for agents:
82
+ | Tool | Returns |
83
+ | --- | --- |
84
+ | `get_latest_agent_context` | The latest handoff as markdown plus a structured summary. Start here. |
85
+ | `get_latest_handoff` | The latest handoff as markdown, optionally for a task |
86
+ | `get_handoff_by_task` | The latest handoff for a task |
87
+ | `get_task_status` | Next action, blockers, and touched files for a task |
88
+ | `get_handoff_files` | Structured file changes from a handoff |
89
+ | `list_tasks` | Tasks with handoffs, newest first |
90
+ | `get_team_timeline_packet` | A redacted, sync-ready packet. The raw transcript is excluded by default. |
91
+ | `list_context_packs` | Saved context packs |
92
+ | `get_context_pack` | A context pack as markdown or JSON |
99
93
 
100
- - `get_latest_handoff`
101
- - `get_handoff_by_task`
102
- - `list_tasks`
103
- - `get_task_status`
104
- - `get_latest_agent_context`
105
- - `get_handoff_files`
106
- - `get_team_timeline_packet`
107
- - `list_context_packs`
108
- - `get_context_pack`
94
+ ## Context packs
109
95
 
110
- `get_team_timeline_packet` returns a sync-ready packet with raw transcripts excluded unless explicitly requested. `get_context_pack` returns a curated prompt pack as markdown by default or JSON when requested.
96
+ `ctxpool ui` turns saved handoffs into blocks (objectives, decisions, constraints, checks, changed files) that you can arrange into a reusable prompt. Transcript blocks are left out of exports unless you turn on **Include transcript** for that pack.
111
97
 
112
- ## Privacy and Security
98
+ ## Configuration
113
99
 
114
- - ContextPool is local-first. It stores data under `~/.ctxpool` unless `CTXPOOL_HOME` is set.
115
- - Handoff packets can include repo paths, diffs, transcript excerpts, and command output. Review exports before sharing.
116
- - Raw transcripts are excluded from team exports by default.
117
- - Context pack transcript blocks are redacted by default.
118
- - The UI binds to `127.0.0.1` by default. Avoid binding to public interfaces unless you understand the local-file exposure risk.
119
- - File preview/open APIs are restricted to repositories already captured in saved handoffs.
100
+ `ctxpool init` writes `~/.ctxpool/config.json`:
120
101
 
121
- Security issues should be reported privately; see `SECURITY.md`.
102
+ ```json
103
+ {
104
+ "version": 1,
105
+ "ui": { "host": "127.0.0.1", "port": 4377 },
106
+ "ollama": { "enabled": false }
107
+ }
108
+ ```
122
109
 
123
- ## Development
110
+ Set `ollama.enabled` (or pass `--ollama`) to have a local Ollama model phrase the next action. It uses `ollama.model` if set, otherwise the first installed model.
124
111
 
125
- ```sh
126
- npm install
127
- npm run typecheck
128
- npm test
129
- npm run build
130
- ```
112
+ | Variable | Purpose |
113
+ | --- | --- |
114
+ | `CTXPOOL_HOME` | Store location (default `~/.ctxpool`) |
115
+ | `CODEX_HOME` | Codex data (default `~/.codex`) |
116
+ | `CLAUDE_CONFIG_DIR` | Claude Code data (default `~/.claude`) |
117
+ | `GEMINI_CLI_HOME` | Folder that holds Gemini CLI's `.gemini` directory (default your home folder) |
118
+ | `CTXPOOL_ANTIGRAVITY_DIR` | Antigravity CLI data for ContextPool to read (default `~/.gemini/antigravity-cli`). `agy` itself ignores it. |
119
+ | `CTXPOOL_EDITOR` | Editor command for "open file" in the UI |
120
+ | `NO_COLOR` | Plain terminal output |
131
121
 
132
- Use fixture data for local UI testing:
122
+ ## Privacy and security
133
123
 
134
- ```sh
135
- CTXPOOL_HOME=.ctxpool-test node dist/cli.js ui
136
- ```
124
+ - Data lives in `~/.ctxpool` with owner-only permissions. Nothing is sent anywhere.
125
+ - Secrets are redacted at capture, and again on team export for packets saved by older versions.
126
+ - The UI binds to `127.0.0.1`. It rejects requests addressed to other hostnames (DNS rebinding), cross-origin writes, and non-JSON writes. File previews are limited to repositories in saved handoffs and do not follow symlinks out of them.
137
127
 
138
- ## Release Checks
128
+ Report security issues privately; see [SECURITY.md](SECURITY.md).
129
+
130
+ ## Development
139
131
 
140
- Before publishing:
132
+ Requires Node.js 22.13 or later. The store uses the built-in `node:sqlite`.
141
133
 
142
134
  ```sh
143
- npm test
135
+ npm install
144
136
  npm run typecheck
137
+ npm test
145
138
  npm run build
146
- npm audit --omit=dev
147
- npm pack --dry-run
139
+ CTXPOOL_HOME=.ctxpool-test npm run dev -- handoff
148
140
  ```
149
141
 
150
- Confirm the package contents include only intentional release files and no local stores, databases, logs, transcripts, or secrets.
151
-
152
142
  ## License
153
143
 
154
144
  MIT