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
@@ -0,0 +1,95 @@
1
+ # Safety Rules
2
+
3
+ Use this reference before running any command that changes evidence, git state, or acceptance state.
4
+
5
+ ## Safe Agent Actions
6
+
7
+ These can run without asking once the user has asked this skill to finish a change:
8
+
9
+ ```bash
10
+ hive-lite status --json
11
+ hive-lite check --context <ctx_id> --json
12
+ hive-lite check <chg_id> --json
13
+ ```
14
+
15
+ Reading `.hive/context/*.json`, `.hive/context/*.md`, `.hive/changes/*/change.json`, and validation logs is also safe.
16
+
17
+ ## Usually Safe Validation
18
+
19
+ You may run `hive-lite validate <chg_id> --json` automatically when the configured command looks like a read-only build/check/test/typecheck/lint command.
20
+
21
+ Examples usually safe:
22
+
23
+ ```text
24
+ npm test
25
+ npm run test
26
+ npm run build
27
+ npm run typecheck
28
+ pnpm test
29
+ bun run typecheck
30
+ node scripts/*check*
31
+ ```
32
+
33
+ Ask first if the command may be slow, needs services, or has side effects.
34
+
35
+ ## Ask First
36
+
37
+ Always ask before running commands involving:
38
+
39
+ ```text
40
+ commit
41
+ stash
42
+ worktree add
43
+ accept
44
+ accept-risk
45
+ reviewed accept
46
+ manual validation
47
+ map delta apply
48
+ ```
49
+
50
+ Manual validation is ask-first because the human must actually verify the product behavior.
51
+
52
+ ## Never Do Automatically
53
+
54
+ Do not run these without explicit user request and confirmation:
55
+
56
+ ```text
57
+ git reset
58
+ git checkout --
59
+ git clean
60
+ rm -rf
61
+ git push
62
+ git merge
63
+ deploy
64
+ release
65
+ kubectl
66
+ terraform apply
67
+ db migrate
68
+ drop
69
+ docker compose down
70
+ ```
71
+
72
+ ## Human-Only Decisions
73
+
74
+ The human must decide:
75
+
76
+ - manual UI/product verification passed or failed,
77
+ - review reason,
78
+ - accept-risk reason,
79
+ - commit message,
80
+ - whether to accept and commit,
81
+ - whether to discard/stash/isolate dirty work.
82
+
83
+ The skill may suggest wording, but the human must confirm it.
84
+
85
+ ## Hard Stops
86
+
87
+ Stop immediately when Hive reports:
88
+
89
+ - scope violation,
90
+ - required validation failed,
91
+ - blocked verdict,
92
+ - changed files outside the intended context,
93
+ - evidence policy says blocked.
94
+
95
+ Do not continue to accept or commit from a hard stop.
@@ -0,0 +1,123 @@
1
+ # Evidence Verdict Handling
2
+
3
+ Use `evidencePolicy.verdict` from `hive-lite check --json` as the main finish-state driver.
4
+
5
+ ## acceptable
6
+
7
+ Meaning: evidence is sufficient.
8
+
9
+ Say:
10
+
11
+ ```text
12
+ Evidence is sufficient:
13
+ - scope is clean
14
+ - required validation/manual evidence is satisfied
15
+ ```
16
+
17
+ Then ask whether to accept and commit. Suggest a commit message, but wait for confirmation.
18
+
19
+ ## needs_validation
20
+
21
+ Meaning: required automatic validation has not run.
22
+
23
+ Action:
24
+
25
+ 1. Inspect `validation.plan`.
26
+ 2. Run safe validation automatically, or ask first if it looks risky.
27
+ 3. Rerun `hive-lite check <chg_id> --json`.
28
+
29
+ Say:
30
+
31
+ ```text
32
+ The change is not ready yet because automatic validation has not run.
33
+ I can run the configured validation now.
34
+ ```
35
+
36
+ ## needs_manual_verification
37
+
38
+ Meaning: this change is directly manually verifiable, but no manual evidence note has been recorded.
39
+
40
+ Action:
41
+
42
+ 1. Ask the human to verify the product behavior.
43
+ 2. Give concrete checks.
44
+ 3. Wait for confirmation.
45
+ 4. Record manual evidence with `hive-lite validate --manual ...`.
46
+ 5. Rerun check.
47
+
48
+ Do not say or imply that you personally verified the UI.
49
+
50
+ Example prompt:
51
+
52
+ ```text
53
+ Automatic validation passed. This is a UI behavior change, so I need your confirmation.
54
+
55
+ Please open Dashboard and confirm:
56
+ - the Action Inbox layout matches the requested hierarchy;
57
+ - no obvious layout break is visible;
58
+ - existing actions/status labels remain visible.
59
+
60
+ Reply "passed" with any note, or describe what failed.
61
+ ```
62
+
63
+ If the human describes a failure, do not accept. Failed manual evidence is optional, not the default. Usually the best next step is to give the coding agent a bounded repair prompt using the same Context Packet and the human's failure observation, then rerun `hive-lite check --context <ctx_id>` after edits.
64
+
65
+ ## needs_review_reason
66
+
67
+ Meaning: Hive needs a human review reason before accepting. This often happens for review-gated scope, unknown verification policy, or internal behavior without focused evidence.
68
+
69
+ Action:
70
+
71
+ 1. Explain why a reason is needed.
72
+ 2. Offer to draft a reason.
73
+ 3. Wait for human approval.
74
+ 4. Accept only after approval.
75
+
76
+ Example:
77
+
78
+ ```text
79
+ Hive needs a review reason because this touched review-gated scope.
80
+ Suggested reason:
81
+ "Reviewed the changed file; it is limited to the intended Action Inbox layout and validation passed."
82
+
83
+ Do you approve this reason for accept?
84
+ ```
85
+
86
+ ## evidence_insufficient
87
+
88
+ Meaning: evidence is not strong enough for normal accept.
89
+
90
+ Action:
91
+
92
+ Offer options:
93
+
94
+ ```text
95
+ 1. Ask the coding agent to add focused automated verification.
96
+ 2. Accept with a reviewed reason if the human believes evidence is sufficient.
97
+ 3. Accept risk if the human knowingly accepts insufficient evidence.
98
+ 4. Stop.
99
+ ```
100
+
101
+ Prefer focused verification when practical. Do not force tests for low-value process compliance.
102
+
103
+ ## blocked
104
+
105
+ Meaning: do not accept.
106
+
107
+ Common reasons:
108
+
109
+ - scope violation,
110
+ - validation failed,
111
+ - validation/CI weakened,
112
+ - high-risk blocker.
113
+
114
+ Action:
115
+
116
+ Stop and explain blockers. Do not validate further unless it helps debugging, and do not accept/commit.
117
+
118
+ Say:
119
+
120
+ ```text
121
+ This change is blocked and cannot be accepted.
122
+ Next options are to send it back to the coding agent, fix the map/scope if the map is wrong, or stop.
123
+ ```
@@ -0,0 +1,203 @@
1
+ ---
2
+ name: hive-lite-map-maintainer
3
+ description: Use this skill when maintaining a Hive Lite Project Map instead of implementing product code. It handles first-time map bootstrap, existing-map refresh after drift, intent-triggered map repair from find/context gaps, map health cleanup, and map delta review/apply workflows while editing only `.hive/map/*.yaml`.
4
+ ---
5
+
6
+ # Hive Lite Map Maintainer
7
+
8
+ ## Purpose
9
+
10
+ Maintain `.hive/map/*.yaml` so Hive Lite can produce high-quality Context Packets and Evidence Policy decisions.
11
+
12
+ This skill is for map work only. It may inspect the repo and edit Project Map YAML, but it must not implement product/application changes.
13
+
14
+ ## References
15
+
16
+ - Read [lifecycle.md](references/lifecycle.md) to choose the right map maintenance mode.
17
+ - Read [repair-rules.md](references/repair-rules.md) before editing Project Map YAML.
18
+
19
+ ## Skill Handoffs
20
+
21
+ Do not assume this skill can invoke `$hive-lite-start-prompt` or `$hive-lite-finish` automatically. When map maintenance is complete, output the next skill prompt the user should run, then stop.
22
+
23
+ - For coding work after map repair: output a `$hive-lite-start-prompt` handoff.
24
+ - For finishing a code change: do not continue here; use `$hive-lite-finish`.
25
+
26
+ If the target handoff skill is unavailable in the active agent CLI, tell the user to install or sync Hive Lite skills for their agent first. Hive Lite cannot detect the running agent by itself; use the user's agent target such as `codex`, `claude`, or `gemini`:
27
+
28
+ ```bash
29
+ hive-lite skills doctor --agent <codex|claude|gemini>
30
+ hive-lite skills install --agent <codex|claude|gemini>
31
+ ```
32
+
33
+ ## Boundaries
34
+
35
+ - Only edit:
36
+ - `.hive/map/project.yaml`
37
+ - `.hive/map/areas.yaml`
38
+ - `.hive/map/rules.yaml`
39
+ - `.hive/map/validation.yaml`
40
+ - Do not edit application source, tests, docs, generated artifacts, `.hive/context`, `.hive/changes`, or `.hive/deltas`.
41
+ - Do not run `hive check`, `hive validate`, `hive accept`, app formatters, app tests, commits, pushes, merges, deploys, or destructive git commands.
42
+ - Do not call an LLM API from Hive Lite. Use Hive Lite CLI facts plus repo inspection.
43
+ - Do not turn the map into a wiki. Only add information that improves `find` or `check`.
44
+ - Durable map changes require human awareness. If you changed map files, summarize exactly what changed and tell the user to run/approve commit separately.
45
+ - Apply Map Delta Candidates only when the user explicitly asked for or confirmed that action. Otherwise list/summarize them and stop.
46
+
47
+ ## Find The CLI
48
+
49
+ Run Hive Lite from the target repo root. Prefer the package command:
50
+
51
+ ```bash
52
+ hive-lite <args>
53
+ ```
54
+
55
+ If `hive-lite` is not available, try an explicit path already given by the user or conversation context, such as `node /path/to/hive-lite/bin/hive.js <args>`. If it is still unclear, ask for the Hive Lite CLI path.
56
+
57
+ In examples below, replace `hive-lite` with the resolved command.
58
+
59
+ ## Workflow
60
+
61
+ ### 0. Git Precondition
62
+
63
+ Run:
64
+
65
+ ```bash
66
+ hive-lite status --json
67
+ ```
68
+
69
+ If it reports `hive.state = repo_setup_required`, stop immediately. Do not run `hive-lite init`, do not create `.hive/map`, and do not initialize git automatically. Tell the user to switch to the correct git repo root, or manually initialize git and create an initial commit before using Hive Lite.
70
+
71
+ ### 1. Establish Mode
72
+
73
+ Read [lifecycle.md](references/lifecycle.md), then classify the task as one of:
74
+
75
+ - `bootstrap`: old/existing project is using Hive Lite for the first time.
76
+ - `refresh`: `.hive/map/*.yaml` exists but may be stale after architecture or repo changes.
77
+ - `intent_repair`: `find` or a start-prompt flow produced `needs_map`, `discovery_context`, broad scope, missing entrypoints, missing validation, or weak evidence policy.
78
+ - `continuous_delta`: accepted Hive Lite changes produced Map Delta Candidates.
79
+ - `recovery`: map files are missing, invalid YAML, or structurally broken.
80
+
81
+ If the user provided a specific requirement, context id, or find output, prefer `intent_repair`.
82
+
83
+ ### 2. Ensure Map Exists
84
+
85
+ Before any mode-specific work, check whether the target repo has the required Hive Lite map files:
86
+
87
+ ```text
88
+ .hive/map/project.yaml
89
+ .hive/map/areas.yaml
90
+ .hive/map/rules.yaml
91
+ .hive/map/validation.yaml
92
+ ```
93
+
94
+ If any required map file is missing, run:
95
+
96
+ ```bash
97
+ hive-lite init
98
+ ```
99
+
100
+ This is setup work. Do it automatically; do not ask the user whether to initialize Hive Lite. Then continue with bootstrap or recovery.
101
+
102
+ If the target directory is not a git repo or Hive Lite init fails, stop and report the blocker instead of inventing map files manually.
103
+
104
+ ### 3. Verify Current Map
105
+
106
+ Run:
107
+
108
+ ```bash
109
+ hive-lite map verify
110
+ ```
111
+
112
+ If YAML is invalid, fix only `.hive/map/*.yaml` if the repair is obvious. If not obvious, stop with the exact file and parser error.
113
+
114
+ ### 4. Gather Facts
115
+
116
+ Use the minimal facts needed for the selected mode:
117
+
118
+ ```bash
119
+ hive-lite map health --json
120
+ hive-lite map health --area <area_id> --json
121
+ hive-lite map prompt --focus "<topic>" --max-areas 8
122
+ hive-lite map prompt --from-find <ctx_id>
123
+ hive-lite map delta list
124
+ ```
125
+
126
+ Also inspect repo evidence with deterministic commands such as:
127
+
128
+ ```bash
129
+ rg --files
130
+ rg "<term>"
131
+ ```
132
+
133
+ Do not infer paths or validation commands without checking files or scripts.
134
+
135
+ ### 5. Edit The Map
136
+
137
+ Read [repair-rules.md](references/repair-rules.md). Keep edits narrow:
138
+
139
+ - Add or repair focused product/work areas.
140
+ - Replace generic one-part areas with dot-separated area ids when needed.
141
+ - Add exact `scope.writable_direct` files.
142
+ - Move broad patterns to `scope.writable_broad_fallback` with `requires_review: true`.
143
+ - Add entrypoint `role`, `source`, and `confidence`.
144
+ - Add minimal `verification` policy for finish-phase Evidence Policy.
145
+ - Add validation metadata only from confirmed scripts or explicit manual profiles.
146
+
147
+ ### 6. Verify The Repair
148
+
149
+ Always run:
150
+
151
+ ```bash
152
+ hive-lite map verify
153
+ hive-lite map health --json
154
+ ```
155
+
156
+ For focused repairs, also run:
157
+
158
+ ```bash
159
+ hive-lite map health --area <area_id> --json
160
+ ```
161
+
162
+ For intent-triggered repairs, rerun the original find:
163
+
164
+ ```bash
165
+ hive-lite find "<findIntent>" --json
166
+ ```
167
+
168
+ The repair is successful when:
169
+
170
+ - `map verify` is ok.
171
+ - The affected area has no critical health findings.
172
+ - Intent-triggered repair now produces `edit_context`, narrow direct writable files, configured validation, and no map-gap warnings.
173
+
174
+ ### 7. Return A Map Maintenance Summary
175
+
176
+ Return:
177
+
178
+ ```text
179
+ Map maintenance complete.
180
+
181
+ Mode:
182
+ - <bootstrap|refresh|intent_repair|continuous_delta|recovery>
183
+
184
+ Changed map files:
185
+ - <file or none>
186
+
187
+ Changed areas/profiles:
188
+ - <area/profile id and concise change>
189
+
190
+ Verification:
191
+ - hive-lite map verify: <ok/fail>
192
+ - hive-lite map health: <healthy/needs_attention/...>
193
+ - focused find rerun, if applicable: <edit_context/discovery_context/needs_map>
194
+
195
+ Remaining TODO:
196
+ - <uncertain path/profile/risk item or none>
197
+
198
+ Next:
199
+ - For coding work: run `$hive-lite-start-prompt` again with the original requirement or context.
200
+ - For changed map files: commit them separately before starting a new requirement.
201
+ ```
202
+
203
+ Do not include a coding agent prompt. This skill only maintains the Project Map.
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "Hive Lite Map Maintainer"
3
+ short_description: "Maintain Hive Lite Project Maps"
4
+ default_prompt: "Use $hive-lite-map-maintainer to refresh or repair the Hive Lite Project Map without changing product code."
5
+
6
+ policy:
7
+ allow_implicit_invocation: true
@@ -0,0 +1,114 @@
1
+ # Hive Lite Map Lifecycle
2
+
3
+ Choose one mode before editing the map.
4
+
5
+ ## bootstrap
6
+
7
+ Use when an existing project is adopting Hive Lite for the first time.
8
+
9
+ Goal:
10
+
11
+ - Create the first 3-8 high-value product/work areas.
12
+ - Make `find` and `check` usable quickly.
13
+ - Do not map the whole project.
14
+
15
+ Suggested flow:
16
+
17
+ ```bash
18
+ hive-lite init
19
+ hive-lite map prompt --focus "highest value product and workflow areas" --max-areas 8
20
+ ```
21
+
22
+ Then inspect repo files and edit `.hive/map/*.yaml` directly.
23
+
24
+ Success:
25
+
26
+ - `map verify` passes.
27
+ - `map health` has no critical findings for the first useful areas.
28
+ - A sample `find` can produce `edit_context`.
29
+
30
+ ## refresh
31
+
32
+ Use when `.hive/map/*.yaml` already exists but may be stale because architecture, paths, scripts, or validation changed outside normal Hive Lite maintenance.
33
+
34
+ Goal:
35
+
36
+ - Preserve existing useful areas.
37
+ - Repair stale paths, missing roles, broad writable scopes, missing validation metadata, and weak verification policy.
38
+ - Do not redesign the whole map unless it is structurally wrong.
39
+
40
+ Suggested flow:
41
+
42
+ ```bash
43
+ hive-lite map health --json
44
+ hive-lite map health --area <area_id> --json
45
+ ```
46
+
47
+ Prioritize critical findings, then warnings that affect `find` or `check`.
48
+
49
+ ## intent_repair
50
+
51
+ Use when a real requirement hits a map gap during start:
52
+
53
+ - `find.mode` is `needs_map` or `discovery_context`.
54
+ - `find` selected a generic/broad area.
55
+ - warnings include `NO_CONFIDENT_AREA`, `MISSING_DIRECT_WRITABLE_SCOPE`, `MISSING_ENTRYPOINT`, or `MISSING_VALIDATION`.
56
+ - `map health --area <selected>` shows critical findings.
57
+
58
+ Goal:
59
+
60
+ - Repair only the area needed for this intent.
61
+ - Rerun `find` until it produces an edit-ready Context Packet.
62
+ - Do not implement the product requirement.
63
+
64
+ Suggested flow:
65
+
66
+ ```bash
67
+ hive-lite map prompt --from-find <ctx_id>
68
+ hive-lite map verify
69
+ hive-lite map health --area <area_id> --json
70
+ hive-lite find "<findIntent>" --json
71
+ ```
72
+
73
+ Success:
74
+
75
+ - rerun `find` returns `mode: edit_context`.
76
+ - direct writable scope is narrow.
77
+ - validation plan exists.
78
+ - review-gated scope is present only as conditional/fallback boundary.
79
+
80
+ ## continuous_delta
81
+
82
+ Use when accepted Hive Lite changes produce Map Delta Candidates.
83
+
84
+ Goal:
85
+
86
+ - Review durable lessons from real accepted changes.
87
+ - Apply only map deltas that improve future `find/check`.
88
+
89
+ Suggested flow:
90
+
91
+ ```bash
92
+ hive-lite map delta list
93
+ hive-lite map delta apply <delta_id>
94
+ ```
95
+
96
+ Only apply a delta when the user explicitly asks or confirms. Reject stale or low-value deltas if the CLI supports it.
97
+
98
+ ## recovery
99
+
100
+ Use when map files are missing, invalid YAML, or structurally broken.
101
+
102
+ Goal:
103
+
104
+ - Restore valid Project Map files.
105
+ - Avoid broad semantic rewrites.
106
+
107
+ Suggested flow:
108
+
109
+ ```bash
110
+ hive-lite init
111
+ hive-lite map verify
112
+ ```
113
+
114
+ If invalid YAML cannot be repaired safely, stop and report the exact error.