hive-lite 0.1.1 → 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
@@ -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`. |
@@ -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
@@ -32,18 +32,15 @@ hive-lite skills install --agent <codex|claude|gemini>
32
32
 
33
33
  ## Authority Boundary
34
34
 
35
- This skill has lifecycle-scoped authority.
35
+ Setup precondition:
36
36
 
37
- Bootstrap / repair exception:
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`.
38
40
 
39
- - If Hive Lite is not initialized, partially initialized, or explicitly being initialized, this skill may run the approved bootstrap command, normally `hive-lite init`.
40
- - Preserve setup side effects produced by the bootstrap command, including `.hive/config.yaml`, `.hive/map/*.yaml`, Hive Lite runtime/evidence directories, and `.gitignore` entries for those runtime/evidence directories.
41
- - These bootstrap side effects are authorized setup artifacts. Do not delete, revert, or "clean up" them merely because they are outside `.hive/map/`.
42
- - Do not hand-edit setup files as ordinary map maintenance. If setup files are missing or inconsistent after bootstrap, report a setup/repair condition or rerun an approved bootstrap/repair command when the task allows it.
41
+ Map-maintenance authority:
43
42
 
44
- Normal map-maintenance mode:
45
-
46
- - After Hive Lite is initialized, directly edit only:
43
+ - Directly edit only:
47
44
  - `.hive/map/project.yaml`
48
45
  - `.hive/map/areas.yaml`
49
46
  - `.hive/map/rules.yaml`
@@ -53,7 +50,7 @@ Normal map-maintenance mode:
53
50
  - Do not run `hive check`, `hive validate`, `hive accept`, app formatters, app tests, commits, pushes, merges, deploys, or destructive git commands.
54
51
  - Do not call an LLM API from Hive Lite. Use Hive Lite CLI facts plus repo inspection.
55
52
  - Do not turn the map into a wiki. Only add information that improves `find` or `check`.
56
- - Durable setup and map changes require human awareness. Summarize setup effects separately from map edits 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.
57
54
  - Apply Map Delta Candidates only when the user explicitly asked for or confirmed that action. Otherwise list/summarize them and stop.
58
55
 
59
56
  ## Find The CLI
@@ -80,6 +77,31 @@ hive-lite status --json
80
77
 
81
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.
82
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
+
83
105
  ### 1. Establish Mode
84
106
 
85
107
  Read [lifecycle.md](references/lifecycle.md), then classify the task as one of:
@@ -103,16 +125,7 @@ Before any mode-specific work, check whether the target repo has the required Hi
103
125
  .hive/map/validation.yaml
104
126
  ```
105
127
 
106
- If any required map file is missing, run:
107
-
108
- ```bash
109
- hive-lite init
110
- ```
111
-
112
- This is setup work. Do it automatically; do not ask the user whether to initialize Hive Lite. Then continue with bootstrap or recovery.
113
- Preserve all setup artifacts created by `hive-lite init`; do not remove `.hive/config.yaml` or Hive Lite `.gitignore` entries as part of cleanup.
114
-
115
- 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.
116
129
 
117
130
  ### 3. Verify Current Map
118
131
 
@@ -195,8 +208,8 @@ Mode:
195
208
  - <bootstrap|refresh|intent_repair|continuous_delta|recovery>
196
209
 
197
210
  Hive Lite setup:
198
- - <initialized with hive-lite init / no setup changes / setup repair needed>
199
- - Setup artifacts preserved: <.hive/config.yaml, .gitignore runtime rules, runtime directories, or none>
211
+ - initialized: yes
212
+ - setup changes made by this skill: none
200
213
 
201
214
  Changed map files:
202
215
  - <file or none>
@@ -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,11 +20,10 @@ 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
- Preserve setup artifacts created by `hive-lite init`, including `.hive/config.yaml`, Hive Lite runtime/evidence directories, and `.gitignore` runtime/evidence rules. 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
 
@@ -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.
@@ -35,7 +35,7 @@ hive-lite skills install --agent <codex|claude|gemini>
35
35
 
36
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
- - Bootstrap exception: when Hive Lite map files are missing, this skill may run `hive-lite init` and must preserve setup artifacts created by that command, including `.hive/config.yaml`, runtime/evidence directories, and Hive Lite `.gitignore` entries. Do not delete or revert those artifacts merely because they are outside `.hive/map/`.
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.
39
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.
40
40
  - During preflight, you may help finish or isolate pre-existing work only after explicit user confirmation.
41
41
  - Never discard changes with destructive commands such as `git reset --hard`, `git checkout --`, or forced branch switches.
@@ -67,21 +67,38 @@ Read [input-calibration.md](references/input-calibration.md). Produce:
67
67
 
68
68
  ### 2. Preflight The Worktree
69
69
 
70
- If `.hive/map/project.yaml`, `.hive/map/areas.yaml`, `.hive/map/rules.yaml`, or `.hive/map/validation.yaml` is missing, run:
70
+ Run:
71
71
 
72
72
  ```bash
