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