ctxpool 0.1.1 → 0.5.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 (61) hide show
  1. package/README.md +107 -99
  2. package/dist/cli.js +336 -183
  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 +18 -13
  10. package/dist/handoff.js +495 -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 +45 -1
  27. package/dist/session.js +1307 -302
  28. package/dist/session.js.map +1 -1
  29. package/dist/store.d.ts +14 -6
  30. package/dist/store.js +90 -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 +92 -7
  36. package/dist/ui.d.ts +10 -1
  37. package/dist/ui.js +355 -382
  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/Geist-Variable-B48wpBRb.woff2 +0 -0
  49. package/dist-web/assets/GeistMono-Variable-BRXCGrxA.woff2 +0 -0
  50. package/dist-web/assets/antigravity-Vc0oU6JN.svg +1 -0
  51. package/dist-web/assets/contextpool-mark-4vSRiUeZ.svg +1 -0
  52. package/dist-web/assets/index-BztZuBPJ.js +21 -0
  53. package/dist-web/assets/index-LvoT6mmM.css +2 -0
  54. package/dist-web/index.html +4 -3
  55. package/package.json +18 -17
  56. package/dist/logs.d.ts +0 -9
  57. package/dist/logs.js +0 -82
  58. package/dist/logs.js.map +0 -1
  59. package/dist-web/assets/contextpool-mark-Bu_00i5t.svg +0 -16
  60. package/dist-web/assets/index-BfHRocKl.js +0 -14
  61. package/dist-web/assets/index-l1QjYqDb.css +0 -2
package/README.md CHANGED
@@ -1,153 +1,161 @@
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.
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.
6
6
 
7
- ## Why
7
+ ```sh
8
+ npm install -g ctxpool
9
+ ctxpool handoff
10
+ ```
8
11
 
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.
12
+ ```
13
+ Handoff ready
10
14
 
11
- The wedge is not generic long-term memory. It is provenance-backed engineering continuity:
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.
12
22
 
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.
23
+ ✓ Copied to clipboard · ~1.4k tokens
24
+ ```
17
25
 
18
- ## Features
26
+ Paste it into the next agent, or let the agent fetch it over MCP.
19
27
 
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
+ ## How it works
28
29
 
29
- ## Install
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.
30
35
 
31
- Requires Node.js `>=22.5.0`.
36
+ ## Supported agents
32
37
 
33
- ```sh
34
- npm install -g ctxpool
35
- ctxpool init
36
- ```
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` |
37
44
 
38
- For one-off usage without a global install:
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.
39
46
 
40
- ```sh
41
- npx ctxpool --help
42
- ```
47
+ ## Commands
43
48
 
44
- ## Quick Start
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), or one by `--id` |
56
+ | `ctxpool ui` | Browse handoffs, activity charts, and context packs 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 |
45
60
 
46
- Capture a handoff from the current workspace:
61
+ Useful options for `handoff` and `capture`:
47
62
 
48
63
  ```sh
49
- ctxpool handoff --from codex --no-ollama
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
50
70
  ```
51
71
 
52
- Open the local context builder UI:
72
+ ## Connect an agent over MCP
53
73
 
54
74
  ```sh
