@shanesaravia/hive 0.1.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 (47) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +21 -0
  3. package/README.md +417 -0
  4. package/dist/bin/hive-emit.js +75 -0
  5. package/dist/bin/hive.js +506 -0
  6. package/node_modules/@hive/shared/dist/index.d.ts +2 -0
  7. package/node_modules/@hive/shared/dist/index.js +2 -0
  8. package/node_modules/@hive/shared/dist/status.d.ts +12 -0
  9. package/node_modules/@hive/shared/dist/status.js +52 -0
  10. package/node_modules/@hive/shared/dist/types.d.ts +384 -0
  11. package/node_modules/@hive/shared/dist/types.js +14 -0
  12. package/node_modules/@hive/shared/package.json +18 -0
  13. package/package.json +72 -0
  14. package/packages/server/dist/api/rest.js +793 -0
  15. package/packages/server/dist/api/ws.js +37 -0
  16. package/packages/server/dist/config.js +24 -0
  17. package/packages/server/dist/control/codexRuntime.js +169 -0
  18. package/packages/server/dist/control/killer.js +25 -0
  19. package/packages/server/dist/control/launcher.js +114 -0
  20. package/packages/server/dist/control/messaging.js +75 -0
  21. package/packages/server/dist/control/nativeCommands.js +29 -0
  22. package/packages/server/dist/control/permissionPark.js +23 -0
  23. package/packages/server/dist/control/providerModels.js +53 -0
  24. package/packages/server/dist/events/eventsStore.js +55 -0
  25. package/packages/server/dist/health/deriveAlerts.js +55 -0
  26. package/packages/server/dist/hooks/hookIngest.js +90 -0
  27. package/packages/server/dist/hooks/hookSpool.js +33 -0
  28. package/packages/server/dist/hooks/setupHooks.js +102 -0
  29. package/packages/server/dist/index.js +88 -0
  30. package/packages/server/dist/messages/messagesStore.js +211 -0
  31. package/packages/server/dist/missions/missionsStore.js +283 -0
  32. package/packages/server/dist/paths/pathResolver.js +167 -0
  33. package/packages/server/dist/plans/plansStore.js +212 -0
  34. package/packages/server/dist/policies/policiesStore.js +61 -0
  35. package/packages/server/dist/reports/githubPublisher.js +21 -0
  36. package/packages/server/dist/reports/missionReport.js +16 -0
  37. package/packages/server/dist/roster/rosterBuilder.js +243 -0
  38. package/packages/server/dist/security/originPolicy.js +31 -0
  39. package/packages/server/dist/skills/skillDiscovery.js +69 -0
  40. package/packages/server/dist/templates/templateDiscovery.js +97 -0
  41. package/packages/server/dist/watch/jobsWatcher.js +224 -0
  42. package/packages/server/dist/watch/sessionsWatcher.js +65 -0
  43. package/packages/web/dist/assets/index-CrKMFCkZ.js +11 -0
  44. package/packages/web/dist/assets/index-gEGU_lr3.css +2 -0
  45. package/packages/web/dist/favicon.svg +12 -0
  46. package/packages/web/dist/index.html +14 -0
  47. package/templates/agents/hive-orchestrator.md +42 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable changes to Hive will be documented in this file.
