nightshift-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +670 -0
  2. package/dist/agent-spawner.d.ts +55 -0
  3. package/dist/agent-spawner.d.ts.map +1 -0
  4. package/dist/agent-spawner.js +468 -0
  5. package/dist/agent-spawner.js.map +1 -0
  6. package/dist/chat-manager.d.ts +72 -0
  7. package/dist/chat-manager.d.ts.map +1 -0
  8. package/dist/chat-manager.js +331 -0
  9. package/dist/chat-manager.js.map +1 -0
  10. package/dist/daemon.d.ts +65 -0
  11. package/dist/daemon.d.ts.map +1 -0
  12. package/dist/daemon.js +563 -0
  13. package/dist/daemon.js.map +1 -0
  14. package/dist/file-lock.d.ts +41 -0
  15. package/dist/file-lock.d.ts.map +1 -0
  16. package/dist/file-lock.js +157 -0
  17. package/dist/file-lock.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +2433 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/ralph-manager.d.ts +148 -0
  23. package/dist/ralph-manager.d.ts.map +1 -0
  24. package/dist/ralph-manager.js +399 -0
  25. package/dist/ralph-manager.js.map +1 -0
  26. package/dist/tool-registry.d.ts +130 -0
  27. package/dist/tool-registry.d.ts.map +1 -0
  28. package/dist/tool-registry.js +280 -0
  29. package/dist/tool-registry.js.map +1 -0
  30. package/dist/tools/agents.d.ts +7 -0
  31. package/dist/tools/agents.d.ts.map +1 -0
  32. package/dist/tools/agents.js +366 -0
  33. package/dist/tools/agents.js.map +1 -0
  34. package/dist/tools/bugs.d.ts +6 -0
  35. package/dist/tools/bugs.d.ts.map +1 -0
  36. package/dist/tools/bugs.js +184 -0
  37. package/dist/tools/bugs.js.map +1 -0
  38. package/dist/tools/chat.d.ts +10 -0
  39. package/dist/tools/chat.d.ts.map +1 -0
  40. package/dist/tools/chat.js +287 -0
  41. package/dist/tools/chat.js.map +1 -0
  42. package/dist/tools/index.d.ts +33 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/index.js +51 -0
  45. package/dist/tools/index.js.map +1 -0
  46. package/dist/tools/prd.d.ts +8 -0
  47. package/dist/tools/prd.d.ts.map +1 -0
  48. package/dist/tools/prd.js +275 -0
  49. package/dist/tools/prd.js.map +1 -0
  50. package/dist/tools/progress.d.ts +5 -0
  51. package/dist/tools/progress.d.ts.map +1 -0
  52. package/dist/tools/progress.js +81 -0
  53. package/dist/tools/progress.js.map +1 -0
  54. package/dist/tools/savepoints.d.ts +5 -0
  55. package/dist/tools/savepoints.d.ts.map +1 -0
  56. package/dist/tools/savepoints.js +100 -0
  57. package/dist/tools/savepoints.js.map +1 -0
  58. package/dist/tools/utility.d.ts +4 -0
  59. package/dist/tools/utility.d.ts.map +1 -0
  60. package/dist/tools/utility.js +375 -0
  61. package/dist/tools/utility.js.map +1 -0
  62. package/dist/tools/workflow.d.ts +10 -0
  63. package/dist/tools/workflow.d.ts.map +1 -0
  64. package/dist/tools/workflow.js +321 -0
  65. package/dist/tools/workflow.js.map +1 -0
  66. package/dist/types.d.ts +105 -0
  67. package/dist/types.d.ts.map +1 -0
  68. package/dist/types.js +2 -0
  69. package/dist/types.js.map +1 -0
  70. package/dist/workflow-manager.d.ts +154 -0
  71. package/dist/workflow-manager.d.ts.map +1 -0
  72. package/dist/workflow-manager.js +356 -0
  73. package/dist/workflow-manager.js.map +1 -0
  74. package/package.json +48 -0
