hive-lite 0.1.0 → 0.1.2

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
@@ -235,6 +235,8 @@ node bin/hive.js map-dump
235
235
 
236
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
237
 
238
+ Inside a git repo, `status` and `next` report `hive_init_required` until the repo has been initialized with `hive-lite init`. Hive Lite skills should stop in this state and ask the human/operator to run init explicitly before start, finish, or map-maintenance workflows continue.
239
+
238
240
  Committed by default:
239
241
 
240
242
  ```text
@@ -264,6 +266,8 @@ node bin/hive.js next --json
264
266
 
265
267
  Typical `phaseGuess` values:
266
268
 
269
+ - `repo_setup_required`: current directory is not inside a git repo
270
+ - `hive_init_required`: run `hive-lite init` explicitly before using Hive Lite skills
267
271
  - `preflight`: dirty worktree must be committed, stashed, isolated, or stopped before a new requirement
268
272
  - `finish`: an in-progress or accepted-uncommitted Hive change should be closed with `$hive-lite-finish`
269
273
  - `map`: Project Map needs bootstrap, refresh, or repair via `$hive-lite-map-maintainer`
@@ -287,6 +291,8 @@ node bin/hive.js status --json
287
291
 
288
292
  It classifies the current repo as:
289
293
 
294
+ - `repo_setup_required`: not inside a git worktree
295
+ - `hive_init_required`: git repo exists, but required Hive Lite setup files are missing
290
296
  - `clean`: safe to start a new `find`
291
297
  - `unmanaged_dirty`: dirty files are not tied to a Hive Change Record
292
298
  - `in_progress`: dirty files belong to an unfinished Hive Change Record
@@ -301,6 +307,7 @@ The durable context router under `.hive/map`.
301
307
  `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
308
 
303
309
  `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.
310
+ An initialized repo with zero configured areas is `needs_mapping`, not `healthy`; it still needs `$hive-lite-map-maintainer` bootstrap work before real requirements can be routed safely.
304
311
 
305
312
  ```bash
306
313
  node bin/hive.js map health
@@ -35,6 +35,7 @@ Human output explains the result. JSON output is a stable contract with fields s
35
35
  It reads:
36
36
 
37
37
  - git repo presence
38
+ - Hive Lite initialization state
38
39
  - worktree state
39
40
  - latest Hive Change Record
40
41
  - Project Map health
@@ -51,6 +52,7 @@ Hive Lite cannot detect the currently running agent CLI. If the caller provides
51
52
  | Value | Meaning | What To Do |
52
53
  | --- | --- | --- |
53
54
  | `repo_setup_required` | Current directory is not inside a git repo. | Stop. Switch to the correct repo root, or manually initialize git and create an initial commit before using Hive Lite. |
55
+ | `hive_init_required` | Current git repo does not have required Hive Lite setup files. | Stop skill workflows. Run `hive-lite init` explicitly from the repo root, commit or preserve setup files, then rerun `next`. |
54
56
  | `skill_preflight` | The selected agent target is missing the operator skill needed for the next Hive Lite step. | Run the recommended `skills install` or `skills sync`, then rerun `next`. |
55
57
  | `preflight` | Worktree has unmanaged dirty changes. | Stop before starting new work. Commit, stash, use a separate worktree, or stop. |
56
58
  | `finish` | A Hive change is in progress, or was accepted without commit. | Use `$hive-lite-finish` to check, validate, record evidence, accept, or commit. |
@@ -101,6 +103,7 @@ node bin/hive.js status --json
101
103
  | Value | Meaning | What To Do |
102
104
  | --- | --- | --- |
103
105
  | `repo_setup_required` | Not inside a git worktree. | Stop. Do not auto-run `git init`. |
106
+ | `hive_init_required` | Inside a git worktree, but required Hive Lite setup files are missing. | Stop all skills. Run `hive-lite init` explicitly from the repo root. |
104
107
  | `clean` | Worktree is clean. | It is safe to start `find`. |
105
108
  | `unmanaged_dirty` | Dirty files are not tied to a Hive Change Record. | Stop and ask the human to commit, stash, use a worktree, or stop. |
106
109
  | `in_progress` | Dirty files belong to an unfinished Hive Change Record. | Continue finish flow: `check`, `validate`, manual evidence, or `accept`. |
@@ -352,6 +355,7 @@ node bin/hive.js map health --json
352
355
  | Value | Meaning | What To Do |
353
356
  | --- | --- | --- |
354
357
  | `healthy` | No critical/warning findings. | Map can support edit-ready areas. |
