ctx-sync 1.2.0 → 1.3.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/README.md ADDED
@@ -0,0 +1,291 @@
1
+ # ctx-sync
2
+
3
+ > Sync your complete development context across machines using Git as the backend.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/ctx-sync.svg)](https://www.npmjs.com/package/ctx-sync)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ **ctx-sync** is a CLI tool that solves the "23-minute context switch" problem by preserving and restoring your entire development state — projects, environment variables, Docker services, mental context, and more — across machines.
9
+
10
+ ## The Problem
11
+
12
+ Research shows developers lose **23 minutes** regaining flow state after interruptions. When switching between machines, they face:
13
+
14
+ - Lost project state (which repos, branches)
15
+ - Missing environment variables
16
+ - Forgotten running services
17
+ - Lost mental context (what was I working on?)
18
+ - Manual reconfiguration of Docker containers
19
+
20
+ **ctx-sync fixes all of this in under 10 seconds.**
21
+
22
+ ## Key Features
23
+
24
+ - **No backend required** — Uses Git for syncing (GitHub, GitLab, any Git host)
25
+ - **Everything encrypted** — Full state encryption with [Age](https://age-encryption.org/)
26
+ - **Encrypt-by-default** — All env vars encrypted, eliminating false negatives
27
+ - **Zero manual entry** — Import from `.env` files in batch
28
+ - **Zero side-channel leaks** — No secrets in CLI args, shell history, or logs
29
+ - **Mental state preserved** — Track tasks, blockers, breadcrumbs
30
+ - **Team support** — Multi-recipient encryption for shared environments
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install -g ctx-sync
36
+ ```
37
+
38
+ **Requirements:** Node.js >= 20.0.0, Git >= 2.25
39
+
40
+ ## Quick Start
41
+
42
+ ### 1. First-time setup
43
+
44
+ ```bash
45
+ ctx-sync init
46
+ ```
47
+
48
+ This generates an encryption key, sets up a Git-backed sync repo, and prompts you to back up your private key to a password manager.
49
+
50
+ ### 2. Track a project
51
+
52
+ ```bash
53
+ cd ~/projects/my-app
54
+ ctx-sync track
55
+ ```
56
+
57
+ ctx-sync auto-detects your Git branch, `.env` files, `docker-compose.yml`, and prompts you for mental context (what are you working on?).
58
+
59
+ ### 3. Sync to remote
60
+
61
+ ```bash
62
+ ctx-sync sync
63
+ ```
64
+
65
+ All state is encrypted, committed to Git, and pushed to your remote.
66
+
67
+ ### 4. Restore on another machine
68
+
69
+ ```bash
70
+ # One-time setup on the new machine
71
+ ctx-sync init --restore
72
+ # Paste your private key from your password manager
73
+
74
+ # Restore a specific project
75
+ ctx-sync restore my-app
76
+ ```
77
+
78
+ ctx-sync decrypts your state, displays your context, and asks before running any commands.
79
+
80
+ If your project is at a different path on the new machine, use `--path`:
81
+
82
+ ```bash
83
+ ctx-sync restore my-app --path ~/code/my-app
84
+ ```
85
+
86
+ ## What Gets Tracked
87
+
88
+ | State | Description |
89
+ |-------|-------------|
90
+ | **Project state** | Git branch, remote, stash count, uncommitted changes |
91
+ | **Environment variables** | All vars from `.env` files, encrypted by default |
92
+ | **Docker services** | Compose services, ports, images, healthchecks |
93
+ | **Mental context** | Current task, blockers, next steps, breadcrumbs |
94
+ | **Running services** | Dev servers, ports, start commands |
95
+ | **Working directories** | Recent and pinned directories with frequency tracking |
96
+
97
+ ## Commands
98
+
99
+ ### Setup
100
+
101
+ | Command | Description |
102
+ |---------|-------------|
103
+ | `ctx-sync init` | First-time setup — generates key, creates Git repo |
104
+ | `ctx-sync init --restore` | Setup on new machine with existing key |
105
+
106
+ ### Project Management
107
+
108
+ | Command | Description |
109
+ |---------|-------------|
110
+ | `ctx-sync track` | Track current project (interactive wizard) |
111
+ | `ctx-sync list` | List all tracked projects |
112
+ | `ctx-sync status` | Show sync status |
113
+ | `ctx-sync restore <project>` | Restore project state (with command confirmation) |
114
+ | `ctx-sync restore <project> --path <dir>` | Restore with custom local project directory |
115
+
116
+ ### Environment Variables
117
+
118
+ | Command | Description |
119
+ |---------|-------------|
120
+ | `ctx-sync env import <file>` | Import from .env file (all encrypted) |
121
+ | `ctx-sync env add <key>` | Add single var (hidden interactive prompt) |
122
+ | `ctx-sync env add <key> --stdin` | Add from stdin pipe |
123
+ | `ctx-sync env scan` | Scan current shell environment |
124
+ | `ctx-sync env list <project>` | List vars (values hidden by default) |
125
+ | `ctx-sync env list <project> --show-values` | List with decrypted values |
126
+
127
+ ### Syncing
128
+
129
+ | Command | Description |
130
+ |---------|-------------|
131
+ | `ctx-sync sync` | Push and pull changes |
132
+ | `ctx-sync push` | Push only |
133
+ | `ctx-sync pull` | Pull only |
134
+
135
+ ### Mental Context
136
+
137
+ | Command | Description |
138
+ |---------|-------------|
139
+ | `ctx-sync note <project>` | Update tasks, blockers, next steps |
140
+ | `ctx-sync show <project>` | Show full project context |
141
+
142
+ ### Docker
143
+
144
+ | Command | Description |
145
+ |---------|-------------|
146
+ | `ctx-sync docker track` | Detect and save Docker Compose state |
147
+ | `ctx-sync docker start <project>` | Start tracked services (with confirmation) |
148
+ | `ctx-sync docker stop <project>` | Stop tracked services |
149
+ | `ctx-sync docker status` | Show running services |
150
+
151
+ ### Key Management
152
+
153
+ | Command | Description |
154
+ |---------|-------------|
155
+ | `ctx-sync key show` | Show public key (never shows private key) |
156
+ | `ctx-sync key rotate` | Rotate key and re-encrypt all state |
157
+ | `ctx-sync key verify` | Verify key file permissions and integrity |
158
+ | `ctx-sync key update` | Update key on secondary machines after rotation |
159
+
160
+ ### Teams
161
+
162
+ | Command | Description |
163
+ |---------|-------------|
164
+ | `ctx-sync team add --name <n> --key <pubkey>` | Add team member |
165
+ | `ctx-sync team remove <name>` | Remove member and re-encrypt |
166
+ | `ctx-sync team list` | List team members |
167
+ | `ctx-sync team revoke <pubkey>` | Revoke key immediately |
168
+
169
+ ### Security & Config
170
+
171
+ | Command | Description |
172
+ |---------|-------------|
173
+ | `ctx-sync audit` | Run security audit (permissions, transport, history) |
174
+ | `ctx-sync config safe-list` | View env var safe-list |
175
+ | `ctx-sync config safe-list add <key>` | Add key to safe-list |
176
+ | `ctx-sync config safe-list remove <key>` | Remove key from safe-list |
177
+
178
+ ## Security Model
179
+
180
+ ctx-sync takes a **defense-in-depth** approach to security:
181
+
182
+ ### Encrypt Everything by Default
183
+
184
+ All state files are encrypted with [Age](https://age-encryption.org/) before being written to disk or committed to Git. The only plaintext file is `manifest.json`, which contains only version and timestamps — no project names, paths, or sensitive data.
185
+
186
+ ### What Gets Encrypted
187
+
188
+ | File | Contents |
189
+ |------|----------|
190
+ | `state.age` | Projects, branches, Git metadata |
191
+ | `env-vars.age` | All environment variables |
192
+ | `docker-state.age` | Container configurations |
193
+ | `mental-context.age` | Tasks, blockers, breadcrumbs |
194
+ | `services.age` | Running services and commands |
195
+ | `directories.age` | Recent and pinned directories |
196
+
197
+ ### Security Properties
198
+
199
+ - **Zero trust** — Git remote compromise reveals only ciphertext
200
+ - **No side-channel leaks** — Secrets never in CLI args, shell history, or logs
201
+ - **Transport security** — Git remote must use SSH or HTTPS (enforced at runtime)
202
+ - **Command confirmation** — Restored commands always shown before execution
203
+ - **File permissions** — Key: `0o600`, config dir: `0o700` (enforced at runtime)
204
+ - **Key rotation** — Built-in rotation with Git history rewriting
205
+ - **Team revocation** — Remove member access with automatic re-encryption
206
+ - **Credential detection** — Recognizes Stripe, GitHub, AWS, Slack, Google, JWT, PEM, and more
207
+ - **Log sanitization** — Secret patterns automatically redacted from all output
208
+
209
+ ## Architecture
210
+
211
+ ```
212
+ ~/.context-sync/ # Git repo (syncs to remote)
213
+ ├── manifest.json # Version + timestamps (only plaintext)
214
+ ├── state.age # Encrypted: projects & branches
215
+ ├── env-vars.age # Encrypted: all environment variables
216
+ ├── docker-state.age # Encrypted: container configurations
217
+ ├── mental-context.age # Encrypted: tasks, blockers, breadcrumbs
218
+ ├── services.age # Encrypted: running services & commands
219
+ └── directories.age # Encrypted: recent & pinned directories
220
+
221
+ ~/.config/ctx-sync/ # Local config (NEVER synced to Git)
222
+ ├── key.txt # Private key (permissions: 600)
223
+ ├── config.json # Local preferences, safe-list
224
+ └── approved-commands.json # Per-machine approved command cache
225
+ ```
226
+
227
+ ## Example Workflow
228
+
229
+ ### Morning on your work laptop
230
+
231
+ ```bash
232
+ cd ~/projects/my-app
233
+ ctx-sync track
234
+
235
+ # ctx-sync detects:
236
+ # Branch: feature/payments
237
+ # .env: 12 variables imported (all encrypted)
238
+ # Docker: postgres, redis tracked
239
+ # You add: "Implementing Stripe webhooks"
240
+
241
+ ctx-sync sync # Encrypted + pushed to Git
242
+ ```
243
+
244
+ ### Evening on your home desktop
245
+
246
+ ```bash
247
+ ctx-sync init --restore # One-time: paste key from 1Password
248
+ ctx-sync restore my-app
249
+
250
+ # Output:
251
+ # Directory: ~/projects/my-app
252
+ # Branch: feature/payments
253
+ # Env vars: 12 decrypted
254
+ # You were working on: "Implementing Stripe webhooks"
255
+ # Next steps: Test with Stripe CLI, Add error handling
256
+ #
257
+ # Commands to execute:
258
+ # 1. docker compose up -d postgres
259
+ # 2. docker compose up -d redis
260
+ # 3. npm run dev (port 3000)
261
+ # Execute all? [y/N/select]
262
+ ```
263
+
264
+ Back to full flow in under 10 seconds.
265
+
266
+ ## Why ctx-sync?
267
+
268
+ | | ctx-sync | Atuin | Dotfile managers | Cloud IDEs |
269
+ |---|---------|-------|-----------------|------------|
270
+ | Project state | **Yes** | No | No | Partial |
271
+ | Environment variables | **Encrypted** | No | Plaintext risk | Vendor-locked |
272
+ | Docker services | **Yes** | No | No | Yes |
273
+ | Mental context | **Yes** | No | No | No |
274
+ | Encryption | **Age (full state)** | Server-side | Usually none | Vendor trust |
275
+ | Backend required | **No (Git)** | Yes | No | Yes |
276
+ | Works offline | **Yes** | Partial | Yes | No |
277
+
278
+ ## Contributing
279
+
280
+ We welcome contributions! See our [Contributing Guide](https://github.com/Ay7ot/ctx-sync/blob/main/CONTRIBUTING.md) for details on branching strategy, commit conventions, and the development workflow.
281
+
282
+ ## Links
283
+
284
+ - [Documentation](https://ctx-sync.live/docs/)
285
+ - [Security Model](https://ctx-sync.live/docs/security.html)
286
+ - [GitHub Repository](https://github.com/Ay7ot/ctx-sync)
287
+ - [Changelog](https://github.com/Ay7ot/ctx-sync/blob/main/CHANGELOG.md)
288
+
289
+ ## License
290
+
291
+ MIT
@@ -2,7 +2,7 @@
2
2
  * Shared constants for ctx-sync.
3
3
  */
4
4
  /** Current CLI version */
5
- export declare const VERSION = "1.2.0";
5
+ export declare const VERSION = "1.3.0";
6
6
  /** Default safe-list: env var keys that MAY be stored as plaintext (with --allow-plain) */
7
7
  export declare const DEFAULT_SAFE_LIST: readonly string[];
8
8
  /** State file names (encrypted) */
@@ -2,7 +2,7 @@
2
2
  * Shared constants for ctx-sync.
3
3
  */
4
4
  /** Current CLI version */
5
- export const VERSION = '1.2.0';
5
+ export const VERSION = '1.3.0';
6
6
  /** Default safe-list: env var keys that MAY be stored as plaintext (with --allow-plain) */
7
7
  export const DEFAULT_SAFE_LIST = [
8
8
  'NODE_ENV',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-sync",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Sync your complete development context across machines using Git",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",