@lumy-pack/syncpoint 0.0.1 → 0.0.3

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,943 @@
1
+ # Syncpoint
2
+
3
+ > Personal Environment Manager — Config backup/restore and machine provisioning CLI
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@lumy-pack/syncpoint.svg)](https://www.npmjs.com/package/@lumy-pack/syncpoint)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ Syncpoint is a powerful CLI tool for managing your development environment configurations. Backup your dotfiles, restore them on new machines, and provision your system with automated templates—all with built-in safety features and security checks.
9
+
10
+ ## ✨ Features
11
+
12
+ - 🧙 **AI-Powered Wizards** — LLM-assisted config generation and template creation with Claude Code
13
+ - 📦 **Config Backup** — Create compressed archives of your dotfiles and configs with metadata tracking
14
+ - 🔄 **Smart Restore** — Hash-based file comparison with automatic safety backups before overwrite
15
+ - 🚀 **Machine Provisioning** — Template-based system setup with YAML-defined installation steps
16
+ - 🛡️ **Security First** — Sensitive file detection, symlink attack prevention, remote script blocking
17
+ - 📊 **Interactive Management** — Browse backups and templates with a beautiful terminal UI
18
+ - 🎯 **Flexible Patterns** — Glob/regex support, tilde expansion, and customizable filename placeholders
19
+
20
+ ## 📦 Installation
21
+
22
+ **Recommended: Use with npx (no installation required)**
23
+
24
+ ```bash
25
+ npx @lumy-pack/syncpoint <command>
26
+ ```
27
+
28
+ Or install globally if you prefer:
29
+
30
+ ```bash
31
+ # Using npm
32
+ npm install -g @lumy-pack/syncpoint
33
+
34
+ # Using pnpm
35
+ pnpm add -g @lumy-pack/syncpoint
36
+ ```
37
+
38
+ ## 🚀 Quick Start
39
+
40
+ ### Option A: 🧙 AI-Powered Setup (Recommended)
41
+
42
+ The fastest and easiest way to get started. AI automatically generates your configuration file.
43
+
44
+ **Requirements:** [Claude Code CLI](https://claude.ai/code) installed (or use `--print` mode)
45
+
46
+ 1. **Initialize syncpoint**
47
+
48
+ ```bash
49
+ npx @lumy-pack/syncpoint init
50
+ ```
51
+
52
+ 2. **Run AI wizard to generate config**
53
+
54
+ ```bash
55
+ npx @lumy-pack/syncpoint wizard
56
+ ```
57
+
58
+ The wizard will automatically:
59
+ - Scan your home directory for backup targets
60
+ - Generate an optimized config.yml via AI
61
+ - Validate and auto-correct (up to 3 retry attempts)
62
+
63
+ 3. **Create your first backup**
64
+
65
+ ```bash
66
+ npx @lumy-pack/syncpoint backup
67
+ ```
68
+
69
+ 4. **Restore on another machine**
70
+
71
+ ```bash
72
+ npx @lumy-pack/syncpoint restore
73
+ ```
74
+
75
+ **Tip:** If you don't have Claude Code, use `--print` to get the prompt for any LLM:
76
+ ```bash
77
+ npx @lumy-pack/syncpoint wizard --print
78
+ ```
79
+
80
+ ---
81
+
82
+ ### Option B: 📝 Manual Setup
83
+
84
+ If you prefer to manually edit your configuration file, use this approach.
85
+
86
+ 1. **Initialize syncpoint**
87
+
88
+ ```bash
89
+ npx @lumy-pack/syncpoint init
90
+ ```
91
+
92
+ 2. **Edit your configuration**
93
+
94
+ Open `~/.syncpoint/config.yml` and customize your backup targets:
95
+
96
+ ```yaml
97
+ backup:
98
+ targets:
99
+ - ~/.zshrc
100
+ - ~/.gitconfig
101
+ - ~/.ssh/config
102
+ exclude:
103
+ - "**/*.swp"
104
+ filename: "{hostname}_{datetime}"
105
+ ```
106
+
107
+ 3. **Create your first backup**
108
+
109
+ ```bash
110
+ npx @lumy-pack/syncpoint backup
111
+ ```
112
+
113
+ 4. **Restore on another machine**
114
+
115
+ ```bash
116
+ npx @lumy-pack/syncpoint restore
117
+ ```
118
+
119
+ ---
120
+
121
+ ### 🎯 Bonus: Create Provisioning Templates
122
+
123
+ To automate new machine setup:
124
+
125
+ ```bash
126
+ # Generate template with AI wizard
127
+ npx @lumy-pack/syncpoint create-template my-dev-setup
128
+
129
+ # Run provisioning
130
+ npx @lumy-pack/syncpoint provision my-dev-setup
131
+ ```
132
+
133
+ ## 📖 Commands
134
+
135
+ ### `syncpoint init`
136
+
137
+ Initialize the syncpoint directory structure and create default configuration.
138
+
139
+ **What it does:**
140
+ - Creates `~/.syncpoint/` directory structure
141
+ - Sets up subdirectories: `backups/`, `templates/`, `scripts/`, `logs/`
142
+ - Generates default `config.yml`
143
+ - Creates an example provisioning template
144
+
145
+ **Usage:**
146
+
147
+ ```bash
148
+ npx @lumy-pack/syncpoint init
149
+ ```
150
+
151
+ ---
152
+
153
+ ### `syncpoint wizard [options]`
154
+
155
+ Interactive LLM-powered wizard to generate personalized `config.yml` based on your home directory.
156
+
157
+ **What it does:**
158
+ 1. Scans your home directory for common configuration files
159
+ 2. Categorizes files (shell configs, git, SSH, application configs)
160
+ 3. Invokes Claude Code to generate customized backup configuration
161
+ 4. Validates generated config with automatic retry on errors (max 3 attempts)
162
+ 5. Backs up existing config before overwrite (saved as `config.yml.bak`)
163
+ 6. Writes validated configuration to `~/.syncpoint/config.yml`
164
+
165
+ **Options:**
166
+
167
+ | Option | Description |
168
+ |--------|-------------|
169
+ | `-p, --print` | Print prompt for manual LLM usage instead of invoking Claude Code |
170
+
171
+ **Usage:**
172
+
173
+ ```bash
174
+ # Interactive wizard (requires Claude Code CLI)
175
+ npx @lumy-pack/syncpoint wizard
176
+
177
+ # Print prompt for manual use
178
+ npx @lumy-pack/syncpoint wizard --print
179
+ ```
180
+
181
+ **Requirements:**
182
+ - Claude Code CLI must be installed for default mode
183
+ - Use `--print` mode if Claude Code is not available
184
+
185
+ **Validation:**
186
+ - Automatic AJV schema validation
187
+ - Retry loop with error feedback to LLM
188
+ - Session resume preserves conversation context
189
+
190
+ ---
191
+
192
+ ### `syncpoint create-template [name] [options]`
193
+
194
+ Interactive LLM-powered wizard to create custom provisioning templates.
195
+
196
+ **What it does:**
197
+ 1. Guides you through defining provisioning requirements
198
+ 2. Invokes Claude Code to generate template YAML
199
+ 3. Validates template structure with automatic retry (max 3 attempts)
200
+ 4. Writes template to `~/.syncpoint/templates/`
201
+ 5. Prevents overwriting existing templates
202
+
203
+ **Options:**
204
+
205
+ | Option | Description |
206
+ |--------|-------------|
207
+ | `-p, --print` | Print prompt for manual LLM usage instead of invoking Claude Code |
208
+
209
+ **Usage:**
210
+
211
+ ```bash
212
+ # Interactive template creation (requires Claude Code CLI)
213
+ npx @lumy-pack/syncpoint create-template
214
+
215
+ # Create with specific name
216
+ npx @lumy-pack/syncpoint create-template my-dev-setup
217
+
218
+ # Print prompt for manual use
219
+ npx @lumy-pack/syncpoint create-template --print
220
+ ```
221
+
222
+ **Template Fields:**
223
+ - `name` (required) — Template name
224
+ - `description` (optional) — Template description
225
+ - `steps` (required) — Array of provisioning steps
226
+ - `backup` (optional) — Backup name to restore after provisioning
227
+ - `sudo` (optional) — Whether sudo privilege is required
228
+
229
+ **Step Fields:**
230
+ - `name` (required) — Step name
231
+ - `command` (required) — Shell command to execute
232
+ - `description` (optional) — Step description
233
+ - `skip_if` (optional) — Condition to skip step
234
+ - `continue_on_error` (optional) — Continue on failure (default: false)
235
+
236
+ ---
237
+
238
+ ### `syncpoint backup [options]`
239
+
240
+ Create a compressed backup archive of your configuration files.
241
+
242
+ **What it does:**
243
+ 1. Scans configured target files and directories
244
+ 2. Applies glob patterns and exclusions
245
+ 3. Warns about large files (>10MB) and sensitive files (SSH keys, certificates)
246
+ 4. Collects file hashes for comparison
247
+ 5. Optionally includes scripts from `~/.syncpoint/scripts/`
248
+ 6. Creates compressed tar.gz archive with metadata
249
+
250
+ **Options:**
251
+
252
+ | Option | Description |
253
+ |--------|-------------|
254
+ | `--dry-run` | Preview files to be backed up without creating archive |
255
+ | `--tag <name>` | Add custom tag to backup filename |
256
+
257
+ **Usage:**
258
+
259
+ ```bash
260
+ # Create a backup
261
+ npx @lumy-pack/syncpoint backup
262
+
263
+ # Preview backup contents
264
+ npx @lumy-pack/syncpoint backup --dry-run
265
+
266
+ # Create a tagged backup
267
+ npx @lumy-pack/syncpoint backup --tag "before-upgrade"
268
+ ```
269
+
270
+ **Output:**
271
+
272
+ Backups are saved to `~/.syncpoint/backups/` (or custom destination) with filename pattern from config. Example: `macbook-pro_2024-01-15_14-30-00.tar.gz`
273
+
274
+ ---
275
+
276
+ ### `syncpoint restore [filename] [options]`
277
+
278
+ Restore configuration files from a backup archive.
279
+
280
+ **What it does:**
281
+ 1. Lists available backups (if no filename provided)
282
+ 2. Generates restore plan by comparing file hashes:
283
+ - `create` — File doesn't exist locally
284
+ - `skip` — File is identical (same hash)
285
+ - `overwrite` — File has been modified
286
+ 3. Creates automatic safety backup of files to be overwritten (tagged `_pre-restore_`)
287
+ 4. Extracts and restores files to original locations
288
+ 5. Validates symlinks to prevent security attacks
289
+
290
+ **Options:**
291
+
292
+ | Option | Description |
293
+ |--------|-------------|
294
+ | `--dry-run` | Show restore plan without actually restoring |
295
+
296
+ **Usage:**
297
+
298
+ ```bash
299
+ # Interactive: select from available backups
300
+ npx @lumy-pack/syncpoint restore
301
+
302
+ # Restore specific backup
303
+ npx @lumy-pack/syncpoint restore macbook-pro_2024-01-15.tar.gz
304
+
305
+ # Preview restore actions
306
+ npx @lumy-pack/syncpoint restore --dry-run
307
+ ```
308
+
309
+ **Safety Features:**
310
+ - Automatic safety backup before any file is overwritten
311
+ - Hash-based comparison to skip identical files
312
+ - Symlink validation to prevent directory traversal attacks
313
+
314
+ ---
315
+
316
+ ### `syncpoint provision [template] [options]`
317
+
318
+ Run template-based machine provisioning to install software and configure your system.
319
+
320
+ **What it does:**
321
+ 1. Loads template YAML from `~/.syncpoint/templates/` (by name) or from a custom path (with `--file`)
322
+ 2. Validates template structure and security
323
+ 3. Checks for sudo requirement (prompts if needed)
324
+ 4. Executes steps sequentially with real-time progress
325
+ 5. Evaluates `skip_if` conditions before running steps
326
+ 6. Captures command output and handles errors
327
+ 7. Optionally restores config backup after provisioning
328
+
329
+ **Options:**
330
+
331
+ | Option | Description |
332
+ |--------|-------------|
333
+ | `-f, --file <path>` | Path to template file (alternative to template name) |
334
+ | `--dry-run` | Show execution plan without running commands |
335
+ | `--skip-restore` | Skip automatic config restore after provisioning |
336
+
337
+ **Usage:**
338
+
339
+ ```bash
340
+ # Run provisioning template by name
341
+ npx @lumy-pack/syncpoint provision my-setup
342
+
343
+ # Run template from custom path
344
+ npx @lumy-pack/syncpoint provision --file ./my-template.yml
345
+
346
+ # Use short flag with relative path
347
+ npx @lumy-pack/syncpoint provision -f ~/templates/custom.yaml
348
+
349
+ # Preview template execution
350
+ npx @lumy-pack/syncpoint provision my-setup --dry-run
351
+
352
+ # Provision without restoring configs
353
+ npx @lumy-pack/syncpoint provision my-setup --skip-restore
354
+
355
+ # Combine --file with other options
356
+ npx @lumy-pack/syncpoint provision -f ./template.yml --dry-run --skip-restore
357
+ ```
358
+
359
+ **Path Resolution:**
360
+ - Supports absolute paths: `/path/to/template.yml`
361
+ - Supports relative paths: `./template.yml`, `../templates/setup.yaml`
362
+ - Supports tilde expansion: `~/templates/custom.yml`
363
+ - Must have `.yml` or `.yaml` extension
364
+
365
+ **Security:**
366
+ - Blocks dangerous remote script patterns (`curl | bash`, `wget | sh`)
367
+ - Sanitizes error output to mask sensitive paths and credentials
368
+ - Validates all templates against schema
369
+ - 5-minute timeout per step
370
+
371
+ ---
372
+
373
+ ### `syncpoint list [type]`
374
+
375
+ Browse and manage backups and templates interactively.
376
+
377
+ **What it does:**
378
+ - Displays interactive menu to browse backups or templates
379
+ - Shows detailed metadata (size, date, file count, description)
380
+ - Allows safe deletion of backups with confirmation
381
+ - Previews template steps and configuration
382
+
383
+ **Usage:**
384
+
385
+ ```bash
386
+ # Interactive menu
387
+ npx @lumy-pack/syncpoint list
388
+
389
+ # Direct navigation
390
+ npx @lumy-pack/syncpoint list backups
391
+ npx @lumy-pack/syncpoint list templates
392
+ ```
393
+
394
+ **Navigation:**
395
+ - Use arrow keys to select items
396
+ - Press Enter to view details
397
+ - Press ESC to go back
398
+ - Confirm before deletion
399
+
400
+ ---
401
+
402
+ ### `syncpoint status [options]`
403
+
404
+ Show status summary and manage cleanup of `~/.syncpoint/` directory.
405
+
406
+ **What it does:**
407
+ - Scans all subdirectories and calculates statistics
408
+ - Displays file counts and total sizes
409
+ - Shows backup timeline (newest and oldest)
410
+ - Optional cleanup mode with multiple strategies
411
+
412
+ **Options:**
413
+
414
+ | Option | Description |
415
+ |--------|-------------|
416
+ | `--cleanup` | Enter interactive cleanup mode |
417
+
418
+ **Usage:**
419
+
420
+ ```bash
421
+ # Show status summary
422
+ npx @lumy-pack/syncpoint status
423
+
424
+ # Cleanup old backups
425
+ npx @lumy-pack/syncpoint status --cleanup
426
+ ```
427
+
428
+ **Cleanup Strategies:**
429
+ - Keep only 5 most recent backups
430
+ - Remove backups older than 30 days
431
+ - Delete all log files
432
+ - Manual selection for precise control
433
+
434
+ ---
435
+
436
+ ## ⚙️ Configuration
437
+
438
+ Syncpoint uses `~/.syncpoint/config.yml` for configuration.
439
+
440
+ ### Configuration Schema
441
+
442
+ ```yaml
443
+ backup:
444
+ # (Required) List of files/directories to backup
445
+ # Supports three pattern types:
446
+ # - Literal paths: ~/.zshrc, /etc/hosts
447
+ # - Glob patterns: ~/.config/*.conf, **/*.toml
448
+ # - Regex patterns: /\.conf$/, /\.toml$/ (scans ~/ with depth limit 5)
449
+ targets:
450
+ - ~/.zshrc
451
+ - ~/.zprofile
452
+ - ~/.gitconfig
453
+ - ~/.ssh/config
454
+ - ~/.config/**/*.conf
455
+ # Example regex: /\.toml$/ finds all .toml files in home directory
456
+
457
+ # (Required) Patterns to exclude from backup
458
+ # Supports glob and regex patterns
459
+ exclude:
460
+ - "**/*.swp"
461
+ - "**/.DS_Store"
462
+ - "**/node_modules"
463
+ # Example regex: "/\\.bak$/" excludes all .bak files
464
+
465
+ # (Required) Backup filename pattern
466
+ # Available placeholders: {hostname}, {date}, {time}, {datetime}, {tag}
467
+ filename: "{hostname}_{datetime}"
468
+
469
+ # (Optional) Custom backup destination
470
+ # Default: ~/.syncpoint/backups/
471
+ destination: ~/Backups
472
+
473
+ scripts:
474
+ # (Optional) Include ~/.syncpoint/scripts/ in backups
475
+ # Default: true
476
+ includeInBackup: true
477
+ ```
478
+
479
+ ### Filename Placeholders
480
+
481
+ | Placeholder | Example | Description |
482
+ |-------------|---------|-------------|
483
+ | `{hostname}` | `macbook-pro` | System hostname |
484
+ | `{date}` | `2024-01-15` | Current date (YYYY-MM-DD) |
485
+ | `{time}` | `14-30-00` | Current time (HH-MM-SS) |
486
+ | `{datetime}` | `2024-01-15_14-30-00` | Combined date and time |
487
+ | `{tag}` | `before-upgrade` | Custom tag from `--tag` option |
488
+
489
+ ### Pattern Types
490
+
491
+ Syncpoint supports three types of patterns for `targets` and `exclude` fields:
492
+
493
+ #### Literal Paths
494
+
495
+ Direct file or directory paths. Tilde (`~`) is automatically expanded to home directory.
496
+
497
+ **Examples:**
498
+ - `~/.zshrc` — Specific file in home directory
499
+ - `/etc/hosts` — Absolute path
500
+ - `~/.ssh/config` — Nested file
501
+
502
+ #### Glob Patterns
503
+
504
+ Wildcard patterns for matching multiple files. Uses standard glob syntax.
505
+
506
+ **Examples:**
507
+ - `*.conf` — All .conf files in current directory
508
+ - `~/.config/*.yml` — All .yml files in ~/.config/
509
+ - `**/*.toml` — All .toml files recursively
510
+ - `~/.config/**/*.conf` — All .conf files under ~/.config/ recursively
511
+
512
+ **Glob metacharacters:** `*` (any), `?` (single), `{a,b}` (alternatives)
513
+
514
+ #### Regex Patterns
515
+
516
+ Regular expressions for advanced pattern matching. Must be enclosed in forward slashes (`/pattern/`).
517
+
518
+ **Format:** `/pattern/` (e.g., `/\.conf$/`)
519
+
520
+ **Examples:**
521
+ - `/\.conf$/` — Files ending with .conf
522
+ - `/\.toml$/` — Files ending with .toml
523
+ - `/\.(bak|tmp)$/` — Files ending with .bak or .tmp
524
+ - `/^\.config\//` — Files starting with .config/
525
+
526
+ **Limitations:**
527
+ - Regex targets scan home directory (`~/`) only
528
+ - Maximum depth: 5 levels for performance
529
+ - No unescaped forward slashes in pattern body
530
+
531
+ **When to use regex:**
532
+ - Complex extension matching: `/\.(conf|toml|yaml)$/`
533
+ - Pattern-based exclusions: `/\.(bak|tmp|cache)$/`
534
+ - Path prefix/suffix matching
535
+
536
+ ### Example Configuration
537
+
538
+ ```yaml
539
+ backup:
540
+ targets:
541
+ - ~/.zshrc
542
+ - ~/.zprofile
543
+ - ~/.gitconfig
544
+ - ~/.gitignore_global
545
+ - ~/.ssh/config
546
+ - ~/.config/starship.toml
547
+ - ~/Documents/notes
548
+
549
+ exclude:
550
+ - "**/*.swp"
551
+ - "**/*.tmp"
552
+ - "**/.DS_Store"
553
+ - "**/*cache*"
554
+
555
+ filename: "{hostname}_{date}_{tag}"
556
+ destination: ~/Dropbox/backups
557
+
558
+ scripts:
559
+ includeInBackup: true
560
+ ```
561
+
562
+ ---
563
+
564
+ ## 📝 Provisioning Templates
565
+
566
+ Templates are YAML files stored in `~/.syncpoint/templates/` that define automated provisioning steps.
567
+
568
+ ### Template Schema
569
+
570
+ ```yaml
571
+ # (Required) Template name
572
+ name: string
573
+
574
+ # (Optional) Template description
575
+ description: string
576
+
577
+ # (Optional) Backup to restore after provisioning
578
+ backup: string
579
+
580
+ # (Optional) Require sudo privilege
581
+ sudo: boolean
582
+
583
+ # (Required) List of provisioning steps
584
+ steps:
585
+ - name: string # (Required) Step name
586
+ description: string # (Optional) Step description
587
+ command: string # (Required) Shell command to execute
588
+ skip_if: string # (Optional) Skip if this command succeeds
589
+ continue_on_error: boolean # (Optional) Continue on failure (default: false)
590
+ ```
591
+
592
+ ### Example Template
593
+
594
+ Create `~/.syncpoint/templates/dev-setup.yml`:
595
+
596
+ ```yaml
597
+ name: Development Setup
598
+ description: Install development tools and configure environment
599
+ sudo: true
600
+
601
+ steps:
602
+ - name: Update System
603
+ description: Update package manager
604
+ command: apt-get update && apt-get upgrade -y
605
+
606
+ - name: Install Git
607
+ command: apt-get install -y git
608
+ skip_if: which git
609
+
610
+ - name: Install Node.js
611
+ command: curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
612
+ skip_if: which node
613
+
614
+ - name: Install pnpm
615
+ command: npm install -g pnpm
616
+ skip_if: which pnpm
617
+
618
+ - name: Configure Git
619
+ command: |
620
+ git config --global user.name "Your Name"
621
+ git config --global user.email "your.email@example.com"
622
+ continue_on_error: true
623
+
624
+ - name: Clone Repositories
625
+ description: Clone important repositories
626
+ command: |
627
+ mkdir -p ~/projects
628
+ cd ~/projects
629
+ git clone https://github.com/username/repo.git
630
+ ```
631
+
632
+ ### Running Templates
633
+
634
+ ```bash
635
+ # Run template by name (from ~/.syncpoint/templates/)
636
+ npx @lumy-pack/syncpoint provision dev-setup
637
+
638
+ # Run template from custom path
639
+ npx @lumy-pack/syncpoint provision --file ./my-template.yml
640
+
641
+ # Preview template execution
642
+ npx @lumy-pack/syncpoint provision dev-setup --dry-run
643
+
644
+ # Run and skip config restore
645
+ npx @lumy-pack/syncpoint provision dev-setup --skip-restore
646
+
647
+ # Combine custom path with options
648
+ npx @lumy-pack/syncpoint provision -f ~/templates/setup.yaml --dry-run
649
+ ```
650
+
651
+ ---
652
+
653
+ ## 📁 Directory Structure
654
+
655
+ After initialization, syncpoint creates the following structure:
656
+
657
+ ```
658
+ ~/.syncpoint/
659
+ ├── config.yml # Main configuration file
660
+ ├── backups/ # Backup archives (tar.gz)
661
+ │ ├── host1_2024-01-15.tar.gz
662
+ │ └── host1_2024-01-20.tar.gz
663
+ ├── templates/ # Provisioning templates (YAML)
664
+ │ ├── example.yml
665
+ │ └── dev-setup.yml
666
+ ├── scripts/ # Optional shell scripts to include in backups
667
+ │ └── custom-script.sh
668
+ └── logs/ # Operation logs
669
+ ```
670
+
671
+ ### Backup Archive Contents
672
+
673
+ Each backup archive contains:
674
+ - Your configuration files in their relative paths
675
+ - `_metadata.json` with backup information:
676
+ - File hashes for comparison
677
+ - System information (hostname, platform, architecture)
678
+ - Backup creation timestamp
679
+ - File count and total size
680
+
681
+ ---
682
+
683
+ ## 💡 Examples
684
+
685
+ ### Backup and Restore Workflow
686
+
687
+ **On your current machine:**
688
+
689
+ ```bash
690
+ # Initialize and configure
691
+ npx @lumy-pack/syncpoint init
692
+ vim ~/.syncpoint/config.yml # Edit targets
693
+
694
+ # Create backup
695
+ npx @lumy-pack/syncpoint backup --tag "work-setup"
696
+ ```
697
+
698
+ **On a new machine:**
699
+
700
+ ```bash
701
+ # Initialize (no installation needed with npx!)
702
+ npx @lumy-pack/syncpoint init
703
+
704
+ # Copy backup file to ~/.syncpoint/backups/
705
+ # Or set custom destination in config.yml
706
+
707
+ # Restore
708
+ npx @lumy-pack/syncpoint restore
709
+ # Select your backup from the list
710
+ ```
711
+
712
+ ### Machine Provisioning Workflow
713
+
714
+ **Setup a new development machine:**
715
+
716
+ ```bash
717
+ # Initialize syncpoint
718
+ npx @lumy-pack/syncpoint init
719
+
720
+ # Create provisioning template
721
+ cat > ~/.syncpoint/templates/new-machine.yml << 'EOF'
722
+ name: New Machine Setup
723
+ description: Complete development environment setup
724
+ sudo: true
725
+
726
+ steps:
727
+ - name: Install Homebrew
728
+ command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
729
+ skip_if: which brew
730
+
731
+ - name: Install Core Tools
732
+ command: brew install git vim tmux
733
+
734
+ - name: Install Node.js
735
+ command: brew install node@20
736
+ skip_if: which node
737
+
738
+ - name: Install pnpm
739
+ command: npm install -g pnpm
740
+ skip_if: which pnpm
741
+ EOF
742
+
743
+ # Preview execution
744
+ npx @lumy-pack/syncpoint provision new-machine --dry-run
745
+
746
+ # Run provisioning
747
+ npx @lumy-pack/syncpoint provision new-machine
748
+ ```
749
+
750
+ ### Cleanup Old Backups
751
+
752
+ ```bash
753
+ # Check current status
754
+ npx @lumy-pack/syncpoint status
755
+
756
+ # Interactive cleanup
757
+ npx @lumy-pack/syncpoint status --cleanup
758
+
759
+ # Options:
760
+ # 1. Keep only 5 most recent backups
761
+ # 2. Remove backups older than 30 days
762
+ # 3. Delete all logs
763
+ # 4. Manual selection
764
+ ```
765
+
766
+ ---
767
+
768
+ ## 🛡️ Security Features
769
+
770
+ Syncpoint includes multiple security layers to protect your data and system:
771
+
772
+ ### Backup Security
773
+
774
+ - **Sensitive File Warnings** — Alerts when backing up SSH keys, certificates, or private keys
775
+ - Patterns: `id_rsa`, `id_ed25519`, `*.pem`, `*.key`
776
+ - **Large File Warnings** — Warns about files larger than 10MB
777
+ - **File Hashing** — SHA-256 hashes for reliable file comparison
778
+
779
+ ### Restore Security
780
+
781
+ - **Automatic Safety Backups** — Creates `_pre-restore_` backup before overwriting files
782
+ - **Hash Comparison** — Skips identical files to prevent unnecessary changes
783
+ - **Symlink Validation** — Prevents symlink attacks and directory traversal
784
+ - **Dry-run Mode** — Preview all changes before applying
785
+
786
+ ### Provisioning Security
787
+
788
+ - **Remote Script Blocking** — Blocks dangerous patterns:
789
+ - `curl ... | bash`
790
+ - `wget ... | sh`
791
+ - `curl ... | python`
792
+ - Any pipe to shell execution from remote sources
793
+ - **Error Sanitization** — Masks sensitive information in error output (paths, passwords, tokens)
794
+ - **Template Validation** — JSON Schema validation for all templates
795
+ - **Sudo Handling** — Prompts for elevation only when required
796
+ - **Command Timeout** — 5-minute timeout per step prevents hanging
797
+
798
+ ### General Safety
799
+
800
+ - **Path Validation** — Prevents operations outside allowed directories
801
+ - **Deletion Restrictions** — Only allows deletion within syncpoint directories
802
+ - **Permission Checks** — Validates file permissions before operations
803
+
804
+ ---
805
+
806
+ ## 🔧 Troubleshooting
807
+
808
+ ### Wizard Commands
809
+
810
+ **Claude Code CLI not found**
811
+
812
+ If you see "Claude Code CLI not found" error:
813
+ 1. Install Claude Code CLI: Visit [claude.ai/code](https://claude.ai/code) for installation instructions
814
+ 2. Or use `--print` mode to get the prompt and use it with your preferred LLM
815
+ 3. Verify installation: `claude --version`
816
+
817
+ **Validation errors after LLM generation**
818
+
819
+ The wizard automatically retries up to 3 times when validation fails:
820
+ - Each retry includes error feedback to help the LLM correct the issues
821
+ - If all retries fail, check the validation error messages
822
+ - Common issues:
823
+ - Missing required fields (`backup.targets`, `backup.exclude`, `backup.filename`)
824
+ - Invalid pattern syntax in targets/exclude arrays
825
+ - Empty or malformed YAML structure
826
+
827
+ **Print mode usage**
828
+
829
+ Use `--print` mode when Claude Code is not available:
830
+ ```bash
831
+ # Get the prompt
832
+ npx @lumy-pack/syncpoint wizard --print > prompt.txt
833
+
834
+ # Copy prompt.txt to your LLM
835
+ # Save the YAML response to ~/.syncpoint/config.yml
836
+ ```
837
+
838
+ **Session context lost**
839
+
840
+ The wizard preserves session context across retries using Claude Code's session management. If context is lost:
841
+ - The wizard will start a new session on the next retry
842
+ - Manual intervention may be needed after 3 failed attempts
843
+
844
+ ### General Issues
845
+
846
+ **Permission errors**
847
+
848
+ If you encounter permission errors:
849
+ - Ensure you have write access to `~/.syncpoint/`
850
+ - Check file permissions: `ls -la ~/.syncpoint/`
851
+ - Run with appropriate permissions (avoid unnecessary sudo)
852
+
853
+ **Large file warnings**
854
+
855
+ Files larger than 10MB trigger warnings:
856
+ - Consider excluding large files using `exclude` patterns
857
+ - Review if these files should be in version control instead
858
+ - Compress large files before backing up
859
+
860
+ **Backup restore conflicts**
861
+
862
+ If restore shows many "overwrite" actions:
863
+ - Use `--dry-run` to preview changes first
864
+ - Automatic safety backup is created before overwrite
865
+ - Review the safety backup in `~/.syncpoint/backups/` tagged with `_pre-restore_`
866
+
867
+ ---
868
+
869
+ ## 🔧 Development
870
+
871
+ ### Build and Test
872
+
873
+ ```bash
874
+ # Install dependencies
875
+ pnpm install
876
+
877
+ # Development mode
878
+ pnpm dev
879
+
880
+ # Build
881
+ pnpm build
882
+
883
+ # Run tests
884
+ pnpm test
885
+
886
+ # Run all tests (unit + integration + e2e + docker)
887
+ pnpm test:all
888
+
889
+ # Lint and format
890
+ pnpm lint
891
+ pnpm format
892
+ ```
893
+
894
+ ### Technology Stack
895
+
896
+ - **CLI Framework:** Commander.js
897
+ - **Terminal UI:** Ink + React
898
+ - **Configuration:** YAML parsing
899
+ - **Validation:** AJV (JSON Schema)
900
+ - **File Operations:** fast-glob, tar
901
+ - **Build:** tsup, TypeScript
902
+ - **Testing:** Vitest
903
+
904
+ ### Project Structure
905
+
906
+ ```
907
+ packages/syncpoint/
908
+ ├── src/
909
+ │ ├── cli.ts # CLI entry point
910
+ │ ├── commands/ # Command implementations
911
+ │ ├── core/ # Core logic (backup, restore, provision)
912
+ │ ├── schemas/ # JSON Schema validation
913
+ │ ├── components/ # React/Ink UI components
914
+ │ └── utils/ # Utilities
915
+ ├── assets/
916
+ │ ├── config.default.yml # Default configuration
917
+ │ └── template.example.yml # Example template
918
+ └── tests/
919
+ ├── unit/
920
+ ├── integration/
921
+ ├── e2e/
922
+ └── docker/
923
+ ```
924
+
925
+ ---
926
+
927
+ ## 📄 License
928
+
929
+ MIT © [Vincent K. Kelvin](https://github.com/vincent-kk)
930
+
931
+ ---
932
+
933
+ ## 🤝 Contributing
934
+
935
+ Contributions are welcome! Please feel free to submit a Pull Request.
936
+
937
+ ## 🐛 Issues
938
+
939
+ If you encounter any issues or have questions, please [open an issue](https://github.com/vincent-kk/lumy-pack/issues) on GitHub.
940
+
941
+ ---
942
+
943
+ Made with ❤️ by Vincent K. Kelvin