@d86e/hive-panel 0.5.0 → 1.0.1

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
@@ -88,11 +88,14 @@ hidden. One process serves one repository.
88
88
  ## When the repository is not initialised
89
89
 
90
90
  `GET /api/snapshot` always answers `200`. Its `initialised` field turns `true`
91
- once git has a ref under `refs/hive/v1` (the ref itself or a sub-ref such as
92
- `refs/hive/v1/mode`). While it is `false` the server does not run the Hive
93
- CLIs: `board` and `tasks` are `[]`, `stats` is `null` and the page shows the
94
- "Initialise Hive" pane. That lets a launcher watch a repository from "not
95
- initialised" to ready without treating it as an error.
91
+ when either `hive init` has written its marker file (`.hive/roles.yaml` or
92
+ `.hive/config.json`) or git has a ref under `refs/hive/v1` (the ref itself or a
93
+ sub-ref such as `refs/hive/v1/mode`). `hive init` itself writes no refs, so the
94
+ marker files are what flip the page right after initialising. While it is
95
+ `false` the server does not run the Hive CLIs: `board` and `tasks` are `[]`,
96
+ `stats` is `null` and the page shows the "Initialise Hive" pane. That lets a
97
+ launcher watch a repository from "not initialised" to ready without treating it
98
+ as an error.
96
99
 
97
100
  ## Write mode
98
101
 
package/README.zh-CN.md CHANGED
@@ -72,7 +72,7 @@ N 条经验」的经验读取行),还有该状态可用的动作。宿主能
72
72
 
73
73
  ## 仓库还没初始化时
74
74
 
75
- `GET /api/snapshot` 永远返回 `200`。`initialised` 在 git 里出现 `refs/hive/v1` 下的 ref(ref 本身,或像 `refs/hive/v1/mode` 这样的子 ref)之后变成 `true`。在它是 `false` 时,服务不去跑 Hive CLI:`board` 和 `tasks` 是 `[]`、`stats` 是 `null`,页面显示「初始化 Hive」面板。这样启动器可以从「还没初始化」一直观察到就绪,而不用把中间状态当成错误。
75
+ `GET /api/snapshot` 永远返回 `200`。`initialised` 在下列任一条件成立时为 `true`:`hive init` 已经写出标记文件(`.hive/roles.yaml` 或 `.hive/config.json`),或 git 里出现 `refs/hive/v1` 下的 ref(ref 本身,或像 `refs/hive/v1/mode` 这样的子 ref)。`hive init` 本身不写 ref,所以初始化完成后立即靠标记文件把页面切到就绪。在它是 `false` 时,服务不去跑 Hive CLI:`board` 和 `tasks` 是 `[]`、`stats` 是 `null`,页面显示「初始化 Hive」面板。这样启动器可以从「还没初始化」一直观察到就绪,而不用把中间状态当成错误。
76
76
 
77
77
  ## 写模式
78
78
 
package/SPEC.md CHANGED
@@ -38,10 +38,18 @@ GET /api/snapshot
38
38
 
39
39
  A missing CLI yields an empty array or null; the page degrades, it never fails.
40
40
 
41
- `initialised` is true once git has a ref under `refs/hive/v1` (the ref itself or a
42
- sub-ref such as `refs/hive/v1/mode`). While it is false the server does not spawn
43
- the CLIs: `board` and `tasks` are `[]`, `stats` is `null`, and the response is
44
- still `200` — never `404` — so a launcher can poll until `hive init` lands.
41
+ `initialised` is true when **either** signal is present:
42
+
43
+ - git has a ref under `refs/hive/v1` (the ref itself or a sub-ref such as
44
+ `refs/hive/v1/mode`), or
45
+ - `hive init` has written its marker file: `.hive/roles.yaml` or `.hive/config.json`.
46
+
47
+ `hive init` writes only `.hive/` files and git hooks — refs appear on the first
48
+ board/mode/task write — so the markers are checked as well; otherwise a freshly
49
+ initialised repository stayed "uninitialised" until something else wrote a ref.
50
+ While `initialised` is false the server does not spawn the CLIs: `board` and
51
+ `tasks` are `[]`, `stats` is `null`, and the response is still `200` — never
52
+ `404` — so a launcher can poll until `hive init` lands.
45
53
 
46
54
  ## 3. Health
47
55
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d86e/hive-panel",
3
- "version": "0.5.0",
3
+ "version": "1.0.1",
4
4
  "description": "A read-only board for a Hive swarm: agents, task lanes and the event tail, served from the refs and files you already have.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/data.js CHANGED
@@ -28,10 +28,29 @@ export function readEvents(repo, limit = 80) {
28
28
  }).filter(Boolean).reverse();
29
29
  }
30
30
 
31
- /** True once Hive has written anything under refs/hive/v1 (the ref itself or a sub-ref). */
31
+ /**
32
+ * Files `hive init` writes before any git ref exists. Either one is enough to
33
+ * call the repository initialised: the refs under refs/hive/v1 only appear on
34
+ * the first board/mode/task write, which can be much later.
35
+ */
36
+ export const INIT_MARKERS = [
37
+ path.join(".hive", "roles.yaml"),
38
+ path.join(".hive", "config.json"),
39
+ ];
40
+
41
+ /**
42
+ * True once `hive init` has written its `.hive/` marker files, or git has a ref
43
+ * under refs/hive/v1 (the ref itself or a sub-ref such as refs/hive/v1/mode).
44
+ * Checking only the refs kept a just-initialised repository (and the page) on
45
+ * the "Initialise Hive" pane until something else wrote a ref.
46
+ *
47
+ * @param {string} repo - repository root.
48
+ * @returns {boolean} whether the repository counts as Hive-initialised.
49
+ */
32
50
  export function isInitialised(repo) {
33
51
  const result = run("git", ["for-each-ref", "--format=%(refname)", "refs/hive/v1"], repo);
34
- return result.code === 0 && result.stdout.trim() !== "";
52
+ if (result.code === 0 && result.stdout.trim() !== "") return true;
53
+ return INIT_MARKERS.some((marker) => fs.existsSync(path.join(repo, marker)));
35
54
  }
36
55
 
37
56
  export function snapshot(repo, env = process.env) {