hive-lite 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 (33) hide show
  1. package/README.md +443 -0
  2. package/bin/hive.js +6 -0
  3. package/docs/cli-semantics.md +386 -0
  4. package/docs/skills/hive-lite-finish/SKILL.md +282 -0
  5. package/docs/skills/hive-lite-finish/agents/openai.yaml +4 -0
  6. package/docs/skills/hive-lite-finish/references/safety.md +95 -0
  7. package/docs/skills/hive-lite-finish/references/verdicts.md +123 -0
  8. package/docs/skills/hive-lite-map-maintainer/SKILL.md +203 -0
  9. package/docs/skills/hive-lite-map-maintainer/agents/openai.yaml +7 -0
  10. package/docs/skills/hive-lite-map-maintainer/references/lifecycle.md +114 -0
  11. package/docs/skills/hive-lite-map-maintainer/references/repair-rules.md +201 -0
  12. package/docs/skills/hive-lite-start-prompt/SKILL.md +283 -0
  13. package/docs/skills/hive-lite-start-prompt/agents/openai.yaml +4 -0
  14. package/docs/skills/hive-lite-start-prompt/references/input-calibration.md +82 -0
  15. package/docs/skills/hive-lite-start-prompt/references/preflight.md +116 -0
  16. package/package.json +40 -0
  17. package/src/cli.js +910 -0
  18. package/src/lib/change.js +642 -0
  19. package/src/lib/context.js +1104 -0
  20. package/src/lib/evidence.js +230 -0
  21. package/src/lib/fsx.js +54 -0
  22. package/src/lib/git.js +128 -0
  23. package/src/lib/glob.js +47 -0
  24. package/src/lib/health.js +1012 -0
  25. package/src/lib/id.js +13 -0
  26. package/src/lib/map.js +713 -0
  27. package/src/lib/next.js +341 -0
  28. package/src/lib/risk.js +122 -0
  29. package/src/lib/roles.js +109 -0
  30. package/src/lib/scope.js +168 -0
  31. package/src/lib/skills.js +349 -0
  32. package/src/lib/status.js +344 -0
  33. package/src/lib/yaml.js +223 -0
