nightshift-mcp 1.0.1 → 1.0.4
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 +799 -672
- package/dist/agent-spawner.d.ts +42 -5
- package/dist/agent-spawner.d.ts.map +1 -1
- package/dist/agent-spawner.js +226 -265
- package/dist/agent-spawner.js.map +1 -1
- package/dist/chat-manager.js +8 -8
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +61 -54
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +126 -126
- package/dist/index.js.map +1 -1
- package/dist/orchestrator.d.ts +91 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +504 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/platform.d.ts +66 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +143 -0
- package/dist/platform.js.map +1 -0
- package/dist/ralph-manager.d.ts.map +1 -1
- package/dist/ralph-manager.js +112 -19
- package/dist/ralph-manager.js.map +1 -1
- package/dist/tools/agents.d.ts +3 -0
- package/dist/tools/agents.d.ts.map +1 -1
- package/dist/tools/agents.js +190 -52
- package/dist/tools/agents.js.map +1 -1
- package/dist/tools/utility.d.ts.map +1 -1
- package/dist/tools/utility.js +92 -55
- package/dist/tools/utility.js.map +1 -1
- package/dist/workflow-manager.d.ts +8 -1
- package/dist/workflow-manager.d.ts.map +1 -1
- package/dist/workflow-manager.js +30 -3
- package/dist/workflow-manager.js.map +1 -1
- package/package.json +50 -48
package/README.md
CHANGED
|
@@ -1,672 +1,799 @@
|
|
|
1
|
-
# NightShift MCP
|
|
2
|
-
|
|
3
|
-
**The responsible kind of multi-agent chaos.**
|
|
4
|
-
|
|
5
|
-
Explicit delegation, review, and handoffs between AI models.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
An MCP (Model Context Protocol) server that enables multi-agent communication and task coordination via shared files. Designed for AI agents (Claude, Codex, Gemini, etc.) to collaborate autonomously with minimal human intervention.
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
- **Multi-agent chat**: Structured messages with agent name, timestamp, type, and content
|
|
14
|
-
- **Failover handling**: Seamless handoffs when an agent hits limits
|
|
15
|
-
- **Ralph-style PRD management**: Work through user stories in prd.json
|
|
16
|
-
- **Progress tracking**: Shared learnings via progress.txt
|
|
17
|
-
- **Agent
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
**
|
|
31
|
-
```bash
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- `
|
|
116
|
-
- `
|
|
117
|
-
- `
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
**
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
Files
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
###
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
"
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
#### `
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
- `
|
|
544
|
-
- `
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
#### `
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
- `
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
1
|
+
# NightShift MCP
|
|
2
|
+
|
|
3
|
+
**The responsible kind of multi-agent chaos.**
|
|
4
|
+
|
|
5
|
+
Explicit delegation, review, and handoffs between AI models.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
An MCP (Model Context Protocol) server that enables multi-agent communication and task coordination via shared files. Designed for AI agents (Claude, Codex, Gemini, etc.) to collaborate autonomously with minimal human intervention.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Multi-agent chat**: Structured messages with agent name, timestamp, type, and content
|
|
14
|
+
- **Failover handling**: Seamless handoffs when an agent hits limits
|
|
15
|
+
- **Ralph-style PRD management**: Work through user stories in prd.json with Zod-validated schemas and helpful error messages
|
|
16
|
+
- **Progress tracking**: Shared learnings via progress.txt
|
|
17
|
+
- **Agent spawning & orchestration**: Spawn Claude, Codex, Gemini, or Vibe as subprocesses with full lifecycle tracking
|
|
18
|
+
- **Autonomous orchestration**: Single `orchestrate` tool runs a claim→implement→complete loop until all stories pass
|
|
19
|
+
- **Agent status tracking**: Monitor spawned agents by PID, check exit codes, and tail output in real-time
|
|
20
|
+
- **Smart retry**: Automatically suggests or uses a different agent when one fails
|
|
21
|
+
- **Workflow management**: Phases, strategic decisions, and agent assignments
|
|
22
|
+
- **Watch/polling**: Monitor for new messages with cursor-based polling
|
|
23
|
+
- **Auto-archiving**: Archive old messages to keep the chat file manageable
|
|
24
|
+
- **Cross-platform**: Works on Windows, Linux, and macOS (uses cross-spawn and platform-safe process management)
|
|
25
|
+
- **Universal compatibility**: Works with any MCP-supporting tool (42 tools across 8 categories)
|
|
26
|
+
- **Simple file-based storage**: No external services required
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
**Via npm (recommended):**
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g nightshift-mcp
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Updating:**
|
|
36
|
+
```bash
|
|
37
|
+
npm update -g nightshift-mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Or build from source:**
|
|
41
|
+
```bash
|
|
42
|
+
git clone <repo-url>
|
|
43
|
+
cd nightshift-mcp
|
|
44
|
+
npm install
|
|
45
|
+
npm run build
|
|
46
|
+
npm link # makes 'nightshift-mcp' available globally
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
### Claude Code (`~/.claude.json`)
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"mcpServers": {
|
|
56
|
+
"nightshift": {
|
|
57
|
+
"command": "nightshift-mcp",
|
|
58
|
+
"args": []
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Codex (`~/.codex/config.toml`)
|
|
65
|
+
|
|
66
|
+
```toml
|
|
67
|
+
[mcp_servers.nightshift]
|
|
68
|
+
command = "nightshift-mcp"
|
|
69
|
+
args = []
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The server automatically uses the current working directory for the `.robot-chat/` folder. You can override this with the `ROBOT_CHAT_PROJECT_PATH` environment variable if needed.
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
For agents to communicate, they must be running in the **same project directory**. The chat file is created at `<project>/.robot-chat/chat.txt` based on where each CLI is started.
|
|
77
|
+
|
|
78
|
+
**Example - two agents working on the same project:**
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Terminal 1
|
|
82
|
+
cd ~/myproject
|
|
83
|
+
claude
|
|
84
|
+
|
|
85
|
+
# Terminal 2
|
|
86
|
+
cd ~/myproject
|
|
87
|
+
codex
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Both agents now share the same chat file and can coordinate via the nightshift tools.
|
|
91
|
+
|
|
92
|
+
**Note:** If agents are started in different directories, they will have separate chat files and won't be able to communicate.
|
|
93
|
+
|
|
94
|
+
## Tools
|
|
95
|
+
|
|
96
|
+
### `read_robot_chat`
|
|
97
|
+
|
|
98
|
+
Read recent messages from the chat file.
|
|
99
|
+
|
|
100
|
+
**Parameters:**
|
|
101
|
+
- `limit` (optional): Maximum messages to return (default: 20)
|
|
102
|
+
- `agent` (optional): Filter by agent name
|
|
103
|
+
- `type` (optional): Filter by message type
|
|
104
|
+
|
|
105
|
+
**Example:**
|
|
106
|
+
```
|
|
107
|
+
Read the last 10 messages from Claude
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `write_robot_chat`
|
|
111
|
+
|
|
112
|
+
Write a message to the chat file.
|
|
113
|
+
|
|
114
|
+
**Parameters:**
|
|
115
|
+
- `agent` (required): Your agent name (e.g., "Claude", "Codex")
|
|
116
|
+
- `type` (required): Message type
|
|
117
|
+
- `content` (required): Message content
|
|
118
|
+
|
|
119
|
+
**Message Types:**
|
|
120
|
+
- `FAILOVER_NEEDED` - Request another agent to take over
|
|
121
|
+
- `FAILOVER_CLAIMED` - Acknowledge taking over a task
|
|
122
|
+
- `TASK_COMPLETE` - Mark a task as finished
|
|
123
|
+
- `STATUS_UPDATE` - Share progress update
|
|
124
|
+
- `HANDOFF` - Pass work to a specific agent
|
|
125
|
+
- `INFO` - General information
|
|
126
|
+
- `ERROR` - Error report
|
|
127
|
+
- `QUESTION` - Ask other agents a question
|
|
128
|
+
- `ANSWER` - Answer a question
|
|
129
|
+
|
|
130
|
+
**Example:**
|
|
131
|
+
```
|
|
132
|
+
Post a STATUS_UPDATE from Claude about completing the login form
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `check_failovers`
|
|
136
|
+
|
|
137
|
+
Find unclaimed FAILOVER_NEEDED messages.
|
|
138
|
+
|
|
139
|
+
**Example:**
|
|
140
|
+
```
|
|
141
|
+
Check if any agent needs help with their task
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### `claim_failover`
|
|
145
|
+
|
|
146
|
+
Claim a failover request from another agent.
|
|
147
|
+
|
|
148
|
+
**Parameters:**
|
|
149
|
+
- `agent` (required): Your agent name
|
|
150
|
+
- `originalAgent` (required): Agent who requested failover
|
|
151
|
+
- `task` (optional): Task description
|
|
152
|
+
|
|
153
|
+
**Example:**
|
|
154
|
+
```
|
|
155
|
+
Claim the failover from Codex and continue working on the authentication feature
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### `get_chat_path`
|
|
159
|
+
|
|
160
|
+
Get the full path to the chat file.
|
|
161
|
+
|
|
162
|
+
### `list_agents`
|
|
163
|
+
|
|
164
|
+
List all agents who have posted to the chat, with their activity stats.
|
|
165
|
+
|
|
166
|
+
**Returns:**
|
|
167
|
+
- Agent name
|
|
168
|
+
- Last seen timestamp
|
|
169
|
+
- Last message type
|
|
170
|
+
- Total message count
|
|
171
|
+
|
|
172
|
+
**Example:**
|
|
173
|
+
```
|
|
174
|
+
Show me which agents have been active in the chat
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `watch_chat`
|
|
178
|
+
|
|
179
|
+
Poll for new messages since a cursor position. Useful for monitoring the chat for updates.
|
|
180
|
+
|
|
181
|
+
**Parameters:**
|
|
182
|
+
- `cursor` (optional): Line number from previous watch call. Omit to get current cursor.
|
|
183
|
+
|
|
184
|
+
**Returns:**
|
|
185
|
+
- `cursor`: Updated cursor for next call
|
|
186
|
+
- `messageCount`: Number of new messages
|
|
187
|
+
- `messages`: Array of new messages
|
|
188
|
+
|
|
189
|
+
**Example workflow:**
|
|
190
|
+
```
|
|
191
|
+
1. Call watch_chat without cursor to get initial position
|
|
192
|
+
2. Store the returned cursor value
|
|
193
|
+
3. Call watch_chat with that cursor to get new messages
|
|
194
|
+
4. Update your cursor with the returned value
|
|
195
|
+
5. Repeat step 3-4 to poll for updates
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### `archive_chat`
|
|
199
|
+
|
|
200
|
+
Archive old messages to a date-stamped file, keeping recent messages in main chat.
|
|
201
|
+
|
|
202
|
+
**Parameters:**
|
|
203
|
+
- `keepRecent` (optional): Number of messages to keep (default: 50)
|
|
204
|
+
|
|
205
|
+
**Example:**
|
|
206
|
+
```
|
|
207
|
+
Archive old messages, keeping the last 20
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Chat File Format
|
|
211
|
+
|
|
212
|
+
Messages are stored in a human-readable format:
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
# Robot Chat - Multi-Agent Communication
|
|
216
|
+
# Format: [AgentName @ HH:MM] MESSAGE_TYPE
|
|
217
|
+
# ========================================
|
|
218
|
+
|
|
219
|
+
[Claude @ 14:32] STATUS_UPDATE
|
|
220
|
+
Working on implementing the login form.
|
|
221
|
+
Files modified: src/components/LoginForm.tsx
|
|
222
|
+
|
|
223
|
+
[Codex @ 14:45] FAILOVER_NEEDED
|
|
224
|
+
Status: Hit rate limit
|
|
225
|
+
Current Task: Implementing user authentication
|
|
226
|
+
Progress: 60% - login form done, need logout and session handling
|
|
227
|
+
Files Modified: src/auth/login.tsx, src/api/auth.ts
|
|
228
|
+
|
|
229
|
+
Requesting another agent continue this work.
|
|
230
|
+
|
|
231
|
+
[Claude @ 14:47] FAILOVER_CLAIMED
|
|
232
|
+
Claiming failover from Codex.
|
|
233
|
+
Continuing task: Implementing user authentication
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Testing
|
|
237
|
+
|
|
238
|
+
### With MCP Inspector
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npx @modelcontextprotocol/inspector node /path/to/nightshift-mcp/dist/index.js /tmp/test-project
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Manual Testing
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# Set project path and run
|
|
248
|
+
ROBOT_CHAT_PROJECT_PATH=/tmp/test-project node dist/index.js
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Development
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
# Watch mode for development
|
|
255
|
+
npm run dev
|
|
256
|
+
|
|
257
|
+
# Build
|
|
258
|
+
npm run build
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Ralph-Style Task Management
|
|
262
|
+
|
|
263
|
+
NightShift includes Ralph-compatible PRD and progress management, enabling structured autonomous development.
|
|
264
|
+
|
|
265
|
+
### Setup
|
|
266
|
+
|
|
267
|
+
1. Create a `prd.json` in your project root:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"project": "MyApp",
|
|
272
|
+
"description": "Feature description",
|
|
273
|
+
"userStories": [
|
|
274
|
+
{
|
|
275
|
+
"id": "US-001",
|
|
276
|
+
"title": "Add database field",
|
|
277
|
+
"description": "As a developer, I need to store the new field",
|
|
278
|
+
"acceptanceCriteria": [
|
|
279
|
+
"Add column to table",
|
|
280
|
+
"Run migration",
|
|
281
|
+
"Typecheck passes"
|
|
282
|
+
],
|
|
283
|
+
"priority": 1,
|
|
284
|
+
"passes": false,
|
|
285
|
+
"notes": ""
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### PRD Schema
|
|
292
|
+
|
|
293
|
+
| Field | Type | Required | Default | Description |
|
|
294
|
+
|-------|------|----------|---------|-------------|
|
|
295
|
+
| `project` | string | no | — | Project name |
|
|
296
|
+
| `description` | string | no | "" | Project description |
|
|
297
|
+
| **`userStories`** | array | **yes** | — | Array of user story objects |
|
|
298
|
+
|
|
299
|
+
**User Story fields:**
|
|
300
|
+
|
|
301
|
+
| Field | Type | Required | Default | Description |
|
|
302
|
+
|-------|------|----------|---------|-------------|
|
|
303
|
+
| **`id`** | string | **yes** | — | Unique ID (e.g., "US-001") |
|
|
304
|
+
| **`title`** | string | **yes** | — | Short title |
|
|
305
|
+
| `description` | string | no | "" | Detailed description |
|
|
306
|
+
| `acceptanceCriteria` | string[] | no | [] | Criteria for completion |
|
|
307
|
+
| `priority` | number | no | 999 | Lower = higher priority |
|
|
308
|
+
| `passes` | boolean | no | false | Whether the story is complete |
|
|
309
|
+
| `notes` | string | no | "" | Implementation notes |
|
|
310
|
+
|
|
311
|
+
### PRD Validation
|
|
312
|
+
|
|
313
|
+
NightShift validates your `prd.json` with Zod schemas and provides helpful error messages when common mistakes are detected:
|
|
314
|
+
|
|
315
|
+
- Using `stories` instead of `userStories` → suggests the correct field name
|
|
316
|
+
- Using `acceptance_criteria` instead of `acceptanceCriteria` → suggests the correct field name
|
|
317
|
+
- Missing required fields (`id`, `title`) → identifies which story has the issue
|
|
318
|
+
- Optional fields default gracefully (`passes` → false, `notes` → "", `acceptanceCriteria` → [])
|
|
319
|
+
|
|
320
|
+
Use `nightshift_setup(showExamples: true)` for the full schema reference and examples.
|
|
321
|
+
|
|
322
|
+
2. Agents use these tools to work through stories:
|
|
323
|
+
|
|
324
|
+
### PRD Tools
|
|
325
|
+
|
|
326
|
+
#### `read_prd`
|
|
327
|
+
Read the full PRD with completion summary.
|
|
328
|
+
|
|
329
|
+
#### `get_next_story`
|
|
330
|
+
Get the highest priority incomplete story.
|
|
331
|
+
|
|
332
|
+
#### `get_incomplete_stories`
|
|
333
|
+
List all remaining work.
|
|
334
|
+
|
|
335
|
+
#### `claim_story`
|
|
336
|
+
Claim a story and notify other agents via chat.
|
|
337
|
+
|
|
338
|
+
**Parameters:**
|
|
339
|
+
- `agent` (required): Your agent name
|
|
340
|
+
- `storyId` (optional): Specific story to claim
|
|
341
|
+
|
|
342
|
+
#### `complete_story`
|
|
343
|
+
Mark story complete, log progress, and notify via chat.
|
|
344
|
+
|
|
345
|
+
**Parameters:**
|
|
346
|
+
- `agent` (required): Your agent name
|
|
347
|
+
- `storyId` (required): Story ID
|
|
348
|
+
- `summary` (required): What was implemented
|
|
349
|
+
- `filesModified` (optional): List of changed files
|
|
350
|
+
- `learnings` (optional): Gotchas/patterns for future iterations
|
|
351
|
+
|
|
352
|
+
#### `mark_story_complete`
|
|
353
|
+
Just mark a story as complete without chat notification.
|
|
354
|
+
|
|
355
|
+
**Parameters:**
|
|
356
|
+
- `storyId` (required): Story ID
|
|
357
|
+
- `notes` (optional): Implementation notes
|
|
358
|
+
|
|
359
|
+
### Progress Tools
|
|
360
|
+
|
|
361
|
+
#### `read_progress`
|
|
362
|
+
Read progress.txt containing learnings from all iterations.
|
|
363
|
+
|
|
364
|
+
#### `append_progress`
|
|
365
|
+
Add a timestamped progress entry.
|
|
366
|
+
|
|
367
|
+
**Parameters:**
|
|
368
|
+
- `content` (required): What was done, files changed, learnings
|
|
369
|
+
|
|
370
|
+
#### `add_codebase_pattern`
|
|
371
|
+
Add a reusable pattern to the Codebase Patterns section.
|
|
372
|
+
|
|
373
|
+
**Parameters:**
|
|
374
|
+
- `pattern` (required): The pattern (e.g., "Use sql<number> for aggregations")
|
|
375
|
+
|
|
376
|
+
### Autonomous Workflow
|
|
377
|
+
|
|
378
|
+
With multiple agents working together:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
382
|
+
│ NightShift Workflow │
|
|
383
|
+
├─────────────────────────────────────────────────────────────┤
|
|
384
|
+
│ │
|
|
385
|
+
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
|
|
386
|
+
│ │ Claude │ │ Codex │ │ Gemini │ │ Vibe │ │
|
|
387
|
+
│ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ │
|
|
388
|
+
│ │ │ │ │ │
|
|
389
|
+
│ └───────────┴─────┬─────┴───────────┘ │
|
|
390
|
+
│ │ │
|
|
391
|
+
│ ▼ │
|
|
392
|
+
│ ┌─────────────────┐ │
|
|
393
|
+
│ │ .robot-chat/ │ ◄── Agent coordination │
|
|
394
|
+
│ │ chat.txt │ │
|
|
395
|
+
│ └─────────────────┘ │
|
|
396
|
+
│ │ │
|
|
397
|
+
│ ┌───────────────┼───────────────┐ │
|
|
398
|
+
│ │ │ │ │
|
|
399
|
+
│ ▼ ▼ ▼ │
|
|
400
|
+
│ ┌─────────┐ ┌──────────┐ ┌────────────┐ │
|
|
401
|
+
│ │ prd.json│ │progress. │ │ Code │ │
|
|
402
|
+
│ │ (tasks) │ │ txt │ │ Changes │ │
|
|
403
|
+
│ └─────────┘ └──────────┘ └────────────┘ │
|
|
404
|
+
│ │
|
|
405
|
+
└─────────────────────────────────────────────────────────────┘
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
Each agent:
|
|
409
|
+
1. Checks for failovers (helps stuck agents first)
|
|
410
|
+
2. Reads progress.txt for codebase patterns
|
|
411
|
+
3. Claims the next story via chat
|
|
412
|
+
4. Implements the story
|
|
413
|
+
5. Runs quality checks
|
|
414
|
+
6. Commits changes
|
|
415
|
+
7. Marks complete and logs learnings
|
|
416
|
+
8. Repeats until all stories pass
|
|
417
|
+
|
|
418
|
+
When an agent hits limits, it posts `FAILOVER_NEEDED` and another agent claims the work.
|
|
419
|
+
|
|
420
|
+
### Completion Signal
|
|
421
|
+
|
|
422
|
+
When all stories in prd.json have `passes: true` AND all bugs in bugs.json have `fixed: true`, the tools:
|
|
423
|
+
|
|
424
|
+
1. Post a `READY_TO_TEST` message to the chat
|
|
425
|
+
2. Return `<promise>COMPLETE</promise>`
|
|
426
|
+
|
|
427
|
+
This signals to humans that work is ready for review.
|
|
428
|
+
|
|
429
|
+
## Bug Tracking
|
|
430
|
+
|
|
431
|
+
When testing reveals issues, add a `bugs.json` file:
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"project": "MyApp",
|
|
436
|
+
"bugs": [
|
|
437
|
+
{
|
|
438
|
+
"id": "BUG-001",
|
|
439
|
+
"title": "Login fails on mobile",
|
|
440
|
+
"description": "Login button unresponsive on iOS Safari",
|
|
441
|
+
"stepsToReproduce": [
|
|
442
|
+
"Open app on iOS Safari",
|
|
443
|
+
"Enter credentials",
|
|
444
|
+
"Tap login button",
|
|
445
|
+
"Nothing happens"
|
|
446
|
+
],
|
|
447
|
+
"priority": 1,
|
|
448
|
+
"fixed": false
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Bug Tools
|
|
455
|
+
|
|
456
|
+
#### `read_bugs`
|
|
457
|
+
Read bugs.json with completion summary.
|
|
458
|
+
|
|
459
|
+
#### `get_next_bug`
|
|
460
|
+
Get highest priority unfixed bug.
|
|
461
|
+
|
|
462
|
+
#### `claim_bug`
|
|
463
|
+
Claim a bug and notify via chat.
|
|
464
|
+
|
|
465
|
+
**Parameters:**
|
|
466
|
+
- `agent` (required): Your agent name
|
|
467
|
+
- `bugId` (optional): Specific bug to claim
|
|
468
|
+
|
|
469
|
+
#### `mark_bug_fixed`
|
|
470
|
+
Mark bug fixed, create savepoint, and notify.
|
|
471
|
+
|
|
472
|
+
**Parameters:**
|
|
473
|
+
- `agent` (required): Your agent name
|
|
474
|
+
- `bugId` (required): Bug ID
|
|
475
|
+
- `summary` (required): What was fixed
|
|
476
|
+
- `filesModified` (optional): Files changed
|
|
477
|
+
|
|
478
|
+
## Savepoints (Recovery)
|
|
479
|
+
|
|
480
|
+
Every completed story and fixed bug automatically creates a savepoint (git commit + tag). Use these for easy rollback if needed.
|
|
481
|
+
|
|
482
|
+
### Savepoint Tools
|
|
483
|
+
|
|
484
|
+
#### `create_savepoint`
|
|
485
|
+
Create a manual checkpoint.
|
|
486
|
+
|
|
487
|
+
**Parameters:**
|
|
488
|
+
- `label` (required): Savepoint name (e.g., "pre-refactor", "auth-working")
|
|
489
|
+
- `message` (optional): Commit message
|
|
490
|
+
|
|
491
|
+
#### `list_savepoints`
|
|
492
|
+
List all savepoints (git tags with `savepoint/` prefix).
|
|
493
|
+
|
|
494
|
+
#### `rollback_savepoint`
|
|
495
|
+
Reset to a previous savepoint. **Warning:** Discards all changes after that point.
|
|
496
|
+
|
|
497
|
+
**Parameters:**
|
|
498
|
+
- `label` (required): Savepoint to rollback to
|
|
499
|
+
|
|
500
|
+
### Example Recovery
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
# Something went wrong after US-003
|
|
504
|
+
# List available savepoints
|
|
505
|
+
list_savepoints
|
|
506
|
+
# → savepoint/US-001, savepoint/US-002, savepoint/US-003
|
|
507
|
+
|
|
508
|
+
# Rollback to after US-002
|
|
509
|
+
rollback_savepoint("US-002")
|
|
510
|
+
# → All changes after US-002 discarded
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
## Workflow Management
|
|
514
|
+
|
|
515
|
+
NightShift includes workflow tools for tracking project phases, recording strategic decisions, and managing agent assignments.
|
|
516
|
+
|
|
517
|
+
### Workflow Tools
|
|
518
|
+
|
|
519
|
+
#### `init_workflow`
|
|
520
|
+
Initialize a new workflow with a project goal and optional custom phases.
|
|
521
|
+
|
|
522
|
+
**Parameters:**
|
|
523
|
+
- `projectGoal` (required): High-level goal of the project
|
|
524
|
+
- `phases` (optional): Custom phases (default: research, decisions, planning, build, test, report)
|
|
525
|
+
|
|
526
|
+
#### `get_workflow_state`
|
|
527
|
+
Get the current workflow state including phase, assignments, and decisions.
|
|
528
|
+
|
|
529
|
+
#### `advance_phase`
|
|
530
|
+
Advance to the next workflow phase when the current phase's exit criteria are met.
|
|
531
|
+
|
|
532
|
+
#### `set_phase`
|
|
533
|
+
Manually set the workflow to a specific phase.
|
|
534
|
+
|
|
535
|
+
**Parameters:**
|
|
536
|
+
- `phase` (required): Target phase (research, decisions, planning, build, test, report, complete)
|
|
537
|
+
|
|
538
|
+
#### `record_decision`
|
|
539
|
+
Record a strategic decision with rationale for future reference.
|
|
540
|
+
|
|
541
|
+
**Parameters:**
|
|
542
|
+
- `topic` (required): What the decision is about
|
|
543
|
+
- `options` (required): Options that were considered
|
|
544
|
+
- `chosen` (required): The chosen option
|
|
545
|
+
- `rationale` (required): Why this option was chosen
|
|
546
|
+
- `decidedBy` (required): Agent or person who decided
|
|
547
|
+
|
|
548
|
+
#### `get_decisions`
|
|
549
|
+
Get all recorded decisions, optionally filtered by topic.
|
|
550
|
+
|
|
551
|
+
#### `get_active_assignments`
|
|
552
|
+
Get all stories currently being worked on by agents.
|
|
553
|
+
|
|
554
|
+
#### `clear_assignment`
|
|
555
|
+
Clear a story assignment (for abandonment/failover scenarios).
|
|
556
|
+
|
|
557
|
+
## Setup & Debugging
|
|
558
|
+
|
|
559
|
+
NightShift includes self-service tools for setup and troubleshooting.
|
|
560
|
+
|
|
561
|
+
### `nightshift_setup`
|
|
562
|
+
|
|
563
|
+
Get configuration instructions and verify project setup.
|
|
564
|
+
|
|
565
|
+
**Parameters:**
|
|
566
|
+
- `showExamples` (optional): Include prd.json and bugs.json templates
|
|
567
|
+
|
|
568
|
+
**Returns:**
|
|
569
|
+
- Project status checks (prd.json, bugs.json, git, .gitignore)
|
|
570
|
+
- Agent configuration examples for Claude and Codex
|
|
571
|
+
- Setup suggestions for any issues found
|
|
572
|
+
- Example templates (if requested)
|
|
573
|
+
|
|
574
|
+
**Example:**
|
|
575
|
+
```
|
|
576
|
+
nightshift_setup(showExamples: true)
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### `nightshift_debug`
|
|
580
|
+
|
|
581
|
+
Diagnose issues and get troubleshooting guidance.
|
|
582
|
+
|
|
583
|
+
**Checks:**
|
|
584
|
+
- File system permissions
|
|
585
|
+
- JSON file validation (prd.json, bugs.json)
|
|
586
|
+
- Daemon lock status
|
|
587
|
+
- Recent chat errors and unclaimed failovers
|
|
588
|
+
- Agent availability
|
|
589
|
+
- Git repository status
|
|
590
|
+
|
|
591
|
+
**Example:**
|
|
592
|
+
```
|
|
593
|
+
nightshift_debug
|
|
594
|
+
# Returns detailed diagnostic report with suggested fixes
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
## Agent Spawning & Orchestration
|
|
598
|
+
|
|
599
|
+
One agent can spawn others as subprocesses, enabling fully autonomous multi-agent workflows with minimal user intervention.
|
|
600
|
+
|
|
601
|
+
### Spawning Tools
|
|
602
|
+
|
|
603
|
+
#### `list_available_agents`
|
|
604
|
+
Check which agent CLIs (claude, codex, gemini, vibe) are installed and ready to run.
|
|
605
|
+
|
|
606
|
+
#### `spawn_agent`
|
|
607
|
+
Spawn another agent as a subprocess and wait for completion.
|
|
608
|
+
|
|
609
|
+
**Parameters:**
|
|
610
|
+
- `agent` (required): "claude", "codex", "gemini", or "vibe"
|
|
611
|
+
- `prompt` (required): Task/prompt to send
|
|
612
|
+
- `timeout` (optional): Seconds before timeout (default: 300)
|
|
613
|
+
|
|
614
|
+
**Example:**
|
|
615
|
+
```
|
|
616
|
+
spawn_agent(agent: "codex", prompt: "Fix the type errors in src/utils.ts")
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
#### `spawn_agent_background`
|
|
620
|
+
Spawn an agent in the background (non-blocking). Returns immediately with PID and output file path.
|
|
621
|
+
|
|
622
|
+
**Parameters:**
|
|
623
|
+
- `agent` (required): "claude", "codex", "gemini", or "vibe"
|
|
624
|
+
- `prompt` (required): Task/prompt to send
|
|
625
|
+
|
|
626
|
+
#### `delegate_story`
|
|
627
|
+
Delegate a PRD user story to another agent with full context. On failure, returns a `retryHint` suggesting alternative available agents.
|
|
628
|
+
|
|
629
|
+
**Parameters:**
|
|
630
|
+
- `agent` (required): "claude", "codex", "gemini", or "vibe"
|
|
631
|
+
- `storyId` (optional): Story ID to delegate (defaults to next available)
|
|
632
|
+
- `background` (optional): Run in background (default: false)
|
|
633
|
+
|
|
634
|
+
**Example:**
|
|
635
|
+
```
|
|
636
|
+
delegate_story(agent: "gemini", storyId: "US-003", background: true)
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
The spawned agent receives:
|
|
640
|
+
- Full story description and acceptance criteria
|
|
641
|
+
- Recent content from progress.txt
|
|
642
|
+
- Recent chat messages for context
|
|
643
|
+
- Instructions to use nightshift tools for coordination
|
|
644
|
+
|
|
645
|
+
#### `delegate_research`
|
|
646
|
+
Delegate a research or planning task to Gemini. Ideal for read-only tasks like codebase analysis, architecture planning, code review, and documentation.
|
|
647
|
+
|
|
648
|
+
**Parameters:**
|
|
649
|
+
- `task` (required): The research/planning task description
|
|
650
|
+
- `context` (optional): Additional context to provide
|
|
651
|
+
- `background` (optional): Run in background (default: false)
|
|
652
|
+
|
|
653
|
+
### Monitoring Tools
|
|
654
|
+
|
|
655
|
+
#### `get_agent_status`
|
|
656
|
+
Check the status of a spawned background agent by PID.
|
|
657
|
+
|
|
658
|
+
**Parameters:**
|
|
659
|
+
- `pid` (required): Process ID of the spawned agent
|
|
660
|
+
|
|
661
|
+
**Returns:**
|
|
662
|
+
- Whether the agent is still running or has exited
|
|
663
|
+
- Exit code (if finished)
|
|
664
|
+
- Last 30 lines of output
|
|
665
|
+
- Story assignment (if delegated via `delegate_story`)
|
|
666
|
+
|
|
667
|
+
#### `list_running_agents`
|
|
668
|
+
List all agents spawned in the current session with their status.
|
|
669
|
+
|
|
670
|
+
**Returns:** Array of agents with PID, agent type, running/exited status, elapsed time, and story assignment.
|
|
671
|
+
|
|
672
|
+
### Orchestration
|
|
673
|
+
|
|
674
|
+
#### `orchestrate`
|
|
675
|
+
Run an autonomous orchestration loop that claims stories, implements them, and marks them complete until all work is done. This is the highest-level automation tool.
|
|
676
|
+
|
|
677
|
+
**Parameters:**
|
|
678
|
+
- `agent` (optional): Your agent name (default: "NightShift")
|
|
679
|
+
- `maxIterations` (optional): Maximum stories to process (default: 50)
|
|
680
|
+
- `mode` (optional): "stories", "bugs", or "all" (default: "all")
|
|
681
|
+
|
|
682
|
+
### Orchestration Patterns
|
|
683
|
+
|
|
684
|
+
**Fully autonomous (recommended):**
|
|
685
|
+
```
|
|
686
|
+
orchestrate(agent: "Claude", mode: "all")
|
|
687
|
+
# Runs until all stories and bugs are complete
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
**Sequential delegation:**
|
|
691
|
+
```
|
|
692
|
+
delegate_story(agent: "codex") # Wait for completion
|
|
693
|
+
delegate_story(agent: "gemini") # Then delegate next
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
**Parallel execution:**
|
|
697
|
+
```
|
|
698
|
+
delegate_story(agent: "codex", storyId: "US-001", background: true)
|
|
699
|
+
delegate_story(agent: "gemini", storyId: "US-002", background: true)
|
|
700
|
+
# Work on US-003 yourself while they run in parallel
|
|
701
|
+
# Monitor with get_agent_status or list_running_agents
|
|
702
|
+
```
|
|
703
|
+
|
|
704
|
+
**Research then implement:**
|
|
705
|
+
```
|
|
706
|
+
delegate_research(task: "Analyze auth patterns and recommend approach")
|
|
707
|
+
# Use findings to inform implementation
|
|
708
|
+
delegate_story(agent: "codex", storyId: "US-001")
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
## NightShift Daemon (Continuous Orchestration)
|
|
712
|
+
|
|
713
|
+
For fully automated, event-driven orchestration, run the NightShift daemon:
|
|
714
|
+
|
|
715
|
+
```bash
|
|
716
|
+
# Start the daemon
|
|
717
|
+
nightshift-daemon
|
|
718
|
+
|
|
719
|
+
# With options
|
|
720
|
+
nightshift-daemon --verbose --max-agents 4 --health-check 1m
|
|
721
|
+
|
|
722
|
+
# Preview mode (see what would happen)
|
|
723
|
+
nightshift-daemon --dry-run --verbose
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
### How It Works
|
|
727
|
+
|
|
728
|
+
The daemon provides hands-off multi-agent orchestration:
|
|
729
|
+
|
|
730
|
+
1. **Event-Driven**: Watches `prd.json` and `chat.txt` for changes
|
|
731
|
+
2. **Auto-Spawning**: Spawns agents for orphaned stories (up to concurrency limit)
|
|
732
|
+
3. **Failover Handling**: Automatically claims and reassigns failover requests
|
|
733
|
+
4. **Smart Retry**: Tracks failed agents per story and tries a different agent on retry
|
|
734
|
+
5. **Health Checks**: Periodic reconciliation as a fallback (default: every 2 min)
|
|
735
|
+
6. **Poison Pill Protection**: Quarantines stories that fail repeatedly
|
|
736
|
+
7. **Stuck Detection**: Kills agents that haven't reported activity
|
|
737
|
+
|
|
738
|
+
### Options
|
|
739
|
+
|
|
740
|
+
| Flag | Description | Default |
|
|
741
|
+
|------|-------------|---------|
|
|
742
|
+
| `--verbose, -v` | Enable debug logging | false |
|
|
743
|
+
| `--dry-run` | Show actions without spawning | false |
|
|
744
|
+
| `--health-check <N>` | Health check interval (e.g., "2m", "30s") | 2m |
|
|
745
|
+
| `--max-agents <N>` | Max concurrent agents | 3 |
|
|
746
|
+
|
|
747
|
+
### Environment
|
|
748
|
+
|
|
749
|
+
- `ROBOT_CHAT_PROJECT_PATH` - Project directory (default: current directory)
|
|
750
|
+
|
|
751
|
+
### Architecture
|
|
752
|
+
|
|
753
|
+
```
|
|
754
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
755
|
+
│ NightShift Daemon │
|
|
756
|
+
├─────────────────────────────────────────────────────────────┤
|
|
757
|
+
│ │
|
|
758
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
759
|
+
│ │ File Watchers (Primary) │ │
|
|
760
|
+
│ │ • prd.json changes → reconcile │ │
|
|
761
|
+
│ │ • chat.txt changes → check failovers │ │
|
|
762
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
763
|
+
│ │ │
|
|
764
|
+
│ ▼ │
|
|
765
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
766
|
+
│ │ Reconciliation Engine │ │
|
|
767
|
+
│ │ • Find orphaned stories │ │
|
|
768
|
+
│ │ • Spawn agents (up to max concurrency) │ │
|
|
769
|
+
│ │ • Handle failovers │ │
|
|
770
|
+
│ │ • Quarantine poison pills │ │
|
|
771
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
772
|
+
│ │ │
|
|
773
|
+
│ ▼ │
|
|
774
|
+
│ ┌──────────────────────────────────────────────────┐ │
|
|
775
|
+
│ │ Health Check (Fallback) │ │
|
|
776
|
+
│ │ • Runs every 2 minutes │ │
|
|
777
|
+
│ │ • Detects stuck agents │ │
|
|
778
|
+
│ │ • Restarts watchers if needed │ │
|
|
779
|
+
│ │ • Reconciles state │ │
|
|
780
|
+
│ └──────────────────────────────────────────────────┘ │
|
|
781
|
+
│ │
|
|
782
|
+
└─────────────────────────────────────────────────────────────┘
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
## Multi-Agent Tips
|
|
786
|
+
|
|
787
|
+
1. **Same directory**: All agents must run in the same project directory to share chat
|
|
788
|
+
2. **Claim before working**: Always claim stories to prevent duplicate work
|
|
789
|
+
3. **Post status updates**: Keep other agents informed of progress
|
|
790
|
+
4. **Document learnings**: Progress.txt helps future iterations
|
|
791
|
+
5. **Handle failovers**: Check for and claim failovers at the start of each session
|
|
792
|
+
6. **Use delegation**: One orchestrating agent can spawn others for parallel work
|
|
793
|
+
7. **Monitor background agents**: Use `get_agent_status` and `list_running_agents` to track spawned agents
|
|
794
|
+
8. **Use `orchestrate` for full autonomy**: The `orchestrate` tool handles the entire claim→implement→complete loop
|
|
795
|
+
9. **Add `.robot-chat/` to your project's `.gitignore`**: Chat logs are ephemeral and shouldn't be committed
|
|
796
|
+
|
|
797
|
+
## License
|
|
798
|
+
|
|
799
|
+
MIT
|