hive-tasks 1.1.0 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
5
5
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [1.2.0] - 2026-12-04
8
+
9
+ ### Added
10
+
11
+ - hive-tasks stats [--json]: counts by state and role, plus the oldest pending card.
12
+ - Resource keys: scope entries may be any stable string (resource:port:3000,
13
+ resource:db:dev), so non-file shared resources are leased exactly like files.
14
+
7
15
  ## [1.1.0] - 2026-12-03
8
16
 
9
17
  ### Added
package/README.md CHANGED
@@ -78,6 +78,28 @@ token-tests-ba66 pending tester token tests
78
78
 
79
79
  Exit codes: 0 done, 1 internal error, 2 refused (already claimed, wrong state, dependency missing, mode freeze, path busy).
80
80
 
81
+ ## Resource keys
82
+
83
+ scope entries are usually paths, but the lease layer does not care: any stable string
84
+ works. Use a prefix for shared things that are not files:
85
+
86
+ ~~~bash
87
+ hive-tasks add --title "run the dev server" --scope src/web --scope resource:port:3000
88
+ hive-tasks add --title "migrate" --scope resource:db:dev
89
+ ~~~
90
+
91
+ Two cards that name the same resource cannot be claimed at the same time, which is the
92
+ same guarantee files get. Nothing else is required: no daemon watches ports.
93
+
94
+ ## Stats
95
+
96
+ ~~~bash
97
+ hive-tasks stats
98
+ hive-tasks stats --json
99
+ ~~~
100
+
101
+ Counts by state and role, plus the oldest pending card.
102
+
81
103
  ## How a claim works
82
104
 
83
105
  1. the card CAS moves pending -> claimed in the task tree (one winner);
@@ -115,7 +137,7 @@ $ hive-tasks done auth-takes-an-object-dea2 # records resultCommit
115
137
  When hive mode is freeze, ready returns only cards tagged fix, so the hotfix can run while
116
138
  the pipeline is red. Everything else waits.
117
139
 
118
- ## Where it fits
140
+ ## Works with
119
141
 
120
142
  | Project | Question |
121
143
  | --- | --- |
package/README.zh-CN.md CHANGED
@@ -78,6 +78,26 @@ token-tests-ba66 pending tester token 测试
78
78
 
79
79
  退出码:0 成功,1 内部错误,2 被拒(已被认领、状态不对、依赖缺失、模式 freeze、路径忙)。
80
80
 
81
+ ## 资源 key
82
+
83
+ scope 里通常放路径,但租约层并不关心内容:任何稳定字符串都行。共享资源用前缀表达:
84
+
85
+ ~~~bash
86
+ hive-tasks add --title "起 dev server" --scope src/web --scope resource:port:3000
87
+ hive-tasks add --title "跑迁移" --scope resource:db:dev
88
+ ~~~
89
+
90
+ 两张卡写了同一个资源,就不可能同时被认领——和文件拿到的是同一种保证。不需要额外的东西:没有守护进程去盯端口。
91
+
92
+ ## 统计
93
+
94
+ ~~~bash
95
+ hive-tasks stats
96
+ hive-tasks stats --json
97
+ ~~~
98
+
99
+ 按状态和角色计数,外加最老的 pending 卡。
100
+
81
101
  ## claim 怎么走
82
102
 
83
103
  1. 卡片 CAS 把 pending 推到 claimed(唯一赢家);
@@ -111,7 +131,7 @@ $ hive-tasks done auth-takes-an-object-dea2 # 只记录 resultComm
111
131
 
112
132
  hive 处于 freeze 模式时,ready 只返回带 fix 标签的卡,让热修能跑、其余等待。
113
133
 
114
- ## 和另外两块的关系
134
+ ## 和谁配合
115
135
 
116
136
  | 项目 | 回答的问题 |
117
137
  | --- | --- |
package/SPEC.md CHANGED
@@ -77,7 +77,7 @@ git update-ref refs/hive/v1/tasks <new-tree> <old-tree>
77
77
  | --- | --- |
78
78
  | goal | what the worker should achieve; free text, no format |
79
79
  | role | who may claim: a role name the team agrees on (coder, tester, reviewer, ...) |
80
- | scope | paths the task is expected to touch; used to claim hive leases |
80
+ | scope | paths or resource keys the task expects to touch; used for hive leases. A resource key is any stable string such as resource:port:3000 |
81
81
  | after | ids that must be done before this becomes ready |
82
82
  | state | see below |
83
83
  | owner | agent id while claimed |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hive-tasks",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Task cards for agent teams: one git tree behind one ref, with a state machine, dependencies and hive leases.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -334,6 +334,24 @@ function run(argv) {
334
334
  return printTask(readTask(repo, id), options.json);
335
335
  }
336
336
 
337
+ if (command === "stats") {
338
+ const items = board(repo);
339
+ const byState = {};
340
+ const byRole = {};
341
+ let oldest = null;
342
+ for (const task of items) {
343
+ byState[task.state] = (byState[task.state] || 0) + 1;
344
+ byRole[task.role] = (byRole[task.role] || 0) + 1;
345
+ if (task.state === "pending" && (!oldest || task.createdAt < oldest.createdAt)) oldest = task;
346
+ }
347
+ const summary = { total: items.length, byState, byRole, oldestPending: oldest ? { id: oldest.id, createdAt: oldest.createdAt } : null };
348
+ if (options.json) return process.stdout.write(JSON.stringify(summary, null, 2) + "\n");
349
+ process.stdout.write("cards: " + summary.total + "\n");
350
+ for (const [state, count] of Object.entries(byState)) process.stdout.write(" " + state.padEnd(8) + count + "\n");
351
+ if (oldest) process.stdout.write("oldest pending: " + oldest.id + " (" + oldest.createdAt + ")\n");
352
+ return;
353
+ }
354
+
337
355
  fail("unknown command: " + command, 2);
338
356
  }
339
357