ctxbaton 0.1.0__tar.gz
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.
- ctxbaton-0.1.0/.claude/settings.local.json +33 -0
- ctxbaton-0.1.0/.gitignore +40 -0
- ctxbaton-0.1.0/LICENSE +21 -0
- ctxbaton-0.1.0/PKG-INFO +155 -0
- ctxbaton-0.1.0/README.md +136 -0
- ctxbaton-0.1.0/SETUP.md +125 -0
- ctxbaton-0.1.0/hooks/stop.sh +36 -0
- ctxbaton-0.1.0/pyproject.toml +36 -0
- ctxbaton-0.1.0/skill/SKILL.md +37 -0
- ctxbaton-0.1.0/skill/scripts/install.sh +34 -0
- ctxbaton-0.1.0/src/ctxbaton/__init__.py +0 -0
- ctxbaton-0.1.0/src/ctxbaton/cli.py +602 -0
- ctxbaton-0.1.0/src/ctxbaton/db.py +195 -0
- ctxbaton-0.1.0/src/ctxbaton/embeddings.py +67 -0
- ctxbaton-0.1.0/src/ctxbaton/server.py +151 -0
- ctxbaton-0.1.0/src/ctxbaton/snapshots.py +165 -0
- ctxbaton-0.1.0/uv.lock +1488 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(npm show:*)",
|
|
5
|
+
"Bash(python3 -c \"import sys,json; d=json.load\\(sys.stdin\\); print\\(json.dumps\\(d.get\\(''''exports'''', {}\\), indent=2\\)\\)\")",
|
|
6
|
+
"Read(//Users/toffe/.npm/_npx/**)",
|
|
7
|
+
"Read(//Users/toffe/node_modules/**)",
|
|
8
|
+
"Read(//usr/local/lib/**)",
|
|
9
|
+
"Bash(npm install:*)",
|
|
10
|
+
"Bash(npm run:*)",
|
|
11
|
+
"Bash(node:*)",
|
|
12
|
+
"Bash(node --experimental-sqlite -e \":*)",
|
|
13
|
+
"WebFetch(domain:www.anthropic.com)",
|
|
14
|
+
"WebFetch(domain:openspec.dev)",
|
|
15
|
+
"WebSearch",
|
|
16
|
+
"Bash(uv sync:*)",
|
|
17
|
+
"Bash(rm -f ~/.mcp-memory/memories.db)",
|
|
18
|
+
"Bash(uv run python -c \":*)",
|
|
19
|
+
"WebFetch(domain:gist.github.com)",
|
|
20
|
+
"WebFetch(domain:gist.githubusercontent.com)",
|
|
21
|
+
"Bash(uv run:*)",
|
|
22
|
+
"Bash(uv tool:*)",
|
|
23
|
+
"Read(//Users/toffe/dev/ai/graceful.ai/**)",
|
|
24
|
+
"Bash(mv mcp-memory:*)",
|
|
25
|
+
"Bash(unicontext:*)",
|
|
26
|
+
"WebFetch(domain:opencode.ai)",
|
|
27
|
+
"WebFetch(domain:developers.openai.com)",
|
|
28
|
+
"Bash(ctxbaton --help)",
|
|
29
|
+
"Bash(ctxbaton context:*)",
|
|
30
|
+
"Bash(uv build:*)"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
.eggs/
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
env/
|
|
13
|
+
|
|
14
|
+
# uv
|
|
15
|
+
.uv/
|
|
16
|
+
|
|
17
|
+
# Distribution
|
|
18
|
+
*.whl
|
|
19
|
+
*.tar.gz
|
|
20
|
+
|
|
21
|
+
# DB files — never commit the memory store
|
|
22
|
+
*.db
|
|
23
|
+
*.db-wal
|
|
24
|
+
*.db-shm
|
|
25
|
+
|
|
26
|
+
# Snapshots — user data, not source
|
|
27
|
+
snapshots/
|
|
28
|
+
|
|
29
|
+
# OS
|
|
30
|
+
.DS_Store
|
|
31
|
+
Thumbs.db
|
|
32
|
+
|
|
33
|
+
# IDE
|
|
34
|
+
.idea/
|
|
35
|
+
.vscode/
|
|
36
|
+
*.swp
|
|
37
|
+
|
|
38
|
+
# Env
|
|
39
|
+
.env
|
|
40
|
+
.env.local
|
ctxbaton-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 melonkernel
|
|
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.
|
ctxbaton-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ctxbaton
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pass context between AI agents like a relay baton — persistent memory, snapshots, and semantic search across sessions
|
|
5
|
+
Project-URL: Homepage, https://github.com/melonkernel/ctxbaton
|
|
6
|
+
Project-URL: Repository, https://github.com/melonkernel/ctxbaton
|
|
7
|
+
Project-URL: Issues, https://github.com/melonkernel/ctxbaton/issues
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: agents,ai,claude,codex,context,mcp,memory,opencode
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: fastembed>=0.4.0
|
|
16
|
+
Requires-Dist: mcp[cli]>=1.0.0
|
|
17
|
+
Requires-Dist: numpy>=1.26.0
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# ctxbaton
|
|
21
|
+
|
|
22
|
+
> Pass context between AI agents like a relay baton.
|
|
23
|
+
|
|
24
|
+
When you switch agents mid-project — because you ran out of tokens, changed tools, or just opened a new session — ctxbaton makes sure nothing is lost. Every agent picks up exactly where the last one stopped.
|
|
25
|
+
|
|
26
|
+
## How it works
|
|
27
|
+
|
|
28
|
+
A lightweight hook fires after every agent turn and saves a snapshot: the current git hash, todo state diff, and transcript path. No tokens spent. No agent cooperation required. It just happens.
|
|
29
|
+
|
|
30
|
+
When you resume — in the same agent or a different one — run:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ctxbaton context # what are we building, what's open, what was decided
|
|
34
|
+
ctxbaton replay # what changed since I was last here
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Install globally
|
|
41
|
+
uv tool install ctxbaton
|
|
42
|
+
|
|
43
|
+
# Wire up the automatic Stop hook (Claude Code)
|
|
44
|
+
ctxbaton hooks install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ctxbaton context # full project context — spec, todos, handoff, decisions
|
|
53
|
+
ctxbaton replay # what changed since last snapshot (git diff + todo changes)
|
|
54
|
+
ctxbaton replay --since 2h # what changed in the last 2 hours
|
|
55
|
+
ctxbaton search "auth" # semantic search across all memories
|
|
56
|
+
|
|
57
|
+
ctxbaton todo list # open tasks
|
|
58
|
+
ctxbaton todo done <id> # mark a task done
|
|
59
|
+
ctxbaton todo start <id> # mark a task in progress
|
|
60
|
+
|
|
61
|
+
ctxbaton memory save --type decision "use JWT over sessions because..."
|
|
62
|
+
ctxbaton memory save --type handoff "stopped mid-auth, next: refresh tokens"
|
|
63
|
+
ctxbaton memory save --type spec "build a REST API with FastAPI"
|
|
64
|
+
ctxbaton memory save --type todo "add rate limiting"
|
|
65
|
+
|
|
66
|
+
ctxbaton snapshot list # full snapshot history with git hashes
|
|
67
|
+
ctxbaton hooks install # install Claude Code Stop hook
|
|
68
|
+
ctxbaton serve # start as MCP server
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Memory types
|
|
72
|
+
|
|
73
|
+
| Type | Purpose |
|
|
74
|
+
|------|---------|
|
|
75
|
+
| `spec` | The current goal or plan |
|
|
76
|
+
| `todo` | A task with status (pending / in_progress / done) |
|
|
77
|
+
| `decision` | An architecture or design choice with rationale |
|
|
78
|
+
| `handoff` | State snapshot when switching agents or sessions |
|
|
79
|
+
| `progress` | What has been completed |
|
|
80
|
+
| `general` | Anything else |
|
|
81
|
+
|
|
82
|
+
## Cross-agent continuity
|
|
83
|
+
|
|
84
|
+
ctxbaton is agent-agnostic. Claude Code, OpenCode, Codex, Cursor — they all call the same CLI and write to the same store.
|
|
85
|
+
|
|
86
|
+
Each project gets its own isolated DB at:
|
|
87
|
+
```
|
|
88
|
+
~/.ctxbaton/projects/-Users-you-dev-myproject/memories.db
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The path mirrors the project directory (same convention as Claude Code's own memory files), so there's no config needed — open a project, run `ctxbaton context`, done.
|
|
92
|
+
|
|
93
|
+
## Automatic snapshots
|
|
94
|
+
|
|
95
|
+
Install the Stop hook once:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
ctxbaton hooks install
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
After that, every time an agent finishes a turn, ctxbaton saves:
|
|
102
|
+
- The current git hash and branch
|
|
103
|
+
- A diff of what todos changed
|
|
104
|
+
- A reference to the session transcript
|
|
105
|
+
|
|
106
|
+
No tokens. No agent cooperation. Just a shell script that runs in milliseconds.
|
|
107
|
+
|
|
108
|
+
## Agent Skills (Claude Code, Codex, Cursor)
|
|
109
|
+
|
|
110
|
+
ctxbaton ships with a `SKILL.md` that auto-injects project context at session start.
|
|
111
|
+
Copy it to your skills directory:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
cp skill/SKILL.md ~/.claude/skills/ctxbaton/SKILL.md
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or run the full installer:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
bash skill/scripts/install.sh
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Then use `/ctxbaton` in any session to load context instantly.
|
|
124
|
+
|
|
125
|
+
## MCP server
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
ctxbaton serve
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Register in Claude Code:
|
|
132
|
+
```bash
|
|
133
|
+
claude mcp add ctxbaton -- ctxbaton serve
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or in any MCP-compatible client:
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"ctxbaton": {
|
|
141
|
+
"command": "ctxbaton",
|
|
142
|
+
"args": ["serve"],
|
|
143
|
+
"env": { "MEMORY_PROJECT": "/path/to/your/project" }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Storage
|
|
150
|
+
|
|
151
|
+
Memories are stored in SQLite with local embeddings ([BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5), ~40MB, downloaded once). No API keys. Works offline.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT — [melonkernel/ctxbaton](https://github.com/melonkernel/ctxbaton)
|
ctxbaton-0.1.0/README.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# ctxbaton
|
|
2
|
+
|
|
3
|
+
> Pass context between AI agents like a relay baton.
|
|
4
|
+
|
|
5
|
+
When you switch agents mid-project — because you ran out of tokens, changed tools, or just opened a new session — ctxbaton makes sure nothing is lost. Every agent picks up exactly where the last one stopped.
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
A lightweight hook fires after every agent turn and saves a snapshot: the current git hash, todo state diff, and transcript path. No tokens spent. No agent cooperation required. It just happens.
|
|
10
|
+
|
|
11
|
+
When you resume — in the same agent or a different one — run:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
ctxbaton context # what are we building, what's open, what was decided
|
|
15
|
+
ctxbaton replay # what changed since I was last here
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Install globally
|
|
22
|
+
uv tool install ctxbaton
|
|
23
|
+
|
|
24
|
+
# Wire up the automatic Stop hook (Claude Code)
|
|
25
|
+
ctxbaton hooks install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ctxbaton context # full project context — spec, todos, handoff, decisions
|
|
34
|
+
ctxbaton replay # what changed since last snapshot (git diff + todo changes)
|
|
35
|
+
ctxbaton replay --since 2h # what changed in the last 2 hours
|
|
36
|
+
ctxbaton search "auth" # semantic search across all memories
|
|
37
|
+
|
|
38
|
+
ctxbaton todo list # open tasks
|
|
39
|
+
ctxbaton todo done <id> # mark a task done
|
|
40
|
+
ctxbaton todo start <id> # mark a task in progress
|
|
41
|
+
|
|
42
|
+
ctxbaton memory save --type decision "use JWT over sessions because..."
|
|
43
|
+
ctxbaton memory save --type handoff "stopped mid-auth, next: refresh tokens"
|
|
44
|
+
ctxbaton memory save --type spec "build a REST API with FastAPI"
|
|
45
|
+
ctxbaton memory save --type todo "add rate limiting"
|
|
46
|
+
|
|
47
|
+
ctxbaton snapshot list # full snapshot history with git hashes
|
|
48
|
+
ctxbaton hooks install # install Claude Code Stop hook
|
|
49
|
+
ctxbaton serve # start as MCP server
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Memory types
|
|
53
|
+
|
|
54
|
+
| Type | Purpose |
|
|
55
|
+
|------|---------|
|
|
56
|
+
| `spec` | The current goal or plan |
|
|
57
|
+
| `todo` | A task with status (pending / in_progress / done) |
|
|
58
|
+
| `decision` | An architecture or design choice with rationale |
|
|
59
|
+
| `handoff` | State snapshot when switching agents or sessions |
|
|
60
|
+
| `progress` | What has been completed |
|
|
61
|
+
| `general` | Anything else |
|
|
62
|
+
|
|
63
|
+
## Cross-agent continuity
|
|
64
|
+
|
|
65
|
+
ctxbaton is agent-agnostic. Claude Code, OpenCode, Codex, Cursor — they all call the same CLI and write to the same store.
|
|
66
|
+
|
|
67
|
+
Each project gets its own isolated DB at:
|
|
68
|
+
```
|
|
69
|
+
~/.ctxbaton/projects/-Users-you-dev-myproject/memories.db
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The path mirrors the project directory (same convention as Claude Code's own memory files), so there's no config needed — open a project, run `ctxbaton context`, done.
|
|
73
|
+
|
|
74
|
+
## Automatic snapshots
|
|
75
|
+
|
|
76
|
+
Install the Stop hook once:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
ctxbaton hooks install
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
After that, every time an agent finishes a turn, ctxbaton saves:
|
|
83
|
+
- The current git hash and branch
|
|
84
|
+
- A diff of what todos changed
|
|
85
|
+
- A reference to the session transcript
|
|
86
|
+
|
|
87
|
+
No tokens. No agent cooperation. Just a shell script that runs in milliseconds.
|
|
88
|
+
|
|
89
|
+
## Agent Skills (Claude Code, Codex, Cursor)
|
|
90
|
+
|
|
91
|
+
ctxbaton ships with a `SKILL.md` that auto-injects project context at session start.
|
|
92
|
+
Copy it to your skills directory:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
cp skill/SKILL.md ~/.claude/skills/ctxbaton/SKILL.md
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Or run the full installer:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
bash skill/scripts/install.sh
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Then use `/ctxbaton` in any session to load context instantly.
|
|
105
|
+
|
|
106
|
+
## MCP server
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
ctxbaton serve
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Register in Claude Code:
|
|
113
|
+
```bash
|
|
114
|
+
claude mcp add ctxbaton -- ctxbaton serve
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Or in any MCP-compatible client:
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"mcpServers": {
|
|
121
|
+
"ctxbaton": {
|
|
122
|
+
"command": "ctxbaton",
|
|
123
|
+
"args": ["serve"],
|
|
124
|
+
"env": { "MEMORY_PROJECT": "/path/to/your/project" }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Storage
|
|
131
|
+
|
|
132
|
+
Memories are stored in SQLite with local embeddings ([BAAI/bge-small-en-v1.5](https://huggingface.co/BAAI/bge-small-en-v1.5), ~40MB, downloaded once). No API keys. Works offline.
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT — [melonkernel/ctxbaton](https://github.com/melonkernel/ctxbaton)
|
ctxbaton-0.1.0/SETUP.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# ctxbaton v2
|
|
2
|
+
|
|
3
|
+
Persistent agent memory with semantic search. One DB per project, stored in
|
|
4
|
+
userspace — mirroring Anthropic's own convention for project-scoped files.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
- Python 3.11+
|
|
9
|
+
- [uv](https://docs.astral.sh/uv/)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv sync
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
On first use the embedding model (BAAI/bge-small-en-v1.5, ~40MB) is
|
|
18
|
+
downloaded to `~/.cache/fastembed/` automatically.
|
|
19
|
+
|
|
20
|
+
## Storage
|
|
21
|
+
|
|
22
|
+
Each project gets its own DB:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
~/.ctxbaton/projects/-Users-you-dev-myproject/memories.db
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The path mirrors the project path with `/` replaced by `-`, same convention
|
|
29
|
+
Claude Code uses for its own project files.
|
|
30
|
+
|
|
31
|
+
Override the project path with the `MEMORY_PROJECT` env var (defaults to cwd).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Register as MCP server
|
|
36
|
+
|
|
37
|
+
The key is passing `MEMORY_PROJECT` so the server opens the right DB.
|
|
38
|
+
|
|
39
|
+
### Claude Code (CLI)
|
|
40
|
+
|
|
41
|
+
Run this from inside your project directory:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
claude mcp add memory \
|
|
45
|
+
--env MEMORY_PROJECT=$(pwd) \
|
|
46
|
+
uv -- --directory /Users/toffe/dev/ai/graceful.ai/ctxbaton run ctxbaton
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or add it to `.claude/settings.json` in your project:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"memory": {
|
|
55
|
+
"command": "uv",
|
|
56
|
+
"args": ["--directory", "/Users/toffe/dev/ai/graceful.ai/ctxbaton", "run", "ctxbaton"],
|
|
57
|
+
"env": { "MEMORY_PROJECT": "/absolute/path/to/your/project" }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Claude Desktop
|
|
64
|
+
|
|
65
|
+
`~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"memory": {
|
|
71
|
+
"command": "uv",
|
|
72
|
+
"args": ["--directory", "/Users/toffe/dev/ai/graceful.ai/ctxbaton", "run", "ctxbaton"],
|
|
73
|
+
"env": { "MEMORY_PROJECT": "/absolute/path/to/your/project" }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### OpenCode
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"mcp": {
|
|
84
|
+
"servers": {
|
|
85
|
+
"memory": {
|
|
86
|
+
"command": "uv",
|
|
87
|
+
"args": ["--directory", "/Users/toffe/dev/ai/graceful.ai/ctxbaton", "run", "ctxbaton"],
|
|
88
|
+
"env": { "MEMORY_PROJECT": "/absolute/path/to/your/project" }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Tools
|
|
98
|
+
|
|
99
|
+
| Tool | Description |
|
|
100
|
+
|------|-------------|
|
|
101
|
+
| `save_memory` | Save a memory to the current project |
|
|
102
|
+
| `search_memories` | Semantic search, returns results with `_score` |
|
|
103
|
+
| `list_memories` | List by type / status / agent / session |
|
|
104
|
+
| `get_context` | Full snapshot: spec + open todos + handoff + decisions |
|
|
105
|
+
| `update_todo_status` | Mark a todo `pending` / `in_progress` / `done` |
|
|
106
|
+
| `get_memory` | Fetch one memory by ID |
|
|
107
|
+
| `update_memory` | Edit content, summary, type, or tags |
|
|
108
|
+
| `delete_memory` | Delete by ID |
|
|
109
|
+
|
|
110
|
+
## Memory types
|
|
111
|
+
|
|
112
|
+
| Type | Purpose |
|
|
113
|
+
|------|---------|
|
|
114
|
+
| `spec` | Current goal or plan |
|
|
115
|
+
| `todo` | Task with status (pending / in_progress / done) |
|
|
116
|
+
| `decision` | Architecture or design choice with rationale |
|
|
117
|
+
| `handoff` | State snapshot when switching agents or sessions |
|
|
118
|
+
| `progress` | What has been completed |
|
|
119
|
+
| `general` | Anything else |
|
|
120
|
+
|
|
121
|
+
## Cross-agent session continuity
|
|
122
|
+
|
|
123
|
+
Pass `agent` (e.g. `"claude"`, `"opencode"`) and `session_id` when saving.
|
|
124
|
+
To resume in a different agent, call `get_context()` — it returns the active
|
|
125
|
+
spec, open todos, latest handoff, and recent decisions in one call.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ctxbaton Stop hook
|
|
3
|
+
# Fires after every Claude turn. Saves a snapshot: git hash, todo diff, transcript path.
|
|
4
|
+
# No tokens required. Runs in milliseconds.
|
|
5
|
+
#
|
|
6
|
+
# Claude Code passes hook data as JSON on stdin:
|
|
7
|
+
# { "session_id": "...", "cwd": "...", "transcript_path": "...", "hook_event_name": "Stop" }
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
# Find ctxbaton — prefer project venv, fall back to PATH
|
|
12
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
13
|
+
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
14
|
+
VENV_BIN="$PROJECT_DIR/.venv/bin/ctxbaton"
|
|
15
|
+
|
|
16
|
+
if [ -x "$VENV_BIN" ]; then
|
|
17
|
+
MCP_MEMORY="$VENV_BIN"
|
|
18
|
+
elif command -v ctxbaton &>/dev/null; then
|
|
19
|
+
MCP_MEMORY="ctxbaton"
|
|
20
|
+
elif command -v uvx &>/dev/null; then
|
|
21
|
+
MCP_MEMORY="uvx --from $PROJECT_DIR ctxbaton"
|
|
22
|
+
else
|
|
23
|
+
echo '{"error": "ctxbaton not found"}' >&2
|
|
24
|
+
exit 0 # don't block Claude on failure
|
|
25
|
+
fi
|
|
26
|
+
|
|
27
|
+
# Read stdin (hook JSON) and pipe to snapshot save
|
|
28
|
+
# MEMORY_PROJECT tells the CLI which DB to use
|
|
29
|
+
INPUT=$(cat)
|
|
30
|
+
CWD=$(echo "$INPUT" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('cwd',''))" 2>/dev/null || echo "")
|
|
31
|
+
export MEMORY_PROJECT="${CWD:-$(pwd)}"
|
|
32
|
+
|
|
33
|
+
echo "$INPUT" | $MCP_MEMORY snapshot save 2>/dev/null || true
|
|
34
|
+
|
|
35
|
+
# Always exit 0 — never block Claude
|
|
36
|
+
exit 0
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "ctxbaton"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Pass context between AI agents like a relay baton — persistent memory, snapshots, and semantic search across sessions"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = { text = "MIT" }
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
|
+
keywords = ["ai", "agents", "memory", "context", "mcp", "claude", "opencode", "codex"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"License :: OSI Approved :: MIT License",
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"mcp[cli]>=1.0.0",
|
|
16
|
+
"fastembed>=0.4.0",
|
|
17
|
+
"numpy>=1.26.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://github.com/melonkernel/ctxbaton"
|
|
22
|
+
Repository = "https://github.com/melonkernel/ctxbaton"
|
|
23
|
+
Issues = "https://github.com/melonkernel/ctxbaton/issues"
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
ctxbaton = "ctxbaton.cli:main"
|
|
27
|
+
|
|
28
|
+
[build-system]
|
|
29
|
+
requires = ["hatchling"]
|
|
30
|
+
build-backend = "hatchling.build"
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.wheel]
|
|
33
|
+
packages = ["src/ctxbaton"]
|
|
34
|
+
|
|
35
|
+
[tool.uv]
|
|
36
|
+
dev-dependencies = []
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ctxbaton
|
|
3
|
+
description: >
|
|
4
|
+
Loads persistent project context at session start. Tracks todos, decisions,
|
|
5
|
+
handoffs, and git state automatically. Use this to resume work across agents
|
|
6
|
+
and sessions without losing context.
|
|
7
|
+
argument-hint: "[query]"
|
|
8
|
+
allowed-tools: Bash(ctxbaton *)
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Project context
|
|
12
|
+
!`ctxbaton context`
|
|
13
|
+
|
|
14
|
+
## Instructions
|
|
15
|
+
|
|
16
|
+
You now have full project context loaded above. Use it to resume work immediately.
|
|
17
|
+
|
|
18
|
+
When starting work on a task, mark it in progress:
|
|
19
|
+
`ctxbaton todo start <id>`
|
|
20
|
+
|
|
21
|
+
When finishing a task:
|
|
22
|
+
`ctxbaton todo done <id>`
|
|
23
|
+
|
|
24
|
+
When making an architecture or design decision:
|
|
25
|
+
`ctxbaton memory save --type decision "<what was decided and why>"`
|
|
26
|
+
|
|
27
|
+
When ending a session or handing off to another agent:
|
|
28
|
+
`ctxbaton memory save --type handoff "<what you were doing, what's next, any blockers>"`
|
|
29
|
+
|
|
30
|
+
To resume after a break or unexpected session end:
|
|
31
|
+
`ctxbaton replay --since 2h`
|
|
32
|
+
|
|
33
|
+
To search past decisions and context:
|
|
34
|
+
`ctxbaton search "<query>"`
|
|
35
|
+
|
|
36
|
+
To add a new todo:
|
|
37
|
+
`ctxbaton memory save --type todo "<task>"`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ctxbaton skill installer
|
|
3
|
+
# Installs the CLI globally and wires up the Stop hook for automatic snapshots.
|
|
4
|
+
#
|
|
5
|
+
# Usage: bash install.sh
|
|
6
|
+
|
|
7
|
+
set -euo pipefail
|
|
8
|
+
|
|
9
|
+
SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
10
|
+
PROJECT_DIR="$(dirname "$SKILL_DIR")"
|
|
11
|
+
|
|
12
|
+
echo "Installing ctxbaton..."
|
|
13
|
+
|
|
14
|
+
# Install CLI globally
|
|
15
|
+
if command -v uv &>/dev/null; then
|
|
16
|
+
uv tool install --editable "$PROJECT_DIR"
|
|
17
|
+
else
|
|
18
|
+
echo "Error: uv is required. Install from https://docs.astral.sh/uv/" >&2
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# Install Stop hook
|
|
23
|
+
ctxbaton hooks install
|
|
24
|
+
|
|
25
|
+
# Copy skill to Claude Code skills directory
|
|
26
|
+
CLAUDE_SKILLS="$HOME/.claude/skills/ctxbaton"
|
|
27
|
+
mkdir -p "$CLAUDE_SKILLS"
|
|
28
|
+
cp -r "$SKILL_DIR/." "$CLAUDE_SKILLS/"
|
|
29
|
+
echo "✓ Skill installed → $CLAUDE_SKILLS"
|
|
30
|
+
|
|
31
|
+
echo ""
|
|
32
|
+
echo "Done. ctxbaton is active."
|
|
33
|
+
echo " Run 'ctxbaton context' to verify."
|
|
34
|
+
echo " Use '/ctxbaton' in Claude Code to load project context."
|
|
File without changes
|