358
+ | `needs_mapping` | Map files are valid, but no areas are configured. | Bootstrap focused areas before starting requirements. |
355
359
  | `needs_attention` | Map has warnings. | Refresh or repair if relevant to the next requirement. |
356
360
  | `unsafe_for_edit_context` | Map has critical findings. | Repair map before relying on edit context. |
357
361
  | `invalid_map` | Map YAML/schema is missing or invalid. | Fix map files before using Hive Lite. |
@@ -61,6 +61,8 @@ In command examples below, replace `hive-lite` with the resolved command.
61
61
 
62
62
  Run `hive-lite status --json` first. If it reports `hive.state = repo_setup_required`, stop immediately. Do not run check/validate/accept 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.
63
63
 
64
+ If it reports `hive.state = hive_init_required`, or `hive.initialized = false`, stop immediately. Do not run `hive-lite init` yourself, and do not run check/validate/accept. Tell the user to run `hive-lite init` from the repo root first. If they expected an existing Hive Lite change, they may be in the wrong directory.
65
+
64
66
  Find one of:
65
67
 
66
68
  - context id from the coding agent output, such as `ctx_xxx`,
@@ -1,6 +1,6 @@
1
1
  ---
2
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`.
3
+ description: Use this skill when maintaining a Hive Lite Project Map instead of implementing product code. It handles first map creation after explicit Hive Lite init, existing-map refresh after drift, intent-triggered map repair from find/context gaps, map health cleanup, and map delta review/apply workflows while directly editing only `.hive/map/*.yaml`.
4
4
  ---
5
5
 
6
6
  # Hive Lite Map Maintainer
@@ -30,18 +30,27 @@ hive-lite skills doctor --agent <codex|claude|gemini>
30
30
  hive-lite skills install --agent <codex|claude|gemini>
31
31
  ```
32
32
 
33
- ## Boundaries
33
+ ## Authority Boundary
34
34
 
35
- - Only edit:
35
+ Setup precondition:
36
+
37
+ - This skill must not run `hive-lite init`.
38
+ - If Hive Lite is not initialized or is partially initialized, stop immediately and tell the user to run `hive-lite init` from the target repo root, then rerun this skill.
39
+ - Do not create `.hive/map` manually, do not edit `.hive/config.yaml`, and do not edit `.gitignore`.
40
+
41
+ Map-maintenance authority:
42
+
43
+ - Directly edit only:
36
44
  - `.hive/map/project.yaml`
37
45
  - `.hive/map/areas.yaml`
38
46
  - `.hive/map/rules.yaml`
39
47
  - `.hive/map/validation.yaml`
40
- - Do not edit application source, tests, docs, generated artifacts, `.hive/context`, `.hive/changes`, or `.hive/deltas`.
48
+ - You may read `.hive/config.yaml`, `.gitignore`, and runtime metadata as needed, but must not directly modify them during normal map maintenance.
49
+ - Do not edit application source, tests, docs, generated artifacts, or non-map project files.
41
50
  - Do not run `hive check`, `hive validate`, `hive accept`, app formatters, app tests, commits, pushes, merges, deploys, or destructive git commands.
42
51
  - Do not call an LLM API from Hive Lite. Use Hive Lite CLI facts plus repo inspection.
43
52
  - 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.
53
+ - Durable map changes require human awareness. Summarize map edits and tell the user to run/approve commit separately.
45
54
  - Apply Map Delta Candidates only when the user explicitly asked for or confirmed that action. Otherwise list/summarize them and stop.
46
55
 
47
56
  ## Find The CLI
@@ -68,6 +77,31 @@ hive-lite status --json
68
77
 
69
78
  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
79
 
80
+ If it reports `hive.state = hive_init_required`, or `hive.initialized = false`, stop immediately. Do not run `hive-lite init` yourself. Tell the user:
81
+
82
+ ```text
83
+ Hive Lite is not initialized in this repo yet.
84
+
85
+ Please run this once from the repo root:
86
+ hive-lite init
87
+
88
+ Then commit or otherwise preserve the setup files, and rerun:
89
+ $hive-lite-map-maintainer
90
+ 这是已有项目第一次接入 Hive Lite。请建立第一版 Project Map,不要改应用代码。
91
+ ```
92
+
93
+ For older Hive Lite versions that do not report `hive.initialized`, check for required setup files before continuing:
94
+
95
+ ```text
96
+ .hive/config.yaml
97
+ .hive/map/project.yaml
98
+ .hive/map/areas.yaml
99
+ .hive/map/rules.yaml
100
+ .hive/map/validation.yaml
101
+ ```
102
+
103
+ If any are missing, stop with the same message. Do not run init automatically.
104
+
71
105
  ### 1. Establish Mode
72
106
 
73
107
  Read [lifecycle.md](references/lifecycle.md), then classify the task as one of:
@@ -91,22 +125,14 @@ Before any mode-specific work, check whether the target repo has the required Hi
91
125
  .hive/map/validation.yaml
92
126
  ```
93
127
 
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.
128
+ If any required map file is missing, stop immediately and tell the user to run `hive-lite init` from the repo root. Do not create missing map files manually.
103
129
 
104
130
  ### 3. Verify Current Map
105
131
 
106
132
  Run:
107
133
 
108
134
  ```bash
109
- hive-lite map verify
135
+ hive-lite map verify --json
110
136
  ```
111
137
 
112
138
  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.
@@ -149,7 +175,7 @@ Read [repair-rules.md](references/repair-rules.md). Keep edits narrow:
149
175
  Always run:
150
176
 
151
177
  ```bash
152
- hive-lite map verify
178
+ hive-lite map verify --json
153
179
  hive-lite map health --json
154
180
  ```
155
181
 
@@ -181,6 +207,10 @@ Map maintenance complete.
181
207
  Mode:
182
208
  - <bootstrap|refresh|intent_repair|continuous_delta|recovery>
183
209
 
210
+ Hive Lite setup:
211
+ - initialized: yes
212
+ - setup changes made by this skill: none
213
+
184
214
  Changed map files:
185
215
  - <file or none>
186
216
 
@@ -188,7 +218,7 @@ Changed areas/profiles:
188
218
  - <area/profile id and concise change>
189
219
 
190
220
  Verification:
191
- - hive-lite map verify: <ok/fail>
221
+ - hive-lite map verify --json: <ok/fail>
192
222
  - hive-lite map health: <healthy/needs_attention/...>
193
223
  - focused find rerun, if applicable: <edit_context/discovery_context/needs_map>
194
224
 
@@ -6,6 +6,11 @@ Choose one mode before editing the map.
6
6
 
7
7
  Use when an existing project is adopting Hive Lite for the first time.
8
8
 
9
+ Precondition:
10
+
11
+ - `hive-lite init` has already been run explicitly by the user/operator.
12
+ - If Hive Lite setup files are missing, stop and tell the user to run `hive-lite init`; do not run it from this skill.
13
+
9
14
  Goal:
10
15
 
11
16
  - Create the first 3-8 high-value product/work areas.
@@ -15,16 +20,15 @@ Goal:
15
20
  Suggested flow:
16
21
 
17
22
  ```bash
18
- hive-lite init
19
23
  hive-lite map prompt --focus "highest value product and workflow areas" --max-areas 8
20
24
  ```
21
25
 
22
- Then inspect repo files and edit `.hive/map/*.yaml` directly.
26
+ Inspect repo files and edit `.hive/map/*.yaml` directly.
23
27
 
24
28
  Success:
25
29
 
26
- - `map verify` passes.
27
- - `map health` has no critical findings for the first useful areas.
30
+ - `map verify --json` reports `ok`.
31
+ - `map health --json` has no critical findings for the first useful areas.
28
32
  - A sample `find` can produce `edit_context`.
29
33
 
30
34
  ## refresh
@@ -97,7 +101,7 @@ Only apply a delta when the user explicitly asks or confirms. Reject stale or lo
97
101
 
98
102
  ## recovery
99
103
 
100
- Use when map files are missing, invalid YAML, or structurally broken.
104
+ Use when initialized map files are invalid YAML or structurally broken. If required Hive Lite setup or map files are missing, stop and tell the user to run `hive-lite init` from the repo root.
101
105
 
102
106
  Goal:
103
107
 
@@ -107,8 +111,7 @@ Goal:
107
111
  Suggested flow:
108
112
 
109
113
  ```bash
110
- hive-lite init
111
- hive-lite map verify
114
+ hive-lite map verify --json
112
115
  ```
113
116
 
114
117
  If invalid YAML cannot be repaired safely, stop and report the exact error.
@@ -33,8 +33,9 @@ hive-lite skills install --agent <codex|claude|gemini>
33
33
 
34
34
  ## Boundaries
35
35
 
36
- - Do not edit application source, tests, docs, `.gitignore`, generated artifacts, `.hive/context`, `.hive/changes`, or `.hive/deltas`.
36
+ - Do not directly edit application source, tests, docs, `.gitignore`, generated artifacts, `.hive/context`, `.hive/changes`, or `.hive/deltas`.
37
37
  - Only edit these Project Map files when map repair is needed: `.hive/map/project.yaml`, `.hive/map/areas.yaml`, `.hive/map/rules.yaml`, `.hive/map/validation.yaml`.
38
+ - Do not run `hive-lite init`. If Hive Lite is not initialized or is partially initialized, stop and tell the user to run `hive-lite init` from the repo root before using this skill.
38
39
  - Do not run `hive check`, `hive validate`, `hive accept`, commits, formatters, or app tests for the new requirement. Those belong after the coding agent changes code.
39
40
  - During preflight, you may help finish or isolate pre-existing work only after explicit user confirmation.
40
41
  - Never discard changes with destructive commands such as `git reset --hard`, `git checkout --`, or forced branch switches.
@@ -66,21 +67,38 @@ Read [input-calibration.md](references/input-calibration.md). Produce:
66
67
 
67
68
  ### 2. Preflight The Worktree
68
69
 
69
- If `.hive/map/project.yaml`, `.hive/map/areas.yaml`, `.hive/map/rules.yaml`, or `.hive/map/validation.yaml` is missing, run:
70
+ Run:
70
71
 
71
72
  ```bash
72
- hive-lite init
73
+ hive-lite status --json
73
74
  ```
74
75
 
75
- Do this automatically; do not ask the user whether to initialize Hive Lite. Initialization is setup work, not the requested product change.
76
+ If status reports `hive.state = repo_setup_required`, stop immediately. Do not run `hive-lite init` 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.
76
77
 
77
- Run:
78
+ If status reports `hive.state = hive_init_required`, or `hive.initialized = false`, stop immediately. Do not run `hive-lite init` yourself. Tell the user:
78
79
 
79
- ```bash
80
- hive-lite status --json
80
+ ```text
81
+ Hive Lite is not initialized in this repo yet.
82
+
83
+ Please run this once from the repo root:
84
+ hive-lite init
85
+
86
+ After the setup files are committed or otherwise preserved, rerun:
87
+ $hive-lite-map-maintainer
88
+ 这是已有项目第一次接入 Hive Lite。请建立第一版 Project Map,不要改应用代码。
81
89
  ```
82
90
 
83
- If status reports `hive.state = repo_setup_required`, stop immediately. Do not run `hive-lite init` 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.
91
+ For older Hive Lite versions that do not report `hive.initialized`, check whether these files exist before continuing:
92
+
93
+ ```text
94
+ .hive/config.yaml
95
+ .hive/map/project.yaml
96
+ .hive/map/areas.yaml
97
+ .hive/map/rules.yaml
98
+ .hive/map/validation.yaml
99
+ ```
100
+
101
+ If any are missing, stop with the same message. Do not run init automatically and do not create missing map files manually.
84
102
 
85
103
  If the command is unavailable in an older Hive Lite, fall back to `git status --porcelain`.
86
104
 
@@ -93,7 +111,7 @@ After any preflight action, rerun `hive-lite status --json`; continue only when
93
111
  Run:
94
112
 
95
113
  ```bash
96
- hive-lite map verify
114
+ hive-lite map verify --json
97
115
  ```
98
116
 
99
117
  If YAML is invalid or required map files are missing, repair only `.hive/map/*.yaml` if the fix is obvious. Otherwise stop and report the blocker.
@@ -182,7 +200,7 @@ Repair principles:
182
200
  After each repair, run:
183
201
 
184
202
  ```bash
185
- hive-lite map verify
203
+ hive-lite map verify --json
186
204
  hive-lite map health --area <area_id> --json
187
205
  hive-lite find "<findIntent>" --json
188
206
  ```
@@ -4,23 +4,24 @@ Use this reference when `hive-lite status --json` is not clean.
4
4
 
5
5
  The goal is to protect the Change Record boundary. A new Hive Lite requirement must start from a clean worktree.
6
6
 
7
- ## After Automatic Init
7
+ ## Hive Lite Not Initialized
8
8
 
9
- If the worktree is dirty only because this skill just ran `hive-lite init`, explain that Hive Lite was initialized automatically and stop before starting the product requirement.
9
+ If `hive-lite status --json` reports `hive.state = hive_init_required` or `hive.initialized = false`, stop immediately. Do not run `hive-lite init` from this skill.
10
10
 
11
- Present options:
11
+ Say:
12
12
 
13
13
  ```text
14
- Hive Lite has been initialized for this repo. The setup files need a git boundary before a product requirement can start.
14
+ Hive Lite is not initialized in this repo yet.
15
15
 
16
- Options:
17
- 1. Commit the Hive Lite setup files.
18
- 2. Stash the setup files.
19
- 3. Create a separate git worktree for the product requirement.
20
- 4. Stop.
16
+ Please run this once from the repo root:
17
+ hive-lite init
18
+
19
+ After the setup files are committed or otherwise preserved, rerun:
20
+ $hive-lite-map-maintainer
21
+ 这是已有项目第一次接入 Hive Lite。请建立第一版 Project Map,不要改应用代码。
21
22
  ```
22
23
 
23
- Do not ask whether to run init; init has already been performed. Do ask before committing, stashing, or creating a worktree.
24
+ Do not continue to find/map repair/start prompt until Hive Lite setup exists.
24
25
 
25
26
  ## States
26
27
 
@@ -107,6 +108,7 @@ hive-lite accept <chg_id> --commit -m "<message>"
107
108
  ## Safety Rules
108
109
 
109
110
  - Do not continue to `find` while status is not clean.
111
+ - Do not run `hive-lite init` from a skill.
110
112
  - Do not initialize git automatically.
111
113
  - Do not assume "new branch" cleans the worktree; dirty files usually follow branch switches.
112
114
  - Prefer commit, stash, or separate git worktree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hive-lite",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Local Project Map + Change Control for coding agents.",
5
5
  "keywords": [
6
6
  "codex",
package/src/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const { version: packageVersion } = require('../package.json');
2
3
  const { requireGitRepo } = require('./lib/git');
3
4
  const { evaluateMapHealth } = require('./lib/health');
4
5
  const { createMapPrompt, initProject, loadProjectMap, suggestMap, verifyProjectMap } = require('./lib/map');
@@ -43,11 +44,28 @@ function parseArgs(args) {
43
44
  return { positional, flags };
44
45
  }
45
46
 
47
+ function isHelpArg(arg) {
48
+ return arg === 'help' || arg === '--help' || arg === '-h';
49
+ }
50
+
51
+ function isHelpFlag(arg) {
52
+ return arg === '--help' || arg === '-h';
53
+ }
54
+
55
+ function isVersionArg(arg) {
56
+ return arg === 'version' || arg === '--version' || arg === '-v';
57
+ }
58
+
59
+ function printVersion() {
60
+ console.log(packageVersion);
61
+ }
62
+
46
63
  function printHelp() {
47
64
  console.log(`
48
65
  Hive Lite - local Project Map + Change Control
49
66
 
50
67
  Usage:
68
+ hive-lite version
51
69
  hive-lite init
52
70
  hive-lite doctor
53
71
  hive-lite status [--json] [--all]
@@ -79,6 +97,16 @@ function currentCliCommandArgv() {
79
97
  return [process.execPath, path.resolve(process.argv[1])];
80
98
  }
81
99
 
100
+ function requireHiveInitialized(cwd, commandName) {
101
+ const status = evaluateWorkspaceStatus(cwd);
102
+ if (status.hive.initialized === false) {
103
+ const missing = status.hive.missingSetupFiles && status.hive.missingSetupFiles.length > 0
104
+ ? ` Missing: ${status.hive.missingSetupFiles.join(', ')}.`
105
+ : '';
106
+ throw new Error(`${commandName} requires Hive Lite initialization. Run hive-lite init from the repo root first.${missing}`);
107
+ }
108
+ }
109
+
82
110
  function printInit(result) {
83
111
  console.log('Hive Lite initialized.');
84
112
  console.log(`Repo: ${result.root}`);
@@ -523,6 +551,11 @@ function printWorkspaceStatus(result) {
523
551
  console.log(`Hive State: ${result.hive.state}`);
524
552
  console.log(`Can Start New Requirement: ${result.canStartNewRequirement ? 'yes' : 'no'}`);
525
553
  console.log(`Reason: ${result.hive.reason}`);
554
+ if (result.hive.initialized === false && result.hive.missingSetupFiles && result.hive.missingSetupFiles.length > 0) {
555
+ console.log('');
556
+ console.log('Missing Hive Lite Setup Files:');
557
+ for (const file of result.hive.missingSetupFiles) console.log(` - ${file}`);
558
+ }
526
559
  if (result.hive.latestChange) {
527
560
  console.log('');
528
561
  console.log('Latest Change:');
@@ -719,7 +752,17 @@ function printSkillsMutation(result) {
719
752
 
720
753
  async function main(argv) {
721
754
  const [command, subcommand, subsubcommand, ...rest] = argv;
722
- if (!command || command === 'help' || command === '--help' || command === '-h') {
755
+ if (!command || isHelpArg(command)) {
756
+ printHelp();
757
+ return;
758
+ }
759
+
760
+ if (isVersionArg(command)) {
761
+ printVersion();
762
+ return;
763
+ }
764
+
765
+ if (subcommand === 'help' || isHelpFlag(subcommand) || isHelpFlag(subsubcommand) || rest.some(isHelpFlag)) {
723
766
  printHelp();
724
767
  return;
725
768
  }
@@ -782,6 +825,7 @@ async function main(argv) {
782
825
  const intent = parsed.positional.join(' ').trim();
783
826
  if (!intent) throw new Error('find requires an intent string');
784
827
  const root = requireGitRepo(process.cwd(), 'hive-lite find');
828
+ requireHiveInitialized(root, 'hive-lite find');
785
829
  const result = createContextPacket(root, intent, {
786
830
  ...parsed.flags,
787
831
  cliCommandArgv: currentCliCommandArgv(),
@@ -795,7 +839,8 @@ async function main(argv) {
795
839
  }
796
840
 
797
841
  if (command === 'check') {
798
- requireGitRepo(process.cwd(), 'hive-lite check');
842
+ const root = requireGitRepo(process.cwd(), 'hive-lite check');
843
+ requireHiveInitialized(root, 'hive-lite check');
799
844
  const parsed = parseArgs([subcommand, subsubcommand, ...rest].filter((item) => item !== undefined));
800
845
  const changeId = parsed.positional[0] || null;
801
846
  const result = createOrUpdateChange(process.cwd(), {
@@ -808,7 +853,8 @@ async function main(argv) {
808
853
  }
809
854
 
810
855
  if (command === 'validate') {
811
- requireGitRepo(process.cwd(), 'hive-lite validate');
856
+ const root = requireGitRepo(process.cwd(), 'hive-lite validate');
857
+ requireHiveInitialized(root, 'hive-lite validate');
812
858
  const parsed = parseArgs([subcommand, subsubcommand, ...rest].filter((item) => item !== undefined));
813
859
  if (!parsed.flags.json && !parsed.flags.manual) {
814
860
  parsed.flags.onStart = (item) => {
@@ -824,7 +870,8 @@ async function main(argv) {
824
870
  }
825
871
 
826
872
  if (command === 'accept') {
827
- requireGitRepo(process.cwd(), 'hive-lite accept');
873
+ const root = requireGitRepo(process.cwd(), 'hive-lite accept');
874
+ requireHiveInitialized(root, 'hive-lite accept');
828
875
  const parsed = parseArgs([subcommand, subsubcommand, ...rest].filter((item) => item !== undefined));
829
876
  const result = acceptChange(process.cwd(), parsed.positional[0] || null, parsed.flags);
830
877
  if (parsed.flags.json) console.log(JSON.stringify(result, null, 2));
@@ -855,6 +902,7 @@ async function main(argv) {
855
902
  return;
856
903
  }
857
904
  if (subcommand === 'prompt') {
905
+ requireHiveInitialized(root, 'hive-lite map prompt');
858
906
  const parsed = parseArgs([subsubcommand, ...rest].filter((item) => item !== undefined));
859
907
  const result = createMapPrompt(root, parsed.flags);
860
908
  if (parsed.flags.json) console.log(JSON.stringify(result, null, 2));
@@ -863,10 +911,12 @@ async function main(argv) {
863
911
  }
864
912
  if (subcommand === 'delta') {
865
913
  if (subsubcommand === 'list') {
914
+ requireHiveInitialized(root, 'hive-lite map delta list');
866
915
  printDeltas(allDeltas(root));
867
916
  return;
868
917
  }
869
918
  if (subsubcommand === 'apply') {
919
+ requireHiveInitialized(root, 'hive-lite map delta apply');
870
920
  const parsed = parseArgs(rest);
871
921
  const id = parsed.positional[0];
872
922
  if (!id) throw new Error('map delta apply requires a delta id');
@@ -877,6 +927,7 @@ async function main(argv) {
877
927
  return;
878
928
  }
879
929
  if (subsubcommand === 'reject') {
930
+ requireHiveInitialized(root, 'hive-lite map delta reject');
880
931
  const parsed = parseArgs(rest);
881
932
  const id = parsed.positional[0];
882
933
  if (!id) throw new Error('map delta reject requires a delta id');
package/src/lib/health.js CHANGED
@@ -877,6 +877,7 @@ function summarize(result, areas, findings) {
877
877
  };
878
878
  let status = 'healthy';
879
879
  if (result.invalidMap) status = 'invalid_map';
880
+ else if (result.emptyMap) status = 'needs_mapping';
880
881
  else if (counts.critical > 0) status = 'unsafe_for_edit_context';
881
882
  else if (counts.warnings > 0) status = 'needs_attention';
882
883
  return {
@@ -912,6 +913,16 @@ function evaluateMapHealth(root, options = {}) {
912
913
  }
913
914
 
914
915
  const allAreas = Array.isArray(areasDoc.areas) ? areasDoc.areas : [];
916
+ if (allAreas.length === 0) {
917
+ addFinding(findings, {
918
+ severity: 'critical',
919
+ code: 'NO_AREAS_CONFIGURED',
920
+ field: 'areas',
921
+ message: 'Project Map has no areas configured.',
922
+ impact: 'Hive Lite cannot safely route requirements until at least one focused area is mapped.',
923
+ fix: 'Use hive-lite-map-maintainer to bootstrap focused Project Map areas.',
924
+ });
925
+ }
915
926
  const selectedAreas = options.area ? allAreas.filter((area) => area.id === options.area) : allAreas;
916
927
  if (options.area && selectedAreas.length === 0) {
917
928
  addFinding(findings, {
@@ -951,7 +962,7 @@ function evaluateMapHealth(root, options = {}) {
951
962
  validateRisk(area, findings);
952
963
  }
953
964
 
954
- const base = { invalidMap, findings };
965
+ const base = { invalidMap, emptyMap: allAreas.length === 0, findings };
955
966
  const summarized = summarize(base, selectedAreas, findings);
956
967
  const areas = selectedAreas.map((area) => {
957
968
  const areaFindings = findings.filter((finding) => finding.areaId === area.id);
package/src/lib/next.js CHANGED
@@ -105,7 +105,7 @@ function mapMaintainerPrompt(mode) {
105
105
  if (mode === 'bootstrap') {
106
106
  return [
107
107
  '$hive-lite-map-maintainer',
108
- '这个项目第一次使用 Hive Lite,请初始化并建立第一版 3-8 个高价值 areas。',
108
+ '这是已有项目第一次接入 Hive Lite。请建立第一版 Project Map,不要改应用代码。',
109
109
  ].join('\n');
110
110
  }
111
111
  if (mode === 'delta') {
@@ -177,11 +177,13 @@ function evaluateNextAction(cwd, options = {}) {
177
177
  const root = repoRoot(cwd);
178
178
  const workspace = evaluateWorkspaceStatus(root);
179
179
  const repoSetupRequired = workspace.hive.state === 'repo_setup_required';
180
- const mapHealth = repoSetupRequired
180
+ const hiveInitRequired = workspace.hive.state === 'hive_init_required';
181
+ const setupRequired = repoSetupRequired || hiveInitRequired;
182
+ const mapHealth = setupRequired
181
183
  ? { status: 'not_checked', critical: 0, warnings: 0, info: 0, areasChecked: 0, topFindings: [] }
182
184
  : mapHealthSummary(root);
183
- const latestChange = repoSetupRequired ? null : latestChangeSummary(root);
184
- const deltas = repoSetupRequired ? [] : pendingDeltas(root);
185
+ const latestChange = setupRequired ? null : latestChangeSummary(root);
186
+ const deltas = setupRequired ? [] : pendingDeltas(root);
185
187
  const warnings = [];
186
188
  const secondaryActions = [];
187
189
 
@@ -222,6 +224,16 @@ function evaluateNextAction(cwd, options = {}) {
222
224
  });
223
225
  summaryForHuman = '当前目录不是 git repo。Hive Lite 不能安全开始;请切到正确的 repo 根目录,或你自己先完成 git 初始化和初始提交。';
224
226
  summaryForAgent = 'No git repository detected. Stop. Do not run find/check/accept or initialize git automatically.';
227
+ } else if (workspace.hive.state === 'hive_init_required') {
228
+ phaseGuess = 'hive_init_required';
229
+ primaryAction = action({
230
+ kind: 'run_hive_init',
231
+ label: 'Run hive-lite init',
232
+ command: 'hive-lite init',
233
+ explanation: 'This git repository has not been initialized for Hive Lite. Run init explicitly before using Hive Lite skills.',
234
+ });
235
+ summaryForHuman = '当前项目还没有初始化 Hive Lite。请先在项目根目录运行 hive-lite init,然后提交 setup/map 文件,再用 hive-lite-map-maintainer 建立 Project Map。';
236
+ summaryForAgent = 'Hive Lite is not initialized. Stop all skill workflows and tell the human to run hive-lite init first.';
225
237
  } else if (!workspace.canStartNewRequirement) {
226
238
  if (workspace.hive.state === 'in_progress') {
227
239
  phaseGuess = 'finish';
package/src/lib/status.js CHANGED
@@ -6,6 +6,14 @@ const { latestChangeId, loadChange } = require('./change');
6
6
  const { exists, readJson } = require('./fsx');
7
7
  const { hiveDir } = require('./map');
8
8
 
9
+ const REQUIRED_HIVE_SETUP_FILES = [
10
+ '.hive/config.yaml',
11
+ '.hive/map/project.yaml',
12
+ '.hive/map/areas.yaml',
13
+ '.hive/map/rules.yaml',
14
+ '.hive/map/validation.yaml',
15
+ ];
16
+
9
17
  function sha256(value) {
10
18
  return createHash('sha256').update(value || '').digest('hex');
11
19
  }
@@ -204,6 +212,10 @@ function action(kind, label, command, description) {
204
212
  return { kind, label, command, description };
205
213
  }
206
214
 
215
+ function missingHiveSetupFiles(root) {
216
+ return REQUIRED_HIVE_SETUP_FILES.filter((file) => !exists(path.join(root, file)));
217
+ }
218
+
207
219
  function actionsFor(state, latestId, diffMatches) {
208
220
  if (state === 'repo_setup_required') {
209
221
  return [
@@ -212,6 +224,12 @@ function actionsFor(state, latestId, diffMatches) {
212
224
  action('manual_git_setup', 'Set up git manually', null, 'If this is a new project, review .gitignore, initialize git, and create an initial commit yourself before running Hive Lite.'),
213
225
  ];
214
226
  }
227
+ if (state === 'hive_init_required') {
228
+ return [
229
+ action('run_hive_init', 'Run Hive Lite init', 'hive-lite init', 'Initialize Hive Lite setup files before using Hive Lite skills.'),
230
+ action('stop', 'Stop', null, 'Do not run start, finish, or map-maintainer skills until Hive Lite has been initialized.'),
231
+ ];
232
+ }
215
233
  if (state === 'clean') {
216
234
  return [
217
235
  action('start_requirement', 'Start a Hive Lite requirement', 'hive-lite find "<intent>" --json', 'The worktree is clean enough to generate a new Context Packet.'),
@@ -281,6 +299,8 @@ function evaluateWorkspaceStatus(cwd, options = {}) {
281
299
  const root = repoRoot(cwd);
282
300
  const files = changedFiles(root);
283
301
  const dirty = files.length > 0;
302
+ const missingSetupFiles = missingHiveSetupFiles(root);
303
+ const initialized = missingSetupFiles.length === 0;
284
304
  const currentDiff = dirty ? diffFromHead(root) : '';
285
305
  const currentDiffHash = dirty ? diffHash(currentDiff) : null;
286
306
  const latest = latestChange(root);
@@ -292,7 +312,10 @@ function evaluateWorkspaceStatus(cwd, options = {}) {
292
312
  ? 'Working tree has dirty files that are not known to be an accepted or in-progress Hive change.'
293
313
  : 'Working tree is clean.';
294
314
 
295
- if (dirty && latest.change) {
315
+ if (!initialized) {
316
+ state = 'hive_init_required';
317
+ reason = 'Hive Lite is not initialized in this git repository. Run hive-lite init before using Hive Lite skills.';
318
+ } else if (dirty && latest.change) {
296
319
  if (accepted(latest.change) && !committed(latest.change) && diffMatches) {
297
320
  state = 'accepted_uncommitted';
298
321
  reason = 'The dirty diff matches the latest accepted Hive change, but no commit was created.';
@@ -330,6 +353,8 @@ function evaluateWorkspaceStatus(cwd, options = {}) {
330
353
  hive: {
331
354
  state,
332
355
  reason,
356
+ initialized,
357
+ missingSetupFiles,
333
358
  latestChange: latestSummary,
334
359
  },
335
360
  canStartNewRequirement: state === 'clean',