the-grid-cc 1.7.13 → 1.7.14
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/02-SUMMARY.md +156 -0
- package/agents/grid-accountant.md +519 -0
- package/agents/grid-git-operator.md +661 -0
- package/agents/grid-researcher.md +421 -0
- package/agents/grid-scout.md +376 -0
- package/commands/grid/VERSION +1 -1
- package/commands/grid/branch.md +567 -0
- package/commands/grid/budget.md +438 -0
- package/commands/grid/daemon.md +637 -0
- package/commands/grid/init.md +375 -18
- package/commands/grid/mc.md +103 -1098
- package/commands/grid/resume.md +656 -0
- package/docs/BUDGET_SYSTEM.md +745 -0
- package/docs/DAEMON_ARCHITECTURE.md +780 -0
- package/docs/GIT_AUTONOMY.md +981 -0
- package/docs/MC_OPTIMIZATION.md +181 -0
- package/docs/MC_PROTOCOLS.md +950 -0
- package/docs/PERSISTENCE.md +962 -0
- package/docs/RESEARCH_FIRST.md +591 -0
- package/package.json +1 -1
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
# /grid:daemon - Background Execution Mode
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
name: grid:daemon
|
|
5
|
+
description: Fire-and-forget long-running autonomous execution
|
|
6
|
+
allowed-tools:
|
|
7
|
+
- Read
|
|
8
|
+
- Write
|
|
9
|
+
- Edit
|
|
10
|
+
- Bash
|
|
11
|
+
- Glob
|
|
12
|
+
- Grep
|
|
13
|
+
- Task
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
Launch, monitor, and control long-running Grid sessions that execute in the background.
|
|
17
|
+
|
|
18
|
+
## USAGE
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
/grid:daemon "task description" # Start new daemon
|
|
22
|
+
/grid:daemon status # Check active daemon
|
|
23
|
+
/grid:daemon status <id> # Check specific daemon
|
|
24
|
+
/grid:daemon list # List all daemons
|
|
25
|
+
/grid:daemon stop # Stop active daemon
|
|
26
|
+
/grid:daemon stop <id> # Stop specific daemon
|
|
27
|
+
/grid:daemon resume "response" # Resume from checkpoint
|
|
28
|
+
/grid:daemon logs # Tail daemon logs
|
|
29
|
+
/grid:daemon logs <id> # Tail specific daemon logs
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## WHEN TO USE
|
|
33
|
+
|
|
34
|
+
**Good for:**
|
|
35
|
+
- Complex multi-hour builds
|
|
36
|
+
- Overnight refactoring
|
|
37
|
+
- Large codebase migrations
|
|
38
|
+
- Tasks you want to run while away
|
|
39
|
+
- Background work while you continue coding
|
|
40
|
+
|
|
41
|
+
**Use regular `/grid` for:**
|
|
42
|
+
- Interactive development
|
|
43
|
+
- Tasks needing frequent input
|
|
44
|
+
- Learning/exploration
|
|
45
|
+
- Quick builds (< 30 min)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## BEHAVIOR
|
|
50
|
+
|
|
51
|
+
### Starting a Daemon
|
|
52
|
+
|
|
53
|
+
When user runs `/grid:daemon "task"`:
|
|
54
|
+
|
|
55
|
+
1. **Generate Daemon ID**
|
|
56
|
+
```
|
|
57
|
+
{YYYYMMDD}-{HHMMSS}-{slug}
|
|
58
|
+
Example: 20260123-143000-build-auth-api
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. **Create Daemon Directory**
|
|
62
|
+
```
|
|
63
|
+
.grid/daemon/{daemon-id}/
|
|
64
|
+
├── task.txt # Original task description
|
|
65
|
+
├── checkpoint.json # Execution state
|
|
66
|
+
├── heartbeat.json # Health monitoring
|
|
67
|
+
├── output.log # Full output log
|
|
68
|
+
└── audit.log # Action audit trail
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
3. **Initialize Checkpoint**
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"version": "1.0",
|
|
75
|
+
"daemon_id": "{id}",
|
|
76
|
+
"created": "{ISO timestamp}",
|
|
77
|
+
"updated": "{ISO timestamp}",
|
|
78
|
+
"status": "starting",
|
|
79
|
+
"task": {
|
|
80
|
+
"description": "{user description}",
|
|
81
|
+
"mode": "autopilot"
|
|
82
|
+
},
|
|
83
|
+
"progress": {
|
|
84
|
+
"current_wave": 0,
|
|
85
|
+
"total_waves": 0,
|
|
86
|
+
"completed_blocks": [],
|
|
87
|
+
"current_block": null,
|
|
88
|
+
"percent": 0
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
4. **Launch Background Execution**
|
|
94
|
+
|
|
95
|
+
**Option A: Claude Code Background Agent (v2.0.60+)**
|
|
96
|
+
- Spawn Task() with daemon orchestrator
|
|
97
|
+
- Use Ctrl+B equivalent to background if available
|
|
98
|
+
- Monitor via scratchpad
|
|
99
|
+
|
|
100
|
+
**Option B: External Process (Fallback)**
|
|
101
|
+
```bash
|
|
102
|
+
nohup claude --print -p "..." > .grid/daemon/{id}/output.log 2>&1 &
|
|
103
|
+
echo $! > .grid/daemon/{id}/pid
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
5. **Display Confirmation**
|
|
107
|
+
```
|
|
108
|
+
DAEMON SPAWNED
|
|
109
|
+
══════════════
|
|
110
|
+
|
|
111
|
+
ID: 20260123-143000-build-auth-api
|
|
112
|
+
Task: Build REST API with user authentication
|
|
113
|
+
Mode: Autopilot
|
|
114
|
+
|
|
115
|
+
Status: Initializing
|
|
116
|
+
Monitor: /grid:daemon status
|
|
117
|
+
Stop: /grid:daemon stop
|
|
118
|
+
|
|
119
|
+
You can close this terminal. Work continues in background.
|
|
120
|
+
|
|
121
|
+
End of Line.
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### Checking Status
|
|
127
|
+
|
|
128
|
+
When user runs `/grid:daemon status`:
|
|
129
|
+
|
|
130
|
+
1. **Find Active Daemon**
|
|
131
|
+
- Check `.grid/daemon/*/checkpoint.json` for `status != "complete"`
|
|
132
|
+
- If multiple active, show list
|
|
133
|
+
- If none active, show "No active daemons"
|
|
134
|
+
|
|
135
|
+
2. **Read Checkpoint State**
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"status": "executing",
|
|
139
|
+
"progress": {
|
|
140
|
+
"current_wave": 2,
|
|
141
|
+
"total_waves": 4,
|
|
142
|
+
"percent": 45
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
3. **Read Recent Scratchpad/Logs**
|
|
148
|
+
- Last 10 entries from scratchpad
|
|
149
|
+
- Last 20 lines from output.log
|
|
150
|
+
|
|
151
|
+
4. **Display Status**
|
|
152
|
+
```
|
|
153
|
+
DAEMON STATUS
|
|
154
|
+
═════════════
|
|
155
|
+
|
|
156
|
+
ID: 20260123-143000-build-auth-api
|
|
157
|
+
Runtime: 1h 23m
|
|
158
|
+
Status: Executing
|
|
159
|
+
|
|
160
|
+
Progress: [█████████░░░░░░░░░░░] 45%
|
|
161
|
+
|
|
162
|
+
Current: Wave 2 of 4
|
|
163
|
+
Block 05 - User Authentication
|
|
164
|
+
├─ Thread 5.1: JWT utilities ✓
|
|
165
|
+
├─ Thread 5.2: Auth middleware ⚡ In Progress
|
|
166
|
+
└─ Thread 5.3: Protected routes ○ Pending
|
|
167
|
+
|
|
168
|
+
Recent Activity:
|
|
169
|
+
14:52 - executor-05: Implementing JWT verification
|
|
170
|
+
14:48 - executor-04: Completed database models
|
|
171
|
+
14:45 - recognizer: Wave 1 verified ✓
|
|
172
|
+
|
|
173
|
+
Commits: 8 made
|
|
174
|
+
Est. Remaining: ~2h 15m
|
|
175
|
+
|
|
176
|
+
End of Line.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
### Handling Checkpoints
|
|
182
|
+
|
|
183
|
+
When daemon reaches a checkpoint:
|
|
184
|
+
|
|
185
|
+
1. **Update Checkpoint State**
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"status": "checkpoint",
|
|
189
|
+
"checkpoint_stack": [{
|
|
190
|
+
"type": "human-verify",
|
|
191
|
+
"block": "07",
|
|
192
|
+
"details": {
|
|
193
|
+
"what_built": "Stripe webhook endpoint",
|
|
194
|
+
"how_to_verify": ["Run stripe listen...", "Trigger event..."]
|
|
195
|
+
},
|
|
196
|
+
"created": "{timestamp}"
|
|
197
|
+
}]
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
2. **Attempt Notification**
|
|
202
|
+
- System notification (if enabled)
|
|
203
|
+
- Write to `.grid/daemon/{id}/ATTENTION_NEEDED`
|
|
204
|
+
|
|
205
|
+
3. **Pause Execution**
|
|
206
|
+
- Daemon waits for user response
|
|
207
|
+
- Heartbeat continues (shows "checkpoint" status)
|
|
208
|
+
|
|
209
|
+
4. **Status Shows Checkpoint**
|
|
210
|
+
```
|
|
211
|
+
DAEMON CHECKPOINT
|
|
212
|
+
═════════════════
|
|
213
|
+
|
|
214
|
+
ID: 20260123-143000-build-auth-api
|
|
215
|
+
Status: AWAITING USER
|
|
216
|
+
|
|
217
|
+
Checkpoint Type: human-verify
|
|
218
|
+
Block: 07 - Payment Webhooks
|
|
219
|
+
|
|
220
|
+
What was built:
|
|
221
|
+
- Stripe webhook endpoint at /api/webhooks/stripe
|
|
222
|
+
- Event handlers for payment intents
|
|
223
|
+
- Signature verification
|
|
224
|
+
|
|
225
|
+
How to verify:
|
|
226
|
+
1. Run: stripe listen --forward-to localhost:3000/api/webhooks/stripe
|
|
227
|
+
2. Run: stripe trigger payment_intent.succeeded
|
|
228
|
+
3. Check logs for "Payment succeeded" event
|
|
229
|
+
|
|
230
|
+
Resume:
|
|
231
|
+
/grid:daemon resume "approved"
|
|
232
|
+
/grid:daemon resume "Issue: [describe problem]"
|
|
233
|
+
|
|
234
|
+
End of Line.
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### Resuming from Checkpoint
|
|
240
|
+
|
|
241
|
+
When user runs `/grid:daemon resume "response"`:
|
|
242
|
+
|
|
243
|
+
1. **Validate Response**
|
|
244
|
+
- "approved" / "done" / "yes" → Clear checkpoint, continue
|
|
245
|
+
- Other text → Pass as feedback, may re-plan
|
|
246
|
+
|
|
247
|
+
2. **Update Checkpoint**
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"status": "executing",
|
|
251
|
+
"checkpoint_stack": [],
|
|
252
|
+
"checkpoint_history": [{
|
|
253
|
+
"type": "human-verify",
|
|
254
|
+
"response": "approved",
|
|
255
|
+
"resolved": "{timestamp}"
|
|
256
|
+
}]
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
3. **Signal Daemon to Continue**
|
|
261
|
+
- Write response to `.grid/daemon/{id}/resume.txt`
|
|
262
|
+
- Daemon monitors this file and continues
|
|
263
|
+
|
|
264
|
+
4. **Display Confirmation**
|
|
265
|
+
```
|
|
266
|
+
DAEMON RESUMED
|
|
267
|
+
══════════════
|
|
268
|
+
|
|
269
|
+
Checkpoint cleared: human-verify (Block 07)
|
|
270
|
+
Response: approved
|
|
271
|
+
|
|
272
|
+
Continuing execution...
|
|
273
|
+
|
|
274
|
+
Current: Block 08 - Order Management
|
|
275
|
+
Status: Executing
|
|
276
|
+
|
|
277
|
+
End of Line.
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
### Stopping a Daemon
|
|
283
|
+
|
|
284
|
+
When user runs `/grid:daemon stop`:
|
|
285
|
+
|
|
286
|
+
1. **Request Graceful Stop**
|
|
287
|
+
- Write "STOP" to `.grid/daemon/{id}/control.txt`
|
|
288
|
+
- Daemon completes current Program, then exits
|
|
289
|
+
|
|
290
|
+
2. **Wait for Completion (with timeout)**
|
|
291
|
+
```
|
|
292
|
+
DAEMON STOPPING
|
|
293
|
+
═══════════════
|
|
294
|
+
|
|
295
|
+
ID: 20260123-143000-build-auth-api
|
|
296
|
+
Waiting for current work to complete...
|
|
297
|
+
|
|
298
|
+
[████████░░░░░░░░░░░░] 40% - Finishing executor-05
|
|
299
|
+
|
|
300
|
+
Timeout: 2 minutes (then force stop)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
3. **Update Final State**
|
|
304
|
+
```json
|
|
305
|
+
{
|
|
306
|
+
"status": "stopped",
|
|
307
|
+
"stop_reason": "user_requested",
|
|
308
|
+
"stopped_at": "{timestamp}"
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
4. **Display Completion**
|
|
313
|
+
```
|
|
314
|
+
DAEMON STOPPED
|
|
315
|
+
══════════════
|
|
316
|
+
|
|
317
|
+
ID: 20260123-143000-build-auth-api
|
|
318
|
+
Final Status: Stopped at Block 05
|
|
319
|
+
|
|
320
|
+
Work Completed:
|
|
321
|
+
- Blocks 01-04 complete
|
|
322
|
+
- Block 05 partial (Thread 5.2 in progress)
|
|
323
|
+
|
|
324
|
+
Commits Made: 8
|
|
325
|
+
Files Modified: 15
|
|
326
|
+
|
|
327
|
+
Resume Later:
|
|
328
|
+
/grid:daemon resume-stopped 20260123-143000-build-auth-api
|
|
329
|
+
|
|
330
|
+
End of Line.
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### Listing Daemons
|
|
336
|
+
|
|
337
|
+
When user runs `/grid:daemon list`:
|
|
338
|
+
|
|
339
|
+
```
|
|
340
|
+
DAEMON LIST
|
|
341
|
+
═══════════
|
|
342
|
+
|
|
343
|
+
Active:
|
|
344
|
+
20260123-143000-build-auth-api Executing 45% 1h 23m
|
|
345
|
+
|
|
346
|
+
Checkpointed:
|
|
347
|
+
20260122-091500-refactor-db human-verify 12h ago
|
|
348
|
+
|
|
349
|
+
Completed:
|
|
350
|
+
20260121-160000-add-tests Complete 100% 2d ago
|
|
351
|
+
20260120-103000-fix-bugs Complete 100% 3d ago
|
|
352
|
+
|
|
353
|
+
Stopped:
|
|
354
|
+
20260119-143000-big-migration Stopped 60% 4d ago
|
|
355
|
+
|
|
356
|
+
Commands:
|
|
357
|
+
/grid:daemon status <id> View details
|
|
358
|
+
/grid:daemon resume <id> Resume checkpointed
|
|
359
|
+
/grid:daemon logs <id> View logs
|
|
360
|
+
/grid:daemon clean Remove completed (>7 days)
|
|
361
|
+
|
|
362
|
+
End of Line.
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
### Viewing Logs
|
|
368
|
+
|
|
369
|
+
When user runs `/grid:daemon logs`:
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
DAEMON LOGS
|
|
373
|
+
═══════════
|
|
374
|
+
|
|
375
|
+
ID: 20260123-143000-build-auth-api
|
|
376
|
+
Showing last 50 lines (tail -f mode):
|
|
377
|
+
|
|
378
|
+
14:52:33 [executor-05] Starting JWT verification implementation
|
|
379
|
+
14:52:35 [executor-05] Reading existing auth utils...
|
|
380
|
+
14:52:38 [executor-05] Creating src/lib/jwt.ts
|
|
381
|
+
14:52:45 [executor-05] Writing verifyToken function
|
|
382
|
+
14:53:12 [executor-05] Adding refresh token rotation
|
|
383
|
+
14:53:45 [executor-05] Committing: feat(05): Add JWT utilities
|
|
384
|
+
14:53:48 [scratchpad] executor-05: Found pattern - uses jose library
|
|
385
|
+
14:54:02 [executor-05] Thread 5.1 complete
|
|
386
|
+
14:54:05 [executor-05] Starting Thread 5.2: Auth middleware
|
|
387
|
+
...
|
|
388
|
+
|
|
389
|
+
(Press Ctrl+C to exit log view)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## DAEMON ORCHESTRATOR
|
|
395
|
+
|
|
396
|
+
The daemon uses a specialized orchestrator that:
|
|
397
|
+
|
|
398
|
+
1. **Operates Headless**
|
|
399
|
+
- No user prompts
|
|
400
|
+
- Decisions logged, not asked
|
|
401
|
+
- Checkpoints pause, don't prompt
|
|
402
|
+
|
|
403
|
+
2. **Writes Heartbeats**
|
|
404
|
+
- Every 30 seconds to heartbeat.json
|
|
405
|
+
- Enables external health monitoring
|
|
406
|
+
|
|
407
|
+
3. **Checkpoints Aggressively**
|
|
408
|
+
- After every Program completion
|
|
409
|
+
- After every wave
|
|
410
|
+
- On any error
|
|
411
|
+
|
|
412
|
+
4. **Handles Recovery**
|
|
413
|
+
- On start, checks for existing checkpoint
|
|
414
|
+
- Verifies git state matches checkpoint
|
|
415
|
+
- Resumes or reconciles as needed
|
|
416
|
+
|
|
417
|
+
### Orchestrator Prompt Template
|
|
418
|
+
|
|
419
|
+
```python
|
|
420
|
+
Task(
|
|
421
|
+
prompt=f"""
|
|
422
|
+
First, read ~/.claude/agents/grid-daemon-orchestrator.md for your role.
|
|
423
|
+
|
|
424
|
+
DAEMON MODE EXECUTION
|
|
425
|
+
═════════════════════
|
|
426
|
+
|
|
427
|
+
Daemon ID: {daemon_id}
|
|
428
|
+
Task: {task_description}
|
|
429
|
+
Mode: Autopilot (zero user interaction unless checkpoint)
|
|
430
|
+
|
|
431
|
+
<checkpoint>
|
|
432
|
+
{checkpoint_json if resuming else "New daemon - no prior state"}
|
|
433
|
+
</checkpoint>
|
|
434
|
+
|
|
435
|
+
<warmth>
|
|
436
|
+
{warmth_from_checkpoint if resuming else "No prior warmth"}
|
|
437
|
+
</warmth>
|
|
438
|
+
|
|
439
|
+
RULES:
|
|
440
|
+
1. Write heartbeat every 30 seconds
|
|
441
|
+
2. Checkpoint after every Program completes
|
|
442
|
+
3. On checkpoint types, PAUSE and wait for resume signal
|
|
443
|
+
4. Never prompt user - log decisions instead
|
|
444
|
+
5. On error, checkpoint and STOP
|
|
445
|
+
|
|
446
|
+
Execute the task. Report progress to checkpoint.json.
|
|
447
|
+
""",
|
|
448
|
+
subagent_type="general-purpose",
|
|
449
|
+
model="opus",
|
|
450
|
+
description=f"Daemon: {daemon_id}"
|
|
451
|
+
)
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## DIRECTORY STRUCTURE
|
|
457
|
+
|
|
458
|
+
```
|
|
459
|
+
.grid/
|
|
460
|
+
├── STATE.md # Regular Grid state
|
|
461
|
+
├── daemon/
|
|
462
|
+
│ ├── active # Symlink to active daemon (if any)
|
|
463
|
+
│ ├── 20260123-143000-build-auth-api/
|
|
464
|
+
│ │ ├── task.txt # Original task
|
|
465
|
+
│ │ ├── checkpoint.json # Full execution state
|
|
466
|
+
│ │ ├── heartbeat.json # Health monitoring
|
|
467
|
+
│ │ ├── control.txt # Control signals (STOP, PAUSE)
|
|
468
|
+
│ │ ├── resume.txt # Resume responses
|
|
469
|
+
│ │ ├── output.log # Full Claude output
|
|
470
|
+
│ │ ├── audit.log # Action audit trail
|
|
471
|
+
│ │ └── ATTENTION_NEEDED # Flag file when checkpoint hit
|
|
472
|
+
│ └── 20260122-091500-refactor-db/
|
|
473
|
+
│ └── ...
|
|
474
|
+
└── ...
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## CONFIGURATION
|
|
480
|
+
|
|
481
|
+
Settings in `.grid/config.json`:
|
|
482
|
+
|
|
483
|
+
```json
|
|
484
|
+
{
|
|
485
|
+
"daemon": {
|
|
486
|
+
"default_mode": "autopilot",
|
|
487
|
+
"max_runtime_hours": 24,
|
|
488
|
+
"checkpoint_on_wave_complete": true,
|
|
489
|
+
"heartbeat_interval_seconds": 30,
|
|
490
|
+
"stall_threshold_minutes": 30,
|
|
491
|
+
|
|
492
|
+
"notifications": {
|
|
493
|
+
"system": true,
|
|
494
|
+
"sound": true,
|
|
495
|
+
"webhook": null
|
|
496
|
+
},
|
|
497
|
+
|
|
498
|
+
"notify_on": {
|
|
499
|
+
"start": false,
|
|
500
|
+
"checkpoint": true,
|
|
501
|
+
"complete": true,
|
|
502
|
+
"error": true,
|
|
503
|
+
"stall": true
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
"cleanup": {
|
|
507
|
+
"auto_clean_completed_days": 7,
|
|
508
|
+
"keep_audit_logs": true
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## CONSTRAINTS
|
|
517
|
+
|
|
518
|
+
- **One active daemon per project** (multiple stopped/completed allowed)
|
|
519
|
+
- **Autopilot mode only** (no GUIDED/HANDS ON in daemon)
|
|
520
|
+
- **Checkpoints still require user** (design intentional for safety)
|
|
521
|
+
- **No destructive git operations** without explicit prior approval
|
|
522
|
+
- **Max runtime enforced** (default 24 hours, configurable)
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## ERROR HANDLING
|
|
527
|
+
|
|
528
|
+
### Daemon Crash
|
|
529
|
+
|
|
530
|
+
If daemon process dies unexpectedly:
|
|
531
|
+
|
|
532
|
+
1. Next `/grid:daemon status` detects no heartbeat
|
|
533
|
+
2. Offers recovery:
|
|
534
|
+
```
|
|
535
|
+
DAEMON RECOVERY NEEDED
|
|
536
|
+
══════════════════════
|
|
537
|
+
|
|
538
|
+
ID: 20260123-143000-build-auth-api
|
|
539
|
+
Last Heartbeat: 15 minutes ago
|
|
540
|
+
Last Checkpoint: Block 05, Thread 5.2
|
|
541
|
+
|
|
542
|
+
The daemon appears to have crashed.
|
|
543
|
+
|
|
544
|
+
Options:
|
|
545
|
+
/grid:daemon recover Resume from last checkpoint
|
|
546
|
+
/grid:daemon status -f Force status check
|
|
547
|
+
/grid:daemon stop -f Mark as stopped, don't resume
|
|
548
|
+
|
|
549
|
+
End of Line.
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### API Errors
|
|
553
|
+
|
|
554
|
+
Rate limits, auth failures, etc:
|
|
555
|
+
|
|
556
|
+
1. Daemon enters exponential backoff
|
|
557
|
+
2. After 5 retries, checkpoints and pauses
|
|
558
|
+
3. Status shows error state:
|
|
559
|
+
```
|
|
560
|
+
Status: ERROR - API rate limit
|
|
561
|
+
Retry in: 5 minutes
|
|
562
|
+
Or: /grid:daemon resume "retry now"
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
## CURRENT LIMITATIONS
|
|
568
|
+
|
|
569
|
+
**What works today (via manual setup):**
|
|
570
|
+
- Basic daemon pattern with nohup
|
|
571
|
+
- State persistence via checkpoint files
|
|
572
|
+
- Manual resume via /grid:daemon resume
|
|
573
|
+
|
|
574
|
+
**What needs Claude Code changes:**
|
|
575
|
+
- Native daemon/service mode
|
|
576
|
+
- Built-in notifications
|
|
577
|
+
- IPC for status queries
|
|
578
|
+
- Automatic crash recovery
|
|
579
|
+
|
|
580
|
+
**What needs external tooling:**
|
|
581
|
+
- Process monitoring daemon
|
|
582
|
+
- System notification integration
|
|
583
|
+
- Webhook delivery service
|
|
584
|
+
|
|
585
|
+
See `/docs/DAEMON_ARCHITECTURE.md` for full technical design and future roadmap.
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
## EXAMPLES
|
|
590
|
+
|
|
591
|
+
### Basic Usage
|
|
592
|
+
|
|
593
|
+
```bash
|
|
594
|
+
# Start daemon for overnight work
|
|
595
|
+
/grid:daemon "Refactor entire codebase to TypeScript with full type safety"
|
|
596
|
+
|
|
597
|
+
# Check progress next morning
|
|
598
|
+
/grid:daemon status
|
|
599
|
+
|
|
600
|
+
# Handle checkpoint
|
|
601
|
+
/grid:daemon resume "approved"
|
|
602
|
+
|
|
603
|
+
# View logs if something seems wrong
|
|
604
|
+
/grid:daemon logs
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
### Complex Project
|
|
608
|
+
|
|
609
|
+
```bash
|
|
610
|
+
# Large project with expected checkpoints
|
|
611
|
+
/grid:daemon "Build complete SaaS application with:
|
|
612
|
+
- User authentication (email + OAuth)
|
|
613
|
+
- Stripe billing integration
|
|
614
|
+
- Admin dashboard
|
|
615
|
+
- API documentation"
|
|
616
|
+
|
|
617
|
+
# Expected checkpoints:
|
|
618
|
+
# 1. human-verify: Auth flow working
|
|
619
|
+
# 2. human-action: Set up Stripe test keys
|
|
620
|
+
# 3. human-verify: Billing integration working
|
|
621
|
+
# 4. human-verify: Final review
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
---
|
|
625
|
+
|
|
626
|
+
## RULES
|
|
627
|
+
|
|
628
|
+
1. **Fire and forget** - User launches, daemon runs independently
|
|
629
|
+
2. **Checkpoint at boundaries** - Every wave, every completion
|
|
630
|
+
3. **Heartbeat always** - 30 second intervals for health monitoring
|
|
631
|
+
4. **Graceful degradation** - Crash → checkpoint → resume
|
|
632
|
+
5. **No silent failures** - Errors trigger notification + pause
|
|
633
|
+
6. **Audit everything** - Full trail in audit.log
|
|
634
|
+
7. **One active per project** - Prevents conflicts
|
|
635
|
+
8. **Safety first** - Checkpoints for anything destructive
|
|
636
|
+
|
|
637
|
+
End of Line.
|