nightshift-mcp 1.1.2 → 2.0.1
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 +352 -971
- package/dist/daemon.d.ts +21 -0
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +208 -8
- package/dist/daemon.js.map +1 -1
- package/dist/database.d.ts +139 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +503 -0
- package/dist/database.js.map +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,971 +1,352 @@
|
|
|
1
|
-
# NightShift MCP
|
|
2
|
-
|
|
3
|
-
**The responsible kind of multi-agent chaos.**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
##
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- **Agent
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
2. Agents use these tools to work through stories:
|
|
355
|
-
|
|
356
|
-
### PRD Tools
|
|
357
|
-
|
|
358
|
-
#### `read_prd`
|
|
359
|
-
Read the full PRD with completion summary.
|
|
360
|
-
|
|
361
|
-
#### `get_next_story`
|
|
362
|
-
Get the highest priority incomplete story.
|
|
363
|
-
|
|
364
|
-
#### `get_incomplete_stories`
|
|
365
|
-
List all remaining work.
|
|
366
|
-
|
|
367
|
-
#### `claim_story`
|
|
368
|
-
Claim a story and notify other agents via chat.
|
|
369
|
-
|
|
370
|
-
**Parameters:**
|
|
371
|
-
- `agent` (required): Your agent name
|
|
372
|
-
- `storyId` (optional): Specific story to claim
|
|
373
|
-
|
|
374
|
-
#### `complete_story`
|
|
375
|
-
Mark story complete, log progress, and notify via chat.
|
|
376
|
-
|
|
377
|
-
**Parameters:**
|
|
378
|
-
- `agent` (required): Your agent name
|
|
379
|
-
- `storyId` (required): Story ID
|
|
380
|
-
- `summary` (required): What was implemented
|
|
381
|
-
- `filesModified` (optional): List of changed files
|
|
382
|
-
- `learnings` (optional): Gotchas/patterns for future iterations
|
|
383
|
-
|
|
384
|
-
#### `mark_story_complete`
|
|
385
|
-
Just mark a story as complete without chat notification.
|
|
386
|
-
|
|
387
|
-
**Parameters:**
|
|
388
|
-
- `storyId` (required): Story ID
|
|
389
|
-
- `notes` (optional): Implementation notes
|
|
390
|
-
|
|
391
|
-
### Progress Tools
|
|
392
|
-
|
|
393
|
-
#### `read_progress`
|
|
394
|
-
Read progress.txt containing learnings from all iterations.
|
|
395
|
-
|
|
396
|
-
#### `append_progress`
|
|
397
|
-
Add a timestamped progress entry.
|
|
398
|
-
|
|
399
|
-
**Parameters:**
|
|
400
|
-
- `content` (required): What was done, files changed, learnings
|
|
401
|
-
|
|
402
|
-
#### `add_codebase_pattern`
|
|
403
|
-
Add a reusable pattern to the Codebase Patterns section.
|
|
404
|
-
|
|
405
|
-
**Parameters:**
|
|
406
|
-
- `pattern` (required): The pattern (e.g., "Use sql<number> for aggregations")
|
|
407
|
-
|
|
408
|
-
### Context Store
|
|
409
|
-
|
|
410
|
-
NightShift includes a selective context retrieval system that replaces prompt-stuffing with topic-based queries. Instead of truncating progress.txt to fit the context window, agents can store and retrieve relevant context on demand.
|
|
411
|
-
|
|
412
|
-
Context entries are stored as individual JSON files in `.robot-chat/context/` for concurrent-safe multi-agent access.
|
|
413
|
-
|
|
414
|
-
#### `store_context`
|
|
415
|
-
Store a context entry for other agents to query later.
|
|
416
|
-
|
|
417
|
-
**Parameters:**
|
|
418
|
-
- `topic` (required): Topic/category (e.g., "authentication", "database-schema")
|
|
419
|
-
- `content` (required): The context to store (learnings, decisions, findings)
|
|
420
|
-
- `agent` (required): Your agent name
|
|
421
|
-
- `tags` (optional): Tags for better searchability (e.g., ["auth", "jwt"])
|
|
422
|
-
|
|
423
|
-
**Example:**
|
|
424
|
-
```
|
|
425
|
-
store_context(topic: "authentication", content: "Using JWT with RS256. Refresh tokens stored in httpOnly cookies.", agent: "Claude", tags: ["jwt", "cookies"])
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
#### `query_context`
|
|
429
|
-
Search stored context entries by topic.
|
|
430
|
-
|
|
431
|
-
**Parameters:**
|
|
432
|
-
- `topic` (required): Search term (case-insensitive match on topic and tags)
|
|
433
|
-
- `limit` (optional): Max entries to return (default: 10)
|
|
434
|
-
|
|
435
|
-
**Example:**
|
|
436
|
-
```
|
|
437
|
-
query_context(topic: "auth")
|
|
438
|
-
# Returns all entries matching "auth" in topic or tags, sorted by recency
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
#### `list_context`
|
|
442
|
-
List all topics in the context store with entry counts.
|
|
443
|
-
|
|
444
|
-
**How delegation uses context:**
|
|
445
|
-
|
|
446
|
-
When `delegate_story` or `delegate_research` spawns an agent, it queries the context store for entries relevant to the task and includes them in the prompt — instead of blindly truncating progress.txt. Agents are also instructed to use `store_context` to save their learnings, creating a self-enriching context loop.
|
|
447
|
-
|
|
448
|
-
### Execution Tracing
|
|
449
|
-
|
|
450
|
-
NightShift automatically traces all agent spawns, completions, and failures into a structured execution log at `.robot-chat/trace.json`. Each trace event has parent-child relationships that can be reconstructed as a tree for debugging multi-agent runs.
|
|
451
|
-
|
|
452
|
-
#### `get_trace`
|
|
453
|
-
View the execution trace as a flat list or tree.
|
|
454
|
-
|
|
455
|
-
**Parameters:**
|
|
456
|
-
- `tree` (optional): Return as tree with parent-child relationships (default: false)
|
|
457
|
-
- `taskId` (optional): Filter by story/task ID
|
|
458
|
-
|
|
459
|
-
**Example:**
|
|
460
|
-
```
|
|
461
|
-
get_trace(tree: true)
|
|
462
|
-
# Returns tree showing: orchestrator → spawned claude (US-001) → completed
|
|
463
|
-
# orchestrator → spawned codex (US-002) → failed → retried with gemini → completed
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
#### `clear_trace`
|
|
467
|
-
Reset the trace for a fresh orchestration run.
|
|
468
|
-
|
|
469
|
-
**What gets traced automatically:**
|
|
470
|
-
- `spawn_agent` and `spawn_agent_background` calls
|
|
471
|
-
- `delegate_story` and `delegate_research` delegations
|
|
472
|
-
- `orchestrate` decisions (inline mode)
|
|
473
|
-
- Agent completions with exit codes
|
|
474
|
-
- Agent failures with error details
|
|
475
|
-
|
|
476
|
-
Each trace event includes metadata: agent type, story ID, prompt length, exit code, and timing.
|
|
477
|
-
|
|
478
|
-
### Autonomous Workflow
|
|
479
|
-
|
|
480
|
-
With multiple agents working together:
|
|
481
|
-
|
|
482
|
-
```
|
|
483
|
-
┌──────────────────────────────────────────────────────────────────┐
|
|
484
|
-
│ NightShift Workflow │
|
|
485
|
-
├──────────────────────────────────────────────────────────────────┤
|
|
486
|
-
│ │
|
|
487
|
-
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
|
|
488
|
-
│ │ Claude │ │ Codex │ │ Gemini │ │ Vibe │ │ Goose │ │
|
|
489
|
-
│ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ │
|
|
490
|
-
│ │ │ │ │ │ │
|
|
491
|
-
│ └───────────┴─────┬─────┴───────────┴───────────┘ │
|
|
492
|
-
│ │ │
|
|
493
|
-
│ ▼ │
|
|
494
|
-
│ ┌──────────────────┐ │
|
|
495
|
-
│ │ .robot-chat/ │ ◄── Agent coordination │
|
|
496
|
-
│ │ chat.txt │ │
|
|
497
|
-
│ └──────────────────┘ │
|
|
498
|
-
│ │ │
|
|
499
|
-
│ ┌──────────┬────────┼────────┬──────────┐ │
|
|
500
|
-
│ │ │ │ │ │ │
|
|
501
|
-
│ ▼ ▼ ▼ ▼ ▼ │
|
|
502
|
-
│ ┌────────┐ ┌────────┐ ┌────┐ ┌──────────┐ ┌──────────┐ │
|
|
503
|
-
│ │prd.json│ │progress│ │Code│ │ context/ │ │trace.json│ │
|
|
504
|
-
│ │(tasks) │ │ .txt │ │ │ │(per-topic│ │(execution│ │
|
|
505
|
-
│ │ │ │ │ │ │ │ queries) │ │ tree) │ │
|
|
506
|
-
│ └────────┘ └────────┘ └────┘ └──────────┘ └──────────┘ │
|
|
507
|
-
│ │
|
|
508
|
-
└──────────────────────────────────────────────────────────────────┘
|
|
509
|
-
```
|
|
510
|
-
|
|
511
|
-
Each agent:
|
|
512
|
-
1. Checks for failovers (helps stuck agents first)
|
|
513
|
-
2. Reads progress.txt for codebase patterns
|
|
514
|
-
3. Claims the next story via chat
|
|
515
|
-
4. Implements the story
|
|
516
|
-
5. Runs quality checks
|
|
517
|
-
6. Commits changes
|
|
518
|
-
7. Marks complete and logs learnings
|
|
519
|
-
8. Repeats until all stories pass
|
|
520
|
-
|
|
521
|
-
When an agent hits limits, it posts `FAILOVER_NEEDED` and another agent claims the work.
|
|
522
|
-
|
|
523
|
-
### Completion Signal
|
|
524
|
-
|
|
525
|
-
When all stories in prd.json have `passes: true` AND all bugs in bugs.json have `fixed: true`, the tools:
|
|
526
|
-
|
|
527
|
-
1. Post a `READY_TO_TEST` message to the chat
|
|
528
|
-
2. Return `<promise>COMPLETE</promise>`
|
|
529
|
-
|
|
530
|
-
This signals to humans that work is ready for review.
|
|
531
|
-
|
|
532
|
-
## Bug Tracking
|
|
533
|
-
|
|
534
|
-
When testing reveals issues, add a `bugs.json` file:
|
|
535
|
-
|
|
536
|
-
```json
|
|
537
|
-
{
|
|
538
|
-
"project": "MyApp",
|
|
539
|
-
"bugs": [
|
|
540
|
-
{
|
|
541
|
-
"id": "BUG-001",
|
|
542
|
-
"title": "Login fails on mobile",
|
|
543
|
-
"description": "Login button unresponsive on iOS Safari",
|
|
544
|
-
"stepsToReproduce": [
|
|
545
|
-
"Open app on iOS Safari",
|
|
546
|
-
"Enter credentials",
|
|
547
|
-
"Tap login button",
|
|
548
|
-
"Nothing happens"
|
|
549
|
-
],
|
|
550
|
-
"priority": 1,
|
|
551
|
-
"fixed": false
|
|
552
|
-
}
|
|
553
|
-
]
|
|
554
|
-
}
|
|
555
|
-
```
|
|
556
|
-
|
|
557
|
-
### Bug Tools
|
|
558
|
-
|
|
559
|
-
#### `read_bugs`
|
|
560
|
-
Read bugs.json with completion summary.
|
|
561
|
-
|
|
562
|
-
#### `get_next_bug`
|
|
563
|
-
Get highest priority unfixed bug.
|
|
564
|
-
|
|
565
|
-
#### `claim_bug`
|
|
566
|
-
Claim a bug and notify via chat.
|
|
567
|
-
|
|
568
|
-
**Parameters:**
|
|
569
|
-
- `agent` (required): Your agent name
|
|
570
|
-
- `bugId` (optional): Specific bug to claim
|
|
571
|
-
|
|
572
|
-
#### `mark_bug_fixed`
|
|
573
|
-
Mark bug fixed, create savepoint, and notify.
|
|
574
|
-
|
|
575
|
-
**Parameters:**
|
|
576
|
-
- `agent` (required): Your agent name
|
|
577
|
-
- `bugId` (required): Bug ID
|
|
578
|
-
- `summary` (required): What was fixed
|
|
579
|
-
- `filesModified` (optional): Files changed
|
|
580
|
-
|
|
581
|
-
## Savepoints (Recovery)
|
|
582
|
-
|
|
583
|
-
Every completed story and fixed bug automatically creates a savepoint (git commit + tag). Use these for easy rollback if needed.
|
|
584
|
-
|
|
585
|
-
### Savepoint Tools
|
|
586
|
-
|
|
587
|
-
#### `create_savepoint`
|
|
588
|
-
Create a manual checkpoint.
|
|
589
|
-
|
|
590
|
-
**Parameters:**
|
|
591
|
-
- `label` (required): Savepoint name (e.g., "pre-refactor", "auth-working")
|
|
592
|
-
- `message` (optional): Commit message
|
|
593
|
-
|
|
594
|
-
#### `list_savepoints`
|
|
595
|
-
List all savepoints (git tags with `savepoint/` prefix).
|
|
596
|
-
|
|
597
|
-
#### `rollback_savepoint`
|
|
598
|
-
Reset to a previous savepoint. **Warning:** Discards all changes after that point.
|
|
599
|
-
|
|
600
|
-
**Parameters:**
|
|
601
|
-
- `label` (required): Savepoint to rollback to
|
|
602
|
-
|
|
603
|
-
### Example Recovery
|
|
604
|
-
|
|
605
|
-
```bash
|
|
606
|
-
# Something went wrong after US-003
|
|
607
|
-
# List available savepoints
|
|
608
|
-
list_savepoints
|
|
609
|
-
# → savepoint/US-001, savepoint/US-002, savepoint/US-003
|
|
610
|
-
|
|
611
|
-
# Rollback to after US-002
|
|
612
|
-
rollback_savepoint("US-002")
|
|
613
|
-
# → All changes after US-002 discarded
|
|
614
|
-
```
|
|
615
|
-
|
|
616
|
-
## Workflow Management
|
|
617
|
-
|
|
618
|
-
NightShift includes workflow tools for tracking project phases, recording strategic decisions, and managing agent assignments.
|
|
619
|
-
|
|
620
|
-
### Workflow Tools
|
|
621
|
-
|
|
622
|
-
#### `init_workflow`
|
|
623
|
-
Initialize a new workflow with a project goal and optional custom phases.
|
|
624
|
-
|
|
625
|
-
**Parameters:**
|
|
626
|
-
- `projectGoal` (required): High-level goal of the project
|
|
627
|
-
- `phases` (optional): Custom phases (default: research, decisions, planning, build, test, report)
|
|
628
|
-
|
|
629
|
-
#### `get_workflow_state`
|
|
630
|
-
Get the current workflow state including phase, assignments, and decisions.
|
|
631
|
-
|
|
632
|
-
#### `advance_phase`
|
|
633
|
-
Advance to the next workflow phase when the current phase's exit criteria are met.
|
|
634
|
-
|
|
635
|
-
#### `set_phase`
|
|
636
|
-
Manually set the workflow to a specific phase.
|
|
637
|
-
|
|
638
|
-
**Parameters:**
|
|
639
|
-
- `phase` (required): Target phase (research, decisions, planning, build, test, report, complete)
|
|
640
|
-
|
|
641
|
-
#### `record_decision`
|
|
642
|
-
Record a strategic decision with rationale for future reference.
|
|
643
|
-
|
|
644
|
-
**Parameters:**
|
|
645
|
-
- `topic` (required): What the decision is about
|
|
646
|
-
- `options` (required): Options that were considered
|
|
647
|
-
- `chosen` (required): The chosen option
|
|
648
|
-
- `rationale` (required): Why this option was chosen
|
|
649
|
-
- `decidedBy` (required): Agent or person who decided
|
|
650
|
-
|
|
651
|
-
#### `get_decisions`
|
|
652
|
-
Get all recorded decisions, optionally filtered by topic.
|
|
653
|
-
|
|
654
|
-
#### `get_active_assignments`
|
|
655
|
-
Get all stories currently being worked on by agents.
|
|
656
|
-
|
|
657
|
-
#### `clear_assignment`
|
|
658
|
-
Clear a story assignment (for abandonment/failover scenarios).
|
|
659
|
-
|
|
660
|
-
## Setup & Debugging
|
|
661
|
-
|
|
662
|
-
NightShift includes self-service tools for setup and troubleshooting.
|
|
663
|
-
|
|
664
|
-
### `nightshift_setup`
|
|
665
|
-
|
|
666
|
-
Get configuration instructions and verify project setup.
|
|
667
|
-
|
|
668
|
-
**Parameters:**
|
|
669
|
-
- `showExamples` (optional): Include prd.json and bugs.json templates
|
|
670
|
-
|
|
671
|
-
**Returns:**
|
|
672
|
-
- Project status checks (prd.json, bugs.json, git, .gitignore)
|
|
673
|
-
- Agent configuration examples for Claude and Codex
|
|
674
|
-
- Setup suggestions for any issues found
|
|
675
|
-
- Example templates (if requested)
|
|
676
|
-
|
|
677
|
-
**Example:**
|
|
678
|
-
```
|
|
679
|
-
nightshift_setup(showExamples: true)
|
|
680
|
-
```
|
|
681
|
-
|
|
682
|
-
### `nightshift_debug`
|
|
683
|
-
|
|
684
|
-
Diagnose issues and get troubleshooting guidance.
|
|
685
|
-
|
|
686
|
-
**Checks:**
|
|
687
|
-
- File system permissions
|
|
688
|
-
- JSON file validation (prd.json, bugs.json)
|
|
689
|
-
- Daemon lock status
|
|
690
|
-
- Recent chat errors and unclaimed failovers
|
|
691
|
-
- Agent availability
|
|
692
|
-
- Git repository status
|
|
693
|
-
|
|
694
|
-
**Example:**
|
|
695
|
-
```
|
|
696
|
-
nightshift_debug
|
|
697
|
-
# Returns detailed diagnostic report with suggested fixes
|
|
698
|
-
```
|
|
699
|
-
|
|
700
|
-
## Agent Spawning & Orchestration
|
|
701
|
-
|
|
702
|
-
One agent can spawn others as subprocesses, enabling fully autonomous multi-agent workflows with minimal user intervention.
|
|
703
|
-
|
|
704
|
-
### Spawning Tools
|
|
705
|
-
|
|
706
|
-
#### `list_available_agents`
|
|
707
|
-
Check which agent CLIs (claude, codex, gemini, vibe, goose) are installed and ready to run.
|
|
708
|
-
|
|
709
|
-
#### `spawn_agent`
|
|
710
|
-
Spawn another agent as a subprocess and wait for completion.
|
|
711
|
-
|
|
712
|
-
**Parameters:**
|
|
713
|
-
- `agent` (required): "claude", "codex", "gemini", "vibe", or "goose"
|
|
714
|
-
- `prompt` (required): Task/prompt to send
|
|
715
|
-
- `timeout` (optional): Seconds before timeout (default: 300)
|
|
716
|
-
|
|
717
|
-
**Example:**
|
|
718
|
-
```
|
|
719
|
-
spawn_agent(agent: "codex", prompt: "Fix the type errors in src/utils.ts")
|
|
720
|
-
```
|
|
721
|
-
|
|
722
|
-
#### `spawn_agent_background`
|
|
723
|
-
Spawn an agent in the background (non-blocking). Returns immediately with PID and output file path.
|
|
724
|
-
|
|
725
|
-
**Parameters:**
|
|
726
|
-
- `agent` (required): "claude", "codex", "gemini", "vibe", or "goose"
|
|
727
|
-
- `prompt` (required): Task/prompt to send
|
|
728
|
-
|
|
729
|
-
#### `delegate_story`
|
|
730
|
-
Delegate a PRD user story to another agent with full context. On failure, returns a `retryHint` suggesting alternative available agents.
|
|
731
|
-
|
|
732
|
-
**Parameters:**
|
|
733
|
-
- `agent` (required): "claude", "codex", "gemini", "vibe", or "goose"
|
|
734
|
-
- `storyId` (optional): Story ID to delegate (defaults to next available)
|
|
735
|
-
- `background` (optional): Run in background (default: false)
|
|
736
|
-
|
|
737
|
-
**Example:**
|
|
738
|
-
```
|
|
739
|
-
delegate_story(agent: "gemini", storyId: "US-003", background: true)
|
|
740
|
-
```
|
|
741
|
-
|
|
742
|
-
The spawned agent receives:
|
|
743
|
-
- Full story description and acceptance criteria
|
|
744
|
-
- Relevant context from the context store (or progress.txt as fallback)
|
|
745
|
-
- Recent chat messages for context
|
|
746
|
-
- Instructions to use nightshift tools for coordination (including `store_context` and `query_context`)
|
|
747
|
-
|
|
748
|
-
#### `delegate_research`
|
|
749
|
-
Delegate a research or planning task to an agent (default: Gemini). Ideal for read-only tasks like codebase analysis, architecture planning, code review, and documentation. Queries the context store for relevant prior findings.
|
|
750
|
-
|
|
751
|
-
**Parameters:**
|
|
752
|
-
- `task` (required): The research/planning task description
|
|
753
|
-
- `agent` (optional): Which agent to use (default: gemini)
|
|
754
|
-
- `context` (optional): Additional context to provide
|
|
755
|
-
- `background` (optional): Run in background (default: false)
|
|
756
|
-
|
|
757
|
-
### Monitoring Tools
|
|
758
|
-
|
|
759
|
-
#### `get_agent_status`
|
|
760
|
-
Check the status of a spawned background agent by PID.
|
|
761
|
-
|
|
762
|
-
**Parameters:**
|
|
763
|
-
- `pid` (required): Process ID of the spawned agent
|
|
764
|
-
|
|
765
|
-
**Returns:**
|
|
766
|
-
- Whether the agent is still running or has exited
|
|
767
|
-
- Exit code (if finished)
|
|
768
|
-
- Last 30 lines of output
|
|
769
|
-
- Story assignment (if delegated via `delegate_story`)
|
|
770
|
-
|
|
771
|
-
#### `list_running_agents`
|
|
772
|
-
List all agents spawned in the current session with their status.
|
|
773
|
-
|
|
774
|
-
**Returns:** Array of agents with PID, agent type, running/exited status, elapsed time, and story assignment.
|
|
775
|
-
|
|
776
|
-
### Orchestration
|
|
777
|
-
|
|
778
|
-
#### `orchestrate`
|
|
779
|
-
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.
|
|
780
|
-
|
|
781
|
-
**Parameters:**
|
|
782
|
-
- `agent` (optional): Your agent name (default: "NightShift")
|
|
783
|
-
- `maxIterations` (optional): Maximum stories to process (default: 50)
|
|
784
|
-
- `mode` (optional): "stories", "bugs", or "all" (default: "all")
|
|
785
|
-
|
|
786
|
-
### Orchestration Patterns
|
|
787
|
-
|
|
788
|
-
**Fully autonomous (recommended):**
|
|
789
|
-
```
|
|
790
|
-
orchestrate(agent: "Claude", mode: "all")
|
|
791
|
-
# Runs until all stories and bugs are complete
|
|
792
|
-
```
|
|
793
|
-
|
|
794
|
-
**Sequential delegation:**
|
|
795
|
-
```
|
|
796
|
-
delegate_story(agent: "codex") # Wait for completion
|
|
797
|
-
delegate_story(agent: "gemini") # Then delegate next
|
|
798
|
-
```
|
|
799
|
-
|
|
800
|
-
**Parallel execution:**
|
|
801
|
-
```
|
|
802
|
-
delegate_story(agent: "codex", storyId: "US-001", background: true)
|
|
803
|
-
delegate_story(agent: "goose", storyId: "US-002", background: true)
|
|
804
|
-
# Work on US-003 yourself while they run in parallel
|
|
805
|
-
# Monitor with get_agent_status or list_running_agents
|
|
806
|
-
```
|
|
807
|
-
|
|
808
|
-
**Research then implement:**
|
|
809
|
-
```
|
|
810
|
-
delegate_research(task: "Analyze auth patterns and recommend approach")
|
|
811
|
-
# Use findings to inform implementation
|
|
812
|
-
delegate_story(agent: "codex", storyId: "US-001")
|
|
813
|
-
```
|
|
814
|
-
|
|
815
|
-
## NightShift Daemon (Continuous Orchestration)
|
|
816
|
-
|
|
817
|
-
For fully automated, event-driven orchestration, run the NightShift daemon:
|
|
818
|
-
|
|
819
|
-
```bash
|
|
820
|
-
# Start the daemon
|
|
821
|
-
nightshift-daemon
|
|
822
|
-
|
|
823
|
-
# With options
|
|
824
|
-
nightshift-daemon --verbose --max-agents 4 --health-check 1m
|
|
825
|
-
|
|
826
|
-
# Preview mode (see what would happen)
|
|
827
|
-
nightshift-daemon --dry-run --verbose
|
|
828
|
-
```
|
|
829
|
-
|
|
830
|
-
### How It Works
|
|
831
|
-
|
|
832
|
-
The daemon provides hands-off multi-agent orchestration:
|
|
833
|
-
|
|
834
|
-
1. **Event-Driven**: Watches `prd.json` and `chat.txt` for changes
|
|
835
|
-
2. **Auto-Spawning**: Spawns agents for orphaned stories (up to concurrency limit)
|
|
836
|
-
3. **Failover Handling**: Automatically claims and reassigns failover requests
|
|
837
|
-
4. **Smart Retry**: Tracks failed agents per story and tries a different agent on retry
|
|
838
|
-
5. **Health Checks**: Periodic reconciliation as a fallback (default: every 2 min)
|
|
839
|
-
6. **Poison Pill Protection**: Quarantines stories that fail repeatedly
|
|
840
|
-
7. **Stuck Detection**: Kills agents that haven't reported activity
|
|
841
|
-
|
|
842
|
-
### Options
|
|
843
|
-
|
|
844
|
-
| Flag | Description | Default |
|
|
845
|
-
|------|-------------|---------|
|
|
846
|
-
| `--verbose, -v` | Enable debug logging | false |
|
|
847
|
-
| `--dry-run` | Show actions without spawning | false |
|
|
848
|
-
| `--health-check <N>` | Health check interval (e.g., "2m", "30s") | 2m |
|
|
849
|
-
| `--max-agents <N>` | Max concurrent agents | 3 |
|
|
850
|
-
|
|
851
|
-
### Environment
|
|
852
|
-
|
|
853
|
-
- `ROBOT_CHAT_PROJECT_PATH` - Project directory (default: current directory)
|
|
854
|
-
|
|
855
|
-
### Architecture
|
|
856
|
-
|
|
857
|
-
```
|
|
858
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
859
|
-
│ NightShift Daemon │
|
|
860
|
-
├─────────────────────────────────────────────────────────────┤
|
|
861
|
-
│ │
|
|
862
|
-
│ ┌──────────────────────────────────────────────────┐ │
|
|
863
|
-
│ │ File Watchers (Primary) │ │
|
|
864
|
-
│ │ • prd.json changes → reconcile │ │
|
|
865
|
-
│ │ • chat.txt changes → check failovers │ │
|
|
866
|
-
│ └──────────────────────────────────────────────────┘ │
|
|
867
|
-
│ │ │
|
|
868
|
-
│ ▼ │
|
|
869
|
-
│ ┌──────────────────────────────────────────────────┐ │
|
|
870
|
-
│ │ Reconciliation Engine │ │
|
|
871
|
-
│ │ • Find orphaned stories │ │
|
|
872
|
-
│ │ • Spawn agents (up to max concurrency) │ │
|
|
873
|
-
│ │ • Handle failovers │ │
|
|
874
|
-
│ │ • Quarantine poison pills │ │
|
|
875
|
-
│ └──────────────────────────────────────────────────┘ │
|
|
876
|
-
│ │ │
|
|
877
|
-
│ ▼ │
|
|
878
|
-
│ ┌──────────────────────────────────────────────────┐ │
|
|
879
|
-
│ │ Health Check (Fallback) │ │
|
|
880
|
-
│ │ • Runs every 2 minutes │ │
|
|
881
|
-
│ │ • Detects stuck agents │ │
|
|
882
|
-
│ │ • Restarts watchers if needed │ │
|
|
883
|
-
│ │ • Reconciles state │ │
|
|
884
|
-
│ └──────────────────────────────────────────────────┘ │
|
|
885
|
-
│ │
|
|
886
|
-
└─────────────────────────────────────────────────────────────┘
|
|
887
|
-
```
|
|
888
|
-
|
|
889
|
-
## Local Models via Ollama
|
|
890
|
-
|
|
891
|
-
NightShift supports local Ollama models through two harnesses:
|
|
892
|
-
|
|
893
|
-
### Goose + Ollama (Recommended for tool use)
|
|
894
|
-
|
|
895
|
-
[Goose](https://github.com/block/goose) has its own tool-calling implementation that works reliably with local models. This is the recommended path for local agent work.
|
|
896
|
-
|
|
897
|
-
```bash
|
|
898
|
-
# Install Goose CLI
|
|
899
|
-
curl -fsSL https://github.com/block/goose/releases/latest/download/install.sh | bash
|
|
900
|
-
|
|
901
|
-
# Install Ollama and pull a model
|
|
902
|
-
ollama pull qwen3.5:4b
|
|
903
|
-
|
|
904
|
-
# Configure nightshift to use Goose with Ollama
|
|
905
|
-
export NIGHTSHIFT_GOOSE_PROVIDER=ollama
|
|
906
|
-
export NIGHTSHIFT_GOOSE_MODEL=qwen3.5:4b
|
|
907
|
-
```
|
|
908
|
-
|
|
909
|
-
Then use `goose` as your agent in nightshift:
|
|
910
|
-
```
|
|
911
|
-
spawn_agent(agent: "goose", prompt: "Fix the pagination bug in src/api.ts")
|
|
912
|
-
delegate_research(agent: "goose", task: "Analyze error handling patterns")
|
|
913
|
-
```
|
|
914
|
-
|
|
915
|
-
**Recommended models** (by hardware):
|
|
916
|
-
|
|
917
|
-
| GPU VRAM | Model | Size | Notes |
|
|
918
|
-
|----------|-------|------|-------|
|
|
919
|
-
| 4GB+ | `qwen3.5:4b` | 3.4 GB | Fast, good tool use |
|
|
920
|
-
| 6GB+ | `qwen3.5:4b-q8_0` | 5.3 GB | Better accuracy, same speed |
|
|
921
|
-
| 8GB+ | `qwen3.5:9b` | 6.6 GB | Best quality, slower on consumer GPUs |
|
|
922
|
-
|
|
923
|
-
### Claude Code + Ollama (Text generation only)
|
|
924
|
-
|
|
925
|
-
For tasks that don't require tool use (summarization, code review, planning):
|
|
926
|
-
|
|
927
|
-
```bash
|
|
928
|
-
export NIGHTSHIFT_OLLAMA_MODEL=qwen3.5:4b # or any Ollama model
|
|
929
|
-
```
|
|
930
|
-
|
|
931
|
-
Then use `ollama` as your agent:
|
|
932
|
-
```
|
|
933
|
-
spawn_agent(agent: "ollama", prompt: "Review this PR for security issues")
|
|
934
|
-
delegate_research(agent: "ollama", task: "Summarize the authentication patterns")
|
|
935
|
-
```
|
|
936
|
-
|
|
937
|
-
This uses Claude Code's harness with Ollama's Anthropic-compatible API. Text generation works well, but local models don't reliably trigger Claude Code's structured tool calls.
|
|
938
|
-
|
|
939
|
-
### Benchmarking Local Models
|
|
940
|
-
|
|
941
|
-
A benchmark suite is included to test which models work on your hardware:
|
|
942
|
-
|
|
943
|
-
```bash
|
|
944
|
-
# Test all tasks with goose + a specific model
|
|
945
|
-
node benchmarks/run-experiment.mjs --agent goose --model qwen3.5:4b
|
|
946
|
-
|
|
947
|
-
# Test only text-level tasks (fast sanity check)
|
|
948
|
-
node benchmarks/run-experiment.mjs --agent goose --model qwen3.5:4b --level text
|
|
949
|
-
|
|
950
|
-
# Compare models
|
|
951
|
-
node benchmarks/run-experiment.mjs --agent goose --model qwen3.5:9b
|
|
952
|
-
```
|
|
953
|
-
|
|
954
|
-
Results are saved to `benchmarks/results/` for comparison across runs.
|
|
955
|
-
|
|
956
|
-
## Multi-Agent Tips
|
|
957
|
-
|
|
958
|
-
1. **Same directory**: All agents must run in the same project directory to share chat
|
|
959
|
-
2. **Claim before working**: Always claim stories to prevent duplicate work
|
|
960
|
-
3. **Post status updates**: Keep other agents informed of progress
|
|
961
|
-
4. **Store context, not just progress**: Use `store_context` to share learnings by topic — other agents can query for exactly what they need instead of reading a giant progress file
|
|
962
|
-
5. **Handle failovers**: Check for and claim failovers at the start of each session
|
|
963
|
-
6. **Use delegation**: One orchestrating agent can spawn others for parallel work
|
|
964
|
-
7. **Monitor background agents**: Use `get_agent_status` and `list_running_agents` to track spawned agents
|
|
965
|
-
8. **Use `orchestrate` for full autonomy**: The `orchestrate` tool handles the entire claim→implement→complete loop
|
|
966
|
-
9. **Review traces after runs**: Use `get_trace(tree: true)` to understand what happened during orchestration
|
|
967
|
-
10. **Add `.robot-chat/` to your project's `.gitignore`**: Chat logs, context, and traces are ephemeral and shouldn't be committed
|
|
968
|
-
|
|
969
|
-
## License
|
|
970
|
-
|
|
971
|
-
MIT
|
|
1
|
+
# NightShift MCP
|
|
2
|
+
|
|
3
|
+
**Multi-agent orchestration across AI models. The responsible kind of multi-agent chaos.**
|
|
4
|
+
|
|
5
|
+
An [MCP](https://modelcontextprotocol.io/) server that coordinates Claude, Codex, Gemini, Vibe, Goose, and local Ollama models as an agentic team. Structured delegation, shared task management, autonomous workflows, and production-grade reliability features. Works with any MCP-compatible client.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Install
|
|
11
|
+
npm install -g nightshift-mcp
|
|
12
|
+
|
|
13
|
+
# Configure for Claude Code (~/.claude.json)
|
|
14
|
+
{
|
|
15
|
+
"mcpServers": {
|
|
16
|
+
"nightshift": { "command": "nightshift-mcp", "args": [] }
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Configure for Codex (~/.codex/config.toml)
|
|
21
|
+
[mcp_servers.nightshift]
|
|
22
|
+
command = "nightshift-mcp"
|
|
23
|
+
args = []
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
All agents must run in the **same project directory** to share coordination state.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Terminal 1 # Terminal 2
|
|
30
|
+
cd ~/myproject cd ~/myproject
|
|
31
|
+
claude codex
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
### Orchestration
|
|
37
|
+
- **Agent spawning**: Spawn Claude, Codex, Gemini, Vibe, Goose, or Ollama as subprocesses with full lifecycle tracking
|
|
38
|
+
- **Autonomous mode**: Single `orchestrate` tool runs claim-implement-complete loops until all stories pass
|
|
39
|
+
- **Daemon mode**: Event-driven background orchestrator with file watchers, health checks, and auto-recovery
|
|
40
|
+
- **Delegation**: Hand off stories or research tasks to specific agents with full context injection
|
|
41
|
+
- **Failover handling**: Seamless handoffs when an agent hits rate limits or context windows
|
|
42
|
+
|
|
43
|
+
### Reliability (New in 2.0)
|
|
44
|
+
- **Circuit breaker**: Per-agent CLOSED/OPEN/HALF_OPEN state machine. Auto-disables failing agents, re-enables after configurable cooldown. Persisted across daemon restarts.
|
|
45
|
+
- **Immutable audit trail**: Append-only SQLite table records every spawn, completion, failure, circuit break, and stuck-agent kill
|
|
46
|
+
- **Run records**: Structured execution history per agent run — duration, exit status, files changed, scope leak detection
|
|
47
|
+
- **Budget tracking**: Per-agent cost tracking with daily/monthly limits, warning thresholds, enable/disable toggle
|
|
48
|
+
- **Autoresearch**: Built-in analytics queries — agent success rates, average duration, scope leak rates
|
|
49
|
+
|
|
50
|
+
### Task Management
|
|
51
|
+
- **PRD-driven workflow**: User stories in `prd.json` with priorities, dependencies (`dependsOn`), and tags for routing
|
|
52
|
+
- **Bug tracking**: `bugs.json` for post-testing feedback loops
|
|
53
|
+
- **Savepoints**: Git-based checkpoints (or JSON fallback) with rollback support
|
|
54
|
+
- **Progress tracking**: Shared learnings via `progress.txt`
|
|
55
|
+
|
|
56
|
+
### Communication
|
|
57
|
+
- **Multi-agent chat**: Structured messaging via `.robot-chat/chat.txt` with agent name, timestamp, and message type
|
|
58
|
+
- **Context store**: Topic-based context retrieval — agents store and query learnings instead of prompt-stuffing
|
|
59
|
+
- **Execution tracing**: Parent-child trace trees for debugging multi-agent runs
|
|
60
|
+
|
|
61
|
+
### Platform
|
|
62
|
+
- **Cross-platform**: Windows, Linux, macOS
|
|
63
|
+
- **6 agent types**: Claude, Codex, Gemini, Vibe, Goose, Ollama
|
|
64
|
+
- **49 MCP tools** across 10 categories
|
|
65
|
+
- **NightShift CLI**: `nightshift` command for agent coordination without MCP
|
|
66
|
+
- **Zero external services**: Everything runs locally with SQLite + file storage
|
|
67
|
+
|
|
68
|
+
## What's New in 2.0
|
|
69
|
+
|
|
70
|
+
- **SQLite foundation**: New data layer (`.robot-chat/nightshift.db`) with ACID transactions and WAL mode. Powers audit trail, run records, budget tracking, and circuit breaker persistence. Legacy managers (chat, PRD, workflow) still use their original files for backwards compatibility — migration planned for 2.1.
|
|
71
|
+
- **Circuit breaker**: Tracks consecutive failures per agent type. Auto-disables after threshold (default: 3), auto-recovers after cooldown (default: 60s). Single-probe enforcement in half-open state.
|
|
72
|
+
- **Immutable audit trail**: Every daemon event logged to `audit_log` table. Queryable by event type, agent, story, or timestamp.
|
|
73
|
+
- **Run records + autoresearch**: Structured execution data feeds analytics queries for agent performance optimization.
|
|
74
|
+
- **Budget tracking**: Enable/disable per agent with configurable daily and monthly cost limits. Ready for OpenRouter integration.
|
|
75
|
+
- **Security**: MCP SDK upgraded to 1.28.0. Zero production dependency vulnerabilities.
|
|
76
|
+
|
|
77
|
+
## Architecture
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
┌───────────────────────────────────────────────────────────┐
|
|
81
|
+
│ NightShift MCP │
|
|
82
|
+
├───────────────────────────────────────────────────────────┤
|
|
83
|
+
│ │
|
|
84
|
+
│ ┌────────┐ ┌────────┐ ┌────────┐ ┌──────┐ ┌──────────┐ │
|
|
85
|
+
│ │ Claude │ │ Codex │ │ Gemini │ │ Vibe │ │Goose/Olla│ │
|
|
86
|
+
│ └───┬────┘ └───┬────┘ └───┬────┘ └──┬───┘ └────┬─────┘ │
|
|
87
|
+
│ └──────────┴─────┬─────┴─────────┴──────────┘ │
|
|
88
|
+
│ ▼ │
|
|
89
|
+
│ ┌─────────────────────┐ │
|
|
90
|
+
│ │ .robot-chat/ │ │
|
|
91
|
+
│ │ │ │
|
|
92
|
+
│ │ chat.txt (msg) │ │
|
|
93
|
+
│ │ nightshift.db (v2) │ │
|
|
94
|
+
│ │ workflow.json │ │
|
|
95
|
+
│ │ trace.json │ │
|
|
96
|
+
│ │ context/ │ │
|
|
97
|
+
│ └─────────────────────┘ │
|
|
98
|
+
│ │ │
|
|
99
|
+
│ ┌────────────────┼────────────────┐ │
|
|
100
|
+
│ ▼ ▼ ▼ │
|
|
101
|
+
│ ┌────────┐ ┌────────────┐ ┌──────────┐ │
|
|
102
|
+
│ │prd.json│ │ nightshift │ │progress │ │
|
|
103
|
+
│ │(stories│ │ .db │ │ .txt │ │
|
|
104
|
+
│ │ + bugs)│ │ (audit, │ │(learnings│ │
|
|
105
|
+
│ │ │ │ budget, │ │ patterns)│ │
|
|
106
|
+
│ │ │ │ runs, │ │ │ │
|
|
107
|
+
│ │ │ │ circuits) │ │ │ │
|
|
108
|
+
│ └────────┘ └────────────┘ └──────────┘ │
|
|
109
|
+
│ │
|
|
110
|
+
└───────────────────────────────────────────────────────────┘
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Usage Patterns
|
|
114
|
+
|
|
115
|
+
### Fully autonomous
|
|
116
|
+
```
|
|
117
|
+
orchestrate(agent: "Claude", mode: "all")
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Parallel delegation
|
|
121
|
+
```
|
|
122
|
+
delegate_story(agent: "codex", storyId: "US-001", background: true)
|
|
123
|
+
delegate_story(agent: "gemini", storyId: "US-002", background: true)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Research then implement
|
|
127
|
+
```
|
|
128
|
+
delegate_research(task: "Analyze auth patterns and recommend approach")
|
|
129
|
+
delegate_story(agent: "codex", storyId: "US-001")
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Daemon (hands-off)
|
|
133
|
+
```bash
|
|
134
|
+
nightshift-daemon --verbose --max-agents 4
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## PRD Setup
|
|
138
|
+
|
|
139
|
+
Create `prd.json` in your project root:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
"project": "MyApp",
|
|
144
|
+
"userStories": [
|
|
145
|
+
{
|
|
146
|
+
"id": "US-001",
|
|
147
|
+
"title": "Set up project structure",
|
|
148
|
+
"acceptanceCriteria": ["Add routes", "Create base components"],
|
|
149
|
+
"priority": 1,
|
|
150
|
+
"passes": false
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "US-002",
|
|
154
|
+
"title": "Add database schema",
|
|
155
|
+
"priority": 2,
|
|
156
|
+
"passes": false,
|
|
157
|
+
"dependsOn": ["US-001"],
|
|
158
|
+
"tags": ["code", "infrastructure"]
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Story fields
|
|
165
|
+
|
|
166
|
+
| Field | Type | Required | Default | Description |
|
|
167
|
+
|-------|------|----------|---------|-------------|
|
|
168
|
+
| `id` | string | yes | — | Unique ID (e.g., "US-001") |
|
|
169
|
+
| `title` | string | yes | — | Short title |
|
|
170
|
+
| `description` | string | no | "" | Detailed description |
|
|
171
|
+
| `acceptanceCriteria` | string[] | no | [] | Completion criteria |
|
|
172
|
+
| `priority` | number | no | 999 | Lower = higher priority |
|
|
173
|
+
| `passes` | boolean | no | false | Whether complete |
|
|
174
|
+
| `dependsOn` | string[] | no | — | Story IDs that must complete first |
|
|
175
|
+
| `tags` | string[] | no | — | Routing hints (e.g., `["code"]`, `["research"]`) |
|
|
176
|
+
|
|
177
|
+
Tags influence agent routing: `research`/`planning` prefers Gemini/Claude, `code`/`implementation` prefers Codex/Claude.
|
|
178
|
+
|
|
179
|
+
## Bug Tracking
|
|
180
|
+
|
|
181
|
+
Add `bugs.json` when testing reveals issues:
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"project": "MyApp",
|
|
186
|
+
"bugs": [
|
|
187
|
+
{
|
|
188
|
+
"id": "BUG-001",
|
|
189
|
+
"title": "Login fails on mobile",
|
|
190
|
+
"description": "Login button unresponsive on iOS Safari",
|
|
191
|
+
"priority": 1,
|
|
192
|
+
"fixed": false
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
When all stories pass and all bugs are fixed, NightShift posts `READY_TO_TEST` to the chat.
|
|
199
|
+
|
|
200
|
+
## Tools Reference
|
|
201
|
+
|
|
202
|
+
NightShift provides 49 tools across 10 categories. Key tools listed below — use `nightshift_setup(showExamples: true)` or `nightshift_help` for full documentation.
|
|
203
|
+
|
|
204
|
+
### Communication
|
|
205
|
+
| Tool | Description |
|
|
206
|
+
|------|-------------|
|
|
207
|
+
| `read_robot_chat` | Read recent messages (filter by agent, type, limit) |
|
|
208
|
+
| `write_robot_chat` | Post a message (STATUS_UPDATE, QUESTION, ERROR, etc.) |
|
|
209
|
+
| `check_failovers` | Find unclaimed failover requests |
|
|
210
|
+
| `claim_failover` | Take over work from a stuck agent |
|
|
211
|
+
| `list_agents` | See who's active with activity stats |
|
|
212
|
+
| `watch_chat` | Cursor-based polling for new messages |
|
|
213
|
+
|
|
214
|
+
### Task Management
|
|
215
|
+
| Tool | Description |
|
|
216
|
+
|------|-------------|
|
|
217
|
+
| `read_prd` | Read PRD with completion summary |
|
|
218
|
+
| `get_next_story` | Get highest priority incomplete story |
|
|
219
|
+
| `claim_story` | Claim a story and notify via chat |
|
|
220
|
+
| `complete_story` | Mark done, log progress, create savepoint |
|
|
221
|
+
| `read_bugs` / `claim_bug` / `mark_bug_fixed` | Bug lifecycle |
|
|
222
|
+
|
|
223
|
+
### Agent Spawning
|
|
224
|
+
| Tool | Description |
|
|
225
|
+
|------|-------------|
|
|
226
|
+
| `list_available_agents` | Check which CLIs are installed and runnable |
|
|
227
|
+
| `spawn_agent` | Spawn agent, wait for completion (sync) |
|
|
228
|
+
| `spawn_agent_background` | Spawn agent, return immediately (async) |
|
|
229
|
+
| `delegate_story` | Delegate a story with full context injection |
|
|
230
|
+
| `delegate_research` | Delegate research/analysis task |
|
|
231
|
+
|
|
232
|
+
### Orchestration
|
|
233
|
+
| Tool | Description |
|
|
234
|
+
|------|-------------|
|
|
235
|
+
| `orchestrate` | Autonomous claim-implement-complete loop |
|
|
236
|
+
| `get_agent_status` | Check background agent by PID |
|
|
237
|
+
| `list_running_agents` | All spawned agents with status |
|
|
238
|
+
|
|
239
|
+
### Workflow
|
|
240
|
+
| Tool | Description |
|
|
241
|
+
|------|-------------|
|
|
242
|
+
| `init_workflow` | Initialize with project goal and phases |
|
|
243
|
+
| `advance_phase` / `set_phase` | Phase management |
|
|
244
|
+
| `record_decision` | Record strategic decisions with rationale |
|
|
245
|
+
|
|
246
|
+
### Context & Tracing
|
|
247
|
+
| Tool | Description |
|
|
248
|
+
|------|-------------|
|
|
249
|
+
| `store_context` / `query_context` | Topic-based context store |
|
|
250
|
+
| `get_trace` | Execution trace (flat or tree view) |
|
|
251
|
+
|
|
252
|
+
### Recovery
|
|
253
|
+
| Tool | Description |
|
|
254
|
+
|------|-------------|
|
|
255
|
+
| `create_savepoint` | Manual git checkpoint |
|
|
256
|
+
| `list_savepoints` | List all savepoints |
|
|
257
|
+
| `rollback_savepoint` | Reset to a previous savepoint |
|
|
258
|
+
|
|
259
|
+
### Setup
|
|
260
|
+
| Tool | Description |
|
|
261
|
+
|------|-------------|
|
|
262
|
+
| `nightshift_setup` | Configuration check and templates |
|
|
263
|
+
| `nightshift_debug` | Diagnostic report with suggested fixes |
|
|
264
|
+
|
|
265
|
+
## Daemon
|
|
266
|
+
|
|
267
|
+
The daemon provides hands-off, event-driven orchestration:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
nightshift-daemon [options]
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
| Flag | Default | Description |
|
|
274
|
+
|------|---------|-------------|
|
|
275
|
+
| `--verbose, -v` | false | Debug logging |
|
|
276
|
+
| `--dry-run` | false | Preview without spawning |
|
|
277
|
+
| `--health-check <N>` | 2m | Health check interval |
|
|
278
|
+
| `--max-agents <N>` | 3 | Max concurrent agents |
|
|
279
|
+
|
|
280
|
+
**What it does:**
|
|
281
|
+
- Watches `prd.json` and `chat.txt` for changes
|
|
282
|
+
- Auto-spawns agents for unassigned stories
|
|
283
|
+
- Circuit breaker disables failing agents, re-enables after cooldown
|
|
284
|
+
- Detects and kills stuck agents
|
|
285
|
+
- Claims failover requests
|
|
286
|
+
- Quarantines stories that fail repeatedly
|
|
287
|
+
- Logs everything to the SQLite audit trail
|
|
288
|
+
|
|
289
|
+
## Local Models
|
|
290
|
+
|
|
291
|
+
### Goose + Ollama (recommended)
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
export NIGHTSHIFT_GOOSE_PROVIDER=ollama
|
|
295
|
+
export NIGHTSHIFT_GOOSE_MODEL=qwen3.5:4b
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
```
|
|
299
|
+
spawn_agent(agent: "goose", prompt: "Fix the pagination bug")
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Direct Ollama (text only)
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
export NIGHTSHIFT_OLLAMA_MODEL=qwen3.5:4b
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
spawn_agent(agent: "ollama", prompt: "Review this PR")
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
| GPU VRAM | Model | Size |
|
|
313
|
+
|----------|-------|------|
|
|
314
|
+
| 4GB+ | `qwen3.5:4b` | 3.4 GB |
|
|
315
|
+
| 6GB+ | `qwen3.5:4b-q8_0` | 5.3 GB |
|
|
316
|
+
| 8GB+ | `qwen3.5:9b` | 6.6 GB |
|
|
317
|
+
|
|
318
|
+
## Data Storage
|
|
319
|
+
|
|
320
|
+
NightShift uses a hybrid storage approach:
|
|
321
|
+
|
|
322
|
+
| Data | Storage | Format |
|
|
323
|
+
|------|---------|--------|
|
|
324
|
+
| Agent chat | `.robot-chat/chat.txt` | Human-readable text |
|
|
325
|
+
| PRD / stories | `prd.json` | JSON |
|
|
326
|
+
| Bugs | `bugs.json` | JSON |
|
|
327
|
+
| Progress | `progress.txt` | Append-only text |
|
|
328
|
+
| Workflow | `.robot-chat/workflow.json` | JSON with file locking |
|
|
329
|
+
| Trace | `.robot-chat/trace.json` | JSON |
|
|
330
|
+
| Context | `.robot-chat/context/*.json` | Per-topic JSON files |
|
|
331
|
+
| **Audit trail** | `.robot-chat/nightshift.db` | SQLite (immutable) |
|
|
332
|
+
| **Run records** | `.robot-chat/nightshift.db` | SQLite |
|
|
333
|
+
| **Budget** | `.robot-chat/nightshift.db` | SQLite |
|
|
334
|
+
| **Circuit breaker** | `.robot-chat/nightshift.db` | SQLite |
|
|
335
|
+
|
|
336
|
+
Add `.robot-chat/` to your `.gitignore` — coordination state is ephemeral.
|
|
337
|
+
|
|
338
|
+
## Development
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
git clone https://gitlab.com/Pike1868/nightshift-mcp.git
|
|
342
|
+
cd nightshift-mcp
|
|
343
|
+
npm install
|
|
344
|
+
npm run build
|
|
345
|
+
npm test # 113 tests
|
|
346
|
+
npm run dev # watch mode
|
|
347
|
+
npm link # global CLI access
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## License
|
|
351
|
+
|
|
352
|
+
MIT
|