73
- hive-lite init
73
+ hive-lite status --json
74
74
  ```
75
75
 
76
- Do this automatically; do not ask the user whether to initialize Hive Lite. Initialization is setup work, not the requested product change. Preserve all setup artifacts created by `hive-lite init`; do not remove `.hive/config.yaml` or Hive Lite `.gitignore` entries as cleanup.
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.
77
77
 
78
- 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:
79
79
 
80
- ```bash
81
- 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,不要改应用代码。
82
89
  ```
83
90
 
84
- 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.
85
102
 
86
103
  If the command is unavailable in an older Hive Lite, fall back to `git status --porcelain`.
87
104
 
@@ -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.1",
3
+ "version": "0.1.2",
4
4
  "description": "Local Project Map + Change Control for coding agents.",
5
5
  "keywords": [
6
6
  "codex",
@@ -37,4 +37,4 @@
37
37
  "engines": {
38
38
  "node": ">=16"
39
39
  }
40
- }
40
+ }
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');
@@ -51,11 +52,20 @@ function isHelpFlag(arg) {
51
52
  return arg === '--help' || arg === '-h';
52
53
  }
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
+
54
63
  function printHelp() {
55
64
  console.log(`
56
65
  Hive Lite - local Project Map + Change Control
57
66
 
58
67
  Usage:
68
+ hive-lite version
59
69
  hive-lite init
60
70
  hive-lite doctor
61
71
  hive-lite status [--json] [--all]
@@ -87,6 +97,16 @@ function currentCliCommandArgv() {
87
97
  return [process.execPath, path.resolve(process.argv[1])];
88
98
  }
