undoai 0.1.0-beta.2 → 1.0.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/USAGE.md ADDED
@@ -0,0 +1,474 @@
1
+ # undoai Usage Guide
2
+
3
+ Detailed guide for using undoai effectively.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Installation](#installation)
8
+ - [Basic Usage](#basic-usage)
9
+ - [Common Workflows](#common-workflows)
10
+ - [Advanced Usage](#advanced-usage)
11
+ - [Troubleshooting](#troubleshooting)
12
+ - [Best Practices](#best-practices)
13
+
14
+ ## Installation
15
+
16
+ ### Option 1: Use from Source
17
+
18
+ ```bash
19
+ # Clone repository
20
+ git clone <your-repo-url>
21
+ cd undoai
22
+
23
+ # Install dependencies
24
+ pnpm install
25
+
26
+ # Build
27
+ pnpm build
28
+
29
+ # Run
30
+ node dist/cli/index.js <command>
31
+ ```
32
+
33
+ ### Option 2: Global Installation (Recommended)
34
+
35
+ ```bash
36
+ # After building
37
+ pnpm link --global
38
+
39
+ # Now use anywhere
40
+ undoai watch
41
+ undoai restore
42
+ undoai status
43
+ ```
44
+
45
+ ## Basic Usage
46
+
47
+ ### Start Watching
48
+
49
+ Navigate to your project directory and start watching:
50
+
51
+ ```bash
52
+ cd ~/my-project
53
+ undoai watch
54
+ ```
55
+
56
+ **Output:**
57
+ ```
58
+ ✅ undoai is now watching
59
+ 📁 Project: /home/user/my-project
60
+ 💾 Storage: /home/user/.undoai
61
+ 🔒 100% local - your code never leaves this machine
62
+
63
+ â„šī¸ Watching for file changes... (Press Ctrl+C to stop)
64
+ ```
65
+
66
+ Leave this terminal running. Open a new terminal for coding.
67
+
68
+ ### Make Changes
69
+
70
+ Work normally with your AI coding assistant (Cursor, Claude, etc). When AI modifies 5+ files:
71
+
72
+ ```
73
+ 📝 [change] src/auth.ts
74
+ 📝 [change] src/db.ts
75
+ 📝 [add] src/utils.ts
76
+ 📝 [change] package.json
77
+ 📝 [delete] old-file.ts
78
+ 📸 Snapshot saved (5 files changed)
79
+ Snapshot ID: 1703265420000
80
+ ```
81
+
82
+ ### Restore from Snapshot
83
+
84
+ If AI breaks something:
85
+
86
+ ```bash
87
+ undoai restore
88
+ ```
89
+
90
+ **Interactive selection:**
91
+ ```
92
+ â„šī¸ Available snapshots:
93
+
94
+ ? Which snapshot do you want to restore?
95
+ ❯ 1. [2 mins ago] 5 files 🤖 AI
96
+ 2. [15 mins ago] 8 files 🤖 AI
97
+ 3. [1 hour ago] 3 files 🤖 AI
98
+ ❌ Cancel
99
+
100
+ ? This will overwrite current files. Continue? (Y/n)
101
+ ```
102
+
103
+ Select snapshot and confirm. Files will be restored instantly.
104
+
105
+ ## Common Workflows
106
+
107
+ ### Workflow 1: Safe AI Experimentation
108
+
109
+ ```bash
110
+ # 1. Start watcher
111
+ undoai watch
112
+
113
+ # 2. Ask AI to refactor your code
114
+ # AI modifies multiple files
115
+ # → Snapshot automatically created
116
+
117
+ # 3. Test the changes
118
+ npm test
119
+
120
+ # 4a. If it works - great! Continue coding
121
+
122
+ # 4b. If it breaks - instant rollback
123
+ undoai restore # Select latest snapshot
124
+ ```
125
+
126
+ ### Workflow 2: Multiple Attempts
127
+
128
+ ```bash
129
+ # 1. Start watcher
130
+ undoai watch
131
+
132
+ # 2. Try approach A (AI generates code)
133
+ # → Snapshot #1 created
134
+
135
+ # 3. Test - doesn't work perfectly
136
+
137
+ # 4. Try approach B (AI rewrites)
138
+ # → Snapshot #2 created
139
+
140
+ # 5. Test - worse! Go back to A
141
+ undoai restore # Select snapshot #1
142
+ ```
143
+
144
+ ### Workflow 3: Before Big Changes
145
+
146
+ ```bash
147
+ # Before asking AI to make big changes:
148
+
149
+ # 1. Check current status
150
+ undoai status
151
+
152
+ # 2. Start watcher if not running
153
+ undoai watch
154
+
155
+ # 3. Proceed with AI changes
156
+ # → Automatic snapshots created
157
+
158
+ # 4. If needed, restore
159
+ undoai restore
160
+ ```
161
+
162
+ ## Advanced Usage
163
+
164
+ ### Custom Burst Threshold
165
+
166
+ Edit `src/cli/commands/watch.ts`:
167
+
168
+ ```typescript
169
+ const watcher = new FileWatcher({
170
+ watchPath: projectRoot,
171
+ onBurstChange: (changedFiles) => { /* ... */ },
172
+ burstThreshold: 3, // Change to 3 files instead of 5
173
+ debounceDelay: 2000,
174
+ });
175
+ ```
176
+
177
+ Then rebuild:
178
+ ```bash
179
+ pnpm build
180
+ ```
181
+
182
+ ### Manual Snapshot Inspection
183
+
184
+ ```bash
185
+ # View all snapshots
186
+ ls -la ~/.undoai/snapshots/
187
+
188
+ # View specific snapshot metadata
189
+ cat ~/.undoai/snapshots/1703265420000/metadata.json
190
+
191
+ # View saved files
192
+ ls ~/.undoai/snapshots/1703265420000/files/
193
+ ```
194
+
195
+ ### Clean Up Old Snapshots
196
+
197
+ ```bash
198
+ # Remove all snapshots
199
+ rm -rf ~/.undoai/snapshots/*
200
+
201
+ # Remove specific snapshot
202
+ rm -rf ~/.undoai/snapshots/1703265420000
203
+
204
+ # Or remove snapshots older than 7 days
205
+ find ~/.undoai/snapshots -mtime +7 -type d -exec rm -rf {} +
206
+ ```
207
+
208
+ ### Export/Backup Snapshots
209
+
210
+ ```bash
211
+ # Backup all snapshots
212
+ tar -czf undoai-backup.tar.gz ~/.undoai/
213
+
214
+ # Restore backup
215
+ tar -xzf undoai-backup.tar.gz -C ~/
216
+ ```
217
+
218
+ ## Troubleshooting
219
+
220
+ ### Problem: "undoai is already watching"
221
+
222
+ **Cause:** Watcher is already running
223
+
224
+ **Solution:**
225
+ ```bash
226
+ # Check if running
227
+ undoai status
228
+
229
+ # Stop it
230
+ undoai stop
231
+
232
+ # Or find and kill process
233
+ ps aux | grep "undoai watch"
234
+ kill <PID>
235
+
236
+ # Then start again
237
+ undoai watch
238
+ ```
239
+
240
+ ### Problem: "No snapshots available"
241
+
242
+ **Cause:** No burst detected yet (< 5 files changed)
243
+
244
+ **Solution:**
245
+ - Make sure watcher is running (`undoai status`)
246
+ - Modify at least 5 files
247
+ - Wait 2 seconds for snapshot creation
248
+ - Or lower burst threshold (see Advanced Usage)
249
+
250
+ ### Problem: Snapshot not created
251
+
252
+ **Possible causes:**
253
+
254
+ 1. **Not enough files changed**
255
+ - Default threshold: 5 files
256
+ - Check: `undoai status`
257
+
258
+ 2. **Changes too slow**
259
+ - Debounce timer resets after 2s of inactivity
260
+ - Quick burst needed
261
+
262
+ 3. **Files in ignored directories**
263
+ - `node_modules`, `.git`, `dist`, `build` are ignored
264
+
265
+ 4. **Permission issues**
266
+ - Check write permissions for `~/.undoai/`
267
+
268
+ **Debug:**
269
+ ```bash
270
+ # Check watcher output in terminal
271
+ # Should see individual file changes logged:
272
+ 📝 [change] src/file1.ts
273
+ 📝 [change] src/file2.ts
274
+ ...
275
+ ```
276
+
277
+ ### Problem: Restore fails
278
+
279
+ **Error: "Snapshot was created in different project"**
280
+
281
+ **Cause:** Snapshot from different directory
282
+
283
+ **Solution:**
284
+ - Snapshots are project-specific
285
+ - Navigate to correct project directory:
286
+ ```bash
287
+ cd /path/to/original/project
288
+ undoai restore
289
+ ```
290
+
291
+ **Error: "Snapshot file not found"**
292
+
293
+ **Cause:** File moved/renamed in original project
294
+
295
+ **Solution:**
296
+ - File paths in snapshot are absolute
297
+ - If project moved, snapshot won't match
298
+ - This is a known limitation
299
+
300
+ ## Best Practices
301
+
302
+ ### 1. Always Run Watcher
303
+
304
+ Start watcher at beginning of coding session:
305
+ ```bash
306
+ # Add to your workflow
307
+ cd ~/my-project
308
+ undoai watch & # Run in background
309
+ ```
310
+
311
+ Or use a terminal multiplexer (tmux/screen).
312
+
313
+ ### 2. Check Status Regularly
314
+
315
+ ```bash
316
+ undoai status
317
+ ```
318
+
319
+ Verify:
320
+ - ✅ Watcher is running
321
+ - ✅ Snapshots are being created
322
+ - ✅ Storage size is reasonable
323
+
324
+ ### 3. Combine with Git
325
+
326
+ undoai complements git:
327
+
328
+ ```bash
329
+ # Normal workflow
330
+ git commit -m "working state"
331
+
332
+ # Let AI make changes
333
+ # → undoai creates snapshots
334
+
335
+ # If AI breaks it
336
+ undoai restore # Quick rollback
337
+
338
+ # If AI improves it
339
+ git add .
340
+ git commit -m "AI improvements"
341
+ ```
342
+
343
+ ### 4. Clean Up Periodically
344
+
345
+ ```bash
346
+ # Check storage size
347
+ undoai status
348
+
349
+ # If too large, remove old snapshots
350
+ # Keep last 10 snapshots
351
+ ls -t ~/.undoai/snapshots/ | tail -n +11 | xargs -I {} rm -rf ~/.undoai/snapshots/{}
352
+ ```
353
+
354
+ ### 5. Test Immediately
355
+
356
+ After AI changes:
357
+ 1. Let snapshot be created (wait 2s)
358
+ 2. Test immediately
359
+ 3. If broken, restore before making more changes
360
+
361
+ ### 6. Use for Experiments
362
+
363
+ When trying new approaches:
364
+ ```bash
365
+ # Current state -> snapshot
366
+ # Try approach A -> snapshot
367
+ # Try approach B -> snapshot
368
+ # Compare and choose best
369
+ ```
370
+
371
+ ### 7. Don't Rely on Forever
372
+
373
+ Snapshots are temporary safety net, not long-term backup:
374
+ - Use git for version control
375
+ - Use undoai for instant rollback
376
+ - Don't keep snapshots for months
377
+
378
+ ## Configuration Tips
379
+
380
+ ### Ignore Additional Directories
381
+
382
+ Edit `src/watcher.ts`:
383
+
384
+ ```typescript
385
+ ignored: [
386
+ '**/node_modules/**',
387
+ '**/.git/**',
388
+ '**/dist/**',
389
+ '**/build/**',
390
+ '**/coverage/**', // Add your directories
391
+ '**/.next/**',
392
+ '**/vendor/**',
393
+ ],
394
+ ```
395
+
396
+ ### Adjust Timing
397
+
398
+ Faster burst detection (1 second):
399
+ ```typescript
400
+ debounceDelay: 1000, // Was 2000
401
+ ```
402
+
403
+ Detect smaller changes (3 files):
404
+ ```typescript
405
+ burstThreshold: 3, // Was 5
406
+ ```
407
+
408
+ Rebuild after changes:
409
+ ```bash
410
+ pnpm build
411
+ ```
412
+
413
+ ## Examples
414
+
415
+ ### Example: Refactoring Session
416
+
417
+ ```bash
418
+ # Start
419
+ $ undoai watch
420
+ ✅ undoai is now watching
421
+
422
+ # Ask AI: "refactor auth module"
423
+ # AI modifies: auth.ts, types.ts, utils.ts, test.ts, index.ts
424
+ 📸 Snapshot saved (5 files changed)
425
+
426
+ # Test
427
+ $ npm test
428
+ FAIL
429
+
430
+ # Instant rollback
431
+ $ undoai restore
432
+ ? Which snapshot? ❯ 1. [1 min ago] 5 files 🤖 AI
433
+ ✅ Restored 5 files
434
+
435
+ # Try different approach
436
+ # Ask AI: "refactor auth module using different pattern"
437
+ 📸 Snapshot saved (5 files changed)
438
+
439
+ # Test
440
+ $ npm test
441
+ PASS ✅
442
+
443
+ # Keep this version!
444
+ $ git add .
445
+ $ git commit -m "refactor: improve auth module"
446
+ ```
447
+
448
+ ### Example: Feature Development
449
+
450
+ ```bash
451
+ # Planning
452
+ $ undoai watch
453
+ $ undoai status
454
+ đŸŸĸ Running
455
+
456
+ # Development
457
+ # Ask AI: "add user profile feature"
458
+ # AI creates multiple files
459
+ 📸 Snapshot saved (7 files changed)
460
+
461
+ # Review changes
462
+ # Looks good but one file needs tweaking
463
+
464
+ # Manual edit that one file
465
+ # Other 6 files are perfect
466
+
467
+ # Commit
468
+ $ git add .
469
+ $ git commit -m "feat: add user profiles"
470
+ ```
471
+
472
+ ---
473
+
474
+ **Need help?** Check [README.md](./README.md) or open a GitHub issue.
@@ -0,0 +1 @@
1
+ # Demo Feature
@@ -0,0 +1 @@
1
+ export const config = { apiKey: 'demo' };
@@ -0,0 +1 @@
1
+ import { UserService } from './user-service';
@@ -0,0 +1 @@
1
+ export interface User { id: string; name: string; }
@@ -0,0 +1 @@
1
+ export class UserService { }
package/dist/cli/index.js CHANGED
File without changes
@@ -0,0 +1,5 @@
1
+ 💎 Premium add-ons (optional):
2
+ Cloud backup (encrypted sync across machines)
3
+ Advanced security scanning
4
+ Team collaboration features
5
+ Priority support
package/package.json CHANGED
@@ -1,23 +1,17 @@
1
1
  {
2
2
  "name": "undoai",
3
- "version": "0.1.0-beta.2",
4
- "description": "Free, local undo button for AI coding - automatic snapshots and instant restore",
3
+ "version": "1.0.1",
4
+ "description": "Free, local undo button for AI coding",
5
5
  "main": "dist/cli/index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "undoai": "dist/cli/index.js"
8
+ "undoai": "./dist/cli/index.js"
9
9
  },
10
- "files": [
11
- "dist/",
12
- "README.md",
13
- "LICENSE"
14
- ],
15
10
  "scripts": {
16
11
  "build": "tsc",
17
12
  "dev": "tsc --watch",
18
13
  "start": "node dist/cli/index.js",
19
- "test": "node dist/cli/index.js",
20
- "prepublishOnly": "npm run build"
14
+ "test": "node dist/cli/index.js"
21
15
  },
22
16
  "keywords": [
23
17
  "cli",
@@ -25,35 +19,20 @@
25
19
  "ai",
26
20
  "snapshot",
27
21
  "restore",
28
- "mrq",
29
- "cursor",
30
- "vibe-coding",
31
- "ai-safety",
32
- "development-tools"
22
+ "mrq"
33
23
  ],
34
24
  "author": "",
35
25
  "license": "MIT",
36
- "repository": {
37
- "type": "git",
38
- "url": "https://github.com/yourusername/undo-ai.git"
39
- },
40
- "bugs": {
41
- "url": "https://github.com/yourusername/undo-ai/issues"
42
- },
43
- "homepage": "https://github.com/yourusername/undo-ai#readme",
44
- "engines": {
45
- "node": ">=18.0.0"
46
- },
47
26
  "dependencies": {
48
27
  "chalk": "^5.6.2",
49
28
  "chokidar": "^3.5.3",
50
29
  "commander": "^14.0.2",
30
+ "inquirer": "^9.3.8",
51
31
  "minimatch": "^10.1.1"
52
32
  },
53
33
  "devDependencies": {
54
34
  "@types/inquirer": "^9.0.9",
55
35
  "@types/node": "^20.10.0",
56
- "inquirer": "^9.3.8",
57
36
  "typescript": "^5.3.0"
58
37
  }
59
- }
38
+ }
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # Run All Tests
3
+
4
+ echo "🚀 Running All Week 1 Tests"
5
+ echo "==========================="
6
+ echo ""
7
+
8
+ # Test 1
9
+ echo "â–ļī¸ Running Test 1..."
10
+ bash test-1-burst.sh
11
+
12
+ # Wait a bit
13
+ sleep 2
14
+
15
+ # Test 3
16
+ echo "â–ļī¸ Running Test 3..."
17
+ bash test-3-compression.sh
18
+
19
+ # Test 2 instructions
20
+ echo ""
21
+ echo "â–ļī¸ Test 2 (Selective Restore) - Manual:"
22
+ echo ""
23
+ cat test-2-selective.sh | grep -A 20 "Step 1"
24
+
25
+ echo ""
26
+ echo "🎉 Automated tests complete!"
27
+ echo ""
28
+ echo "Next: Run Test 2 manually with:"
29
+ echo " node dist/cli/index.js restore -i"
30
+ echo ""