@yail259/overnight 0.1.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/README.md +219 -0
- package/bun.lock +63 -0
- package/dist/cli.js +26102 -0
- package/package.json +33 -0
- package/src/cli.ts +434 -0
- package/src/notify.ts +50 -0
- package/src/report.ts +115 -0
- package/src/runner.ts +283 -0
- package/src/types.ts +48 -0
- package/tsconfig.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# overnight
|
|
2
|
+
|
|
3
|
+
Batch job runner for Claude Code. Queue tasks, run them unattended, get results. Designed for overnight/AFK use.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Crash Recovery** - Auto-checkpoints after each job. Use `overnight resume` to continue after interrupts.
|
|
8
|
+
- **Retry Logic** - Auto-retries 3x on API/network errors with exponential backoff.
|
|
9
|
+
- **Push Notifications** - `--notify` sends completion summary to ntfy.sh (free, no signup).
|
|
10
|
+
- **Markdown Reports** - `-r report.md` generates a summary with status and next steps.
|
|
11
|
+
- **Verification Loops** - Optionally runs a verification prompt after each task.
|
|
12
|
+
- **Secure by Default** - No Bash access by default. Whitelist tools per-task.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# npm
|
|
18
|
+
npm install -g overnight
|
|
19
|
+
|
|
20
|
+
# bun
|
|
21
|
+
bun install -g overnight
|
|
22
|
+
|
|
23
|
+
# npx (no install)
|
|
24
|
+
npx overnight run tasks.yaml
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Requires Claude Code CLI installed and authenticated.
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Create a tasks.yaml file
|
|
33
|
+
overnight init
|
|
34
|
+
|
|
35
|
+
# Edit with your tasks, then run
|
|
36
|
+
overnight run tasks.yaml
|
|
37
|
+
|
|
38
|
+
# Run with notifications and report
|
|
39
|
+
overnight run tasks.yaml --notify -r report.md
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Commands
|
|
43
|
+
|
|
44
|
+
| Command | Description |
|
|
45
|
+
|---------|-------------|
|
|
46
|
+
| `overnight run <file>` | Run jobs from YAML file |
|
|
47
|
+
| `overnight resume <file>` | Resume interrupted run from checkpoint |
|
|
48
|
+
| `overnight single "<prompt>"` | Run a single task directly |
|
|
49
|
+
| `overnight init` | Create example tasks.yaml |
|
|
50
|
+
|
|
51
|
+
## tasks.yaml Format
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
defaults:
|
|
55
|
+
timeout_seconds: 300 # Per-task timeout (default: 300)
|
|
56
|
+
stall_timeout_seconds: 120 # No-activity timeout (default: 120)
|
|
57
|
+
verify: true # Run verification pass (default: true)
|
|
58
|
+
allowed_tools: # Whitelist tools (default: Read,Edit,Write,Glob,Grep)
|
|
59
|
+
- Read
|
|
60
|
+
- Edit
|
|
61
|
+
- Glob
|
|
62
|
+
- Grep
|
|
63
|
+
|
|
64
|
+
tasks:
|
|
65
|
+
# Simple format
|
|
66
|
+
- "Fix the bug in auth.py"
|
|
67
|
+
|
|
68
|
+
# Detailed format
|
|
69
|
+
- prompt: "Add input validation"
|
|
70
|
+
timeout_seconds: 600
|
|
71
|
+
verify: false
|
|
72
|
+
allowed_tools: [Read, Edit, Bash, Glob, Grep]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## CLI Options
|
|
76
|
+
|
|
77
|
+
### `overnight run`
|
|
78
|
+
|
|
79
|
+
| Option | Description |
|
|
80
|
+
|--------|-------------|
|
|
81
|
+
| `-o, --output <file>` | Save results JSON |
|
|
82
|
+
| `-r, --report <file>` | Generate markdown report |
|
|
83
|
+
| `-s, --state-file <file>` | Custom checkpoint file |
|
|
84
|
+
| `--notify` | Send push notification via ntfy.sh |
|
|
85
|
+
| `--notify-topic <topic>` | ntfy.sh topic (default: overnight) |
|
|
86
|
+
| `-q, --quiet` | Minimal output |
|
|
87
|
+
|
|
88
|
+
### `overnight single`
|
|
89
|
+
|
|
90
|
+
| Option | Description |
|
|
91
|
+
|--------|-------------|
|
|
92
|
+
| `-t, --timeout <secs>` | Timeout in seconds (default: 300) |
|
|
93
|
+
| `--verify/--no-verify` | Run verification pass (default: true) |
|
|
94
|
+
| `-T, --tools <tool...>` | Allowed tools (can specify multiple) |
|
|
95
|
+
|
|
96
|
+
## Example Workflows
|
|
97
|
+
|
|
98
|
+
### Development: Run overnight, check in morning
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
nohup overnight run tasks.yaml --notify -r report.md -o results.json > overnight.log 2>&1 &
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### CI/CD: Run and fail if any task fails
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
overnight run tasks.yaml -q
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Single task with Bash access
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
overnight single "Run tests and fix failures" -T Read -T Edit -T Bash -T Glob
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Resume after crash/interrupt
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
overnight resume tasks.yaml
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Push Notifications
|
|
123
|
+
|
|
124
|
+
overnight uses [ntfy.sh](https://ntfy.sh) for push notifications - free, no signup required.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Send to default topic
|
|
128
|
+
overnight run tasks.yaml --notify
|
|
129
|
+
|
|
130
|
+
# Send to custom topic
|
|
131
|
+
overnight run tasks.yaml --notify --notify-topic my-overnight-jobs
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
To receive notifications:
|
|
135
|
+
1. Install the ntfy app ([iOS](https://apps.apple.com/app/ntfy/id1625396347), [Android](https://play.google.com/store/apps/details?id=io.heckel.ntfy))
|
|
136
|
+
2. Subscribe to your topic (default: `overnight`)
|
|
137
|
+
3. Run with `--notify`
|
|
138
|
+
|
|
139
|
+
## Crash Recovery
|
|
140
|
+
|
|
141
|
+
overnight automatically saves state after each completed job to `.overnight-state.json`.
|
|
142
|
+
|
|
143
|
+
If the run is interrupted (crash, Ctrl+C, network issues):
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Resume from last checkpoint
|
|
147
|
+
overnight resume tasks.yaml
|
|
148
|
+
|
|
149
|
+
# Resume with custom state file
|
|
150
|
+
overnight resume tasks.yaml --state-file my-state.json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The state file is automatically deleted on successful completion.
|
|
154
|
+
|
|
155
|
+
## Security
|
|
156
|
+
|
|
157
|
+
By default, overnight only allows safe file operations:
|
|
158
|
+
- `Read` - Read files
|
|
159
|
+
- `Edit` - Edit files
|
|
160
|
+
- `Write` - Write files
|
|
161
|
+
- `Glob` - Find files by pattern
|
|
162
|
+
- `Grep` - Search file contents
|
|
163
|
+
|
|
164
|
+
**No Bash access by default.** To enable Bash for specific tasks:
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
tasks:
|
|
168
|
+
- prompt: "Run tests and fix failures"
|
|
169
|
+
allowed_tools:
|
|
170
|
+
- Read
|
|
171
|
+
- Edit
|
|
172
|
+
- Bash
|
|
173
|
+
- Glob
|
|
174
|
+
- Grep
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Exit Codes
|
|
178
|
+
|
|
179
|
+
| Code | Meaning |
|
|
180
|
+
|------|---------|
|
|
181
|
+
| 0 | All tasks succeeded |
|
|
182
|
+
| 1 | One or more tasks failed |
|
|
183
|
+
|
|
184
|
+
## Files Created
|
|
185
|
+
|
|
186
|
+
| File | Description |
|
|
187
|
+
|------|-------------|
|
|
188
|
+
| `.overnight-state.json` | Checkpoint file (deleted on success) |
|
|
189
|
+
| `report.md` | Summary report (if `-r` used) |
|
|
190
|
+
| `results.json` | Full results (if `-o` used) |
|
|
191
|
+
|
|
192
|
+
## Job Statuses
|
|
193
|
+
|
|
194
|
+
| Status | Description |
|
|
195
|
+
|--------|-------------|
|
|
196
|
+
| `success` | Task completed successfully |
|
|
197
|
+
| `failed` | Task encountered an error |
|
|
198
|
+
| `timeout` | Task exceeded timeout |
|
|
199
|
+
| `stalled` | Task had no activity for too long |
|
|
200
|
+
| `verification_failed` | Verification found issues |
|
|
201
|
+
|
|
202
|
+
## Requirements
|
|
203
|
+
|
|
204
|
+
- Node.js 18+ or Bun
|
|
205
|
+
- Claude Code CLI installed and authenticated
|
|
206
|
+
- `@anthropic-ai/claude-agent-sdk` (installed automatically)
|
|
207
|
+
|
|
208
|
+
## Building from Source
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
git clone https://github.com/yail259/overnight.git
|
|
212
|
+
cd overnight
|
|
213
|
+
bun install
|
|
214
|
+
bun run compile # Creates standalone binary
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
MIT
|
package/bun.lock
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"lockfileVersion": 1,
|
|
3
|
+
"configVersion": 1,
|
|
4
|
+
"workspaces": {
|
|
5
|
+
"": {
|
|
6
|
+
"name": "overnight",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@anthropic-ai/claude-agent-sdk": "^0.1.0",
|
|
9
|
+
"commander": "^12.0.0",
|
|
10
|
+
"yaml": "^2.3.4",
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@types/node": "^20.11.0",
|
|
14
|
+
"typescript": "^5.3.0",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
"packages": {
|
|
19
|
+
"@anthropic-ai/claude-agent-sdk": ["@anthropic-ai/claude-agent-sdk@0.1.77", "", { "optionalDependencies": { "@img/sharp-darwin-arm64": "^0.33.5", "@img/sharp-darwin-x64": "^0.33.5", "@img/sharp-linux-arm": "^0.33.5", "@img/sharp-linux-arm64": "^0.33.5", "@img/sharp-linux-x64": "^0.33.5", "@img/sharp-linuxmusl-arm64": "^0.33.5", "@img/sharp-linuxmusl-x64": "^0.33.5", "@img/sharp-win32-x64": "^0.33.5" }, "peerDependencies": { "zod": "^3.25.0 || ^4.0.0" } }, "sha512-ZEjWQtkoB2MEY6K16DWMmF+8OhywAynH0m08V265cerbZ8xPD/2Ng2jPzbbO40mPeFSsMDJboShL+a3aObP0Jg=="],
|
|
20
|
+
|
|
21
|
+
"@img/sharp-darwin-arm64": ["@img/sharp-darwin-arm64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-arm64": "1.0.4" }, "os": "darwin", "cpu": "arm64" }, "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ=="],
|
|
22
|
+
|
|
23
|
+
"@img/sharp-darwin-x64": ["@img/sharp-darwin-x64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-x64": "1.0.4" }, "os": "darwin", "cpu": "x64" }, "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q=="],
|
|
24
|
+
|
|
25
|
+
"@img/sharp-libvips-darwin-arm64": ["@img/sharp-libvips-darwin-arm64@1.0.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg=="],
|
|
26
|
+
|
|
27
|
+
"@img/sharp-libvips-darwin-x64": ["@img/sharp-libvips-darwin-x64@1.0.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ=="],
|
|
28
|
+
|
|
29
|
+
"@img/sharp-libvips-linux-arm": ["@img/sharp-libvips-linux-arm@1.0.5", "", { "os": "linux", "cpu": "arm" }, "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g=="],
|
|
30
|
+
|
|
31
|
+
"@img/sharp-libvips-linux-arm64": ["@img/sharp-libvips-linux-arm64@1.0.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA=="],
|
|
32
|
+
|
|
33
|
+
"@img/sharp-libvips-linux-x64": ["@img/sharp-libvips-linux-x64@1.0.4", "", { "os": "linux", "cpu": "x64" }, "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw=="],
|
|
34
|
+
|
|
35
|
+
"@img/sharp-libvips-linuxmusl-arm64": ["@img/sharp-libvips-linuxmusl-arm64@1.0.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA=="],
|
|
36
|
+
|
|
37
|
+
"@img/sharp-libvips-linuxmusl-x64": ["@img/sharp-libvips-linuxmusl-x64@1.0.4", "", { "os": "linux", "cpu": "x64" }, "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw=="],
|
|
38
|
+
|
|
39
|
+
"@img/sharp-linux-arm": ["@img/sharp-linux-arm@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm": "1.0.5" }, "os": "linux", "cpu": "arm" }, "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ=="],
|
|
40
|
+
|
|
41
|
+
"@img/sharp-linux-arm64": ["@img/sharp-linux-arm64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm64": "1.0.4" }, "os": "linux", "cpu": "arm64" }, "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA=="],
|
|
42
|
+
|
|
43
|
+
"@img/sharp-linux-x64": ["@img/sharp-linux-x64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linux-x64": "1.0.4" }, "os": "linux", "cpu": "x64" }, "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA=="],
|
|
44
|
+
|
|
45
|
+
"@img/sharp-linuxmusl-arm64": ["@img/sharp-linuxmusl-arm64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linuxmusl-arm64": "1.0.4" }, "os": "linux", "cpu": "arm64" }, "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g=="],
|
|
46
|
+
|
|
47
|
+
"@img/sharp-linuxmusl-x64": ["@img/sharp-linuxmusl-x64@0.33.5", "", { "optionalDependencies": { "@img/sharp-libvips-linuxmusl-x64": "1.0.4" }, "os": "linux", "cpu": "x64" }, "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw=="],
|
|
48
|
+
|
|
49
|
+
"@img/sharp-win32-x64": ["@img/sharp-win32-x64@0.33.5", "", { "os": "win32", "cpu": "x64" }, "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg=="],
|
|
50
|
+
|
|
51
|
+
"@types/node": ["@types/node@20.19.30", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-WJtwWJu7UdlvzEAUm484QNg5eAoq5QR08KDNx7g45Usrs2NtOPiX8ugDqmKdXkyL03rBqU5dYNYVQetEpBHq2g=="],
|
|
52
|
+
|
|
53
|
+
"commander": ["commander@12.1.0", "", {}, "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA=="],
|
|
54
|
+
|
|
55
|
+
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
|
56
|
+
|
|
57
|
+
"undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
|
|
58
|
+
|
|
59
|
+
"yaml": ["yaml@2.8.2", "", { "bin": { "yaml": "bin.mjs" } }, "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A=="],
|
|
60
|
+
|
|
61
|
+
"zod": ["zod@4.3.6", "", {}, "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg=="],
|
|
62
|
+
}
|
|
63
|
+
}
|