89
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
+
90
110
  function printInit(result) {
91
111
  console.log('Hive Lite initialized.');
92
112
  console.log(`Repo: ${result.root}`);
@@ -531,6 +551,11 @@ function printWorkspaceStatus(result) {
531
551
  console.log(`Hive State: ${result.hive.state}`);
532
552
  console.log(`Can Start New Requirement: ${result.canStartNewRequirement ? 'yes' : 'no'}`);
533
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
+ }
534
559
  if (result.hive.latestChange) {
535
560
  console.log('');
536
561
  console.log('Latest Change:');
@@ -732,6 +757,11 @@ async function main(argv) {
732
757
  return;
733
758
  }
734
759
 
760
+ if (isVersionArg(command)) {
761
+ printVersion();
762
+ return;
763
+ }
764
+
735
765
  if (subcommand === 'help' || isHelpFlag(subcommand) || isHelpFlag(subsubcommand) || rest.some(isHelpFlag)) {
736
766
  printHelp();
737
767
  return;
@@ -795,6 +825,7 @@ async function main(argv) {
795
825
  const intent = parsed.positional.join(' ').trim();
796
826
  if (!intent) throw new Error('find requires an intent string');
797
827
  const root = requireGitRepo(process.cwd(), 'hive-lite find');
828
+ requireHiveInitialized(root, 'hive-lite find');
798
829
  const result = createContextPacket(root, intent, {
799
830
  ...parsed.flags,
800
831
  cliCommandArgv: currentCliCommandArgv(),
@@ -808,7 +839,8 @@ async function main(argv) {
808
839
  }
809
840
 
810
841
  if (command === 'check') {
811
- requireGitRepo(process.cwd(), 'hive-lite check');
842
+ const root = requireGitRepo(process.cwd(), 'hive-lite check');
843
+ requireHiveInitialized(root, 'hive-lite check');
812
844
  const parsed = parseArgs([subcommand, subsubcommand, ...rest].filter((item) => item !== undefined));
813
845
  const changeId = parsed.positional[0] || null;
814
846
  const result = createOrUpdateChange(process.cwd(), {
@@ -821,7 +853,8 @@ async function main(argv) {
821
853
  }
822
854
 
823
855
  if (command === 'validate') {
824
- requireGitRepo(process.cwd(), 'hive-lite validate');
856
+ const root = requireGitRepo(process.cwd(), 'hive-lite validate');
857
+ requireHiveInitialized(root, 'hive-lite validate');
825
858
  const parsed = parseArgs([subcommand, subsubcommand, ...rest].filter((item) => item !== undefined));
826
859
  if (!parsed.flags.json && !parsed.flags.manual) {
827
860
  parsed.flags.onStart = (item) => {
@@ -837,7 +870,8 @@ async function main(argv) {
837
870
  }
838
871
 
839
872
  if (command === 'accept') {
840
- requireGitRepo(process.cwd(), 'hive-lite accept');
873
+ const root = requireGitRepo(process.cwd(), 'hive-lite accept');
874
+ requireHiveInitialized(root, 'hive-lite accept');
841
875
  const parsed = parseArgs([subcommand, subsubcommand, ...rest].filter((item) => item !== undefined));
842
876
  const result = acceptChange(process.cwd(), parsed.positional[0] || null, parsed.flags);
843
877
  if (parsed.flags.json) console.log(JSON.stringify(result, null, 2));
@@ -868,6 +902,7 @@ async function main(argv) {
868
902
  return;
869
903
  }
870
904
  if (subcommand === 'prompt') {
905
+ requireHiveInitialized(root, 'hive-lite map prompt');
871
906
  const parsed = parseArgs([subsubcommand, ...rest].filter((item) => item !== undefined));
872
907
  const result = createMapPrompt(root, parsed.flags);
873
908
  if (parsed.flags.json) console.log(JSON.stringify(result, null, 2));
@@ -876,10 +911,12 @@ async function main(argv) {
876
911
  }
877
912
  if (subcommand === 'delta') {
878
913
  if (subsubcommand === 'list') {
914
+ requireHiveInitialized(root, 'hive-lite map delta list');
879
915
  printDeltas(allDeltas(root));
880
916
  return;
881
917
  }
882
918
  if (subsubcommand === 'apply') {
919
+ requireHiveInitialized(root, 'hive-lite map delta apply');
883
920
  const parsed = parseArgs(rest);
884
921
  const id = parsed.positional[0];
885
922
  if (!id) throw new Error('map delta apply requires a delta id');
@@ -890,6 +927,7 @@ async function main(argv) {
890
927
  return;
891
928
  }
892
929
  if (subsubcommand === 'reject') {
930
+ requireHiveInitialized(root, 'hive-lite map delta reject');
893
931
  const parsed = parseArgs(rest);
894
932
  const id = parsed.positional[0];
895
933
  if (!id) throw new Error('map delta reject requires a delta 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。保留 hive-lite init 创建的 setup 产物,例如 .hive/config.yaml 和 .gitignore runtime 规则;初始化后只直接编辑 .hive/map/*.yaml。',
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',