ctx-sync 1.2.0 → 1.2.1

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,284 @@
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
+ ## What Gets Tracked
81
+
82
+ | State | Description |
83
+ |-------|-------------|
84
+ | **Project state** | Git branch, remote, stash count, uncommitted changes |
85
+ | **Environment variables** | All vars from `.env` files, encrypted by default |
86
+ | **Docker services** | Compose services, ports, images, healthchecks |
87
+ | **Mental context** | Current task, blockers, next steps, breadcrumbs |
88
+ | **Running services** | Dev servers, ports, start commands |
89
+ | **Working directories** | Recent and pinned directories with frequency tracking |
90
+
91
+ ## Commands
92
+
93
+ ### Setup
94
+
95
+ | Command | Description |
96
+ |---------|-------------|
97
+ | `ctx-sync init` | First-time setup — generates key, creates Git repo |
98
+ | `ctx-sync init --restore` | Setup on new machine with existing key |
99
+
100
+ ### Project Management
101
+
102
+ | Command | Description |
103
+ |---------|-------------|
104
+ | `ctx-sync track` | Track current project (interactive wizard) |
105
+ | `ctx-sync list` | List all tracked projects |
106
+ | `ctx-sync status` | Show sync status |
107
+ | `ctx-sync restore <project>` | Restore project state (with command confirmation) |
108
+
109
+ ### Environment Variables
110
+
111
+ | Command | Description |
112
+ |---------|-------------|
113
+ | `ctx-sync env import <file>` | Import from .env file (all encrypted) |
114
+ | `ctx-sync env add <key>` | Add single var (hidden interactive prompt) |
115
+ | `ctx-sync env add <key> --stdin` | Add from stdin pipe |
116
+ | `ctx-sync env scan` | Scan current shell environment |
117
+ | `ctx-sync env list <project>` | List vars (values hidden by default) |
118
+ | `ctx-sync env list <project> --show-values` | List with decrypted values |
119
+
120
+ ### Syncing
121
+
122
+ | Command | Description |
123
+ |---------|-------------|
124
+ | `ctx-sync sync` | Push and pull changes |
125
+ | `ctx-sync push` | Push only |
126
+ | `ctx-sync pull` | Pull only |
127
+
128
+ ### Mental Context
129
+
130
+ | Command | Description |
131
+ |---------|-------------|
132
+ | `ctx-sync note <project>` | Update tasks, blockers, next steps |
133
+ | `ctx-sync show <project>` | Show full project context |
134
+
135
+ ### Docker
136
+
137
+ | Command | Description |
138
+ |---------|-------------|
139
+ | `ctx-sync docker track` | Detect and save Docker Compose state |
140
+ | `ctx-sync docker start <project>` | Start tracked services (with confirmation) |
141
+ | `ctx-sync docker stop <project>` | Stop tracked services |
142
+ | `ctx-sync docker status` | Show running services |
143
+
144
+ ### Key Management
145
+
146
+ | Command | Description |
147
+ |---------|-------------|
148
+ | `ctx-sync key show` | Show public key (never shows private key) |
149
+ | `ctx-sync key rotate` | Rotate key and re-encrypt all state |
150
+ | `ctx-sync key verify` | Verify key file permissions and integrity |
151
+ | `ctx-sync key update` | Update key on secondary machines after rotation |
152
+
153
+ ### Teams
154
+
155
+ | Command | Description |
156
+ |---------|-------------|
157
+ | `ctx-sync team add --name <n> --key <pubkey>` | Add team member |
158
+ | `ctx-sync team remove <name>` | Remove member and re-encrypt |
159
+ | `ctx-sync team list` | List team members |
160
+ | `ctx-sync team revoke <pubkey>` | Revoke key immediately |
161
+
162
+ ### Security & Config
163
+
164
+ | Command | Description |
165
+ |---------|-------------|
166
+ | `ctx-sync audit` | Run security audit (permissions, transport, history) |
167
+ | `ctx-sync config safe-list` | View env var safe-list |
168
+ | `ctx-sync config safe-list add <key>` | Add key to safe-list |
169
+ | `ctx-sync config safe-list remove <key>` | Remove key from safe-list |
170
+
171
+ ## Security Model
172
+
173
+ ctx-sync takes a **defense-in-depth** approach to security:
174
+
175
+ ### Encrypt Everything by Default
176
+
177
+ 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.
178
+
179
+ ### What Gets Encrypted
180
+
181
+ | File | Contents |
182
+ |------|----------|
183
+ | `state.age` | Projects, branches, Git metadata |
184
+ | `env-vars.age` | All environment variables |
185
+ | `docker-state.age` | Container configurations |
186
+ | `mental-context.age` | Tasks, blockers, breadcrumbs |
187
+ | `services.age` | Running services and commands |
188
+ | `directories.age` | Recent and pinned directories |
189
+
190
+ ### Security Properties
191
+
192
+ - **Zero trust** — Git remote compromise reveals only ciphertext
193
+ - **No side-channel leaks** — Secrets never in CLI args, shell history, or logs
194
+ - **Transport security** — Git remote must use SSH or HTTPS (enforced at runtime)
195
+ - **Command confirmation** — Restored commands always shown before execution
196
+ - **File permissions** — Key: `0o600`, config dir: `0o700` (enforced at runtime)
197
+ - **Key rotation** — Built-in rotation with Git history rewriting
198
+ - **Team revocation** — Remove member access with automatic re-encryption
199
+ - **Credential detection** — Recognizes Stripe, GitHub, AWS, Slack, Google, JWT, PEM, and more
200
+ - **Log sanitization** — Secret patterns automatically redacted from all output
201
+
202
+ ## Architecture
203
+
204
+ ```
205
+ ~/.context-sync/ # Git repo (syncs to remote)
206
+ ├── manifest.json # Version + timestamps (only plaintext)
207
+ ├── state.age # Encrypted: projects & branches
208
+ ├── env-vars.age # Encrypted: all environment variables
209
+ ├── docker-state.age # Encrypted: container configurations
210
+ ├── mental-context.age # Encrypted: tasks, blockers, breadcrumbs
211
+ ├── services.age # Encrypted: running services & commands
212
+ └── directories.age # Encrypted: recent & pinned directories
213
+
214
+ ~/.config/ctx-sync/ # Local config (NEVER synced to Git)
215
+ ├── key.txt # Private key (permissions: 600)
216
+ ├── config.json # Local preferences, safe-list
217
+ └── approved-commands.json # Per-machine approved command cache
218
+ ```
219
+
220
+ ## Example Workflow
221
+
222
+ ### Morning on your work laptop
223
+
224
+ ```bash
225
+ cd ~/projects/my-app
226
+ ctx-sync track
227
+
228
+ # ctx-sync detects:
229
+ # Branch: feature/payments
230
+ # .env: 12 variables imported (all encrypted)
231
+ # Docker: postgres, redis tracked
232
+ # You add: "Implementing Stripe webhooks"
233
+
234
+ ctx-sync sync # Encrypted + pushed to Git
235
+ ```
236
+
237
+ ### Evening on your home desktop
238
+
239
+ ```bash
240
+ ctx-sync init --restore # One-time: paste key from 1Password
241
+ ctx-sync restore my-app
242
+
243
+ # Output:
244
+ # Directory: ~/projects/my-app
245
+ # Branch: feature/payments
246
+ # Env vars: 12 decrypted
247
+ # You were working on: "Implementing Stripe webhooks"
248
+ # Next steps: Test with Stripe CLI, Add error handling
249
+ #
250
+ # Commands to execute:
251
+ # 1. docker compose up -d postgres
252
+ # 2. docker compose up -d redis
253
+ # 3. npm run dev (port 3000)
254
+ # Execute all? [y/N/select]
255
+ ```
256
+
257
+ Back to full flow in under 10 seconds.
258
+
259
+ ## Why ctx-sync?
260
+
261
+ | | ctx-sync | Atuin | Dotfile managers | Cloud IDEs |
262
+ |---|---------|-------|-----------------|------------|
263
+ | Project state | **Yes** | No | No | Partial |
264
+ | Environment variables | **Encrypted** | No | Plaintext risk | Vendor-locked |
265
+ | Docker services | **Yes** | No | No | Yes |
266
+ | Mental context | **Yes** | No | No | No |
267
+ | Encryption | **Age (full state)** | Server-side | Usually none | Vendor trust |
268
+ | Backend required | **No (Git)** | Yes | No | Yes |
269
+ | Works offline | **Yes** | Partial | Yes | No |
270
+
271
+ ## Contributing
272
+
273
+ 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.
274
+
275
+ ## Links
276
+
277
+ - [Documentation](https://ctx-sync.live/docs/)
278
+ - [Security Model](https://ctx-sync.live/docs/security.html)
279
+ - [GitHub Repository](https://github.com/Ay7ot/ctx-sync)
280
+ - [Changelog](https://github.com/Ay7ot/ctx-sync/blob/main/CHANGELOG.md)
281
+
282
+ ## License
283
+
284
+ 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.2.1";
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.2.1';
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.2.1",
4
4
  "description": "Sync your complete development context across machines using Git",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",