@traisetech/autopilot 0.1.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/CHANGELOG.md +17 -0
- package/LICENSE +22 -0
- package/README.md +210 -0
- package/bin/autopilot.js +48 -0
- package/docs/ARCHITECTURE.md +534 -0
- package/docs/CONFIGURATION.md +82 -0
- package/docs/CONTRIBUTING.md +47 -0
- package/docs/DESIGN_DELIVERY.md +441 -0
- package/docs/DESIGN_SUMMARY.md +61 -0
- package/docs/EXTENDING.md +69 -0
- package/docs/SAFETY-FEATURES.md +56 -0
- package/docs/START_HERE.md +41 -0
- package/docs/TROUBLESHOOTING.md +40 -0
- package/package.json +59 -0
- package/src/commands/doctor.js +121 -0
- package/src/commands/init.js +92 -0
- package/src/commands/start.js +41 -0
- package/src/commands/status.js +56 -0
- package/src/commands/stop.js +50 -0
- package/src/config/defaults.js +34 -0
- package/src/config/ignore.js +37 -0
- package/src/config/loader.js +47 -0
- package/src/core/commit.js +116 -0
- package/src/core/git.js +154 -0
- package/src/core/safety.js +38 -0
- package/src/core/watcher.js +309 -0
- package/src/index.js +50 -0
- package/src/utils/banner.js +6 -0
- package/src/utils/logger.js +49 -0
- package/src/utils/paths.js +59 -0
- package/src/utils/process.js +141 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
# Autopilot CLI - Architecture
|
|
2
|
+
|
|
3
|
+
**Built by Praise Masunga (PraiseTechzw)**
|
|
4
|
+
|
|
5
|
+
This document reflects the current implementation of Autopilot CLI.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Current Project Structure
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
autopilot-cli/
|
|
13
|
+
├── bin/
|
|
14
|
+
│ └── autopilot.js # CLI entrypoint (Commander)
|
|
15
|
+
├── src/
|
|
16
|
+
│ ├── commands/ # CLI command handlers
|
|
17
|
+
│ │ ├── init.js
|
|
18
|
+
│ │ ├── start.js
|
|
19
|
+
│ │ ├── stop.js
|
|
20
|
+
│ │ ├── status.js
|
|
21
|
+
│ │ └── doctor.js
|
|
22
|
+
│ ├── core/ # Core logic
|
|
23
|
+
│ │ ├── watcher.js # Watcher engine
|
|
24
|
+
│ │ ├── git.js # Git helper utilities
|
|
25
|
+
│ │ ├── commit.js # Smart commit message logic
|
|
26
|
+
│ │ └── safety.js # Basic validation stubs
|
|
27
|
+
│ ├── config/ # Configuration + ignore parsing
|
|
28
|
+
│ │ ├── defaults.js
|
|
29
|
+
│ │ ├── loader.js
|
|
30
|
+
│ │ └── ignore.js
|
|
31
|
+
│ └── utils/ # Utilities
|
|
32
|
+
│ ├── logger.js
|
|
33
|
+
│ ├── paths.js
|
|
34
|
+
│ └── process.js
|
|
35
|
+
├── docs/ # Documentation
|
|
36
|
+
├── test/ # Tests (node:test)
|
|
37
|
+
├── README.md
|
|
38
|
+
└── index.js # Programmatic API
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Runtime Flow (Start)
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
autopilot start
|
|
47
|
+
-> src/commands/start.js
|
|
48
|
+
-> new Watcher(repoPath)
|
|
49
|
+
-> core/watcher.js
|
|
50
|
+
-> chokidar watches repo
|
|
51
|
+
-> debounce + rate limit
|
|
52
|
+
-> git status
|
|
53
|
+
-> commit message (core/commit.js)
|
|
54
|
+
-> git add/commit
|
|
55
|
+
-> git push (optional)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Key Responsibilities
|
|
61
|
+
|
|
62
|
+
### CLI Layer
|
|
63
|
+
- `bin/autopilot.js` wires commands via Commander
|
|
64
|
+
- `src/commands/*` are thin handlers that call core logic
|
|
65
|
+
|
|
66
|
+
### Core Layer
|
|
67
|
+
- `core/watcher.js` orchestrates watching, debouncing, safety checks, and git actions
|
|
68
|
+
- `core/git.js` wraps git commands with safe results
|
|
69
|
+
- `core/commit.js` generates smart conventional commit messages
|
|
70
|
+
|
|
71
|
+
### Config Layer
|
|
72
|
+
- `.autopilotrc.json` is loaded at runtime
|
|
73
|
+
- `.autopilotignore` patterns are loaded and merged with built‑ins
|
|
74
|
+
|
|
75
|
+
### Utils
|
|
76
|
+
- PID management and signal handling in `utils/process.js`
|
|
77
|
+
- Logging via `utils/logger.js`
|
|
78
|
+
- Path helpers in `utils/paths.js`
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Logs and State
|
|
83
|
+
|
|
84
|
+
- PID file: `.autopilot.pid` in repo root
|
|
85
|
+
- Log file: `autopilot.log` in repo root
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Programmatic API
|
|
90
|
+
|
|
91
|
+
`index.js` exports the command handlers and core utilities for reuse.
|
|
92
|
+
|
|
93
|
+
See [docs/EXTENDING.md](EXTENDING.md) for examples.
|
|
94
|
+
# Autopilot CLI - Architecture Design Document
|
|
95
|
+
|
|
96
|
+
**Built by Praise Masunga (PraiseTechzw)**
|
|
97
|
+
**Repository:** github.com/praisetechzw/autopilot-cli
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 1. PRODUCTION-GRADE FOLDER STRUCTURE
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
autopilot-cli/
|
|
105
|
+
│
|
|
106
|
+
├── bin/
|
|
107
|
+
│ └── autopilot.js # CLI entrypoint, executable wrapper
|
|
108
|
+
│
|
|
109
|
+
├── src/
|
|
110
|
+
│ ├── cli/ # CLI interface layer
|
|
111
|
+
│ │ ├── commands/ # Command implementations
|
|
112
|
+
│ │ │ ├── init.js # Initialize repo config
|
|
113
|
+
│ │ │ ├── start.js # Start watcher daemon
|
|
114
|
+
│ │ │ ├── stop.js # Stop watcher daemon
|
|
115
|
+
│ │ │ ├── status.js # Show watcher status
|
|
116
|
+
│ │ │ └── doctor.js # Diagnose & validate setup
|
|
117
|
+
│ │ ├── input-parser.js # Parse CLI args & flags
|
|
118
|
+
│ │ └── output-formatter.js # Format console output
|
|
119
|
+
│ │
|
|
120
|
+
│ ├── core/ # Business logic layer
|
|
121
|
+
│ │ ├── watcher.js # File system watcher orchestrator
|
|
122
|
+
│ │ ├── git-executor.js # Git command execution wrapper
|
|
123
|
+
│ │ ├── commit-engine.js # Smart commit logic & message generation
|
|
124
|
+
│ │ ├── branch-guard.js # Safety checks (branch protection, etc)
|
|
125
|
+
│ │ ├── event-debouncer.js # File event debouncing
|
|
126
|
+
│ │ └── signal-handler.js # Process signal handling (SIGINT, etc)
|
|
127
|
+
│ │
|
|
128
|
+
│ ├── config/ # Configuration management
|
|
129
|
+
│ │ ├── config-loader.js # Load & merge configs
|
|
130
|
+
│ │ ├── config-validator.js # Validate config schema
|
|
131
|
+
│ │ ├── defaults.js # Default configuration values
|
|
132
|
+
│ │ ├── ignore-parser.js # Parse .autopilotignore
|
|
133
|
+
│ │ └── schema.json # JSON Schema for .autopilotrc.json
|
|
134
|
+
│ │
|
|
135
|
+
│ ├── daemon/ # Process & state management
|
|
136
|
+
│ │ ├── daemon-manager.js # PID file, process lifecycle
|
|
137
|
+
│ │ ├── state-store.js # Persistent state (JSON)
|
|
138
|
+
│ │ ├── lock-manager.js # File-based locking
|
|
139
|
+
│ │ └── health-check.js # Daemon health monitoring
|
|
140
|
+
│ │
|
|
141
|
+
│ ├── safety/ # Safety & validation
|
|
142
|
+
│ │ ├── safety-checks.js # Pre-commit validations
|
|
143
|
+
│ │ ├── file-analyzer.js # Detect large/sensitive files
|
|
144
|
+
│ │ ├── branch-detector.js # Current branch detection
|
|
145
|
+
│ │ └── conflict-resolver.js # Handle merge conflicts
|
|
146
|
+
│ │
|
|
147
|
+
│ ├── logger/ # Logging & output
|
|
148
|
+
│ │ ├── logger.js # Structured logger
|
|
149
|
+
│ │ ├── log-levels.js # Log level constants
|
|
150
|
+
│ │ └── formatters.js # Output formatting (JSON, text, etc)
|
|
151
|
+
│ │
|
|
152
|
+
│ ├── utils/ # Utility functions
|
|
153
|
+
│ │ ├── fs-utils.js # File system helpers
|
|
154
|
+
│ │ ├── path-helpers.js # Path resolution
|
|
155
|
+
│ │ ├── os-helpers.js # OS-specific utilities
|
|
156
|
+
│ │ ├── retry-logic.js # Retry with exponential backoff
|
|
157
|
+
│ │ └── error-handler.js # Centralized error handling
|
|
158
|
+
│ │
|
|
159
|
+
│ ├── types/ # JSDoc type definitions (CommonJS)
|
|
160
|
+
│ │ ├── config.types.js # Config type definitions
|
|
161
|
+
│ │ ├── daemon.types.js # Daemon type definitions
|
|
162
|
+
│ │ └── errors.types.js # Error type definitions
|
|
163
|
+
│ │
|
|
164
|
+
│ └── index.js # Main export (for programmatic use)
|
|
165
|
+
│
|
|
166
|
+
├── test/ # Test suite
|
|
167
|
+
│ ├── unit/ # Unit tests
|
|
168
|
+
│ │ ├── config.test.js
|
|
169
|
+
│ │ ├── git-executor.test.js
|
|
170
|
+
│ │ ├── commit-engine.test.js
|
|
171
|
+
│ │ └── branch-guard.test.js
|
|
172
|
+
│ ├── integration/ # Integration tests
|
|
173
|
+
│ │ ├── watcher.test.js
|
|
174
|
+
│ │ ├── daemon.test.js
|
|
175
|
+
│ │ └── commands.test.js
|
|
176
|
+
│ └── fixtures/ # Test data & fixtures
|
|
177
|
+
│
|
|
178
|
+
├── docs/ # Documentation
|
|
179
|
+
│ ├── ARCHITECTURE.md # This file
|
|
180
|
+
│ ├── CONTRIBUTING.md # Contribution guidelines
|
|
181
|
+
│ ├── SAFETY-FEATURES.md # Safety mechanisms explained
|
|
182
|
+
│ ├── CONFIGURATION.md # Config reference
|
|
183
|
+
│ ├── EXTENDING.md # Plugin/extension guide
|
|
184
|
+
│ └── TROUBLESHOOTING.md # Common issues
|
|
185
|
+
│
|
|
186
|
+
├── examples/ # Example configs & usage
|
|
187
|
+
│ ├── .autopilotrc.json.example # Example repo config
|
|
188
|
+
│ ├── .autopilotignore.example # Example ignore file
|
|
189
|
+
│ └── hooks/ # Git hook examples (optional)
|
|
190
|
+
│
|
|
191
|
+
├── .github/
|
|
192
|
+
│ ├── workflows/ # CI/CD pipelines
|
|
193
|
+
│ └── ISSUE_TEMPLATE/ # Issue templates
|
|
194
|
+
│
|
|
195
|
+
├── .gitignore
|
|
196
|
+
├── .autopilotignore # Ignore for autopilot itself
|
|
197
|
+
├── LICENSE # MIT + Praise Masunga (PraiseTechzw)
|
|
198
|
+
├── package.json # ✓ Built by Praise Masunga
|
|
199
|
+
├── README.md # ✓ Built by Praise Masunga
|
|
200
|
+
└── CHANGELOG.md
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 2. FOLDER & FILE RESPONSIBILITIES
|
|
206
|
+
|
|
207
|
+
### `bin/autopilot.js`
|
|
208
|
+
- **Responsibility:** Executable wrapper, shebang line, minimal CLI bootstrap
|
|
209
|
+
- **No Logic:** Delegates to `src/cli/commands`
|
|
210
|
+
- **Usage:** `#!/usr/bin/env node`
|
|
211
|
+
|
|
212
|
+
### `src/cli/commands/`
|
|
213
|
+
- **Responsibility:** Command implementations (init, start, stop, status, doctor)
|
|
214
|
+
- **User Interaction:** Takes parsed args, produces output
|
|
215
|
+
- **Delegation:** Calls core business logic, handles command-specific validation
|
|
216
|
+
|
|
217
|
+
### `src/core/watcher.js`
|
|
218
|
+
- **Responsibility:** Orchestrates file system watching via chokidar
|
|
219
|
+
- **Not Responsible:** Git operations, commit decisions, debouncing logic
|
|
220
|
+
- **Single Concern:** Watch → emit events
|
|
221
|
+
|
|
222
|
+
### `src/core/commit-engine.js`
|
|
223
|
+
- **Responsibility:** Smart commit logic
|
|
224
|
+
- **Features:**
|
|
225
|
+
- Analyze changed files → generate commit message
|
|
226
|
+
- Apply conventional commit format
|
|
227
|
+
- Respect commit message templates
|
|
228
|
+
- Validate commit pre-conditions
|
|
229
|
+
|
|
230
|
+
### `src/core/branch-guard.js`
|
|
231
|
+
- **Responsibility:** Safety gates before actions
|
|
232
|
+
- **Checks:**
|
|
233
|
+
- Protected branches (main, master)
|
|
234
|
+
- Dirty working directory
|
|
235
|
+
- Remote tracking status
|
|
236
|
+
- Uncommitted dependencies
|
|
237
|
+
- Large file detection
|
|
238
|
+
|
|
239
|
+
### `src/config/`
|
|
240
|
+
- **Responsibility:** All configuration loading, merging, validation
|
|
241
|
+
- **No Side Effects:** Pure functions
|
|
242
|
+
- **Schema Validation:** JSON Schema in `schema.json`
|
|
243
|
+
- **Hierarchy:** CLI args > env vars > .autopilotrc.json > defaults
|
|
244
|
+
|
|
245
|
+
### `src/daemon/`
|
|
246
|
+
- **Responsibility:** Process lifecycle, PID management, state persistence
|
|
247
|
+
- **Not Responsible:** Watching files or running git commands
|
|
248
|
+
- **Single Concern:** "Is the daemon running? Store/retrieve state."
|
|
249
|
+
|
|
250
|
+
### `src/safety/`
|
|
251
|
+
- **Responsibility:** All validation and safety checks
|
|
252
|
+
- **Pre-commit Checks:**
|
|
253
|
+
- File size limits
|
|
254
|
+
- Sensitive files detection (secrets, keys)
|
|
255
|
+
- Conflict markers
|
|
256
|
+
- Binary files
|
|
257
|
+
|
|
258
|
+
### `src/logger/`
|
|
259
|
+
- **Responsibility:** Structured logging with levels (debug, info, warn, error)
|
|
260
|
+
- **Output Formats:** Human-readable + JSON (for CI/CD integration)
|
|
261
|
+
- **No Business Logic:** Pure output formatting
|
|
262
|
+
|
|
263
|
+
### `src/utils/`
|
|
264
|
+
- **Responsibility:** Cross-cutting utilities (FS, paths, OS, retry, errors)
|
|
265
|
+
- **Reusable:** Used across all layers
|
|
266
|
+
- **No Dependencies:** Minimal, focused utilities
|
|
267
|
+
|
|
268
|
+
### `src/types/`
|
|
269
|
+
- **Responsibility:** JSDoc type definitions (since no TypeScript)
|
|
270
|
+
- **Purpose:** IDE autocomplete, documentation, safety
|
|
271
|
+
- **Format:** JSDoc `@typedef` in CommonJS
|
|
272
|
+
|
|
273
|
+
### `test/`
|
|
274
|
+
- **Unit Tests:** Pure functions, mocked dependencies
|
|
275
|
+
- **Integration Tests:** Real file system, controlled git repos
|
|
276
|
+
- **Fixtures:** Test data, sample configs
|
|
277
|
+
|
|
278
|
+
### `docs/`
|
|
279
|
+
- **ARCHITECTURE.md:** This design document
|
|
280
|
+
- **CONFIGURATION.md:** .autopilotrc.json schema reference
|
|
281
|
+
- **SAFETY-FEATURES.md:** All safety mechanisms explained
|
|
282
|
+
- **EXTENDING.md:** How to add custom hooks/plugins
|
|
283
|
+
- **TROUBLESHOOTING.md:** Common issues & solutions
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 3. DESIGN PRINCIPLES (10 CORE PRINCIPLES)
|
|
288
|
+
|
|
289
|
+
1. **Single Responsibility:** Each module does ONE thing well.
|
|
290
|
+
- Commands ≠ Core Logic ≠ Config ≠ Daemon Management
|
|
291
|
+
- Easy to test, replace, understand
|
|
292
|
+
|
|
293
|
+
2. **Separation of Concerns:** Clear layer boundaries.
|
|
294
|
+
- CLI Layer (user interaction)
|
|
295
|
+
- Core Layer (business logic)
|
|
296
|
+
- Config Layer (configuration)
|
|
297
|
+
- Daemon Layer (process management)
|
|
298
|
+
- Safety Layer (validation)
|
|
299
|
+
|
|
300
|
+
3. **Configuration as Code:** All behavior driven by `.autopilotrc.json`
|
|
301
|
+
- No hardcoded rules in source
|
|
302
|
+
- Environment variable overrides supported
|
|
303
|
+
- Validated against JSON Schema
|
|
304
|
+
|
|
305
|
+
4. **Fail-Safe by Default:**
|
|
306
|
+
- Protected branches (main, master) → refuse auto-commit
|
|
307
|
+
- Dirty state → abort silently (no data loss)
|
|
308
|
+
- Large files → warn before committing
|
|
309
|
+
- Conflicts → pause, alert user
|
|
310
|
+
|
|
311
|
+
5. **Defensive Git Execution:**
|
|
312
|
+
- All git commands wrapped with error handling
|
|
313
|
+
- Retry logic with exponential backoff
|
|
314
|
+
- Graceful degradation (push fails → log, don't crash)
|
|
315
|
+
- Pre-execution validation (branch exists, etc)
|
|
316
|
+
|
|
317
|
+
6. **No External Dependencies Beyond Essential:**
|
|
318
|
+
- ✅ Keep: chokidar (battle-tested file watcher)
|
|
319
|
+
- ✅ Keep: commander (mature CLI framework)
|
|
320
|
+
- ✅ Keep: fs-extra (safe file operations)
|
|
321
|
+
- ❌ Avoid: Heavy frameworks, large dependency trees
|
|
322
|
+
|
|
323
|
+
7. **Process Lifecycle Management:**
|
|
324
|
+
- PID file for daemon tracking
|
|
325
|
+
- Graceful shutdown (SIGINT, SIGTERM)
|
|
326
|
+
- State persistence (what was last committed, etc)
|
|
327
|
+
- Health checks (is daemon actually running?)
|
|
328
|
+
|
|
329
|
+
8. **Extensibility Without Bloat:**
|
|
330
|
+
- Hook system for custom logic (pre-commit, post-push)
|
|
331
|
+
- Plugin architecture for custom message generators
|
|
332
|
+
- Custom ignore patterns support
|
|
333
|
+
- Programmatic API via `src/index.js`
|
|
334
|
+
|
|
335
|
+
9. **Safety Before Speed:**
|
|
336
|
+
- Debounce to avoid commit spam
|
|
337
|
+
- Minimum time between commits
|
|
338
|
+
- File size limits
|
|
339
|
+
- Conflict detection
|
|
340
|
+
- Branch protection
|
|
341
|
+
- Dry-run mode support
|
|
342
|
+
|
|
343
|
+
10. **Maintainability & Testability:**
|
|
344
|
+
- All business logic is pure functions (easy to test)
|
|
345
|
+
- No global state (except intentional singletons: logger, config)
|
|
346
|
+
- Dependency injection via function parameters
|
|
347
|
+
- Comprehensive error messages (not cryptic)
|
|
348
|
+
- Structured logging for debugging
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## 4. KEY ARCHITECTURAL PATTERNS
|
|
353
|
+
|
|
354
|
+
### Pattern: Layered Architecture
|
|
355
|
+
```
|
|
356
|
+
CLI Layer (commands)
|
|
357
|
+
↓
|
|
358
|
+
Core Layer (business logic)
|
|
359
|
+
↓
|
|
360
|
+
Config Layer (loaded once, immutable)
|
|
361
|
+
↓
|
|
362
|
+
Utils Layer (pure functions)
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Pattern: Dependency Injection
|
|
366
|
+
```javascript
|
|
367
|
+
// Bad: Tight coupling
|
|
368
|
+
const watcher = new Watcher();
|
|
369
|
+
|
|
370
|
+
// Good: Inject dependencies
|
|
371
|
+
const watcher = new Watcher(config, logger, gitExecutor);
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Pattern: Error Boundary
|
|
375
|
+
```javascript
|
|
376
|
+
// All git operations wrapped
|
|
377
|
+
try {
|
|
378
|
+
await gitExecutor.commit(message);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
logger.error(`Commit failed: ${error.message}`);
|
|
381
|
+
// Graceful handling, not crash
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### Pattern: Configuration Validation
|
|
386
|
+
```javascript
|
|
387
|
+
// Load → Validate → Use
|
|
388
|
+
const config = configLoader.load();
|
|
389
|
+
configValidator.validate(config); // Throws if invalid
|
|
390
|
+
const watcher = new Watcher(config); // Safe to use
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## 5. COMMAND STRUCTURE EXAMPLE
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
// src/cli/commands/start.js
|
|
399
|
+
async function start(options, config) {
|
|
400
|
+
// 1. Validate environment
|
|
401
|
+
validateGitRepo();
|
|
402
|
+
config = configValidator.validate(config);
|
|
403
|
+
|
|
404
|
+
// 2. Check daemon state
|
|
405
|
+
const running = daemonManager.isRunning();
|
|
406
|
+
if (running) throw new Error("Already running");
|
|
407
|
+
|
|
408
|
+
// 3. Initialize core services
|
|
409
|
+
const watcher = new Watcher(config, logger);
|
|
410
|
+
const gitExecutor = new GitExecutor(logger);
|
|
411
|
+
const commitEngine = new CommitEngine(config);
|
|
412
|
+
|
|
413
|
+
// 4. Setup signal handlers
|
|
414
|
+
signalHandler.onShutdown(async () => {
|
|
415
|
+
await watcher.stop();
|
|
416
|
+
daemonManager.clearPid();
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// 5. Start watching
|
|
420
|
+
await watcher.start();
|
|
421
|
+
daemonManager.savePid(process.pid);
|
|
422
|
+
|
|
423
|
+
// 6. Output result
|
|
424
|
+
logger.info(`✓ Autopilot started (PID: ${process.pid})`);
|
|
425
|
+
}
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
## 6. CREDIT/SIGNATURE PLACEMENT
|
|
431
|
+
|
|
432
|
+
| Location | Signature |
|
|
433
|
+
|----------|-----------|
|
|
434
|
+
| `bin/autopilot.js` | First comment: `// Built by Praise Masunga (PraiseTechzw)` |
|
|
435
|
+
| `package.json` | `"author": "Praise Masunga (PraiseTechzw)"`, `"homepage": "https://github.com/praisetechzw/autopilot-cli"` |
|
|
436
|
+
| `README.md` | "**Built by Praise Masunga (PraiseTechzw)**" at top |
|
|
437
|
+
| `LICENSE` | "Copyright (c) 2026 Praise Masunga (PraiseTechzw)" |
|
|
438
|
+
| `src/index.js` | Header comment only (not in every file) |
|
|
439
|
+
| CLI Output | Version command: `autopilot@0.1.0 - Built by Praise Masunga (PraiseTechzw)` |
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## 7. CONFIGURATION SCHEMA (.autopilotrc.json)
|
|
444
|
+
|
|
445
|
+
```json
|
|
446
|
+
{
|
|
447
|
+
"version": "1.0",
|
|
448
|
+
"watchDebounceMs": 2000,
|
|
449
|
+
"minCommitIntervalSec": 60,
|
|
450
|
+
"autoPush": false,
|
|
451
|
+
"pushRetries": 3,
|
|
452
|
+
"protectedBranches": ["main", "master", "develop"],
|
|
453
|
+
"commitMessage": "chore: autopilot update",
|
|
454
|
+
"commitMessageMode": "smart",
|
|
455
|
+
"safety": {
|
|
456
|
+
"checkLargeFiles": true,
|
|
457
|
+
"maxFileSizeKb": 100,
|
|
458
|
+
"detectSensitiveFiles": true,
|
|
459
|
+
"checkForConflicts": true
|
|
460
|
+
},
|
|
461
|
+
"hooks": {
|
|
462
|
+
"preCommit": null,
|
|
463
|
+
"postCommit": null,
|
|
464
|
+
"postPush": null
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## 8. IGNORE FILE FORMAT (.autopilotignore)
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
# Standard gitignore-like syntax
|
|
475
|
+
node_modules/
|
|
476
|
+
.git/
|
|
477
|
+
.env*
|
|
478
|
+
*.log
|
|
479
|
+
dist/
|
|
480
|
+
build/
|
|
481
|
+
coverage/
|
|
482
|
+
|
|
483
|
+
# Comments and blank lines ignored
|
|
484
|
+
# Glob patterns supported
|
|
485
|
+
**/.DS_Store
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## 9. ROADMAP FOR EXTENSIBILITY
|
|
491
|
+
|
|
492
|
+
### Phase 1 (MVP)
|
|
493
|
+
- ✓ Core commands (init, start, stop, status)
|
|
494
|
+
- ✓ Basic safety checks
|
|
495
|
+
- ✓ Config validation
|
|
496
|
+
|
|
497
|
+
### Phase 2 (Hooks & Plugins)
|
|
498
|
+
- Pre-commit hooks (custom validation)
|
|
499
|
+
- Post-commit hooks (custom actions)
|
|
500
|
+
- Custom commit message generators
|
|
501
|
+
|
|
502
|
+
### Phase 3 (Advanced)
|
|
503
|
+
- Webhook integrations
|
|
504
|
+
- Slack notifications
|
|
505
|
+
- GitHub/GitLab API integration
|
|
506
|
+
- Conditional logic in config
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## 10. TESTING STRATEGY
|
|
511
|
+
|
|
512
|
+
```
|
|
513
|
+
Unit Tests (80% coverage)
|
|
514
|
+
├── Config validation
|
|
515
|
+
├── Commit engine logic
|
|
516
|
+
├── Branch guard rules
|
|
517
|
+
├── Event debouncer timing
|
|
518
|
+
└── Safe file operations
|
|
519
|
+
|
|
520
|
+
Integration Tests (60% coverage)
|
|
521
|
+
├── Full watcher lifecycle
|
|
522
|
+
├── Daemon start/stop
|
|
523
|
+
├── Real git operations (test repo)
|
|
524
|
+
└── Signal handling
|
|
525
|
+
|
|
526
|
+
No E2E tests (too flaky with file watchers)
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
531
|
+
**Status:** Architecture Design Document (Pre-Implementation)
|
|
532
|
+
**Version:** 1.0
|
|
533
|
+
**Last Updated:** January 31, 2026
|
|
534
|
+
**Architect:** Praise Masunga (PraiseTechzw)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Configuration Reference - Autopilot CLI
|
|
2
|
+
|
|
3
|
+
**Built by Praise Masunga (PraiseTechzw)**
|
|
4
|
+
|
|
5
|
+
This document reflects the current `.autopilotrc.json` options.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## File Locations
|
|
10
|
+
|
|
11
|
+
- Config: `.autopilotrc.json` (repo root)
|
|
12
|
+
- Ignore: `.autopilotignore` (repo root)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Full Example
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"debounceSeconds": 20,
|
|
21
|
+
"minSecondsBetweenCommits": 180,
|
|
22
|
+
"autoPush": true,
|
|
23
|
+
"blockBranches": ["main", "master"],
|
|
24
|
+
"requireChecks": false,
|
|
25
|
+
"checks": ["npm test"],
|
|
26
|
+
"commitMessageMode": "smart"
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Settings
|
|
33
|
+
|
|
34
|
+
### `debounceSeconds`
|
|
35
|
+
- **Type:** number
|
|
36
|
+
- **Default:** 20
|
|
37
|
+
- **Description:** Wait time after the last file change before checking git status.
|
|
38
|
+
|
|
39
|
+
### `minSecondsBetweenCommits`
|
|
40
|
+
- **Type:** number
|
|
41
|
+
- **Default:** 180
|
|
42
|
+
- **Description:** Minimum time between commits (anti-spam).
|
|
43
|
+
|
|
44
|
+
### `autoPush`
|
|
45
|
+
- **Type:** boolean
|
|
46
|
+
- **Default:** true
|
|
47
|
+
- **Description:** Push to `origin/<branch>` after commit.
|
|
48
|
+
|
|
49
|
+
### `blockBranches`
|
|
50
|
+
- **Type:** string[]
|
|
51
|
+
- **Default:** `["main", "master"]`
|
|
52
|
+
- **Description:** Branches where auto-commit is disabled.
|
|
53
|
+
|
|
54
|
+
### `requireChecks`
|
|
55
|
+
- **Type:** boolean
|
|
56
|
+
- **Default:** false
|
|
57
|
+
- **Description:** Run checks before commit. If any fail, commit is skipped.
|
|
58
|
+
|
|
59
|
+
### `checks`
|
|
60
|
+
- **Type:** string[]
|
|
61
|
+
- **Default:** `[]`
|
|
62
|
+
- **Description:** Shell commands executed sequentially when `requireChecks` is true.
|
|
63
|
+
|
|
64
|
+
### `commitMessageMode`
|
|
65
|
+
- **Type:** `"smart" | "simple"`
|
|
66
|
+
- **Default:** `"smart"`
|
|
67
|
+
- **Description:** Smart uses file-based conventional commit messages; simple uses `chore: update changes`.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Ignore File (.autopilotignore)
|
|
72
|
+
|
|
73
|
+
Gitignore-style patterns. Example:
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
node_modules/
|
|
77
|
+
dist/
|
|
78
|
+
.env
|
|
79
|
+
*.log
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Autopilot also always ignores `.git`, `.autopilot.pid`, and `autopilot.log`.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
**Built by Praise Masunga (PraiseTechzw)**
|
|
4
|
+
|
|
5
|
+
Thanks for contributing to Autopilot CLI.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
1. Fork the repo
|
|
12
|
+
2. Create a branch: `git checkout -b feature/your-change`
|
|
13
|
+
3. Make changes
|
|
14
|
+
4. Run tests: `node --test`
|
|
15
|
+
5. Open a pull request
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Code Style
|
|
20
|
+
|
|
21
|
+
- CommonJS modules
|
|
22
|
+
- Keep functions small and focused
|
|
23
|
+
- Prefer clear logging and error handling
|
|
24
|
+
- Avoid breaking existing CLI behavior
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Commit Messages
|
|
29
|
+
|
|
30
|
+
Use conventional commits when possible:
|
|
31
|
+
|
|
32
|
+
- `feat: ...`
|
|
33
|
+
- `fix: ...`
|
|
34
|
+
- `docs: ...`
|
|
35
|
+
- `chore: ...`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Documentation
|
|
40
|
+
|
|
41
|
+
If behavior changes, update:
|
|
42
|
+
- [README.md](../README.md)
|
|
43
|
+
- Relevant docs under [docs/](.)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
**Built by Praise Masunga (PraiseTechzw)**
|