nightshift-mcp 2.1.2 → 2.1.3

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 CHANGED
@@ -1,379 +1,364 @@
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
44
- - **Health tracker**: Per-agent failure tracking. 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, 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
- ### New in 2.1
51
- - **Runtime project switching**: `set_project_path` tool + optional `projectPath` param on all tools. No more restarting the MCP server to switch projects.
52
- - **Token tracking**: Parses token usage from Codex, Ollama, Gemini, and Claude output. Every `spawn_agent` call logs to `.robot-chat/runs.jsonl`.
53
- - **Run log + stats**: Structured JSONL log per spawn. `get_run_stats` tool for aggregate tokens per agent, avg durations, rate limit counts.
54
- - **Rate limit detection**: Parses 429s, "quota exceeded", retry-after from agent output. Returns structured `rate_limited` status.
55
- - **Agent role tagging**: `role` param on `spawn_agent`, `delegate_story` — planner, coder, fixer, verifier, etc. Shows in run log and chat.
56
- - **Configurable pipelines**: Define multi-step agent pipelines (e.g., Gemini plans → Codex implements → Claude verifies). Tag-based routing. `get_pipeline` / `set_pipeline` tools.
57
- - **Tool usage tracking**: Parses which tools agents used (Read, Edit, Bash, exec, shell commands) from output.
58
-
59
- ### Task Management
60
- - **PRD-driven workflow**: User stories in `prd.json` with priorities, dependencies (`dependsOn`), and tags for routing
61
- - **Bug tracking**: `bugs.json` for post-testing feedback loops
62
- - **Savepoints**: Git-based checkpoints (or JSON fallback) with rollback support
63
- - **Progress tracking**: Shared learnings via `progress.txt`
64
-
65
- ### Communication
66
- - **Multi-agent chat**: Structured messaging via `.robot-chat/chat.txt` with agent name, timestamp, and message type
67
- - **Context store**: Topic-based context retrieval — agents store and query learnings instead of prompt-stuffing
68
- - **Execution tracing**: Parent-child trace trees for debugging multi-agent runs
69
-
70
- ### Platform
71
- - **Cross-platform**: Windows, Linux, macOS
72
- - **6 agent types**: Claude, Codex, Gemini, Vibe, Goose, Ollama
73
- - **52 MCP tools** across 10 categories
74
- - **NightShift CLI**: `nightshift` command for agent coordination without MCP
75
- - **Zero external services**: Everything runs locally with SQLite + file storage
76
-
77
- ## What's New in 2.1
78
-
79
- - **Runtime project switching**: `set_project_path` tool changes the active project without restarting. All PRD, chat, bug, and progress tools also accept an optional `projectPath` param for per-call overrides.
80
- - **Token tracking + run log**: Every `spawn_agent` call (foreground and background) appends to `.robot-chat/runs.jsonl` with agent, role, duration, tokens, rate limit info, and tools used. `get_run_stats` tool returns aggregate analytics.
81
- - **Configurable pipelines**: Define agent pipelines via `nightshift.config.json` or `set_pipeline` tool. 5 built-in pipelines (default, frontend, backend, research, quick) with tag-based routing. Pipelines execute in the daemon and orchestrator — earlier steps capture output as context for later steps.
82
- - **Agent role tagging**: `role` param on spawn/delegate tools. Feeds run log and chat messages.
83
- - **Rate limit detection**: Parses 429, quota exhausted, retry-after from agent output.
84
- - **Health tracker rename**: "circuit breaker" → "health tracker" in all user-facing names.
85
-
86
- ### What was in 2.0
87
- - SQLite foundation (`.robot-chat/nightshift.db`) with ACID transactions and WAL mode
88
- - Health tracker (per-agent failure tracking with auto-disable/re-enable)
89
- - Immutable audit trail, run records, budget tracking, autoresearch queries
90
- - MCP SDK 1.28.0, zero production vulnerabilities
91
-
92
- ## Architecture
93
-
94
- ```
95
- ┌───────────────────────────────────────────────────────────┐
96
- NightShift MCP
97
- ├───────────────────────────────────────────────────────────┤
98
-
99
- ┌────────┐ ┌────────┐ ┌────────┐ ┌──────┐ ┌──────────┐
100
- Claude │ │ Codex │ │ Gemini │ │ Vibe │ │Goose/Olla│ │
101
- └───┬────┘ └───┬────┘ └───┬────┘ └──┬───┘ └────┬─────┘
102
- └──────────┴─────┬─────┴─────────┴──────────┘
103
-
104
- ┌─────────────────────┐
105
- .robot-chat/
106
-
107
- chat.txt (msg) │
108
- │ │ nightshift.db (v2) │ │
109
- workflow.json │ │
110
- │ │ trace.json │ │
111
- │ │ context/ │ │
112
- │ └─────────────────────┘ │
113
- │ │ │
114
- │ ┌────────────────┼────────────────┐ │
115
- │ ▼ ▼ ▼ │
116
- │ ┌────────┐ ┌────────────┐ ┌──────────┐ │
117
- │ │prd.json│ │ nightshift │ │progress │ │
118
- │ │(stories│ │ .db │ │ .txt │ │
119
- │ │ + bugs)│ │ (audit, │ │(learnings│ │
120
- │ │ │ │ budget, │ │ patterns)│ │
121
- │ │ │ │ runs, │ │ │ │
122
- │ │ │ │ circuits) │ │ │ │
123
- │ └────────┘ └────────────┘ └──────────┘ │
124
- │ │
125
- └───────────────────────────────────────────────────────────┘
126
- ```
127
-
128
- ## Usage Patterns
129
-
130
- ### Fully autonomous
131
- ```
132
- orchestrate()
133
- ```
134
-
135
- ### Parallel delegation
136
- ```
137
- delegate_story(agent: "codex", storyId: "US-001", background: true)
138
- delegate_story(agent: "gemini", storyId: "US-002", background: true)
139
- ```
140
-
141
- ### Research then implement
142
- ```
143
- delegate_research(task: "Analyze auth patterns and recommend approach")
144
- delegate_story(agent: "codex", storyId: "US-001")
145
- ```
146
-
147
- ### Pipeline (multi-step)
148
- ```
149
- set_pipeline(name: "default", steps: [
150
- { agent: "gemini", role: "planner" },
151
- { agent: "codex", role: "implementer" },
152
- { agent: "claude", role: "verifier" }
153
- ])
154
- orchestrate()
155
- ```
156
-
157
- ### Daemon (hands-off)
158
- ```bash
159
- nightshift-daemon --verbose --max-agents 4
160
- ```
161
-
162
- ## PRD Setup
163
-
164
- Create `prd.json` in your project root:
165
-
166
- ```json
167
- {
168
- "project": "MyApp",
169
- "userStories": [
170
- {
171
- "id": "US-001",
172
- "title": "Set up project structure",
173
- "acceptanceCriteria": ["Add routes", "Create base components"],
174
- "priority": 1,
175
- "passes": false
176
- },
177
- {
178
- "id": "US-002",
179
- "title": "Add database schema",
180
- "priority": 2,
181
- "passes": false,
182
- "dependsOn": ["US-001"],
183
- "tags": ["code", "infrastructure"]
184
- }
185
- ]
186
- }
187
- ```
188
-
189
- ### Story fields
190
-
191
- | Field | Type | Required | Default | Description |
192
- |-------|------|----------|---------|-------------|
193
- | `id` | string | yes | — | Unique ID (e.g., "US-001") |
194
- | `title` | string | yes | — | Short title |
195
- | `description` | string | no | "" | Detailed description |
196
- | `acceptanceCriteria` | string[] | no | [] | Completion criteria |
197
- | `priority` | number | no | 999 | Lower = higher priority |
198
- | `passes` | boolean | no | false | Whether complete |
199
- | `dependsOn` | string[] | no | — | Story IDs that must complete first |
200
- | `tags` | string[] | no | — | Routing hints (e.g., `["code"]`, `["research"]`) |
201
-
202
- Tags influence agent routing: `research`/`planning` prefers Gemini/Claude, `code`/`implementation` prefers Codex/Claude.
203
-
204
- ## Bug Tracking
205
-
206
- Add `bugs.json` when testing reveals issues:
207
-
208
- ```json
209
- {
210
- "project": "MyApp",
211
- "bugs": [
212
- {
213
- "id": "BUG-001",
214
- "title": "Login fails on mobile",
215
- "description": "Login button unresponsive on iOS Safari",
216
- "priority": 1,
217
- "fixed": false
218
- }
219
- ]
220
- }
221
- ```
222
-
223
- When all stories pass and all bugs are fixed, NightShift posts `READY_TO_TEST` to the chat.
224
-
225
- ## Tools Reference
226
-
227
- NightShift provides 52 tools across 10 categories. Key tools listed below — use `nightshift_setup(showExamples: true)` or `nightshift_help` for full documentation.
228
-
229
- ### Communication
230
- | Tool | Description |
231
- |------|-------------|
232
- | `read_robot_chat` | Read recent messages (filter by agent, type, limit) |
233
- | `write_robot_chat` | Post a message (STATUS_UPDATE, QUESTION, ERROR, etc.) |
234
- | `check_failovers` | Find unclaimed failover requests |
235
- | `claim_failover` | Take over work from a stuck agent |
236
- | `list_agents` | See who's active with activity stats |
237
- | `watch_chat` | Cursor-based polling for new messages |
238
-
239
- ### Task Management
240
- | Tool | Description |
241
- |------|-------------|
242
- | `read_prd` | Read PRD with completion summary |
243
- | `get_next_story` | Get highest priority incomplete story |
244
- | `claim_story` | Claim a story and notify via chat |
245
- | `complete_story` | Mark done, log progress, create savepoint |
246
- | `read_bugs` / `claim_bug` / `mark_bug_fixed` | Bug lifecycle |
247
-
248
- ### Agent Spawning
249
- | Tool | Description |
250
- |------|-------------|
251
- | `list_available_agents` | Check which CLIs are installed and runnable |
252
- | `spawn_agent` | Spawn agent, wait for completion (sync) |
253
- | `spawn_agent_background` | Spawn agent, return immediately (async) |
254
- | `delegate_story` | Delegate a story with full context injection |
255
- | `delegate_research` | Delegate research/analysis task |
256
- | `get_run_stats` | Token usage, durations, rate limits from run log |
257
-
258
- ### Orchestration & Pipelines
259
- | Tool | Description |
260
- |------|-------------|
261
- | `orchestrate` | Autonomous claim-implement-complete loop |
262
- | `get_agent_status` | Check background agent by PID |
263
- | `list_running_agents` | All spawned agents with status |
264
- | `set_project_path` | Switch active project at runtime |
265
- | `get_pipeline` | View configured pipelines and tag routing |
266
- | `set_pipeline` | Create/update agent pipelines at runtime |
267
-
268
- ### Workflow
269
- | Tool | Description |
270
- |------|-------------|
271
- | `init_workflow` | Initialize with project goal and phases |
272
- | `advance_phase` / `set_phase` | Phase management |
273
- | `record_decision` | Record strategic decisions with rationale |
274
-
275
- ### Context & Tracing
276
- | Tool | Description |
277
- |------|-------------|
278
- | `store_context` / `query_context` | Topic-based context store |
279
- | `get_trace` | Execution trace (flat or tree view) |
280
-
281
- ### Recovery
282
- | Tool | Description |
283
- |------|-------------|
284
- | `create_savepoint` | Manual git checkpoint |
285
- | `list_savepoints` | List all savepoints |
286
- | `rollback_savepoint` | Reset to a previous savepoint |
287
-
288
- ### Setup
289
- | Tool | Description |
290
- |------|-------------|
291
- | `nightshift_setup` | Configuration check and templates |
292
- | `nightshift_debug` | Diagnostic report with suggested fixes |
293
-
294
- ## Daemon
295
-
296
- The daemon provides hands-off, event-driven orchestration:
297
-
298
- ```bash
299
- nightshift-daemon [options]
300
- ```
301
-
302
- | Flag | Default | Description |
303
- |------|---------|-------------|
304
- | `--verbose, -v` | false | Debug logging |
305
- | `--dry-run` | false | Preview without spawning |
306
- | `--health-check <N>` | 2m | Health check interval |
307
- | `--max-agents <N>` | 3 | Max concurrent agents |
308
-
309
- **What it does:**
310
- - Watches `prd.json` and `chat.txt` for changes
311
- - Auto-spawns agents for unassigned stories
312
- - Health tracker disables failing agents, re-enables after cooldown
313
- - Detects and kills stuck agents
314
- - Claims failover requests
315
- - Quarantines stories that fail repeatedly
316
- - Logs everything to the SQLite audit trail
317
-
318
- ## Local Models
319
-
320
- NightShift supports local models via [Goose](https://github.com/block/goose) + Ollama or direct Ollama integration.
321
-
322
- ### Goose + Ollama
323
-
324
- ```bash
325
- export NIGHTSHIFT_GOOSE_PROVIDER=ollama
326
- export NIGHTSHIFT_GOOSE_MODEL=<your-model>
327
- ```
328
-
329
- ```
330
- spawn_agent(agent: "goose", prompt: "Fix the pagination bug")
331
- ```
332
-
333
- ### Direct Ollama
334
-
335
- ```bash
336
- export NIGHTSHIFT_OLLAMA_MODEL=<your-model>
337
- ```
338
-
339
- ```
340
- spawn_agent(agent: "ollama", prompt: "Review this PR")
341
- ```
342
-
343
- Any Ollama-compatible model works. Choose a model that fits your available resources.
344
-
345
- ## Data Storage
346
-
347
- NightShift uses a hybrid storage approach:
348
-
349
- | Data | Storage | Format |
350
- |------|---------|--------|
351
- | Agent chat | `.robot-chat/chat.txt` | Human-readable text |
352
- | PRD / stories | `prd.json` | JSON |
353
- | Bugs | `bugs.json` | JSON |
354
- | Progress | `progress.txt` | Append-only text |
355
- | Workflow | `.robot-chat/workflow.json` | JSON with file locking |
356
- | Trace | `.robot-chat/trace.json` | JSON |
357
- | Context | `.robot-chat/context/*.json` | Per-topic JSON files |
358
- | **Audit trail** | `.robot-chat/nightshift.db` | SQLite (immutable) |
359
- | **Run records** | `.robot-chat/nightshift.db` | SQLite |
360
- | **Budget** | `.robot-chat/nightshift.db` | SQLite |
361
- | **Health tracker** | `.robot-chat/nightshift.db` | SQLite |
362
- | **Run log** | `.robot-chat/runs.jsonl` | JSONL (append-only) |
363
- | **Pipeline config** | `.robot-chat/pipeline-override.json` | JSON (runtime) |
364
-
365
- Add `.robot-chat/` to your `.gitignore` — coordination state is ephemeral.
366
-
367
- ## Development
368
-
369
- ```bash
370
- npm install
371
- npm run build
372
- npm test # run test suite
373
- npm run dev # watch mode
374
- npm link # global CLI access
375
- ```
376
-
377
- ## License
378
-
379
- 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
+ - **Runtime project switching**: Switch active project without restarting the MCP server
43
+
44
+ ### Reliability
45
+ - **Health tracker**: Per-agent failure tracking. Auto-disables failing agents, re-enables after configurable cooldown. Persisted across daemon restarts.
46
+ - **Immutable audit trail**: Append-only SQLite table records every spawn, completion, failure, and stuck-agent kill
47
+ - **Run records**: Structured execution history per agent run duration, exit status, files changed, scope leak detection
48
+ - **Budget tracking**: Per-agent cost tracking with daily/monthly limits, warning thresholds, enable/disable toggle
49
+ - **Autoresearch**: Built-in analytics queries — agent success rates, average duration, scope leak rates
50
+
51
+ ### Observability
52
+ - **Token tracking**: Parses token usage from agent output. Every `spawn_agent` call logs to `.robot-chat/runs.jsonl`.
53
+ - **Run log + stats**: Structured JSONL log per spawn. `get_run_stats` for aggregate tokens per agent, avg durations, rate limit counts.
54
+ - **Rate limit detection**: Parses 429s, "quota exceeded", retry-after from agent output. Returns structured `rate_limited` status.
55
+ - **Agent role tagging**: `role` param on `spawn_agent`, `delegate_story` — planner, coder, fixer, verifier, etc.
56
+ - **Configurable pipelines**: Define multi-step agent pipelines with tag-based routing. `get_pipeline` / `set_pipeline` tools.
57
+ - **Tool usage tracking**: Parses which tools agents used from output.
58
+
59
+ ### Task Management
60
+ - **PRD-driven workflow**: User stories in `prd.json` with priorities, dependencies (`dependsOn`), and tags for routing
61
+ - **Bug tracking**: `bugs.json` for post-testing feedback loops
62
+ - **Savepoints**: Git-based checkpoints (or JSON fallback) with rollback support
63
+ - **Progress tracking**: Shared learnings via `progress.txt`
64
+
65
+ ### Communication
66
+ - **Multi-agent chat**: Structured messaging via `.robot-chat/chat.txt` with agent name, timestamp, and message type
67
+ - **Context store**: Topic-based context retrieval — agents store and query learnings instead of prompt-stuffing
68
+ - **Execution tracing**: Parent-child trace trees for debugging multi-agent runs
69
+
70
+ ### Platform
71
+ - **Cross-platform**: Windows, Linux, macOS
72
+ - **6 agent types**: Claude, Codex, Gemini, Vibe, Goose, Ollama
73
+ - **52 MCP tools** across 10 categories
74
+ - **NightShift CLI**: `nightshift` command for agent coordination without MCP
75
+ - **Zero external services**: Everything runs locally with SQLite + file storage
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()
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
+ ### Pipeline (multi-step)
133
+ ```
134
+ set_pipeline(name: "default", steps: [
135
+ { agent: "gemini", role: "planner" },
136
+ { agent: "codex", role: "implementer" },
137
+ { agent: "claude", role: "verifier" }
138
+ ])
139
+ orchestrate()
140
+ ```
141
+
142
+ ### Daemon (hands-off)
143
+ ```bash
144
+ nightshift-daemon --verbose --max-agents 4
145
+ ```
146
+
147
+ ## PRD Setup
148
+
149
+ Create `prd.json` in your project root:
150
+
151
+ ```json
152
+ {
153
+ "project": "MyApp",
154
+ "userStories": [
155
+ {
156
+ "id": "US-001",
157
+ "title": "Set up project structure",
158
+ "acceptanceCriteria": ["Add routes", "Create base components"],
159
+ "priority": 1,
160
+ "passes": false
161
+ },
162
+ {
163
+ "id": "US-002",
164
+ "title": "Add database schema",
165
+ "priority": 2,
166
+ "passes": false,
167
+ "dependsOn": ["US-001"],
168
+ "tags": ["code", "infrastructure"]
169
+ }
170
+ ]
171
+ }
172
+ ```
173
+
174
+ ### Story fields
175
+
176
+ | Field | Type | Required | Default | Description |
177
+ |-------|------|----------|---------|-------------|
178
+ | `id` | string | yes | — | Unique ID (e.g., "US-001") |
179
+ | `title` | string | yes | — | Short title |
180
+ | `description` | string | no | "" | Detailed description |
181
+ | `acceptanceCriteria` | string[] | no | [] | Completion criteria |
182
+ | `priority` | number | no | 999 | Lower = higher priority |
183
+ | `passes` | boolean | no | false | Whether complete |
184
+ | `dependsOn` | string[] | no | — | Story IDs that must complete first |
185
+ | `tags` | string[] | no | — | Routing hints (e.g., `["code"]`, `["research"]`) |
186
+
187
+ Tags influence agent routing: `research`/`planning` prefers Gemini/Claude, `code`/`implementation` prefers Codex/Claude.
188
+
189
+ ## Bug Tracking
190
+
191
+ Add `bugs.json` when testing reveals issues:
192
+
193
+ ```json
194
+ {
195
+ "project": "MyApp",
196
+ "bugs": [
197
+ {
198
+ "id": "BUG-001",
199
+ "title": "Login fails on mobile",
200
+ "description": "Login button unresponsive on iOS Safari",
201
+ "priority": 1,
202
+ "fixed": false
203
+ }
204
+ ]
205
+ }
206
+ ```
207
+
208
+ When all stories pass and all bugs are fixed, NightShift posts `READY_TO_TEST` to the chat.
209
+
210
+ ## Tools Reference
211
+
212
+ NightShift provides 52 tools across 10 categories. Key tools listed below — use `nightshift_setup(showExamples: true)` or `nightshift_help` for full documentation.
213
+
214
+ ### Communication
215
+ | Tool | Description |
216
+ |------|-------------|
217
+ | `read_robot_chat` | Read recent messages (filter by agent, type, limit) |
218
+ | `write_robot_chat` | Post a message (STATUS_UPDATE, QUESTION, ERROR, etc.) |
219
+ | `check_failovers` | Find unclaimed failover requests |
220
+ | `claim_failover` | Take over work from a stuck agent |
221
+ | `list_agents` | See who's active with activity stats |
222
+ | `watch_chat` | Cursor-based polling for new messages |
223
+
224
+ ### Task Management
225
+ | Tool | Description |
226
+ |------|-------------|
227
+ | `read_prd` | Read PRD with completion summary |
228
+ | `get_next_story` | Get highest priority incomplete story |
229
+ | `claim_story` | Claim a story and notify via chat |
230
+ | `complete_story` | Mark done, log progress, create savepoint |
231
+ | `read_bugs` / `claim_bug` / `mark_bug_fixed` | Bug lifecycle |
232
+
233
+ ### Agent Spawning
234
+ | Tool | Description |
235
+ |------|-------------|
236
+ | `list_available_agents` | Check which CLIs are installed and runnable |
237
+ | `spawn_agent` | Spawn agent, wait for completion (sync) |
238
+ | `spawn_agent_background` | Spawn agent, return immediately (async) |
239
+ | `delegate_story` | Delegate a story with full context injection |
240
+ | `delegate_research` | Delegate research/analysis task |
241
+ | `get_run_stats` | Token usage, durations, rate limits from run log |
242
+
243
+ ### Orchestration & Pipelines
244
+ | Tool | Description |
245
+ |------|-------------|
246
+ | `orchestrate` | Autonomous claim-implement-complete loop |
247
+ | `get_agent_status` | Check background agent by PID |
248
+ | `list_running_agents` | All spawned agents with status |
249
+ | `set_project_path` | Switch active project at runtime |
250
+ | `get_pipeline` | View configured pipelines and tag routing |
251
+ | `set_pipeline` | Create/update agent pipelines at runtime |
252
+
253
+ ### Workflow
254
+ | Tool | Description |
255
+ |------|-------------|
256
+ | `init_workflow` | Initialize with project goal and phases |
257
+ | `advance_phase` / `set_phase` | Phase management |
258
+ | `record_decision` | Record strategic decisions with rationale |
259
+
260
+ ### Context & Tracing
261
+ | Tool | Description |
262
+ |------|-------------|
263
+ | `store_context` / `query_context` | Topic-based context store |
264
+ | `get_trace` | Execution trace (flat or tree view) |
265
+
266
+ ### Recovery
267
+ | Tool | Description |
268
+ |------|-------------|
269
+ | `create_savepoint` | Manual git checkpoint |
270
+ | `list_savepoints` | List all savepoints |
271
+ | `rollback_savepoint` | Reset to a previous savepoint |
272
+
273
+ ### Setup
274
+ | Tool | Description |
275
+ |------|-------------|
276
+ | `nightshift_setup` | Configuration check and templates |
277
+ | `nightshift_debug` | Diagnostic report with suggested fixes |
278
+
279
+ ## Daemon
280
+
281
+ The daemon provides hands-off, event-driven orchestration:
282
+
283
+ ```bash
284
+ nightshift-daemon [options]
285
+ ```
286
+
287
+ | Flag | Default | Description |
288
+ |------|---------|-------------|
289
+ | `--verbose, -v` | false | Debug logging |
290
+ | `--dry-run` | false | Preview without spawning |
291
+ | `--health-check <N>` | 2m | Health check interval |
292
+ | `--max-agents <N>` | 3 | Max concurrent agents |
293
+
294
+ **What it does:**
295
+ - Watches `prd.json` and `chat.txt` for changes
296
+ - Auto-spawns agents for unassigned stories
297
+ - Health tracker disables failing agents, re-enables after cooldown
298
+ - Detects and kills stuck agents
299
+ - Claims failover requests
300
+ - Quarantines stories that fail repeatedly
301
+ - Logs everything to the SQLite audit trail
302
+
303
+ ## Local Models
304
+
305
+ NightShift supports local models via [Goose](https://github.com/block/goose) + Ollama or direct Ollama integration.
306
+
307
+ ### Goose + Ollama
308
+
309
+ ```bash
310
+ export NIGHTSHIFT_GOOSE_PROVIDER=ollama
311
+ export NIGHTSHIFT_GOOSE_MODEL=<your-model>
312
+ ```
313
+
314
+ ```
315
+ spawn_agent(agent: "goose", prompt: "Fix the pagination bug")
316
+ ```
317
+
318
+ ### Direct Ollama
319
+
320
+ ```bash
321
+ export NIGHTSHIFT_OLLAMA_MODEL=<your-model>
322
+ ```
323
+
324
+ ```
325
+ spawn_agent(agent: "ollama", prompt: "Review this PR")
326
+ ```
327
+
328
+ Any Ollama-compatible model works. Choose a model that fits your available resources.
329
+
330
+ ## Data Storage
331
+
332
+ NightShift uses a hybrid storage approach:
333
+
334
+ | Data | Storage | Format |
335
+ |------|---------|--------|
336
+ | Agent chat | `.robot-chat/chat.txt` | Human-readable text |
337
+ | PRD / stories | `prd.json` | JSON |
338
+ | Bugs | `bugs.json` | JSON |
339
+ | Progress | `progress.txt` | Append-only text |
340
+ | Workflow | `.robot-chat/workflow.json` | JSON with file locking |
341
+ | Trace | `.robot-chat/trace.json` | JSON |
342
+ | Context | `.robot-chat/context/*.json` | Per-topic JSON files |
343
+ | **Audit trail** | `.robot-chat/nightshift.db` | SQLite (immutable) |
344
+ | **Run records** | `.robot-chat/nightshift.db` | SQLite |
345
+ | **Budget** | `.robot-chat/nightshift.db` | SQLite |
346
+ | **Health tracker** | `.robot-chat/nightshift.db` | SQLite |
347
+ | **Run log** | `.robot-chat/runs.jsonl` | JSONL (append-only) |
348
+ | **Pipeline config** | `.robot-chat/pipeline-override.json` | JSON (runtime) |
349
+
350
+ Add `.robot-chat/` to your `.gitignore` — coordination state is ephemeral.
351
+
352
+ ## Development
353
+
354
+ ```bash
355
+ npm install
356
+ npm run build
357
+ npm test # run test suite
358
+ npm run dev # watch mode
359
+ npm link # global CLI access
360
+ ```
361
+
362
+ ## License
363
+
364
+ MIT