package/README.md ADDED
@@ -0,0 +1,670 @@
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 tracking**: See which agents are active and what they're working on
18
+ - **Watch/polling**: Monitor for new messages with cursor-based polling
19
+ - **Auto-archiving**: Archive old messages to keep the chat file manageable
20
+ - **Universal compatibility**: Works with any MCP-supporting tool
21
+ - **Simple file-based storage**: No external services required
22
+
23
+ ## Installation
24
+
25
+ **Via npm (recommended):**
26
+ ```bash
27
+ npm install -g nightshift-mcp
28
+ ```
29
+
30
+ **Or build from source:**
31
+ ```bash
32
+ git clone <repo-url>
33
+ cd nightshift-mcp
34
+ npm install
35
+ npm run build
36
+ npm link # makes 'nightshift-mcp' available globally
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ ### Claude Code (`~/.claude.json`)
42
+
43
+ ```json
44
+ {
45
+ "mcpServers": {
46
+ "nightshift": {
47
+ "command": "node",
48
+ "args": ["/path/to/nightshift-mcp/dist/index.js"],
49
+ "env": {
50
+ "ROBOT_CHAT_PROJECT_PATH": "${PWD}"
51
+ }
52
+ }
53
+ }
54
+ }
55
+ ```
56
+
57
+ ### Codex (`~/.codex/config.toml`)
58
+
59
+ ```toml
60
+ [mcp_servers.nightshift]
61
+ command = "node"
62
+ args = ["/path/to/nightshift-mcp/dist/index.js"]
63
+ env = { ROBOT_CHAT_PROJECT_PATH = "${PWD}" }
64
+ ```
65
+
66
+ ## Usage
67
+
68
+ 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.
69
+
70
+ **Example - two agents working on the same project:**
71
+
72
+ ```bash
73
+ # Terminal 1
74
+ cd ~/myproject
75
+ claude
76
+
77
+ # Terminal 2
78
+ cd ~/myproject
79
+ codex
80
+ ```
81
+
82
+ Both agents now share the same chat file and can coordinate via the nightshift tools.
83
+
84
+ **Note:** If agents are started in different directories, they will have separate chat files and won't be able to communicate.
85
+
86
+ ## Tools
87
+
88
+ ### `read_robot_chat`
89
+
90
+ Read recent messages from the chat file.
91
+
92
+ **Parameters:**
93
+ - `limit` (optional): Maximum messages to return (default: 20)
94
+ - `agent` (optional): Filter by agent name
95
+ - `type` (optional): Filter by message type
96
+
97
+ **Example:**
98
+ ```
99
+ Read the last 10 messages from Claude
100
+ ```
101
+
102
+ ### `write_robot_chat`
103
+
104
+ Write a message to the chat file.
105
+
106
+ **Parameters:**
107
+ - `agent` (required): Your agent name (e.g., "Claude", "Codex")
108
+ - `type` (required): Message type
109
+ - `content` (required): Message content
110
+
111
+ **Message Types:**
112
+ - `FAILOVER_NEEDED` - Request another agent to take over
113
+ - `FAILOVER_CLAIMED` - Acknowledge taking over a task
114
+ - `TASK_COMPLETE` - Mark a task as finished
115
+ - `STATUS_UPDATE` - Share progress update
116
+ - `HANDOFF` - Pass work to a specific agent
117
+ - `INFO` - General information
118
+ - `ERROR` - Error report
119
+ - `QUESTION` - Ask other agents a question
120
+ - `ANSWER` - Answer a question
121
+
122
+ **Example:**
123
+ ```
124
+ Post a STATUS_UPDATE from Claude about completing the login form
125
+ ```
126
+
127
+ ### `check_failovers`
128
+
129
+ Find unclaimed FAILOVER_NEEDED messages.
130
+
131
+ **Example:**
132
+ ```
133
+ Check if any agent needs help with their task
134
+ ```
135
+
136
+ ### `claim_failover`
137
+
138
+ Claim a failover request from another agent.
139
+
140
+ **Parameters:**
141
+ - `agent` (required): Your agent name
142
+ - `originalAgent` (required): Agent who requested failover
143
+ - `task` (optional): Task description
144
+
145
+ **Example:**
146
+ ```
147
+ Claim the failover from Codex and continue working on the authentication feature
148
+ ```
149
+
150
+ ### `get_chat_path`
151
+
152
+ Get the full path to the chat file.
153
+
154
+ ### `list_agents`
155
+
156
+ List all agents who have posted to the chat, with their activity stats.
157
+
158
+ **Returns:**
159
+ - Agent name
160
+ - Last seen timestamp
161
+ - Last message type
162
+ - Total message count
163
+
164
+ **Example:**
165
+ ```
166
+ Show me which agents have been active in the chat
167
+ ```
168
+
169
+ ### `watch_chat`
170
+
171
+ Poll for new messages since a cursor position. Useful for monitoring the chat for updates.
172
+
173
+ **Parameters:**
174
+ - `cursor` (optional): Line number from previous watch call. Omit to get current cursor.
175
+
176
+ **Returns:**
177
+ - `cursor`: Updated cursor for next call
178
+ - `messageCount`: Number of new messages
179
+ - `messages`: Array of new messages
180
+
181
+ **Example workflow:**
182
+ ```
183
+ 1. Call watch_chat without cursor to get initial position
184
+ 2. Store the returned cursor value
185
+ 3. Call watch_chat with that cursor to get new messages
186
+ 4. Update your cursor with the returned value
187
+ 5. Repeat step 3-4 to poll for updates
188
+ ```
189
+
190
+ ### `archive_chat`
191
+
192
+ Archive old messages to a date-stamped file, keeping recent messages in main chat.
193
+
194
+ **Parameters:**
195
+ - `keepRecent` (optional): Number of messages to keep (default: 50)
196
+
197
+ **Example:**
198
+ ```
199
+ Archive old messages, keeping the last 20
200
+ ```
201
+
202
+ ## Chat File Format
203
+
204
+ Messages are stored in a human-readable format:
205
+
206
+ ```
207
+ # Robot Chat - Multi-Agent Communication
208
+ # Format: [AgentName @ HH:MM] MESSAGE_TYPE
209
+ # ========================================
210
+
211
+ [Claude @ 14:32] STATUS_UPDATE
212
+ Working on implementing the login form.
213
+ Files modified: src/components/LoginForm.tsx
214
+
215
+ [Codex @ 14:45] FAILOVER_NEEDED
216
+ Status: Hit rate limit
217
+ Current Task: Implementing user authentication
218
+ Progress: 60% - login form done, need logout and session handling
219
+ Files Modified: src/auth/login.tsx, src/api/auth.ts
220
+
221
+ Requesting another agent continue this work.
222
+
223
+ [Claude @ 14:47] FAILOVER_CLAIMED
224
+ Claiming failover from Codex.
225
+ Continuing task: Implementing user authentication
226
+ ```
227
+
228
+ ## Testing
229
+
230
+ ### With MCP Inspector
231
+
232
+ ```bash
233
+ npx @modelcontextprotocol/inspector node /path/to/nightshift-mcp/dist/index.js /tmp/test-project
234
+ ```
235
+
236
+ ### Manual Testing
237
+
238
+ ```bash
239
+ # Set project path and run
240
+ ROBOT_CHAT_PROJECT_PATH=/tmp/test-project node dist/index.js
241
+ ```
242
+
243
+ ## Development
244
+
245
+ ```bash
246
+ # Watch mode for development
247
+ npm run dev
248
+
249
+ # Build
250
+ npm run build
251
+ ```
252
+
253
+ ## Ralph-Style Task Management
254
+
255
+ NightShift includes Ralph-compatible PRD and progress management, enabling structured autonomous development.
256
+
257
+ ### Setup
258
+
259
+ 1. Create a `prd.json` in your project root:
260
+
261
+ ```json
262
+ {
263
+ "project": "MyApp",
264
+ "branchName": "feature/my-feature",
265
+ "description": "Feature description",
266
+ "userStories": [
267
+ {
268
+ "id": "US-001",
269
+ "title": "Add database field",
270
+ "description": "As a developer, I need to store the new field",
271
+ "acceptanceCriteria": [
272
+ "Add column to table",
273
+ "Run migration",
274
+ "Typecheck passes"
275
+ ],
276
+ "priority": 1,
277
+ "passes": false,
278
+ "notes": ""
279
+ }
280
+ ]
281
+ }
282
+ ```
283
+
284
+ 2. Agents use these tools to work through stories:
285
+
286
+ ### PRD Tools
287
+
288
+ #### `read_prd`
289
+ Read the full PRD with completion summary.
290
+
291
+ #### `get_next_story`
292
+ Get the highest priority incomplete story.
293
+
294
+ #### `get_incomplete_stories`
295
+ List all remaining work.
296
+
297
+ #### `claim_story`
298
+ Claim a story and notify other agents via chat.
299
+
300
+ **Parameters:**
301
+ - `agent` (required): Your agent name
302
+ - `storyId` (optional): Specific story to claim
303
+
304
+ #### `complete_story`
305
+ Mark story complete, log progress, and notify via chat.
306
+
307
+ **Parameters:**
308
+ - `agent` (required): Your agent name
309
+ - `storyId` (required): Story ID
310
+ - `summary` (required): What was implemented
311
+ - `filesModified` (optional): List of changed files
312
+ - `learnings` (optional): Gotchas/patterns for future iterations
313
+
314
+ #### `mark_story_complete`
315
+ Just mark a story as complete without chat notification.
316
+
317
+ **Parameters:**
318
+ - `storyId` (required): Story ID
319
+ - `notes` (optional): Implementation notes
320
+
321
+ ### Progress Tools
322
+
323
+ #### `read_progress`
324
+ Read progress.txt containing learnings from all iterations.
325
+
326
+ #### `append_progress`
327
+ Add a timestamped progress entry.
328
+
329
+ **Parameters:**
330
+ - `content` (required): What was done, files changed, learnings
331
+
332
+ #### `add_codebase_pattern`
333
+ Add a reusable pattern to the Codebase Patterns section.
334
+
335
+ **Parameters:**
336
+ - `pattern` (required): The pattern (e.g., "Use sql<number> for aggregations")
337
+
338
+ ### Autonomous Workflow
339
+
340
+ With multiple agents working together:
341
+
342
+ ```
343
+ ┌─────────────────────────────────────────────────────────────┐
344
+ │ NightShift Workflow │
345
+ ├─────────────────────────────────────────────────────────────┤
346
+ │ │
347
+ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │
348
+ │ │ Claude │ │ Codex │ │ Gemini │ │ Vibe │ │
349
+ │ └───┬────┘ └───┬────┘ └───┬────┘ └───┬────┘ │
350
+ │ │ │ │ │ │
351
+ │ └───────────┴─────┬─────┴───────────┘ │
352
+ │ │ │
353
+ │ ▼ │
354
+ │ ┌─────────────────┐ │
355
+ │ │ .robot-chat/ │ ◄── Agent coordination │
356
+ │ │ chat.txt │ │
357
+ │ └─────────────────┘ │
358
+ │ │ │
359
+ │ ┌───────────────┼───────────────┐ │
360
+ │ │ │ │ │
361
+ │ ▼ ▼ ▼ │
362
+ │ ┌─────────┐ ┌──────────┐ ┌────────────┐ │
363
+ │ │ prd.json│ │progress. │ │ Code │ │
364
+ │ │ (tasks) │ │ txt │ │ Changes │ │
365
+ │ └─────────┘ └──────────┘ └────────────┘ │
366
+ │ │
367
+ └─────────────────────────────────────────────────────────────┘
368
+ ```
369
+
370
+ Each agent:
371
+ 1. Checks for failovers (helps stuck agents first)
372
+ 2. Reads progress.txt for codebase patterns
373
+ 3. Claims the next story via chat
374
+ 4. Implements the story
375
+ 5. Runs quality checks
376
+ 6. Commits changes
377
+ 7. Marks complete and logs learnings
378
+ 8. Repeats until all stories pass
379
+
380
+ When an agent hits limits, it posts `FAILOVER_NEEDED` and another agent claims the work.
381
+
382
+ ### Completion Signal
383
+
384
+ When all stories in prd.json have `passes: true` AND all bugs in bugs.json have `fixed: true`, the tools:
385
+
386
+ 1. Post a `READY_TO_TEST` message to the chat
387
+ 2. Return `<promise>COMPLETE</promise>`
388
+
389
+ This signals to humans that work is ready for review.
390
+
391
+ ## Bug Tracking
392
+
393
+ When testing reveals issues, add a `bugs.json` file:
394
+
395
+ ```json
396
+ {
397
+ "project": "MyApp",
398
+ "bugs": [
399
+ {
400
+ "id": "BUG-001",
401
+ "title": "Login fails on mobile",
402
+ "description": "Login button unresponsive on iOS Safari",
403
+ "stepsToReproduce": [
404
+ "Open app on iOS Safari",
405
+ "Enter credentials",
406
+ "Tap login button",
407
+ "Nothing happens"
408
+ ],
409
+ "priority": 1,
410
+ "fixed": false
411
+ }
412
+ ]
413
+ }
414
+ ```
415
+
416
+ ### Bug Tools
417
+
418
+ #### `read_bugs`
419
+ Read bugs.json with completion summary.
420
+
421
+ #### `get_next_bug`
422
+ Get highest priority unfixed bug.
423
+
424
+ #### `claim_bug`
425
+ Claim a bug and notify via chat.
426
+
427
+ **Parameters:**
428
+ - `agent` (required): Your agent name
429
+ - `bugId` (optional): Specific bug to claim
430
+
431
+ #### `mark_bug_fixed`
432
+ Mark bug fixed, create savepoint, and notify.
433
+
434
+ **Parameters:**
435
+ - `agent` (required): Your agent name
436
+ - `bugId` (required): Bug ID
437
+ - `summary` (required): What was fixed
438
+ - `filesModified` (optional): Files changed
439
+
440
+ ## Savepoints (Recovery)
441
+
442
+ Every completed story and fixed bug automatically creates a savepoint (git commit + tag). Use these for easy rollback if needed.
443
+
444
+ ### Savepoint Tools
445
+
446
+ #### `create_savepoint`
447
+ Create a manual checkpoint.
448
+
449
+ **Parameters:**
450
+ - `label` (required): Savepoint name (e.g., "pre-refactor", "auth-working")
451
+ - `message` (optional): Commit message
452
+
453
+ #### `list_savepoints`
454
+ List all savepoints (git tags with `savepoint/` prefix).
455
+
456
+ #### `rollback_savepoint`
457
+ Reset to a previous savepoint. **Warning:** Discards all changes after that point.
458
+
459
+ **Parameters:**
460
+ - `label` (required): Savepoint to rollback to
461
+
462
+ ### Example Recovery
463
+
464
+ ```bash
465
+ # Something went wrong after US-003
466
+ # List available savepoints
467
+ list_savepoints
468
+ # → savepoint/US-001, savepoint/US-002, savepoint/US-003
469
+
470
+ # Rollback to after US-002
471
+ rollback_savepoint("US-002")
472
+ # → All changes after US-002 discarded
473
+ ```
474
+
475
+ ## Setup & Debugging
476
+
477
+ NightShift includes self-service tools for setup and troubleshooting.
478
+
479
+ ### `nightshift_setup`
480
+
481
+ Get configuration instructions and verify project setup.
482
+
483
+ **Parameters:**
484
+ - `showExamples` (optional): Include prd.json and bugs.json templates
485
+
486
+ **Returns:**
487
+ - Project status checks (prd.json, bugs.json, git, .gitignore)
488
+ - Agent configuration examples for Claude and Codex
489
+ - Setup suggestions for any issues found
490
+ - Example templates (if requested)
491
+
492
+ **Example:**
493
+ ```
494
+ nightshift_setup(showExamples: true)
495
+ ```
496
+
497
+ ### `nightshift_debug`
498
+
499
+ Diagnose issues and get troubleshooting guidance.
500
+
501
+ **Checks:**
502
+ - File system permissions
503
+ - JSON file validation (prd.json, bugs.json)
504
+ - Daemon lock status
505
+ - Recent chat errors and unclaimed failovers
506
+ - Agent availability
507
+ - Git repository status
508
+
509
+ **Example:**
510
+ ```
511
+ nightshift_debug
512
+ # Returns detailed diagnostic report with suggested fixes
513
+ ```
514
+
515
+ ## Agent Spawning (Autonomous Orchestration)
516
+
517
+ One agent can spawn others as subprocesses, enabling fully autonomous multi-agent workflows with minimal user intervention.
518
+
519
+ ### Tools
520
+
521
+ #### `list_available_agents`
522
+ Check which agent CLIs (claude, codex, gemini, vibe) are installed.
523
+
524
+ #### `spawn_agent`
525
+ Spawn another agent as a subprocess and wait for completion.
526
+
527
+ **Parameters:**
528
+ - `agent` (required): "claude", "codex", "gemini", or "vibe"
529
+ - `prompt` (required): Task/prompt to send
530
+ - `timeout` (optional): Seconds before timeout (default: 300)
531
+
532
+ **Example:**
533
+ ```
534
+ spawn_agent(agent: "codex", prompt: "Fix the type errors in src/utils.ts")
535
+ ```
536
+
537
+ #### `spawn_agent_background`
538
+ Spawn an agent in the background (non-blocking).
539
+
540
+ **Parameters:**
541
+ - `agent` (required): "claude", "codex", "gemini", or "vibe"
542
+ - `prompt` (required): Task/prompt to send
543
+
544
+ Returns immediately with PID and output file path.
545
+
546
+ #### `delegate_story`
547
+ Delegate a PRD user story to another agent with full context.
548
+
549
+ **Parameters:**
550
+ - `agent` (required): "claude", "codex", "gemini", or "vibe"
551
+ - `storyId` (optional): Story ID to delegate (defaults to next available)
552
+ - `background` (optional): Run in background (default: false)
553
+
554
+ **Example:**
555
+ ```
556
+ delegate_story(agent: "gemini", storyId: "US-003", background: true)
557
+ ```
558
+
559
+ The spawned agent receives:
560
+ - Full story description and acceptance criteria
561
+ - Recent content from progress.txt
562
+ - Recent chat messages for context
563
+ - Instructions to use nightshift tools for coordination
564
+
565
+ ### Orchestration Patterns
566
+
567
+ **Sequential delegation:**
568
+ ```
569
+ delegate_story(agent: "codex") # Wait for completion
570
+ delegate_story(agent: "gemini") # Then delegate next
571
+ ```
572
+
573
+ **Parallel execution:**
574
+ ```
575
+ delegate_story(agent: "codex", storyId: "US-001", background: true)
576
+ delegate_story(agent: "gemini", storyId: "US-002", background: true)
577
+ # Work on US-003 yourself while they run in parallel
578
+ ```
579
+
580
+ **Ad-hoc task delegation:**
581
+ ```
582
+ spawn_agent(agent: "claude", prompt: "Review the auth module and suggest improvements")
583
+ ```
584
+
585
+ ## NightShift Daemon (Continuous Orchestration)
586
+
587
+ For fully automated, event-driven orchestration, run the NightShift daemon:
588
+
589
+ ```bash
590
+ # Start the daemon
591
+ nightshift-daemon
592
+
593
+ # With options
594
+ nightshift-daemon --verbose --max-agents 4 --health-check 1m
595
+
596
+ # Preview mode (see what would happen)
597
+ nightshift-daemon --dry-run --verbose
598
+ ```
599
+
600
+ ### How It Works
601
+
602
+ The daemon provides hands-off multi-agent orchestration:
603
+
604
+ 1. **Event-Driven**: Watches `prd.json` and `chat.txt` for changes
605
+ 2. **Auto-Spawning**: Spawns agents for orphaned stories (up to concurrency limit)
606
+ 3. **Failover Handling**: Automatically claims and reassigns failover requests
607
+ 4. **Health Checks**: Periodic reconciliation as a fallback (default: every 2 min)
608
+ 5. **Poison Pill Protection**: Quarantines stories that fail repeatedly
609
+ 6. **Stuck Detection**: Kills agents that haven't reported activity
610
+
611
+ ### Options
612
+
613
+ | Flag | Description | Default |
614
+ |------|-------------|---------|
615
+ | `--verbose, -v` | Enable debug logging | false |
616
+ | `--dry-run` | Show actions without spawning | false |
617
+ | `--health-check <N>` | Health check interval (e.g., "2m", "30s") | 2m |
618
+ | `--max-agents <N>` | Max concurrent agents | 3 |
619
+
620
+ ### Environment
621
+
622
+ - `ROBOT_CHAT_PROJECT_PATH` - Project directory (default: current directory)
623
+
624
+ ### Architecture
625
+
626
+ ```
627
+ ┌─────────────────────────────────────────────────────────────┐
628
+ │ NightShift Daemon │
629
+ ├─────────────────────────────────────────────────────────────┤
630
+ │ │
631
+ │ ┌──────────────────────────────────────────────────┐ │
632
+ │ │ File Watchers (Primary) │ │
633
+ │ │ • prd.json changes → reconcile │ │
634
+ │ │ • chat.txt changes → check failovers │ │
635
+ │ └──────────────────────────────────────────────────┘ │
636
+ │ │ │
637
+ │ ▼ │
638
+ │ ┌──────────────────────────────────────────────────┐ │
639
+ │ │ Reconciliation Engine │ │
640
+ │ │ • Find orphaned stories │ │
641
+ │ │ • Spawn agents (up to max concurrency) │ │
642
+ │ │ • Handle failovers │ │
643
+ │ │ • Quarantine poison pills │ │
644
+ │ └──────────────────────────────────────────────────┘ │
645
+ │ │ │
646
+ │ ▼ │
647
+ │ ┌──────────────────────────────────────────────────┐ │
648
+ │ │ Health Check (Fallback) │ │
649
+ │ │ • Runs every 2 minutes │ │
650
+ │ │ • Detects stuck agents │ │
651
+ │ │ • Restarts watchers if needed │ │
652
+ │ │ • Reconciles state │ │
653
+ │ └──────────────────────────────────────────────────┘ │
654
+ │ │
655
+ └─────────────────────────────────────────────────────────────┘
656
+ ```
657
+
658
+ ## Multi-Agent Tips
659
+
660
+ 1. **Same directory**: All agents must run in the same project directory to share chat
661
+ 2. **Claim before working**: Always claim stories to prevent duplicate work
662
+ 3. **Post status updates**: Keep other agents informed of progress
663
+ 4. **Document learnings**: Progress.txt helps future iterations
664
+ 5. **Handle failovers**: Check for and claim failovers at the start of each session
665
+ 6. **Use delegation**: One orchestrating agent can spawn others for parallel work
666
+ 7. **Add `.robot-chat/` to your project's `.gitignore`**: Chat logs are ephemeral and shouldn't be committed
667
+
668
+ ## License
669
+
670
+ MIT