package/README.md ADDED
@@ -0,0 +1,443 @@
1
+ # Hive Lite
2
+
3
+ Hive Lite is a local Project Map + Change Control CLI for coding agents.
4
+
5
+ It deliberately starts small:
6
+
7
+ - no server
8
+ - no Dashboard
9
+ - no Feature or Task objects
10
+ - no agent runner
11
+ - no embeddings
12
+ - no SQLite
13
+
14
+ The first loop is:
15
+
16
+ ```text
17
+ intent -> hive-lite find -> Context Packet
18
+ agent edits code outside Hive
19
+ current diff -> hive-lite check -> Change Record
20
+ validate -> accept -> optional Map Delta Candidate
21
+ ```
22
+
23
+ ## Commands
24
+
25
+ For detailed CLI output meanings and "what to do next" tables, see [docs/cli-semantics.md](docs/cli-semantics.md).
26
+ For a non-technical pilot-user workflow guide in Chinese, see [docs/user-pilot-guide.zh.md](docs/user-pilot-guide.zh.md).
27
+
28
+ Examples below use `node bin/hive.js` from this repository. When installed as a package, use `hive-lite` instead.
29
+
30
+ ### Setup And Health
31
+
32
+ Initialize Hive Lite in a git repo:
33
+
34
+ ```bash
35
+ node bin/hive.js init
36
+ ```
37
+
38
+ Creates durable map files under `.hive/map/` and runtime directories such as `.hive/context/` and `.hive/changes/`. This command requires an existing git repository.
39
+
40
+ Check basic map file validity:
41
+
42
+ ```bash
43
+ node bin/hive.js doctor
44
+ node bin/hive.js map verify
45
+ node bin/hive.js map verify --json
46
+ ```
47
+
48
+ Inspect Project Map readiness for safe `find` / `check` behavior:
49
+
50
+ ```bash
51
+ node bin/hive.js map health
52
+ node bin/hive.js map health --area dashboard.action_inbox
53
+ node bin/hive.js map health --json
54
+ ```
55
+
56
+ ### Current State And Next Action
57
+
58
+ Inspect worktree state, latest Hive change, and recent split notes:
59
+
60
+ ```bash
61
+ node bin/hive.js status
62
+ node bin/hive.js status --json
63
+ node bin/hive.js status --all --json
64
+ ```
65
+
66
+ Ask Hive Lite what the operator should do next:
67
+
68
+ ```bash
69
+ node bin/hive.js next
70
+ node bin/hive.js next --json
71
+ node bin/hive.js next --agent codex --json
72
+ ```
73
+
74
+ `status` and `next` show actionable split notes by default: active split notes with accepted phase progress, or the newest unstarted split note when no active split exists. Use `status --all` to inspect every runtime split note. `next` may recommend start, finish, map maintenance, split continuation, dirty-worktree cleanup, or git repo setup. It does not run agents, commit, accept risk, or modify files.
75
+ In JSON output, `splitNoteSummary.primaryRecentSplitNote` identifies the split note that `status`/`next` treat as primary, and `splitNoteSummary.otherActiveSplitNotes` lists older active split notes with accepted progress.
76
+
77
+ When you pass `next --agent <codex|claude|gemini>` or `next --path <skills-dir>`, `next` also checks whether the recommended Hive Lite operator skill is installed in that target. If it is missing or stale, `next` recommends installing/syncing skills before the handoff.
78
+
79
+ ### Install Agent Skills
80
+
81
+ Hive Lite ships three operator skills:
82
+
83
+ - `hive-lite-start-prompt`
84
+ - `hive-lite-finish`
85
+ - `hive-lite-map-maintainer`
86
+
87
+ Check installed skill status:
88
+
89
+ ```bash
90
+ node bin/hive.js skills doctor
91
+ node bin/hive.js skills doctor --agent codex
92
+ node bin/hive.js skills doctor --path ~/.codex/skills
93
+ node bin/hive.js skills doctor --json
94
+ ```
95
+
96
+ `skills doctor` does not detect which agent CLI is installed or currently running. It checks the selected skills directories: all known target paths by default, one or more paths with `--agent`, or a custom path with `--path`.
97
+
98
+ Codex, Claude, and Gemini targets are global user-skill installs. `--agent codex` writes to `~/.codex/skills`, `--agent claude` writes to `~/.claude/skills`, and `--agent gemini` writes to `~/.gemini/skills`. They do not create or update repo-local `.codex/skills`, `.claude/skills`, or `.gemini/skills`. Use `--path <repo-local-skills-dir>` only when you intentionally want a custom repo-local copy that Hive Lite can inspect.
99
+
100
+ Install missing skills:
101
+
102
+ ```bash
103
+ node bin/hive.js skills install --agent codex
104
+ node bin/hive.js skills install --agent claude
105
+ node bin/hive.js skills install --agent gemini
106
+ node bin/hive.js skills install --agent all
107
+ ```
108
+
109
+ `install` creates missing skills but does not overwrite stale local copies unless `--force` is passed.
110
+
111
+ Synchronize bundled skills over existing stale copies:
112
+
113
+ ```bash
114
+ node bin/hive.js skills sync --agent codex
115
+ node bin/hive.js skills sync --agent all
116
+ ```
117
+
118
+ Use `--dry-run` to preview writes. Use `--path <skills-dir>` for a custom target.
119
+
120
+ ### Start A Requirement
121
+
122
+ Generate a Context Packet from a user intent:
123
+
124
+ ```bash
125
+ node bin/hive.js find "Dashboard Action Inbox content should align left" --explain
126
+ node bin/hive.js find "Dashboard Action Inbox content should align left" --json
127
+ node bin/hive.js find "Dashboard Action Inbox content should align left" --area dashboard.action_inbox
128
+ node bin/hive.js find "Dashboard Action Inbox content should align left" --max-files 12
129
+ ```
130
+
131
+ Possible modes:
132
+
133
+ - `edit_context`: safe to hand the packet to a coding agent
134
+ - `discovery_context`: useful for investigation, but not an edit permit
135
+ - `needs_map`: Project Map does not support this intent yet
136
+ - `needs_decomposition`: intent is too broad for one Context Packet / Change Record
137
+
138
+ For decomposed work, continue a specific phase:
139
+
140
+ ```bash
141
+ node bin/hive.js find "Update server API for Action Inbox hierarchy" --from-split split_xxx --phase phase_server_api --area server.action_inbox_api --json
142
+ ```
143
+
144
+ When `--from-split` and `--phase` point to a recorded split phase, Hive Lite constrains routing to that phase's primary area. Generated split notes include `--area <primaryAreaId>` so copied commands stay narrowly scoped even if the original intent was broad.
145
+ If the split note or phase cannot be found, Hive Lite does not treat the copied command as an edit permit. If `--area` disagrees with the recorded phase area, the recorded phase area wins and Hive Lite prints a warning.
146
+ When Hive Lite is run from a source checkout with `node /path/to/bin/hive.js`, generated split notes render that Node command first and include `hive-lite` as a package-alias fallback when available.
147
+
148
+ ### Check And Validate A Change
149
+
150
+ After a coding agent edits files, create or refresh a Change Record from the current diff:
151
+
152
+ ```bash
153
+ node bin/hive.js check --context ctx_xxx
154
+ node bin/hive.js check --context ctx_xxx --json
155
+ node bin/hive.js check chg_xxx
156
+ ```
157
+
158
+ Run the validation plan recorded on the Change Record:
159
+
160
+ ```bash
161
+ node bin/hive.js validate chg_xxx
162
+ node bin/hive.js validate chg_xxx --profile dashboard-build
163
+ node bin/hive.js validate chg_xxx --cmd "npm test"
164
+ ```
165
+
166
+ Record human/manual evidence:
167
+
168
+ ```bash
169
+ node bin/hive.js validate chg_xxx \
170
+ --manual manual-verification \
171
+ --result passed \
172
+ --note "Opened the Dashboard and verified the Action Inbox layout."
173
+ ```
174
+
175
+ Manual `--result` values are `passed`, `failed`, or `not_applicable`. Manual notes should say what was actually checked.
176
+
177
+ ### Accept A Change
178
+
179
+ Accept after evidence is sufficient:
180
+
181
+ ```bash
182
+ node bin/hive.js accept chg_xxx
183
+ node bin/hive.js accept chg_xxx --commit -m "Left align Action Inbox content"
184
+ ```
185
+
186
+ Accept with a human review reason when Hive Lite requires one:
187
+
188
+ ```bash
189
+ node bin/hive.js accept chg_xxx --reviewed --reason "Reviewed internal behavior; automated validation passed."
190
+ ```
191
+
192
+ Accept explicit risk only when the human knowingly accepts insufficient evidence:
193
+
194
+ ```bash
195
+ node bin/hive.js accept chg_xxx --accept-risk --reason "No focused test exists yet; accepting low-risk isolated UI logic after review."
196
+ ```
197
+
198
+ `blocked` changes cannot be accepted in the MVP.
199
+
200
+ ### Maintain The Project Map
201
+
202
+ Generate a prompt for map bootstrap, refresh, or intent-triggered repair:
203
+
204
+ ```bash
205
+ node bin/hive.js map health --area dashboard.action_inbox
206
+ node bin/hive.js map prompt --focus "Dashboard Action Inbox" --from-find ctx_xxx
207
+ node bin/hive.js map prompt --focus "Dashboard surfaces" --max-areas 8
208
+ node bin/hive.js map prompt --from-find ctx_xxx --json
209
+ ```
210
+
211
+ Inspect and apply durable map delta candidates produced by accepted changes:
212
+
213
+ ```bash
214
+ node bin/hive.js map delta list
215
+ node bin/hive.js map delta apply delta_xxx
216
+ node bin/hive.js map delta reject delta_xxx --reason "One-off change; not durable map knowledge."
217
+ ```
218
+
219
+ ### Debug / Inspection
220
+
221
+ Show a raw Change Record:
222
+
223
+ ```bash
224
+ node bin/hive.js show-change chg_xxx
225
+ node bin/hive.js show-change
226
+ ```
227
+
228
+ Dump the loaded Project Map as JSON:
229
+
230
+ ```bash
231
+ node bin/hive.js map-dump
232
+ ```
233
+
234
+ ## Local Data
235
+
236
+ Hive Lite requires a git repository. If the current directory is not inside a git worktree, `status` and `next` will report `repo_setup_required`, and workflow commands such as `init`, `find`, `check`, `validate`, and `accept` stop. Hive Lite does not initialize git automatically; switch to the correct repo root or manually initialize git and create an initial commit first.
237
+
238
+ Committed by default:
239
+
240
+ ```text
241
+ .hive/config.yaml
242
+ .hive/map/**
243
+ ```
244
+
245
+ Ignored by default:
246
+
247
+ ```text
248
+ .hive/context/**
249
+ .hive/changes/**
250
+ .hive/patches/**
251
+ .hive/state/**
252
+ ```
253
+
254
+ Do not blanket-ignore `.hive/`. If `.hive/map/*.yaml` is hidden by `.gitignore` or `.git/info/exclude`, map refreshes will not show up as normal git changes. Ignore only runtime evidence directories, not the durable Project Map.
255
+
256
+ ## Next Action
257
+
258
+ `next` is a lightweight local state interpreter. It does not run an agent, change files, accept risk, commit, or manage a workflow. It reads git state plus Hive artifacts and suggests the next operator step:
259
+
260
+ ```bash
261
+ node bin/hive.js next
262
+ node bin/hive.js next --json
263
+ ```
264
+
265
+ Typical `phaseGuess` values:
266
+
267
+ - `preflight`: dirty worktree must be committed, stashed, isolated, or stopped before a new requirement
268
+ - `finish`: an in-progress or accepted-uncommitted Hive change should be closed with `$hive-lite-finish`
269
+ - `map`: Project Map needs bootstrap, refresh, or repair via `$hive-lite-map-maintainer`
270
+ - `split_continue`: a recent split note has a ready remaining phase; continue through `$hive-lite-start-prompt`
271
+ - `start`: safe to begin a new bounded requirement with `$hive-lite-start-prompt`
272
+
273
+ This is the CLI layer that a future static report or companion UI should read first.
274
+
275
+ ## Core Objects
276
+
277
+ ### Worktree Boundary
278
+
279
+ Hive Lite does not require a new branch for every requirement, but a new requirement should start from a clean working tree.
280
+
281
+ Use `status` before generating a start prompt:
282
+
283
+ ```bash
284
+ node bin/hive.js status
285
+ node bin/hive.js status --json
286
+ ```
287
+
288
+ It classifies the current repo as:
289
+
290
+ - `clean`: safe to start a new `find`
291
+ - `unmanaged_dirty`: dirty files are not tied to a Hive Change Record
292
+ - `in_progress`: dirty files belong to an unfinished Hive Change Record
293
+ - `accepted_uncommitted`: the latest Hive Change Record was accepted without a commit
294
+
295
+ For non-clean states, commit, stash, or move to a separate git worktree before starting a new requirement. This keeps `check` tied to one clear dirty diff.
296
+
297
+ ### Project Map
298
+
299
+ The durable context router under `.hive/map`.
300
+
301
+ `map prompt` prints a copyable prompt for an external agent CLI. It does not call an LLM and does not write map files. Its job is to help draft 3-8 high-value areas from repo evidence, then a human reviews and edits `.hive/map/areas.yaml`.
302
+
303
+ `map health` is a deterministic readiness check for the Project Map. It does not score the map or repair it. It checks whether areas have enough precise routing, writable scope, entrypoints, validation, verification policy, and boundaries for `find` to safely generate an `edit_context` and for `check` to explain evidence needs.
304
+
305
+ ```bash
306
+ node bin/hive.js map health
307
+ node bin/hive.js map health --area dashboard.action_inbox
308
+ node bin/hive.js map health --json
309
+ ```
310
+
311
+ When `find` reports a map gap, pass the generated context packet back into `map prompt`:
312
+
313
+ ```bash
314
+ node bin/hive.js map prompt --from-find ctx_xxx
315
+ ```
316
+
317
+ The prompt will include the intent, selected area, warnings, relevant files, scope quality, and current scope so an external agent can propose a narrow map repair.
318
+ For `--from-find`, an editing-capable external agent is instructed to edit only `.hive/map/project.yaml`, `.hive/map/areas.yaml`, `.hive/map/rules.yaml`, and `.hive/map/validation.yaml` directly, then summarize the map changes. If it cannot edit files, it should fall back to complete replacement YAML for the affected map files.
319
+
320
+ Areas can use tiered scope:
321
+
322
+ ```yaml
323
+ scope:
324
+ readable:
325
+ - apps/dashboard/src/**
326
+ writable_direct:
327
+ - apps/dashboard/src/components/ActionInbox.tsx
328
+ writable_conditional:
329
+ - pattern: apps/dashboard/src/stores/**
330
+ reason: only if grouping depends on store shape
331
+ requires_review: true
332
+ writable_broad_fallback:
333
+ - pattern: apps/dashboard/src/**
334
+ reason: fallback only
335
+ requires_review: true
336
+ forbidden:
337
+ - apps/dashboard/dist/**
338
+ ```
339
+
340
+ `find` uses this to choose a packet mode: `edit_context`, `discovery_context`, `needs_map`, or `needs_decomposition`. `check` treats direct files as clean, while conditional or broad fallback matches require review.
341
+
342
+ Areas should also give Hive Lite enough evidence-policy signal for the finish phase. Keep this small: roles and verification policy are not a code graph, they are just hints for whether a change is UI-visible, internal logic, CLI behavior, config, or unknown.
343
+
344
+ Canonical entrypoint roles:
345
+
346
+ ```text
347
+ page
348
+ ui_component
349
+ styles
350
+ state_store
351
+ grouping_logic
352
+ data_transform
353
+ api_contract
354
+ schema_logic
355
+ cli_behavior
356
+ error_handling
357
+ cache_logic
358
+ config
359
+ docs
360
+ test
361
+ unknown
362
+ ```
363
+
364
+ Example:
365
+
366
+ ```yaml
367
+ entrypoints:
368
+ - path: apps/dashboard/src/pages/InboxPage.vue
369
+ role: page
370
+ source: manual
371
+ confidence: high
372
+ - path: apps/dashboard/src/components/InboxItemCard.vue
373
+ role: ui_component
374
+ source: manual
375
+ confidence: high
376
+
377
+ verification:
378
+ direct_manual_allowed: true
379
+ manual_profiles:
380
+ - manual-verification
381
+ focused_test_recommended_for_roles:
382
+ - grouping_logic
383
+ - data_transform
384
+ - error_handling
385
+ review_with_reason_allowed: true
386
+ risk_acceptance_allowed: false
387
+ ```
388
+
389
+ Validation profiles can add lightweight metadata so `check` can describe what kind of evidence a command provides:
390
+
391
+ ```yaml
392
+ profiles:
393
+ - id: dashboard-build
394
+ command: bun --cwd apps/dashboard build
395
+ evidence_type: build
396
+ covers_roles:
397
+ - page
398
+ - ui_component
399
+ - styles
400
+ safety: safe_auto
401
+ ```
402
+
403
+ ### Context Packet
404
+
405
+ Generated by `find`. It tells an agent where to look, what it may edit, what not to touch, and how to validate.
406
+
407
+ ### Change Record
408
+
409
+ Generated by `check`. It captures the working tree diff, scope result, validation state, evidence policy, deterministic risk, and next action.
410
+
411
+ ### Evidence Policy
412
+
413
+ Hive Lite does not force every change to add tests. It asks whether evidence is sufficient for this change, or whether the human must record a reason.
414
+
415
+ `check` adds an Evidence Policy section with verdicts such as:
416
+
417
+ - `acceptable`: evidence is sufficient
418
+ - `needs_validation`: required command validation has not run
419
+ - `needs_manual_verification`: a directly verifiable change needs a manual evidence note
420
+ - `needs_review_reason`: accept requires `--reviewed --reason "..."`
421
+ - `evidence_insufficient`: add focused evidence when practical, or accept with an explicit reason/risk
422
+ - `blocked`: scope violation, failed validation, or another blocker
423
+
424
+ Manual evidence is recorded through `validate`:
425
+
426
+ ```bash
427
+ node bin/hive.js validate chg_xxx \
428
+ --manual dashboard-action-inbox-visual \
429
+ --result passed \
430
+ --note "Opened Dashboard and confirmed the Action Inbox hierarchy."
431
+ ```
432
+
433
+ For internal changes that are not directly manually verifiable, prefer focused automated evidence when practical. If a focused test is not worth the cost, accept with a reason:
434
+
435
+ ```bash
436
+ node bin/hive.js accept chg_xxx \
437
+ --reviewed \
438
+ --reason "Reviewed grouping logic; typecheck passed and the change is isolated to direct writable files."
439
+ ```
440
+
441
+ ## MVP Cutline
442
+
443
+ Hive Lite does not write code in MVP. It helps a coding agent start in the right place and helps a human decide whether the resulting diff is acceptable.
package/bin/hive.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ require('../src/cli').main(process.argv.slice(2)).catch((error) => {
4
+ console.error(`error: ${error.message}`);
5
+ process.exit(1);
6
+ });