cortex-sync 0.1.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/CHANGELOG.md +36 -0
- package/LICENSE +661 -0
- package/README.md +163 -0
- package/dist/cli.js +1090 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# cortex
|
|
2
|
+
|
|
3
|
+
**Sync Claude Code sessions between machines with automatic path remapping.**
|
|
4
|
+
|
|
5
|
+
Claude Code stores your session history in `~/.claude/projects/` using absolute paths. Switch from your Mac to a Linux server and those sessions are gone — the paths don't match. `cortex` fixes that.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g cortex-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## How it works
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
Machine A (Mac) Machine B (Linux)
|
|
17
|
+
───────────────────────── ──────────────────────────────
|
|
18
|
+
~/.claude/projects/ ~/.claude/projects/
|
|
19
|
+
-Users-alice-myapp/ -home-alice-work-myapp/
|
|
20
|
+
abc123.jsonl abc123.jsonl
|
|
21
|
+
cwd: /Users/alice/myapp ──────▶ cwd: /home/alice/work/myapp
|
|
22
|
+
cortex ↑ paths remapped automatically
|
|
23
|
+
sync → pull
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`cortex` identifies your project by its git remote URL (or first commit hash), maps it to the correct path on each machine, and rewrites only the structural path fields inside each JSONL session file — without touching your conversation history.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# 1. Install
|
|
34
|
+
npm install -g cortex-cli
|
|
35
|
+
|
|
36
|
+
# 2. Configure on Machine A
|
|
37
|
+
cortex init
|
|
38
|
+
# → pick GitHub (PAT) or a local folder (Dropbox / iCloud / Syncthing)
|
|
39
|
+
# → set your encryption passphrase (never stored)
|
|
40
|
+
|
|
41
|
+
# 3. Push your sessions
|
|
42
|
+
cortex sync
|
|
43
|
+
|
|
44
|
+
# 4. On Machine B — pull and start working
|
|
45
|
+
cortex init # same storage, same passphrase
|
|
46
|
+
cortex pull # downloads, decrypts, remaps paths automatically
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Open any project on Machine B — Claude Code shows your full session history.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
| Command | What it does |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `cortex init` | Configure storage, email, and passphrase |
|
|
58
|
+
| `cortex sync` | Encrypt `~/.claude/` and upload |
|
|
59
|
+
| `cortex pull` | Download, decrypt, remap paths |
|
|
60
|
+
| `cortex status` | Show what's out of sync (no download) |
|
|
61
|
+
| `cortex convert <file> --to <target>` | Convert a Claude Code skill |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Storage backends
|
|
66
|
+
|
|
67
|
+
### GitHub private repo (recommended)
|
|
68
|
+
|
|
69
|
+
No OAuth app needed — just a Personal Access Token.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
cortex init
|
|
73
|
+
# Select "GitHub private repo"
|
|
74
|
+
# → Create a PAT at: github.com/settings/tokens/new?scopes=repo
|
|
75
|
+
# → Paste the token (ghp_...)
|
|
76
|
+
# → cortex validates it and creates the private repo automatically
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Local folder
|
|
80
|
+
|
|
81
|
+
Works with Dropbox, iCloud Drive, Syncthing, NFS, or any shared directory.
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
cortex init
|
|
85
|
+
# Select "Local folder"
|
|
86
|
+
# → Enter path: ~/Dropbox/cortex-backup
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Skill conversion
|
|
92
|
+
|
|
93
|
+
Convert Claude Code skills to other AI tool formats using your own Anthropic API key.
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# To Antigravity → .agent/skills/<name>/SKILL.md
|
|
97
|
+
cortex convert ~/.claude/skills/tdd.md --to antigravity --output-dir ./my-project
|
|
98
|
+
|
|
99
|
+
# To Cursor → .cursorrules (intelligent append, no duplicates across runs)
|
|
100
|
+
cortex convert ~/.claude/skills/tdd.md --to cursor --output-dir ./my-project
|
|
101
|
+
|
|
102
|
+
# Both at once
|
|
103
|
+
cortex convert ~/.claude/skills/tdd.md --to all --output-dir ./my-project
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
API key priority: `ANTHROPIC_API_KEY` env → `~/.cortex/api-key.enc` (encrypted) → interactive prompt.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Security
|
|
111
|
+
|
|
112
|
+
Everything is encrypted **before** leaving your machine. Your storage provider sees only ciphertext.
|
|
113
|
+
|
|
114
|
+
| What | How |
|
|
115
|
+
|---|---|
|
|
116
|
+
| Encryption | AES-256-GCM (authenticated) |
|
|
117
|
+
| Key derivation | PBKDF2, 600,000 iterations, SHA-256 |
|
|
118
|
+
| Salt | SHA-256(lowercase(your email)) |
|
|
119
|
+
| Passphrase | Never stored anywhere — derived fresh each session |
|
|
120
|
+
| Secret detection | Warns before encrypting if API keys or PEM keys are found in your files |
|
|
121
|
+
|
|
122
|
+
The GitHub PAT is stored in `~/.cortex/config.json` (your machine, your user). The Anthropic API key — if you choose to save it — goes to `~/.cortex/api-key.enc`, encrypted with your sync passphrase.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## How path remapping works
|
|
127
|
+
|
|
128
|
+
Claude Code encodes project paths into directory names by replacing every non-alphanumeric character with `-`:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
/home/alice/work/myapp → -home-alice-work-myapp
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This encoding is **lossy** — it cannot be reversed. `cortex` reads the `cwd` field inside each JSONL session file, which holds the original absolute path, and uses that as the source of truth.
|
|
135
|
+
|
|
136
|
+
On `cortex pull`, for each project:
|
|
137
|
+
|
|
138
|
+
1. Reads `cwd` from the session JSONL to get the original path
|
|
139
|
+
2. Identifies the project via `git remote.origin.url` or `git rev-list --max-parents=0 HEAD`
|
|
140
|
+
3. Looks up your local path in `~/.cortex/path-mappings.json` (prompts once if unknown)
|
|
141
|
+
4. Rewrites only the 4 structural fields per line: `cwd`, `filePath`, `file_path`, `file.filePath`
|
|
142
|
+
5. Renames `~/.claude/projects/<old-encoded>/` → `<new-encoded>/`
|
|
143
|
+
|
|
144
|
+
Conversation history, command outputs, and text responses are **never modified**.
|
|
145
|
+
|
|
146
|
+
For projects without git, drop a `cortex.json` in the project root:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{ "projectId": "my-unique-id" }
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Requirements
|
|
155
|
+
|
|
156
|
+
- Node.js ≥ 20
|
|
157
|
+
- Claude Code installed on each machine you want to sync
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
[AGPL-3.0](LICENSE) — free to use, modify, and distribute. Forks used to run a hosted service must publish their source changes.
|