@jonit-dev/night-watch-cli 1.0.0
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/LICENSE +21 -0
- package/README.md +509 -0
- package/bin/night-watch.mjs +2 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +35 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +376 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.d.ts +15 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +135 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/logs.d.ts +15 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +104 -0
- package/dist/commands/logs.js.map +1 -0
- package/dist/commands/review.d.ts +26 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +144 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +26 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +161 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/status.d.ts +14 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +303 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/uninstall.d.ts +13 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +97 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +213 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +33 -0
- package/dist/constants.js.map +1 -0
- package/dist/types.d.ts +35 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/crontab.d.ts +50 -0
- package/dist/utils/crontab.d.ts.map +1 -0
- package/dist/utils/crontab.js +116 -0
- package/dist/utils/crontab.js.map +1 -0
- package/dist/utils/shell.d.ts +13 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +44 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/ui.d.ts +55 -0
- package/dist/utils/ui.d.ts.map +1 -0
- package/dist/utils/ui.js +121 -0
- package/dist/utils/ui.js.map +1 -0
- package/package.json +64 -0
- package/scripts/night-watch-cron.sh +148 -0
- package/scripts/night-watch-helpers.sh +155 -0
- package/scripts/night-watch-pr-reviewer-cron.sh +135 -0
- package/templates/night-watch-pr-reviewer.md +144 -0
- package/templates/night-watch.config.json +21 -0
- package/templates/night-watch.md +100 -0
- package/templates/prd-executor.md +235 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joao Pio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
# Night Watch CLI
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/night-watch-cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
7
|
+
**Autonomous PRD execution using AI Provider CLIs + cron**
|
|
8
|
+
|
|
9
|
+
Night Watch is a battle-tested autonomous PRD executor that uses AI provider CLIs (Claude CLI or Codex) + cron to implement PRD tickets, open PRs, and fix CI failures — all while you sleep.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# 1. Install globally
|
|
17
|
+
npm install -g night-watch-cli
|
|
18
|
+
|
|
19
|
+
# 2. Initialize in your project
|
|
20
|
+
cd your-project
|
|
21
|
+
night-watch init
|
|
22
|
+
|
|
23
|
+
# 3. Check provider detection
|
|
24
|
+
night-watch run --dry-run # Shows which provider CLI will be used
|
|
25
|
+
|
|
26
|
+
# 4. Add your PRD files
|
|
27
|
+
echo "# My First PRD\n\nImplement feature X..." > docs/PRDs/night-watch/my-feature.md
|
|
28
|
+
|
|
29
|
+
# 5. Run or install cron
|
|
30
|
+
night-watch run # Run once
|
|
31
|
+
night-watch install # Setup automated cron
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Supported Providers
|
|
37
|
+
|
|
38
|
+
Night Watch acts as a wrapper/orchestrator that calls CLI-based AI coding tools. The following providers are supported:
|
|
39
|
+
|
|
40
|
+
| Provider | CLI Command | Auto-Mode Flag | Slash Commands |
|
|
41
|
+
|----------|-------------|----------------|----------------|
|
|
42
|
+
| `claude` | `claude` | `--dangerously-skip-permissions` | `-p "/command-name"` |
|
|
43
|
+
| `codex` | `codex` | `--yolo` | `--prompt "text"` |
|
|
44
|
+
|
|
45
|
+
**Provider Detection:**
|
|
46
|
+
- Night Watch auto-detects your provider based on the `provider` field in `night-watch.config.json`
|
|
47
|
+
- Default provider is `claude`
|
|
48
|
+
- Change provider with `--provider codex` flag or set `provider: "codex"` in config
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
### npm (Recommended)
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm install -g night-watch-cli
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### npx (No install)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx night-watch-cli init
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### From Source
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/joaopio/night-watch-cli.git
|
|
70
|
+
cd night-watch-cli
|
|
71
|
+
npm install
|
|
72
|
+
npm run build
|
|
73
|
+
npm link
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Commands Reference
|
|
79
|
+
|
|
80
|
+
### `night-watch init`
|
|
81
|
+
|
|
82
|
+
Initialize Night Watch in your project. Creates all necessary directories, configuration files, and provider slash commands.
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
night-watch init # Initialize with defaults
|
|
86
|
+
night-watch init --force # Overwrite existing configuration
|
|
87
|
+
night-watch init --prd-dir docs/prds # Custom PRD directory
|
|
88
|
+
night-watch init --provider codex # Use codex provider
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**What it creates:**
|
|
92
|
+
- `docs/PRDs/night-watch/done/` — Directory for completed PRDs
|
|
93
|
+
- `docs/PRDs/night-watch/NIGHT-WATCH-SUMMARY.md` — Progress tracking file
|
|
94
|
+
- `logs/` — Log files directory (added to .gitignore)
|
|
95
|
+
- `.claude/commands/night-watch.md` — Claude slash command for PRD execution
|
|
96
|
+
- `.claude/commands/night-watch-pr-reviewer.md` — Claude slash command for PR review
|
|
97
|
+
- `night-watch.config.json` — Configuration file
|
|
98
|
+
|
|
99
|
+
**Prerequisites:**
|
|
100
|
+
- Git repository
|
|
101
|
+
- GitHub CLI (`gh`) authenticated
|
|
102
|
+
- Provider CLI installed (Claude CLI or Codex)
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### `night-watch run`
|
|
107
|
+
|
|
108
|
+
Execute the PRD executor. Scans for eligible PRDs and implements them using the configured provider CLI.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
night-watch run # Execute PRD executor
|
|
112
|
+
night-watch run --dry-run # Show what would be executed (with diagnostics)
|
|
113
|
+
night-watch run --provider codex # Override provider
|
|
114
|
+
night-watch run --timeout 3600 # Override max runtime (1 hour)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
### `night-watch review`
|
|
120
|
+
|
|
121
|
+
Execute the PR reviewer. Finds open PRs on night-watch/ or feat/ branches, checks CI status and review scores, and fixes issues.
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
night-watch review # Execute PR reviewer
|
|
125
|
+
night-watch review --dry-run # Show PRs needing work (with diagnostics)
|
|
126
|
+
night-watch review --provider codex # Override provider
|
|
127
|
+
night-watch review --timeout 1800 # Override max runtime (30 min)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
### `night-watch install`
|
|
133
|
+
|
|
134
|
+
Install crontab entries for automated execution.
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
night-watch install # Install with default schedules
|
|
138
|
+
night-watch install --schedule "0 * * * *" # Custom executor schedule
|
|
139
|
+
night-watch install --reviewer-schedule "0 */2 * * *" # Custom reviewer schedule
|
|
140
|
+
night-watch install --no-reviewer # Skip reviewer cron
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Default Schedules:**
|
|
144
|
+
- Executor: `0 0-15 * * *` (hourly from midnight to 3pm UTC)
|
|
145
|
+
- Reviewer: `0 0,3,6,9,12,15 * * *` (every 3 hours)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### `night-watch uninstall`
|
|
150
|
+
|
|
151
|
+
Remove crontab entries for the current project.
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
night-watch uninstall
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### `night-watch status`
|
|
160
|
+
|
|
161
|
+
Show current Night Watch status including lock files, PRD counts, open PRs, and log file info.
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
night-watch status # Basic status
|
|
165
|
+
night-watch status --verbose # Detailed status with log snippets
|
|
166
|
+
night-watch status --json # Output as JSON
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Status shows:**
|
|
170
|
+
- Process status (executor/reviewer running or not)
|
|
171
|
+
- PRD status (pending vs completed)
|
|
172
|
+
- PR status (open PRs on night-watch/feat branches)
|
|
173
|
+
- Crontab status (installed or not)
|
|
174
|
+
- Log file status (size, last lines)
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### `night-watch logs`
|
|
179
|
+
|
|
180
|
+
View log output from executor and reviewer.
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
night-watch logs # View last 50 lines of all logs
|
|
184
|
+
night-watch logs -n 100 # View last 100 lines
|
|
185
|
+
night-watch logs --follow # Follow logs in real-time
|
|
186
|
+
night-watch logs --type run # View executor logs only
|
|
187
|
+
night-watch logs --type review # View reviewer logs only
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Configuration
|
|
193
|
+
|
|
194
|
+
Configuration is loaded in this order (later overrides earlier):
|
|
195
|
+
1. Default values
|
|
196
|
+
2. Config file (`night-watch.config.json`)
|
|
197
|
+
3. Environment variables
|
|
198
|
+
4. CLI flags
|
|
199
|
+
|
|
200
|
+
### Config File
|
|
201
|
+
|
|
202
|
+
Create `night-watch.config.json` in your project root:
|
|
203
|
+
|
|
204
|
+
```json
|
|
205
|
+
{
|
|
206
|
+
"projectName": "my-project",
|
|
207
|
+
"defaultBranch": "main",
|
|
208
|
+
"provider": "claude",
|
|
209
|
+
"reviewerEnabled": true,
|
|
210
|
+
"prdDir": "docs/PRDs/night-watch",
|
|
211
|
+
"maxRuntime": 7200,
|
|
212
|
+
"reviewerMaxRuntime": 3600,
|
|
213
|
+
"branchPrefix": "night-watch",
|
|
214
|
+
"branchPatterns": ["feat/", "night-watch/"],
|
|
215
|
+
"minReviewScore": 80,
|
|
216
|
+
"maxLogSize": 524288,
|
|
217
|
+
"cronSchedule": "0 0-15 * * *",
|
|
218
|
+
"reviewerSchedule": "0 0,3,6,9,12,15 * * *"
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Environment Variables
|
|
223
|
+
|
|
224
|
+
**Night Watch Config (prefixed with `NW_`):**
|
|
225
|
+
|
|
226
|
+
| Variable | Config Key |
|
|
227
|
+
|----------|------------|
|
|
228
|
+
| `NW_PRD_DIR` | `prdDir` |
|
|
229
|
+
| `NW_MAX_RUNTIME` | `maxRuntime` |
|
|
230
|
+
| `NW_REVIEWER_MAX_RUNTIME` | `reviewerMaxRuntime` |
|
|
231
|
+
| `NW_BRANCH_PREFIX` | `branchPrefix` |
|
|
232
|
+
| `NW_BRANCH_PATTERNS` | `branchPatterns` (JSON array or comma-separated) |
|
|
233
|
+
| `NW_MIN_REVIEW_SCORE` | `minReviewScore` |
|
|
234
|
+
| `NW_MAX_LOG_SIZE` | `maxLogSize` |
|
|
235
|
+
| `NW_CRON_SCHEDULE` | `cronSchedule` |
|
|
236
|
+
| `NW_REVIEWER_SCHEDULE` | `reviewerSchedule` |
|
|
237
|
+
| `NW_PROVIDER` | `provider` |
|
|
238
|
+
|
|
239
|
+
### CLI Flags
|
|
240
|
+
|
|
241
|
+
Flags override all other configuration:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
night-watch run --provider codex --timeout 3600
|
|
245
|
+
night-watch review --provider claude --timeout 1800
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## PRD Format
|
|
251
|
+
|
|
252
|
+
Night Watch looks for PRD files in `docs/PRDs/night-watch/` (configurable). PRDs are markdown files with optional dependency declarations.
|
|
253
|
+
|
|
254
|
+
### Basic PRD
|
|
255
|
+
|
|
256
|
+
```markdown
|
|
257
|
+
# Feature: User Authentication
|
|
258
|
+
|
|
259
|
+
## Overview
|
|
260
|
+
Implement user authentication using JWT tokens.
|
|
261
|
+
|
|
262
|
+
## Requirements
|
|
263
|
+
- [ ] Login endpoint
|
|
264
|
+
- [ ] Logout endpoint
|
|
265
|
+
- [ ] Token refresh
|
|
266
|
+
- [ ] Password hashing
|
|
267
|
+
|
|
268
|
+
## Acceptance Criteria
|
|
269
|
+
- Users can log in with email/password
|
|
270
|
+
- Tokens expire after 24 hours
|
|
271
|
+
- All endpoints have proper error handling
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### PRD with Dependencies
|
|
275
|
+
|
|
276
|
+
```markdown
|
|
277
|
+
# Feature: User Profile
|
|
278
|
+
|
|
279
|
+
Depends on: Feature: User Authentication
|
|
280
|
+
|
|
281
|
+
## Overview
|
|
282
|
+
Add user profile management.
|
|
283
|
+
|
|
284
|
+
## Requirements
|
|
285
|
+
- [ ] Profile page
|
|
286
|
+
- [ ] Edit profile
|
|
287
|
+
- [ ] Avatar upload
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
When a PRD specifies `Depends on:`, Night Watch will only process it after the dependency's PRD file is moved to `done/`.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## How It Works
|
|
295
|
+
|
|
296
|
+
### Architecture Overview
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
+-------------------------------------------------------------+
|
|
300
|
+
| Night Watch CLI |
|
|
301
|
+
| (Node.js wrapper for discoverability, config, distribution) |
|
|
302
|
+
+-------------------------------------------------------------+
|
|
303
|
+
|
|
|
304
|
+
v
|
|
305
|
+
+-------------------------------------------------------------+
|
|
306
|
+
| Bash Scripts |
|
|
307
|
+
| (Battle-tested core logic for PRD execution and review) |
|
|
308
|
+
| |
|
|
309
|
+
| +---------------------+ +--------------------------------+ |
|
|
310
|
+
| | night-watch-cron.sh | | night-watch-pr-reviewer-cron.sh | |
|
|
311
|
+
| | (PRD Executor) | | (PR Reviewer) | |
|
|
312
|
+
| +---------------------+ +--------------------------------+ |
|
|
313
|
+
| | | |
|
|
314
|
+
| +-----------+--------------+ |
|
|
315
|
+
| v |
|
|
316
|
+
| +-----------------------------+ |
|
|
317
|
+
| | night-watch-helpers.sh | |
|
|
318
|
+
| | (Shared utilities) | |
|
|
319
|
+
| +-----------------------------+ |
|
|
320
|
+
+-------------------------------------------------------------+
|
|
321
|
+
|
|
|
322
|
+
v
|
|
323
|
+
+-------------------------------------------------------------+
|
|
324
|
+
| External Tools |
|
|
325
|
+
| |
|
|
326
|
+
| +----------------+ +------------+ +------------------+ |
|
|
327
|
+
| | Provider CLI | | GitHub CLI | | Git Worktrees | |
|
|
328
|
+
| | (Claude/Codex) | | (PR mgmt) | | (Isolation) | |
|
|
329
|
+
| +----------------+ +------------+ +------------------+ |
|
|
330
|
+
+-------------------------------------------------------------+
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### PRD Execution Flow
|
|
334
|
+
|
|
335
|
+
1. **Scan for PRDs** — Find markdown files in `docs/PRDs/night-watch/`
|
|
336
|
+
2. **Check dependencies** — Skip PRDs with unmet dependencies
|
|
337
|
+
3. **Check for open PRs** — Skip PRDs that already have an open PR
|
|
338
|
+
4. **Acquire lock** — Prevent concurrent executions
|
|
339
|
+
5. **Create worktree** — Isolate changes in a git worktree
|
|
340
|
+
6. **Launch Provider CLI** — Execute PRD using provider CLI with slash command
|
|
341
|
+
7. **Verify PR created** — Check that a PR was opened
|
|
342
|
+
8. **Mark done** — Move PRD to `done/` directory
|
|
343
|
+
9. **Cleanup** — Remove lock files and worktrees
|
|
344
|
+
|
|
345
|
+
### PR Review Flow
|
|
346
|
+
|
|
347
|
+
1. **Find open PRs** — Search for PRs on `night-watch/` or `feat/` branches
|
|
348
|
+
2. **Check CI status** — Identify failed checks
|
|
349
|
+
3. **Check review scores** — Find PRs with score < 80/100
|
|
350
|
+
4. **Acquire lock** — Prevent concurrent executions
|
|
351
|
+
5. **Launch Provider CLI** — Execute PR fix using provider CLI with slash command
|
|
352
|
+
6. **Cleanup** — Remove lock files
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Troubleshooting
|
|
357
|
+
|
|
358
|
+
### "Current directory is not a git repository"
|
|
359
|
+
|
|
360
|
+
Run `night-watch init` from the root of a git repository:
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
cd your-project
|
|
364
|
+
git init # if not already a git repo
|
|
365
|
+
night-watch init
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### "GitHub CLI (gh) is not authenticated"
|
|
369
|
+
|
|
370
|
+
Authenticate with GitHub:
|
|
371
|
+
|
|
372
|
+
```bash
|
|
373
|
+
gh auth login
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### "Provider CLI is not available"
|
|
377
|
+
|
|
378
|
+
Install the appropriate provider CLI:
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
# Claude CLI
|
|
382
|
+
# Follow instructions at https://docs.anthropic.com/en/docs/claude-cli
|
|
383
|
+
|
|
384
|
+
# Codex CLI
|
|
385
|
+
# Follow instructions at https://github.com/openai/codex
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### "Night Watch is already installed"
|
|
389
|
+
|
|
390
|
+
Uninstall first, then reinstall:
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
night-watch uninstall
|
|
394
|
+
night-watch install
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### "Lock file exists but process not running"
|
|
398
|
+
|
|
399
|
+
Remove stale lock files:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
rm /tmp/night-watch-*.lock
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Or use `night-watch status --verbose` to check which lock files are stale.
|
|
406
|
+
|
|
407
|
+
### Logs not being created
|
|
408
|
+
|
|
409
|
+
Ensure the logs directory exists and is writable:
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
mkdir -p logs
|
|
413
|
+
chmod 755 logs
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### PRD not being processed
|
|
417
|
+
|
|
418
|
+
Check:
|
|
419
|
+
1. PRD is in the correct directory (`docs/PRDs/night-watch/`)
|
|
420
|
+
2. Dependencies are satisfied (check `done/` directory)
|
|
421
|
+
3. No open PR exists for this PRD
|
|
422
|
+
4. Run `night-watch run --dry-run` to see what would be processed
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## Contributing
|
|
427
|
+
|
|
428
|
+
### Development Setup
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
git clone https://github.com/joaopio/night-watch-cli.git
|
|
432
|
+
cd night-watch-cli
|
|
433
|
+
npm install
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Build
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
npm run build
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### Test
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
npm test
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Run in Development
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
npm run dev -- init
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Project Structure
|
|
455
|
+
|
|
456
|
+
```
|
|
457
|
+
night-watch-cli/
|
|
458
|
+
+-- bin/
|
|
459
|
+
| +-- night-watch.mjs # ESM entry point
|
|
460
|
+
+-- src/
|
|
461
|
+
| +-- cli.ts # CLI entry
|
|
462
|
+
| +-- config.ts # Config loader
|
|
463
|
+
| +-- types.ts # TypeScript types
|
|
464
|
+
| +-- constants.ts # Default values
|
|
465
|
+
| +-- commands/ # Command implementations
|
|
466
|
+
| | +-- init.ts
|
|
467
|
+
| | +-- run.ts
|
|
468
|
+
| | +-- review.ts
|
|
469
|
+
| | +-- install.ts
|
|
470
|
+
| | +-- uninstall.ts
|
|
471
|
+
| | +-- status.ts
|
|
472
|
+
| | +-- logs.ts
|
|
473
|
+
| +-- utils/
|
|
474
|
+
| +-- shell.ts # Shell execution
|
|
475
|
+
| +-- crontab.ts # Crontab management
|
|
476
|
+
+-- scripts/ # Bundled bash scripts
|
|
477
|
+
| +-- night-watch-cron.sh
|
|
478
|
+
| +-- night-watch-pr-reviewer-cron.sh
|
|
479
|
+
| +-- night-watch-helpers.sh
|
|
480
|
+
+-- templates/ # Template files
|
|
481
|
+
| +-- night-watch.md
|
|
482
|
+
| +-- night-watch-pr-reviewer.md
|
|
483
|
+
| +-- night-watch.config.json
|
|
484
|
+
+-- dist/ # Compiled output
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Publishing (For Maintainers)
|
|
490
|
+
|
|
491
|
+
To publish a new version to npm:
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
# 1. Update version in package.json
|
|
495
|
+
# 2. Build and test
|
|
496
|
+
npm run build
|
|
497
|
+
npm test
|
|
498
|
+
|
|
499
|
+
# 3. Publish to npm (public access)
|
|
500
|
+
npm run publish:npm
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
The `publish:npm` script runs `npm publish --access public`.
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## License
|
|
508
|
+
|
|
509
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join } from 'path';
|
|
6
|
+
import { initCommand } from './commands/init.js';
|
|
7
|
+
import { runCommand } from './commands/run.js';
|
|
8
|
+
import { reviewCommand } from './commands/review.js';
|
|
9
|
+
import { installCommand } from './commands/install.js';
|
|
10
|
+
import { uninstallCommand } from './commands/uninstall.js';
|
|
11
|
+
import { statusCommand } from './commands/status.js';
|
|
12
|
+
import { logsCommand } from './commands/logs.js';
|
|
13
|
+
// Get package.json version
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
const packageJsonPath = join(__dirname, '..', 'package.json');
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
18
|
+
const program = new Command();
|
|
19
|
+
program
|
|
20
|
+
.name('night-watch')
|
|
21
|
+
.description('Autonomous PRD execution using Claude CLI + cron')
|
|
22
|
+
.version(packageJson.version);
|
|
23
|
+
// Register init command
|
|
24
|
+
initCommand(program);
|
|
25
|
+
// Register run command
|
|
26
|
+
runCommand(program);
|
|
27
|
+
// Register review command
|
|
28
|
+
reviewCommand(program);
|
|
29
|
+
// Register Phase 5 commands
|
|
30
|
+
installCommand(program);
|
|
31
|
+
uninstallCommand(program);
|
|
32
|
+
statusCommand(program);
|
|
33
|
+
logsCommand(program);
|
|
34
|
+
program.parse();
|
|
35
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/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