55
- ctxpool ui
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
56
78
  ```
57
79
 
58
- Then open:
80
+ All tools are read-only.
59
81
 
60
- ```text
61
- http://127.0.0.1:4377
62
- ```
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 |
63
93
 
64
- If the default port is busy, `ctxpool ui` tries the next few ports automatically unless a fixed `--port` is provided.
94
+ ## The web UI
65
95
 
66
- ## Context Packs
96
+ ```sh
97
+ ctxpool ui --open
98
+ ```
67
99
 
68
- 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.
100
+ A local dashboard for everything you've handed off, served from `127.0.0.1:4377`:
69
101
 
70
- Raw transcript text is redacted by default in context packs. Enable raw transcript export only when the destination is trusted.
102
+ - **Overview**: the latest handoff with its next action, handoffs over time by agent, how tasks moved between agents, which checks were passing at handoff, and the files that keep coming back.
103
+ - **Handoffs**: every capture, newest first, with the source agent's logo, repo and branch, checks, and diff size. Filter by agent, task, or check status.
104
+ - **Handoff detail**: the next action, objective, plan progress, each check with its exit code, changed files with diffs, the transcript, and the exact markdown that was copied. **Continue in** copies a command that starts Claude Code, Codex, or Gemini CLI with the handoff as its first prompt.
105
+ - **Connect agents**: the MCP setup command for each agent, and which agents' session folders were found on this machine.
71
106
 
72
- Saved packs stay local in the ContextPool store.
107
+ New handoffs appear without a reload. Press <kbd>⌘K</kbd> to jump to any handoff, task, or pack.
73
108
 
74
- ## CLI
109
+ ## Context packs
75
110
 
76
- ```sh
77
- ctxpool init
78
- ctxpool handoff --from codex --no-ollama
79
- ctxpool capture --from claude --task billing-flow
80
- ctxpool ui
81
- ctxpool tasks
82
- ctxpool show latest --task billing-flow
83
- ctxpool team export --task billing-flow
84
- ctxpool mcp start
85
- ```
111
+ A pack combines the parts of several handoffs that still matter (objectives, decisions, constraints, checks, changed files) into one reusable prompt. Open a handoff and choose **Add to pack**, or start a pack and add blocks from any handoff. Packs save as you edit, and agents can read them over MCP with `get_context_pack`. Transcript blocks are left out of exports unless you turn on **Include transcript** for that pack.
86
112
 
87
- `ctxpool team export` writes a sync-ready JSON packet under the local ContextPool home directory. Raw transcript entries are excluded by default:
113
+ ## Configuration
88
114
 
89
- ```sh
90
- ctxpool team export --task my-task
91
- ctxpool team export --task my-task --include-transcript
92
- ```
115
+ `ctxpool init` writes `~/.ctxpool/config.json`:
93
116
 
94
- ## MCP Tools
117
+ ```json
118
+ {
119
+ "version": 1,
120
+ "ui": { "host": "127.0.0.1", "port": 4377 },
121
+ "ollama": { "enabled": false }
122
+ }
123
+ ```
95
124
 
96
- ContextPool exposes local MCP tools for agents:
125
+ 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.
97
126
 
98
- - `get_latest_handoff`
99
- - `get_handoff_by_task`
100
- - `list_tasks`
101
- - `get_task_status`
102
- - `get_latest_agent_context`
103
- - `get_handoff_files`
104
- - `get_team_timeline_packet`
105
- - `list_context_packs`
106
- - `get_context_pack`
127
+ | Variable | Purpose |
128
+ | --- | --- |
129
+ | `CTXPOOL_HOME` | Store location (default `~/.ctxpool`) |
130
+ | `CODEX_HOME` | Codex data (default `~/.codex`) |
131
+ | `CLAUDE_CONFIG_DIR` | Claude Code data (default `~/.claude`) |
132
+ | `GEMINI_CLI_HOME` | Folder that holds Gemini CLI's `.gemini` directory (default your home folder) |
133
+ | `CTXPOOL_ANTIGRAVITY_DIR` | Antigravity CLI data for ContextPool to read (default `~/.gemini/antigravity-cli`). `agy` itself ignores it. |
134
+ | `CTXPOOL_EDITOR` | Editor command for "open file" in the UI |
135
+ | `NO_COLOR` | Plain terminal output |
107
136
 
108
- `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.
137
+ ## Privacy and security
109
138
 
110
- ## Privacy and Security
139
+ - Data lives in `~/.ctxpool` with owner-only permissions. Nothing is sent anywhere.
140
+ - Secrets are redacted at capture, and again on team export for packets saved by older versions.
141
+ - 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.
111
142
 
112
- - ContextPool is local-first. It stores data under `~/.ctxpool` unless `CTXPOOL_HOME` is set.
113
- - Handoff packets can include repo paths, diffs, transcript excerpts, and command output. Review exports before sharing.
114
- - Raw transcripts are excluded from team exports by default.
115
- - Context pack transcript blocks are redacted by default.
116
- - The UI binds to `127.0.0.1` by default. Avoid binding to public interfaces unless you understand the local-file exposure risk.
117
- - File preview/open APIs are restricted to repositories already captured in saved handoffs.
143
+ Report security issues privately; see [SECURITY.md](SECURITY.md).
118
144
 
119
- Security issues should be reported privately; see `SECURITY.md`.
145
+ Agent logos in the UI are trademarks of their owners and are shown only to identify where a session came from. The UI uses the Geist typeface (SIL Open Font License).
120
146
 
121
147
  ## Development
122
148
 
149
+ Requires Node.js 22.13 or later. The store uses the built-in `node:sqlite`.
150
+
123
151
  ```sh
124
152
  npm install
125
153
  npm run typecheck
126
154
  npm test
127
155
  npm run build
156
+ CTXPOOL_HOME=.ctxpool-test npm run dev -- handoff
128
157
  ```
129
158
 
130
- When working from source, run CLI commands through the development entrypoint:
131
-
132
- ```sh
133
- CTXPOOL_HOME=.ctxpool-test npm run dev -- ui
134
- npm run dev -- --version
135
- ```
136
-
137
- ## Release Checks
138
-
139
- Before publishing:
140
-
141
- ```sh
142
- npm test
143
- npm run typecheck
144
- npm run build
145
- npm audit --omit=dev
146
- npm pack --dry-run
147
- ```
148
-
149
- Confirm the package contents include only intentional release files and no local stores, databases, logs, transcripts, or secrets.
150
-
151
159
  ## License
152
160
 
153
161
  MIT