4
+
5
+ ## 0.1.0 — 2026-08-23
6
+
7
+ Initial public preview of Hive, a provider-neutral local mission-control interface for Claude Code, Codex, and agent fleets.
8
+
9
+ ### Highlights
10
+
11
+ - Durable direct and orchestrated missions with continuous threaded follow-up
12
+ - Claude Code and Codex provider/model selection using existing local authentication
13
+ - Parallel manager and worker visibility, phased plans, progress, evidence, outputs, and completion gates
14
+ - Mission health, lifecycle, recovery, policies, budgets, templates, notifications, and searchable history
15
+ - Repository-aware working directories, skills, MCP configuration, and Git worktrees where supported
16
+ - Installable `hive` CLI with diagnostics, optional setup, persistent local state, and graceful lifecycle commands
17
+ - Verified npm artifact across macOS and Ubuntu on Node.js 20 and 22
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shane Saravia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,417 @@
1
+ <div align="center">
2
+ <img src="docs/assets/hive-logo.svg" width="104" alt="Hive bee and honeycomb logo" />
3
+ <h1>Hive</h1>
4
+ <p><strong>Provider-neutral mission control for Claude Code, Codex, and agent fleets.</strong></p>
5
+ <p>Direct, supervise, and recover durable AI missions from one local, observable interface.</p>
6
+ </div>
7
+
8
+ [![Release verification](https://github.com/shanesaravia/hive/actions/workflows/release-verification.yml/badge.svg)](https://github.com/shanesaravia/hive/actions/workflows/release-verification.yml)
9
+
10
+ ![Hive fleet dashboard showing provider-tagged missions, live status, worker counts, token usage, health alerts, search, and filters](docs/assets/hive-fleet-dashboard.png)
11
+
12
+ ## What Hive is
13
+
14
+ Hive is a provider-neutral, local mission-control layer for working with Claude Code, Codex, orchestrators, and their worker fleets without losing the outcome behind a stream of short-lived jobs and terminal windows.
15
+
16
+ In Hive, a **mission** is the durable unit of work. Its name, conversation, status, history, and outputs remain attached to one card even when Claude resumes into a new job ID. A mission can run in either of two modes:
17
+
18
+ - **Direct** — one selected-provider agent works directly. Best for questions, small fixes, and focused tasks.
19
+ - **Orchestrated** — a manager plans the work and delegates implementation to parallel worker agents, using isolated worktrees where the provider supports them.
20
+
21
+ Hive is currently a local development project. It stores provider-neutral mission data locally and uses the installed `claude` or `codex` CLI to launch, resume, and stop work. Authentication remains entirely owned by the selected CLI.
22
+
23
+ ## Why Hive
24
+
25
+ Provider applications are good places to run an individual agent. Hive is designed for the operational layer above them: maintaining one durable mission across provider turns, coordinating managers and parallel workers, exposing evidence-backed progress, detecting unhealthy work, enforcing human checkpoints, and preserving a searchable record of how an outcome was produced.
26
+
27
+ Hive does not resell model access or replace provider authentication. It gives locally authenticated providers a shared mission model and a consistent supervision surface, so teams and individuals are not locked into one agent runtime or forced to operate a fleet through disconnected terminal sessions.
28
+
29
+ ## Highlights
30
+
31
+ - Durable mission cards across Claude job resumptions
32
+ - Continuous threaded follow-up conversations
33
+ - Direct and orchestrated execution modes for either provider
34
+ - Per-mission Claude Code or Codex provider and model selection
35
+ - Provider model discovery from the locally installed CLIs
36
+ - Structured phased plans, weighted progress, dependency graphs, revisions, and evidence
37
+ - Parallel worker visibility, assignments, elapsed time, activity, token usage, changed files, tests, and outputs
38
+ - Separate mission lifecycle and runtime activity states
39
+ - Decision inbox, optional desktop notifications, and mission search/filtering
40
+ - Idle, stalled, retry-loop, overlap, stale-process, and token-without-progress detection
41
+ - User-controlled Pause, Resume, Complete, Reopen, Archive, manager handoff, task retry, cancellation, reassignment, and reprioritization
42
+ - Orchestrator-proposed **Awaiting acceptance** state
43
+ - Completion gates with verification evidence, explicit waivers, and user acceptance
44
+ - Reusable built-in, user, and repository mission templates with a visual editor
45
+ - Workspace and mission policies, permissions, worker/token/time budgets, and usage projections
46
+ - Semantic activity feed plus parallel manager/worker timeline
47
+ - Markdown/JSON mission reports and optional GitHub issue/PR publishing
48
+ - Repository-aware Claude skill discovery and `/skill` autocomplete
49
+ - Repository/working-directory selection with `~` expansion and path suggestions
50
+ - Claude-native graceful stopping through `claude stop <jobId>`
51
+ - Indexed SQLite conversation history with search, paginated loading, and bounded model context
52
+ - Durable recovery across Hive, terminal, and computer restarts
53
+
54
+ ## Requirements
55
+
56
+ - macOS or Linux
57
+ - Node.js 20 or newer
58
+ - npm
59
+ - At least one supported CLI installed and authenticated: Claude Code as `claude`, Codex as `codex`, or both
60
+ - Git for worktree-based orchestrated missions
61
+
62
+ Confirm the main prerequisites:
63
+
64
+ ```bash
65
+ node --version
66
+ claude --version
67
+ codex --version
68
+ git --version
69
+ ```
70
+
71
+ ## Install
72
+
73
+ Install Hive globally from npm:
74
+
75
+ ```bash
76
+ npm install --global @shanesaravia/hive
77
+ ```
78
+
79
+ Preview Hive's optional Claude integration setup:
80
+
81
+ ```bash
82
+ hive setup
83
+ ```
84
+
85
+ The preview does not modify files. Apply it explicitly if you use Claude Code and want Hive's orchestrator persona and activity relay hooks:
86
+
87
+ ```bash
88
+ hive setup --yes
89
+ ```
90
+
91
+ Setup performs two additive local changes:
92
+
93
+ 1. Installs `~/.claude/agents/hive-orchestrator.md`.
94
+ 2. Additively merges Hive hooks into `~/.claude/settings.json` while preserving existing hooks and writing `~/.claude/settings.json.hive-backup`.
95
+
96
+ Setup is safe to rerun after an upgrade. Codex missions are adapted directly by Hive and do not depend on Claude's hook installation.
97
+
98
+ ## Run Hive
99
+
100
+ Start Hive and open the local dashboard:
101
+
102
+ ```bash
103
+ hive
104
+ ```
105
+
106
+ Hive serves the dashboard and API from one local production process, normally at:
107
+
108
+ ```text
109
+ http://127.0.0.1:4317
110
+ ```
111
+
112
+ Useful commands:
113
+
114
+ | Command | Purpose |
115
+ | --- | --- | --- |
116
+ | `hive` or `hive start` | Start Hive and open the dashboard. |
117
+ | `hive doctor` | Check Node, provider CLIs, authentication, paths, and configuration. |
118
+ | `hive setup` | Preview optional provider integration changes. |
119
+ | `hive setup --yes` | Apply the previewed setup. |
120
+ | `hive status` | Report whether Hive is running and its local address. |
121
+ | `hive open` | Open an already-running dashboard. |
122
+ | `hive stop` | Gracefully stop Hive. |
123
+ | `hive --version` | Show the installed version. |
124
+
125
+ ## Update or uninstall
126
+
127
+ Update to the newest release:
128
+
129
+ ```bash
130
+ npm install --global @shanesaravia/hive@latest
131
+ ```
132
+
133
+ Uninstall the executable:
134
+
135
+ ```bash
136
+ npm uninstall --global @shanesaravia/hive
137
+ ```
138
+
139
+ Uninstalling the npm package intentionally retains mission history, configuration, logs, and provider integration files. Run `hive doctor` before uninstalling to see their exact platform-specific locations if you also want to remove that data manually.
140
+
141
+ ## Create a mission
142
+
143
+ 1. Select **New mission**.
144
+ 2. Enter the intended working directory. Absolute paths and paths beginning with `~` are supported; matching local folders appear as you type.
145
+ 3. Choose **Claude** or **Codex**, then optionally select a model. Leaving model blank uses that CLI's configured default.
146
+ 4. Choose **Direct** or **Orchestrated** mode.
147
+ 5. Describe the task and optionally provide a mission name.
148
+ 6. For Claude missions, choose whether to work in a new Git worktree. Codex missions currently use Codex's workspace-write sandbox in the selected repository; Hive-created Codex worktrees are not yet available.
149
+ 7. Start the mission and open its card to follow progress or continue the conversation.
150
+
151
+ The selected working directory matters. The provider CLI is launched from that directory so it can resolve the same repository instructions, configuration, MCP servers, and skills it would see when launched manually there.
152
+
153
+ ## Continue a conversation
154
+
155
+ Open a mission card and send a follow-up from the Conversation panel. Both providers preserve their native conversation/thread identity while Hive records each turn under the same durable mission.
156
+
157
+ For Claude missions, type `/` in either the new-mission prompt or an existing conversation to search registered project, user, plugin, and built-in skills. Recognized skills are highlighted and sent as ordinary prompt text, leaving Claude Code responsible for skill execution and permissions. Hive discovers skill metadata only; it does not preload entire skill bodies into mission context.
158
+
159
+ ## Navigate the fleet
160
+
161
+ The fleet is organized around attention rather than process creation time:
162
+
163
+ 1. **Needs you** decisions appear globally with context, choices, recommendations, and the impact of waiting.
164
+ 2. **Awaiting acceptance** missions appear before active work because they require your review and sign-off.
165
+ 3. Active, failed, paused, completed, and archived missions remain in separate operational sections.
166
+
167
+ Search covers mission names, conversations, plans, workers, files, errors, decisions, evidence, and outputs. Filters are available for lifecycle/activity status, repository, template, and date. Claude sessions started outside Hive appear separately as discovered local sessions; they can be adopted, stopped, or hidden without pretending they are already durable Hive missions.
168
+
169
+ ## Understand a mission
170
+
171
+ Each mission has four primary views:
172
+
173
+ | View | What it shows |
174
+ | --- | --- |
175
+ | Conversation | The durable user/orchestrator thread across all provider turns |
176
+ | Plan & workers | Goal, current work, next work, blockers, phased plan, dependencies, gates, evidence, budgets, skills, workers, and outputs |
177
+ | Activity | A semantic event feed or parallel timeline for the manager and workers |
178
+ | Technical | Provider job history, bounded handoff context, policies, and mission-report export |
179
+
180
+ Worker rows open a detail drawer containing the assignment, role, current tool/command, files read or changed, tests, artifacts, timing, tokens, termination state, and task-specific controls. Runtime job IDs remain available for diagnosis without becoming the mission's product identity.
181
+
182
+ ## Plans, progress, and dependencies
183
+
184
+ For non-trivial work, orchestrators publish a structured plan with phases, milestones, tasks, optional subtasks, dependencies, owners, weights, blockers, acceptance criteria, and evidence. Hive then derives progress from completed task weights rather than asking an LLM to estimate a percentage.
185
+
186
+ The plan begins with:
187
+
188
+ - the durable mission goal;
189
+ - distinct task, phase, and completion-gate progress;
190
+ - **Now**, **Next**, and **Needs attention** summaries;
191
+ - the current phase and next milestone;
192
+ - revision age and warnings when live worker activity no longer matches the plan.
193
+
194
+ Use **Plan** for the readable phased workflow and **Dependencies** for the interactive work graph and critical path. Completed and future phases collapse by default, task operational details are expandable, and dependency IDs are translated into task names.
195
+
196
+ An optional plan checkpoint appears only before execution begins. It lets you approve the proposed approach or request changes, but autonomous missions do not require that checkpoint. Once any work starts, stale plan-approval controls disappear. This is separate from accepting the completed mission.
197
+
198
+ ## Completion and acceptance
199
+
200
+ Templates and orchestrators can define required completion gates for tests, typecheck, lint, CI, review, PRs, screenshots, documentation, user approval, or a custom requirement. Technical gates must be satisfied or explicitly waived with a recorded reason before completion.
201
+
202
+ When an orchestrator believes the work and verification are complete, it moves the mission to **Awaiting acceptance**. From there:
203
+
204
+ - **Accept & complete** records the user's acceptance, satisfies pending `user_approval` gates, and completes the mission;
205
+ - **Request changes** reopens the mission for another conversational turn;
206
+ - unresolved technical gates continue to block completion and identify exactly what remains.
207
+
208
+ The orchestrator proposing completion never silently marks the durable mission complete; the user remains the final authority.
209
+
210
+ ## Templates
211
+
212
+ Hive includes workflows for feature implementation, bug fixing, PR review, incident investigation, security audit, refactoring, dependency upgrades, and UI implementation. A template can define manager instructions, stages, worker roles, dependencies, completion gates, budgets, permissions, mode, and worktree behavior.
213
+
214
+ Open **Templates** from the fleet header to inspect a template before use. Built-ins are read-only; they can be duplicated into editable user or repository templates. Custom templates are validated, versioned, and can be previewed, edited, or deleted without mutating missions that already retained an earlier version.
215
+
216
+ Template files live in:
217
+
218
+ | Scope | Path |
219
+ | --- | --- |
220
+ | User | `~/.claude-hive/templates/*.json` |
221
+ | Repository | `<repository>/.hive/templates/*.json` |
222
+
223
+ Repository templates can override matching built-in/user template IDs for that repository.
224
+
225
+ ## Policies, permissions, and budgets
226
+
227
+ Workspace policy defaults can restrict allowed roots, tools, network access, commits, pushes, pull requests, releases, and destructive actions. A mission receives a durable policy snapshot that can be changed later only with explicit confirmation.
228
+
229
+ Mission budgets can set maximum total workers, concurrent workers, tokens, and elapsed minutes. Hive shows consumption and projected exhaustion. These are coordination limits: orchestrators are instructed to stop and request approval before exceeding them, while filesystem and tool restrictions are also applied to provider launch configuration where supported.
230
+
231
+ ## Decisions, health, and recovery
232
+
233
+ Hive turns structured user questions into a global decision inbox and can optionally send desktop notifications. Answers are delivered back to the same durable mission and retained in its history.
234
+
235
+ Health alerts explain the condition, supporting evidence, and a suggested recovery action. Detection includes quiet workers, finished workers with an idle orchestrator, retry loops, duplicate delegation, overlapping file ownership, stale processes, high token growth without progress, and unclear waiting states. Card-level notices are deduplicated so the most actionable condition is shown first.
236
+
237
+ Mission and task controls include pause/resume, graceful or confirmed force stop, manager replacement, retry, cancellation, worker replacement/reassignment, priority changes, plan revision, fresh review, verification pass, completion, reopening, archive, and permanent deletion. Control actions are recorded in the activity timeline.
238
+
239
+ ## Reports and GitHub
240
+
241
+ The Technical view exports a mission report as Markdown or JSON. Reports include the request, plan, decisions, workers, changed files, verification, outputs, resource use, conversation, and remaining risks. With a locally authenticated `gh` CLI, Hive can post a report to a GitHub issue or pull request after explicit confirmation; it does not publish automatically.
242
+
243
+ ## Mission lifecycle and activity
244
+
245
+ Hive deliberately separates the durable mission lifecycle from current runtime activity.
246
+
247
+ | Mission lifecycle | Meaning |
248
+ | --- | --- |
249
+ | Active | The mission remains in progress |
250
+ | Awaiting acceptance | The orchestrator reports that work and verification are complete and requests your acceptance |
251
+ | Paused | Inactivity is intentional; stalled warnings are suppressed |
252
+ | Completed | The user accepted the outcome or manually completed the mission |
253
+ | Failed | The mission ended unsuccessfully |
254
+ | Archived | The mission is retained as a terminal historical record |
255
+
256
+ | Runtime activity | Meaning |
257
+ | --- | --- |
258
+ | Working | An orchestrator or worker is currently active |
259
+ | Needs you | The provider is waiting for a decision or input |
260
+ | Idle | The mission is active, but nothing is currently running |
261
+ | Stalled | An active mission has exceeded the inactivity threshold |
262
+ | Offline | A paused or terminal mission has no live process |
263
+
264
+ A Claude job ending does **not** automatically mean its mission succeeded. Orchestrators move missions to **Awaiting acceptance**; the user accepts completion or requests changes. Manual lifecycle controls are available in the mission header.
265
+
266
+ ## MCP servers, skills, and project configuration
267
+
268
+ Hive launches the normal local provider CLI rather than a separate container or account.
269
+
270
+ - User-scoped Claude configuration is available to launched agents.
271
+ - Project-scoped MCP servers, skills, plugins, settings, and `CLAUDE.md` files depend on the selected working directory.
272
+ - MCP authentication and required environment variables must be available to the Hive server process.
273
+ - Worker agents do not automatically inherit a skill invoked earlier in the manager conversation; the orchestrator must explicitly assign relevant skills to workers.
274
+
275
+ Codex likewise uses the locally authenticated `codex` CLI. Whether that CLI is authenticated through a ChatGPT subscription or API-key billing is outside Hive; no provider credentials are stored by Hive.
276
+
277
+ Orchestrated managers cannot directly edit files: Hive launches them with `Edit`, `Write`, and `NotebookEdit` disabled. They delegate repository changes to worker agents. Direct missions do not apply that manager-only restriction.
278
+
279
+ ## Local data and architecture
280
+
281
+ ```text
282
+ Browser UI (React + Vite)
283
+ │ REST + WebSocket
284
+ Hive server (Fastify)
285
+
286
+ ├── adapts Claude and Codex runtime state into provider-neutral turns
287
+ ├── launches/resumes/stops the selected local CLI
288
+ ├── persists mission metadata in Hive's local data directory
289
+ └── stores indexed conversation history in SQLite
290
+ ```
291
+
292
+ Hive uses filesystem watchers and local runtime adapters for live provider state instead of polling an LLM. Full conversation history is stored separately from model context; normal follow-ups use the provider's native thread, while manager handoff context is deliberately bounded to a compact summary, recent messages, and a small set of relevant older messages.
293
+
294
+ Restarting Hive does not erase missions. On startup, it reloads mission metadata, conversations, plans, revisions, events, policies, Codex adapter state, and provider job relationships. Completed or interrupted provider turns are reconciled with live processes. A stopped mission can be resumed later; a computer restart may end a live CLI process, but the durable mission and conversation remain available for recovery or manager replacement.
295
+
296
+ New CLI installations use platform-standard local directories. Existing installations with `~/.claude-hive` continue using it automatically, so upgrading does not relocate or lose mission data. Run `hive doctor` to see the exact paths selected on the current machine.
297
+
298
+ | Platform | Data/configuration | Logs |
299
+ | --- | --- | --- |
300
+ | macOS | `~/Library/Application Support/Hive` | `~/Library/Logs/Hive/hive.log` |
301
+ | Linux | `$XDG_DATA_HOME/hive` and `$XDG_CONFIG_HOME/hive` | `$XDG_STATE_HOME/hive/logs/hive.log` |
302
+ | Windows | `%LOCALAPPDATA%\Hive` and `%APPDATA%\Hive` | `%LOCALAPPDATA%\Hive\logs\hive.log` |
303
+ | Existing Hive installation | `~/.claude-hive` | `~/.claude-hive/logs/hive.log` |
304
+
305
+ Important files below are relative to the selected Hive data directory unless stated otherwise:
306
+
307
+ | Path | Contents |
308
+ | --- | --- |
309
+ | `missions.json` | Durable mission metadata and Claude job relationships |
310
+ | `hive.db` | Indexed mission conversation history and plans |
311
+ | `events.jsonl` | Activity event log |
312
+ | `hook-spool.jsonl` | Claude hook events buffered while Hive is unavailable |
313
+ | `policies.json` | Workspace policy defaults |
314
+ | `templates` | User-created mission templates |
315
+ | `codex-jobs` | Hive's durable Codex turn adapters and JSONL output |
316
+ | `codex-sessions` | Live Codex process adapters |
317
+ | `~/.claude/agents/hive-orchestrator.md` | Installed Hive manager persona |
318
+ | `~/.claude/settings.json` | Claude settings with additive Hive hooks |
319
+
320
+ ## Configuration
321
+
322
+ | Variable | Default | Description |
323
+ | --- | --- | --- |
324
+ | `HIVE_PORT` | `4317` | Hive server and event relay port |
325
+ | `HIVE_DATA_DIR` | Platform data directory | Override Hive mission and database storage |
326
+ | `HIVE_CONFIG_DIR` | Platform configuration directory | Override CLI configuration storage |
327
+ | `HIVE_STATE_DIR` | Platform state directory | Override runtime PID and port storage |
328
+ | `HIVE_LOG_DIR` | Platform log directory | Override durable server-log storage |
329
+ | `HIVE_ALLOWED_ORIGINS` | Hive's own local origins | Comma-separated additional browser origins allowed to access the local API |
330
+ | `VITE_HIVE_PORT` | `4317` | Server port used by the web application |
331
+ | `HIVE_STALLED_AFTER_MS` | `600000` | Inactivity duration before an active mission is marked stalled |
332
+
333
+ If you change `HIVE_PORT`, use the same value for `VITE_HIVE_PORT` when starting the web application.
334
+
335
+ ## Development commands
336
+
337
+ Clone the repository and install dependencies when contributing from source:
338
+
339
+ ```bash
340
+ git clone https://github.com/shanesaravia/hive.git
341
+ cd hive
342
+ npm install
343
+ ```
344
+
345
+ ```bash
346
+ npm run dev # Start server and web development processes
347
+ npm test # Run workspace tests
348
+ npm run typecheck # Type-check server, shared package, web, and CLI
349
+ npm run build # Create production builds for all workspaces
350
+ ```
351
+
352
+ Useful CLI commands:
353
+
354
+ ```bash
355
+ npm run hive -- setup
356
+ npm run hive -- setup --yes
357
+ npm run hive -- serve
358
+ npm run hive -- orchestrator start "<task>" [--worktree] [--name <name>]
359
+ ```
360
+
361
+ The product roadmap and completion checklist live in [`docs/IMPROVEMENTS.md`](docs/IMPROVEMENTS.md).
362
+
363
+ ## Troubleshooting
364
+
365
+ ### The UI says it is connecting to the Hive server
366
+
367
+ Confirm the health endpoint responds:
368
+
369
+ ```bash
370
+ curl http://127.0.0.1:4317/health
371
+ ```
372
+
373
+ If it does not, run `hive status`, restart with `hive`, and inspect the log path reported by `hive doctor`. Contributors using the source development environment can restart `npm run dev`.
374
+
375
+ ### A working directory is rejected
376
+
377
+ Use an existing directory. Hive supports `~`, `~/path`, absolute paths, and relative paths based on the directory from which Hive was launched.
378
+
379
+ ### Project skills or MCP servers are missing
380
+
381
+ Confirm the mission uses the intended repository directory. Project-scoped configuration is resolved from that directory. For MCP authentication issues, open a normal Claude Code session in the same directory and run `/mcp`.
382
+
383
+ ### New orchestrators do not report Awaiting acceptance
384
+
385
+ Refresh the installed persona after upgrading Hive:
386
+
387
+ ```bash
388
+ hive setup --yes
389
+ ```
390
+
391
+ Already-running Claude sessions may retain their earlier instructions; lifecycle controls can still be used manually.
392
+
393
+ ### A mission is Active but Stalled
394
+
395
+ This means the mission remains unfinished while Hive sees no meaningful runtime activity. Send a follow-up, pause it if inactivity is intentional, or complete/archive it from the mission header.
396
+
397
+ ### Accept & complete says completion gates remain
398
+
399
+ Open **Plan & workers** and inspect Completion gates. Tests, CI, review, documentation, and other technical gates must be satisfied or waived with a reason. A pending user-approval gate is satisfied automatically by **Accept & complete** and should not block that action.
400
+
401
+ ### Data after a restart
402
+
403
+ Restart Hive with `hive`, then reopen the same mission card. Hive reloads durable state from the platform path shown by `hive doctor`; existing installations using `~/.claude-hive` continue to use it automatically. Do not delete the selected data directory if you want to preserve mission history.
404
+
405
+ ## Current limitations
406
+
407
+ - Hive is local-first and has no multi-user authentication or remote deployment model.
408
+ - Codex uses its workspace-write sandbox in the selected repository; Hive-created Codex worktrees are not yet available.
409
+ - Claude hooks provide richer tool-level evidence than providers or workers that do not emit equivalent structured events.
410
+ - Policies and budgets combine launch-time enforcement with orchestrator guidance; they are not a substitute for operating-system isolation.
411
+ - Optional multi-mission initiatives remain intentionally deferred. A mission is the primary durable unit of work.
412
+
413
+ ## Project status
414
+
415
+ Hive is under active development. Persistence formats, APIs, and UI behavior may evolve. Review the [improvements roadmap](docs/IMPROVEMENTS.md) before relying on it for critical or unattended workflows.
416
+
417
+ Hive is available under the [MIT License](LICENSE).
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ // Plain non-LLM HTTP POST — safe to call from any agent's Bash tool. Fails
3
+ // silently and fast if the Hive server isn't running, so it never blocks or
4
+ // costs extra agent turns.
5
+ import { execFileSync } from "node:child_process";
6
+ import fs from "node:fs";
7
+ import os from "node:os";
8
+ import path from "node:path";
9
+ const PORT = process.env.HIVE_PORT ?? "4317";
10
+ const SESSIONS_DIR = path.join(os.homedir(), ".claude", "sessions");
11
+ function parseArgs(argv) {
12
+ const out = {};
13
+ for (let i = 0; i < argv.length; i++) {
14
+ const arg = argv[i];
15
+ if (arg.startsWith("--")) {
16
+ out[arg.slice(2)] = argv[i + 1];
17
+ i++;
18
+ }
19
+ }
20
+ return out;
21
+ }
22
+ /**
23
+ * There's no documented env var carrying the calling session's ID, so when
24
+ * --sessionId isn't passed explicitly, fall back to walking up from this
25
+ * process's parent looking for a matching ~/.claude/sessions/<pid>.json —
26
+ * hive-emit is invoked as a child of the claude CLI process (possibly via an
27
+ * intermediate shell), so one of the first few ancestors should match.
28
+ */
29
+ function detectSessionId() {
30
+ let pid = process.ppid;
31
+ for (let hops = 0; hops < 4 && pid > 1; hops++) {
32
+ try {
33
+ const raw = fs.readFileSync(path.join(SESSIONS_DIR, `${pid}.json`), "utf-8");
34
+ return JSON.parse(raw).sessionId;
35
+ }
36
+ catch {
37
+ // not this pid — walk up one more level
38
+ }
39
+ try {
40
+ // `ps` works on both macOS and Linux, unlike /proc which is Linux-only.
41
+ const out = execFileSync("ps", ["-o", "ppid=", "-p", String(pid)], {
42
+ encoding: "utf-8",
43
+ }).trim();
44
+ pid = Number(out) || -1;
45
+ }
46
+ catch {
47
+ break;
48
+ }
49
+ }
50
+ return undefined;
51
+ }
52
+ async function main() {
53
+ const args = parseArgs(process.argv.slice(2));
54
+ const sessionId = args.sessionId ?? detectSessionId();
55
+ const { phase, detail, target: targetWorker, task: targetTask, jobId } = args;
56
+ if (!sessionId || !phase || !detail) {
57
+ console.error('Usage: hive-emit --phase <phase> --detail "<text>" [--target <worker>] [--task <task-id>] [--sessionId <id>] [--jobId <id>]');
58
+ process.exit(1);
59
+ }
60
+ try {
61
+ const controller = new AbortController();
62
+ const timeout = setTimeout(() => controller.abort(), 1000);
63
+ await fetch(`http://127.0.0.1:${PORT}/events`, {
64
+ method: "POST",
65
+ headers: { "Content-Type": "application/json" },
66
+ body: JSON.stringify({ sessionId, jobId, phase, detail, targetWorker, targetTask }),
67
+ signal: controller.signal,
68
+ });
69
+ clearTimeout(timeout);
70
+ }
71
+ catch {
72
+ // Hive server not running — silently no-op, never block the agent's turn.
73
+ }
74
+ }
75
+ main();