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.
@@ -0,0 +1,287 @@
1
+ # Contributing to undoai
2
+
3
+ Thank you for your interest in contributing to undoai! This document provides guidelines for contributing to the project.
4
+
5
+ ## 🚀 Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Node.js 18+ (LTS recommended)
10
+ - pnpm (package manager)
11
+ - Git
12
+ - Basic TypeScript knowledge
13
+
14
+ ### Development Setup
15
+
16
+ 1. **Fork and Clone**
17
+ ```bash
18
+ git clone https://github.com/your-username/undoai.git
19
+ cd undoai
20
+ ```
21
+
22
+ 2. **Install Dependencies**
23
+ ```bash
24
+ pnpm install
25
+ ```
26
+
27
+ 3. **Build the Project**
28
+ ```bash
29
+ pnpm build
30
+ ```
31
+
32
+ 4. **Test Your Changes**
33
+ ```bash
34
+ # Run the CLI locally
35
+ node dist/cli/index.js watch
36
+
37
+ # In another terminal
38
+ bash test-watcher.sh
39
+ ```
40
+
41
+ ## 📁 Project Structure
42
+
43
+ ```
44
+ undoai/
45
+ ├── src/
46
+ │ ├── watcher.ts # File watching logic
47
+ │ ├── core/
48
+ │ │ ├── storage.ts # File storage operations
49
+ │ │ ├── snapshot.ts # Snapshot management
50
+ │ │ └── daemon.ts # Process management
51
+ │ ├── cli/
52
+ │ │ ├── index.ts # CLI entry point
53
+ │ │ └── commands/ # Command implementations
54
+ │ │ ├── watch.ts
55
+ │ │ ├── restore.ts
56
+ │ │ ├── stop.ts
57
+ │ │ └── status.ts
58
+ │ └── utils/
59
+ │ └── logger.ts # Console logging
60
+ ├── dist/ # Compiled output (generated)
61
+ ├── test-files/ # Test files (ignored by git)
62
+ └── test-watcher.sh # Test script
63
+ ```
64
+
65
+ ## 🔧 Development Workflow
66
+
67
+ ### Making Changes
68
+
69
+ 1. **Create a Branch**
70
+ ```bash
71
+ git checkout -b feature/your-feature-name
72
+ # or
73
+ git checkout -b fix/your-bug-fix
74
+ ```
75
+
76
+ 2. **Make Your Changes**
77
+ - Write clean, readable code
78
+ - Follow existing code style
79
+ - Add comments for complex logic
80
+ - Update documentation if needed
81
+
82
+ 3. **Test Your Changes**
83
+ ```bash
84
+ # Build
85
+ pnpm build
86
+
87
+ # Test manually
88
+ node dist/cli/index.js <command>
89
+ ```
90
+
91
+ 4. **Commit Your Changes**
92
+ ```bash
93
+ git add .
94
+ git commit -m "feat: add your feature description"
95
+ # or
96
+ git commit -m "fix: fix your bug description"
97
+ ```
98
+
99
+ Follow [Conventional Commits](https://www.conventionalcommits.org/):
100
+ - `feat:` - New feature
101
+ - `fix:` - Bug fix
102
+ - `docs:` - Documentation only
103
+ - `refactor:` - Code refactoring
104
+ - `test:` - Adding tests
105
+ - `chore:` - Maintenance tasks
106
+
107
+ 5. **Push and Create PR**
108
+ ```bash
109
+ git push origin feature/your-feature-name
110
+ ```
111
+
112
+ Then create a Pull Request on GitHub.
113
+
114
+ ## 📝 Code Style
115
+
116
+ ### TypeScript Guidelines
117
+
118
+ - **Use explicit types** where clarity is needed
119
+ - **Use interfaces** for object shapes
120
+ - **Use const** for variables that don't change
121
+ - **Export types** for public APIs
122
+
123
+ **Example:**
124
+ ```typescript
125
+ // Good
126
+ export interface SnapshotMetadata {
127
+ timestamp: number;
128
+ fileCount: number;
129
+ }
130
+
131
+ function createSnapshot(files: Set<string>): string {
132
+ const snapshotId = Date.now().toString();
133
+ // ...
134
+ return snapshotId;
135
+ }
136
+
137
+ // Avoid
138
+ function createSnapshot(files) { // Missing type
139
+ var id = Date.now(); // Use const
140
+ // ...
141
+ }
142
+ ```
143
+
144
+ ### Naming Conventions
145
+
146
+ - **Files**: `kebab-case.ts` (e.g., `snapshot-manager.ts`)
147
+ - **Classes**: `PascalCase` (e.g., `SnapshotManager`)
148
+ - **Functions**: `camelCase` (e.g., `createSnapshot`)
149
+ - **Constants**: `UPPER_SNAKE_CASE` (e.g., `STORAGE_PATHS`)
150
+ - **Interfaces**: `PascalCase` (e.g., `WatcherOptions`)
151
+
152
+ ### Comments
153
+
154
+ - Use JSDoc for public APIs
155
+ - Explain "why" not "what" in comments
156
+ - Keep comments up-to-date
157
+
158
+ **Example:**
159
+ ```typescript
160
+ /**
161
+ * Create a snapshot from changed files
162
+ * @param changedFiles - Set of file paths that changed
163
+ * @param label - Snapshot label (AI_BURST or AUTO)
164
+ * @returns Snapshot ID (timestamp)
165
+ */
166
+ createSnapshot(changedFiles: Set<string>, label: string): string {
167
+ // Generate timestamp-based ID for chronological sorting
168
+ const snapshotId = Date.now().toString();
169
+ // ...
170
+ }
171
+ ```
172
+
173
+ ## 🧪 Testing Guidelines
174
+
175
+ ### Manual Testing Checklist
176
+
177
+ Before submitting a PR, test:
178
+
179
+ - [ ] `undoai watch` - starts correctly
180
+ - [ ] Burst detection triggers (5+ files)
181
+ - [ ] `undoai restore` - shows snapshots and restores
182
+ - [ ] `undoai stop` - stops watcher
183
+ - [ ] `undoai status` - shows correct info
184
+ - [ ] Edge cases:
185
+ - [ ] Empty snapshots directory
186
+ - [ ] Non-existent snapshot restore
187
+ - [ ] Stopping when not running
188
+ - [ ] Multiple rapid bursts
189
+
190
+ ### Test Script
191
+
192
+ Use the provided test script:
193
+ ```bash
194
+ bash test-watcher.sh
195
+ ```
196
+
197
+ ## 🐛 Bug Reports
198
+
199
+ When reporting bugs, include:
200
+
201
+ 1. **Description** - What happened vs what should happen
202
+ 2. **Steps to Reproduce** - Exact commands run
203
+ 3. **Environment**:
204
+ - OS version
205
+ - Node.js version
206
+ - pnpm version
207
+ 4. **Output** - Console output or error messages
208
+ 5. **Snapshot Info** (if relevant):
209
+ - `undoai status` output
210
+ - Contents of `~/.undoai/`
211
+
212
+ **Example:**
213
+ ```markdown
214
+ ## Bug Description
215
+ `undoai restore` fails when snapshot directory is empty
216
+
217
+ ## Steps to Reproduce
218
+ 1. `rm -rf ~/.undoai/snapshots/*`
219
+ 2. `node dist/cli/index.js restore`
220
+
221
+ ## Expected
222
+ Should show "No snapshots available" message
223
+
224
+ ## Actual
225
+ TypeError: Cannot read property 'length' of undefined
226
+
227
+ ## Environment
228
+ - OS: Ubuntu 22.04
229
+ - Node: v20.10.0
230
+ - pnpm: 8.15.0
231
+ ```
232
+
233
+ ## ✨ Feature Requests
234
+
235
+ For feature requests:
236
+
237
+ 1. **Check Roadmap** - See if already planned in [README.md](./README.md)
238
+ 2. **Open Discussion** - Create a GitHub Discussion first
239
+ 3. **Describe Use Case** - Why is this needed?
240
+ 4. **Suggest Implementation** - How might it work?
241
+
242
+ ## 📦 Adding Dependencies
243
+
244
+ Before adding new dependencies:
245
+
246
+ 1. **Check if really needed** - Can we implement internally?
247
+ 2. **Prefer small packages** - Avoid heavy dependencies
248
+ 3. **Check maintenance** - Is it actively maintained?
249
+ 4. **Document reason** - Why this package?
250
+
251
+ Add to correct section:
252
+ ```bash
253
+ # Production dependency
254
+ pnpm add package-name
255
+
256
+ # Dev dependency
257
+ pnpm add -D package-name
258
+ ```
259
+
260
+ ## 🚀 Release Process
261
+
262
+ (For maintainers)
263
+
264
+ 1. Update version in `package.json`
265
+ 2. Update CHANGELOG.md
266
+ 3. Create git tag:
267
+ ```bash
268
+ git tag v1.0.0
269
+ git push origin v1.0.0
270
+ ```
271
+ 4. Create GitHub release
272
+ 5. Publish to npm (future):
273
+ ```bash
274
+ pnpm publish
275
+ ```
276
+
277
+ ## 📄 License
278
+
279
+ By contributing, you agree that your contributions will be licensed under the MIT License.
280
+
281
+ ## 🙏 Questions?
282
+
283
+ - Open a GitHub Discussion
284
+ - Check existing issues
285
+ - Read the [README.md](./README.md)
286
+
287
+ Thank you for contributing to undoai! 🎉
package/QUICKSTART.md ADDED
@@ -0,0 +1,90 @@
1
+ # undoai - Quick Reference
2
+
3
+ ## Installation
4
+ ```bash
5
+ pnpm install
6
+ pnpm build
7
+ ```
8
+
9
+ ## Commands
10
+
11
+ ### Start Watching
12
+ ```bash
13
+ node dist/cli/index.js watch
14
+ # or after global install:
15
+ undoai watch
16
+ ```
17
+
18
+ ### Restore from Snapshot
19
+ ```bash
20
+ node dist/cli/index.js restore
21
+ # or:
22
+ undoai restore
23
+ ```
24
+
25
+ ### Stop Watching
26
+ ```bash
27
+ node dist/cli/index.js stop
28
+ # or:
29
+ undoai stop
30
+ ```
31
+
32
+ ### Check Status
33
+ ```bash
34
+ node dist/cli/index.js status
35
+ # or:
36
+ undoai status
37
+ ```
38
+
39
+ ## Quick Test
40
+ ```bash
41
+ # Terminal 1: Start watcher
42
+ pnpm build
43
+ node dist/cli/index.js watch
44
+
45
+ # Terminal 2: Trigger burst
46
+ bash test-watcher.sh
47
+
48
+ # Terminal 2: Restore
49
+ node dist/cli/index.js restore
50
+ ```
51
+
52
+ ## Storage Location
53
+ ```bash
54
+ ~/.undoai/
55
+ ├── daemon.pid
56
+ └── snapshots/
57
+ └── <timestamp>/
58
+ ├── metadata.json
59
+ └── files/
60
+ ```
61
+
62
+ ## Configuration Defaults
63
+ - **Burst threshold**: 5 files
64
+ - **Debounce delay**: 2000ms (2 seconds)
65
+ - **Ignored dirs**: node_modules, .git, dist, build
66
+
67
+ ## Global Install (Optional)
68
+ ```bash
69
+ pnpm link --global
70
+ # Now use 'undoai' anywhere
71
+ ```
72
+
73
+ ## Documentation
74
+ - [README.md](./README.md) - Overview & features
75
+ - [USAGE.md](./USAGE.md) - Detailed usage guide
76
+ - [CONTRIBUTING.md](./CONTRIBUTING.md) - Development guide
77
+
78
+ ## Phase 1 Features ✅
79
+ ✅ Auto-snapshot on burst (≥5 files)
80
+ ✅ Interactive restore
81
+ ✅ Daemon management
82
+ ✅ Status tracking
83
+ ✅ 100% local storage
84
+ ✅ Zero configuration
85
+
86
+ ## Coming in Phase 2
87
+ - Security scanning (secrets detection)
88
+ - Smart snapshot retention
89
+ - Diff viewer
90
+ - Selective file restore