@tamai/hub-cli 0.1.12 → 0.1.14

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
@@ -67,7 +67,7 @@ hub infra help
67
67
  hub deploy help
68
68
  ```
69
69
 
70
- 動詞は `task` が `new` / `add` / `claim` / `next` / `show` / `report` / `note` / `list` / `audit` / `brief`、
70
+ 動詞は `task` が `new` / `add` / `claim` / `next` / `show` / `edit` / `report` / `accept` / `note` / `list` / `audit` / `brief`、
71
71
  `project` が `list` / `show` / `create` / `update` / `move`、
72
72
  `infra` が `list` / `new` / `show` / `update` / `note` / `link` / `unlink`、
73
73
  `deploy` が `list` / `show` / `link` / `unlink`。
@@ -76,7 +76,7 @@ hub deploy help
76
76
 
77
77
  `help` と `--version` は認証情報なしでも読める。
78
78
 
79
- `show` / `claim` / `report` / `note` の `<id>` には**記録番号**(`150` / `#150`)も渡せる(`context_ref` が `docs/records/150-…` のタスクを一覧から引く。番号は repo ごとの採番なので別 repo と重なることがあり、そのときは今いる作業ツリーに記録ファイルがある方を採り、割り切れなければ候補を出して止まる)。
79
+ `show` / `claim` / `report` / `note` / `edit` の `<id>` には**記録番号**(`150` / `#150`)も渡せる(`context_ref` が `docs/records/150-…` のタスクを一覧から引く。番号は repo ごとの採番なので別 repo と重なることがあり、そのときは今いる作業ツリーに記録ファイルがある方を採り、割り切れなければ候補を出して止まる)。
80
80
 
81
81
  ### `project update` の参照リンクは URL を貼るだけでよい
82
82
 
@@ -246,6 +246,19 @@ hub infra note example.jp --note '…' --operation-id 01M33H236V8MACB2DFR641ATK3
246
246
  作成は通信エラーでも409でも自動再送しない。結果を `show` / `list` で確認してから判断する。
247
247
  削除動詞は作らない。正確なオプションとserver資産へ指定できない項目は `hub infra help` を正本とする。
248
248
 
249
+ ### 起票済みタスクを直す(`hub task edit`)
250
+
251
+ ```bash
252
+ hub task edit 01M3QW0PAMPVYGXWAEV8KGSEMP --title '新しいタイトル'
253
+ hub task edit 196 --due 2026-10-15 --project hub
254
+ hub task edit 196 --context-ref docs/records/196-cli-task-edit.md
255
+ ```
256
+
257
+ タイトル・本文(`--body-file` で全置換)・project・期限・`context_ref` を直す。`none` は未記入へ戻す。
258
+ version は CLI が取り直し、409 は1回だけ取り直して再送する。**本文を含む更新は再送しない**
259
+ (読んだ本文に依存するため)。owner と status は扱わない(claim / report / 看板の領分)。
260
+ doing のタスクは owner しか直せない(API が403を返す)。
261
+
249
262
  ### `--repo-card` の出力先は cwd 基準
250
263
 
251
264
  ```bash
@@ -270,10 +283,26 @@ git root は探すが、出力先の基準にはしない(`context_ref` だけ
270
283
  **解決した出力先を起票前に stderr へ 1 行出す**。確認待ちや自動停止は行わない。
271
284
  `--repo-card <dir>` でディレクトリを明示できる(リポジトリ相対のみ。絶対パスは不可)。
272
285
 
273
- ## done にしない
286
+ ## done にする(`hub task accept`・オーケストレーターだけ)
287
+
288
+ done は「本番へ反映し、本番で検証まで終えた」状態を指す(デプロイを伴わないタスクでも、記録の
289
+ commit と push まで済んでいること)。**ワーカーは `hub task report` まで**で、done にはしない。
274
290
 
275
- `done`(検収)は CLI から行えない。エージェントは `hub task report` までで、
276
- done にするのは人間が dash で行う。done は「本番へ反映し、本番で検証まで終えた」状態を指す。
291
+ オーケストレーターだけは、閉じてよい区分のタスク(`docs/notes/2026-10-16 エージェントによる完了(裁定と実装指示).md`
292
+ §1)を根拠つきで閉じられる。人の確認が要る区分は人が dash で閉じる。
293
+
294
+ ```bash
295
+ HUB_ACTOR=orchestrator hub task accept <id> --verified production --summary "本番で一覧が200を返すことを確かめた" \
296
+ --ref abc1234 --ref docs/records/208-agent-accept.md
297
+ ```
298
+
299
+ - `--verified` は本番で確かめた(`production`)か、デプロイが無い(`no-deploy`)か。`--summary` は1〜2000文字。
300
+ `--ref` は commit・CI の run・記録のパス(1〜500文字・20個まで・繰り返し指定可)。欠けたら HTTP を送らずに止まる
301
+ - API は `HUB_ACTOR` の名乗りを Worker の許可リスト(env `AGENT_ACCEPT_ACTORS`)と突き合わせる。
302
+ 許可されていなければ 403、review でなければ 409。**再送しない**
303
+ - 成功すると結果(status: done)を表示する。経緯には「エージェントが閉じた」と根拠が残り、
304
+ `hub task audit` がエージェントの閉じた done を一覧にする(週1回の抜き取りの入口)
305
+ - 間違えて閉じたら owner が review へ戻して理由を note に残す。成果物の復旧(コードの差し戻し・データの復元)は別の作業
277
306
 
278
307
  ## リリース手順
279
308
 
@@ -312,10 +341,17 @@ GitHub 側には `hub-cli-v*` タグの作成・変更・削除を release 担
312
341
 
313
342
  ## 配備(Mac mini)
314
343
 
315
- `runner/deploy-from-macbook.sh` の手順 3 が `npm i -g @tamai/hub-cli@latest` を実行する
316
- (2026-09-16 に旧ラッパー `/opt/homebrew/bin/hub` を `hub.wrapper.bak` へ退避して切替済み)。
344
+ Mac mini では Hermes(アシタカ)が `hub` を使う。npm の global install で入れ、更新も同じ
345
+ コマンドを手で打つ(自動の配布経路は無い。2026-09-26 に hub-runner とその配備 script を退役した)。
346
+
347
+ ```sh
348
+ ssh mini-ts 'bash -lc "npm i -g @tamai/hub-cli@latest && command -v hub && hub --version"'
349
+ ```
350
+
351
+ 認証ファイル `~/.config/tamai/hub-tasks.env` の置き方は ops repo の `docs/環境 mini(Mac mini).md`。
317
352
  repo 直参照のラッパー(`~/.local/bin/hub`)は Mac mini には置かない。PATH 上で先に当たると
318
- 旧実体を指すため、切り替えたら `command -v hub` と `hub --version` で実体を確かめる。
353
+ 旧実体を指すため、入れ直したら `command -v hub` と `hub --version` で実体を確かめる
354
+ (2026-09-16 に旧ラッパー `/opt/homebrew/bin/hub` を `hub.wrapper.bak` へ退避して切替済み)。
319
355
 
320
356
  ## ライセンス
321
357
 
@@ -0,0 +1,60 @@
1
+ import { cliError, requireSinglePositional, usageError } from "../lib/args.mjs";
2
+ import { ApiError, withGuidance } from "../lib/api.mjs";
3
+ import { printTaskResult } from "../lib/format.mjs";
4
+ import { resolveTaskIdArg } from "../lib/task-ref.mjs";
5
+
6
+ // エージェントによる完了(記録208・`docs/notes/2026-10-16 エージェントによる完了(裁定と実装指示).md`)。
7
+ //
8
+ // **閉じてよいのはオーケストレーターだけ**で、API が `HUB_ACTOR` の名乗りを許可リスト
9
+ // (Worker の env `AGENT_ACCEPT_ACTORS`)と突き合わせる。CLI は根拠(evidence)の形を
10
+ // HTTP より前に検査し、結果を必ず表示する。**再送しない**(done は取り消しの効かない記録になる)。
11
+
12
+ /** `--verified` の語と API の値。CLI はハイフン、API はアンダースコア。 */
13
+ const VERIFIED = { production: "production", "no-deploy": "no_deploy" };
14
+ // API(`dash/src/features/tasks/routes.ts`)の上限と同じ。往復してから400を読むより速く弾く
15
+ const MAX_SUMMARY = 2_000;
16
+ const MAX_REF = 500;
17
+ const MAX_REFS = 20;
18
+
19
+ const FORBIDDEN_GUIDANCE = "この名乗り(HUB_ACTOR)は accept を許可されていません(この操作は再送しません)";
20
+ const CONFLICT_GUIDANCE = "review ではありません(hub task show で今の status を確かめてください)";
21
+
22
+ function guided(error) {
23
+ if (!(error instanceof ApiError)) return error;
24
+ if (error.status === 403) return withGuidance(error, FORBIDDEN_GUIDANCE);
25
+ if (error.status === 409) return withGuidance(error, CONFLICT_GUIDANCE);
26
+ return error;
27
+ }
28
+
29
+ export const taskAcceptCommand = {
30
+ name: "accept",
31
+ options: { allowed: ["verified", "summary", "ref"], repeatable: ["ref"] },
32
+ async run({ options, positional, dependencies, api }) {
33
+ const ref = requireSinglePositional(positional, "タスクID");
34
+ if (options.verified === undefined) throw usageError("--verified production|no-deploy を指定してください");
35
+ const verified = Object.hasOwn(VERIFIED, options.verified) ? VERIFIED[options.verified] : undefined;
36
+ if (verified === undefined) throw usageError("--verified は production か no-deploy です");
37
+ if (!options.summary?.trim()) throw usageError("--summaryを指定してください");
38
+ if (options.summary.length > MAX_SUMMARY) throw usageError(`--summary は${MAX_SUMMARY}文字までです`);
39
+ const refs = options.ref;
40
+ if (refs.length > MAX_REFS) throw usageError(`--ref は${MAX_REFS}個までです`);
41
+ if (refs.some((value) => value.trim() === "" || value.length > MAX_REF)) {
42
+ throw usageError(`--ref は1〜${MAX_REF}文字です`);
43
+ }
44
+ const id = await resolveTaskIdArg(ref, api, dependencies);
45
+
46
+ let payload;
47
+ try {
48
+ payload = await api(`/api/tasks/${encodeURIComponent(id)}/accept`, {
49
+ method: "POST",
50
+ body: JSON.stringify({ evidence: { verified, summary: options.summary, refs } }),
51
+ });
52
+ } catch (error) {
53
+ throw guided(error);
54
+ }
55
+ if (typeof payload?.item?.id !== "string" || payload.item.status !== "done") {
56
+ throw cliError("accept後のAPI応答が不正です(hub task show で status を確かめてください)");
57
+ }
58
+ printTaskResult(payload, options.json, dependencies.stdout, "show");
59
+ },
60
+ };
@@ -1,3 +1,4 @@
1
+ import { withProjectOnLinearGuidance } from "../lib/api.mjs";
1
2
  import { requireSinglePositional } from "../lib/args.mjs";
2
3
  import { printTaskResult } from "../lib/format.mjs";
3
4
  import { resolveTaskProject } from "../lib/records.mjs";
@@ -16,7 +17,12 @@ export const taskAddCommand = {
16
17
  if (project) body.project = project;
17
18
  if (options.due) body.due = options.due;
18
19
  if (options["body-file"]) body.body = await dependencies.readFileImpl(options["body-file"], "utf8");
19
- const payload = await api("/api/tasks", { method: "POST", body: JSON.stringify(body) });
20
+ let payload;
21
+ try {
22
+ payload = await api("/api/tasks", { method: "POST", body: JSON.stringify(body) });
23
+ } catch (error) {
24
+ throw withProjectOnLinearGuidance(error);
25
+ }
20
26
  printTaskResult(payload, options.json, dependencies.stdout, "task");
21
27
  },
22
28
  };
@@ -7,6 +7,55 @@ import {
7
7
  } from "../lib/git.mjs";
8
8
  import { findRepoRoot } from "../lib/records.mjs";
9
9
 
10
+ /**
11
+ * service の accept(記録208)が API に入った日。accept は `updated_at` を進めるので、
12
+ * これより前に最後に更新された done は**エージェントが閉じたものではありえない**。
13
+ * done は数百件あり全件の詳細を引くと重いので、この日以降の done だけ経緯を見る。
14
+ */
15
+ export const AGENT_ACCEPT_SINCE = "2026-10-16";
16
+ const DETAIL_CONCURRENCY = 6;
17
+
18
+ /** done のうち、最後の accepted が `via: "agent"` のもの。経緯を引けなかった件数も返す。 */
19
+ async function agentAccepted(items, api) {
20
+ const candidates = items.filter((item) => typeof item?.id === "string"
21
+ && typeof item.updated_at === "string" && item.updated_at >= AGENT_ACCEPT_SINCE);
22
+ const found = [];
23
+ let failed = 0;
24
+ let next = 0;
25
+ async function worker() {
26
+ while (next < candidates.length) {
27
+ const item = candidates[next];
28
+ next += 1;
29
+ let events;
30
+ try {
31
+ const detail = await api(`/api/tasks/${encodeURIComponent(item.id)}`);
32
+ events = Array.isArray(detail?.events) ? detail.events : null;
33
+ } catch {
34
+ events = null;
35
+ }
36
+ if (events === null) {
37
+ failed += 1;
38
+ continue;
39
+ }
40
+ const accepted = events.filter((event) => event?.kind === "accepted").at(-1);
41
+ if (accepted?.meta?.via !== "agent") continue;
42
+ const evidence = accepted.meta.evidence ?? {};
43
+ found.push({
44
+ id: item.id,
45
+ title: item.title ?? null,
46
+ actor: accepted.actor ?? null,
47
+ at: accepted.at ?? null,
48
+ verified: typeof evidence.verified === "string" ? evidence.verified : null,
49
+ summary: typeof evidence.summary === "string" ? evidence.summary : null,
50
+ refs: Array.isArray(evidence.refs) ? evidence.refs.filter((ref) => typeof ref === "string") : [],
51
+ });
52
+ }
53
+ }
54
+ await Promise.all(Array.from({ length: Math.min(DETAIL_CONCURRENCY, candidates.length) }, worker));
55
+ found.sort((a, b) => String(b.at).localeCompare(String(a.at)));
56
+ return { since: AGENT_ACCEPT_SINCE, checked: candidates.length - failed, failed, items: found };
57
+ }
58
+
10
59
  export const taskAuditCommand = {
11
60
  name: "audit",
12
61
  options: {},
@@ -32,7 +81,11 @@ export const taskAuditCommand = {
32
81
  unpushed: gitState.unpushed !== null,
33
82
  },
34
83
  ...auditDoneTasks(items, gitState),
84
+ agent_accepted: await agentAccepted(items, api),
35
85
  };
86
+ if (report.agent_accepted.failed > 0) {
87
+ dependencies.stderr.write(`警告: done ${report.agent_accepted.failed}件の経緯を取得できず、エージェントが閉じたかを確かめられませんでした。\n`);
88
+ }
36
89
  if (options.json) {
37
90
  dependencies.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
38
91
  return;
@@ -0,0 +1,115 @@
1
+ import { isConflictError, withGuidance, withProjectOnLinearGuidance } from "../lib/api.mjs";
2
+ import { requireSinglePositional, usageError } from "../lib/args.mjs";
3
+ import { printTaskResult } from "../lib/format.mjs";
4
+ import { resolveTaskProject } from "../lib/records.mjs";
5
+ import { resolveTaskIdArg } from "../lib/task-ref.mjs";
6
+
7
+ /**
8
+ * 起票済みタスクの手入力の列を直す(記録196)。API(`PATCH /api/tasks/:id`)と dash のシートは
9
+ * 既に対応していて、CLI だけが無かった。
10
+ *
11
+ * **扱わない列**:
12
+ * - `owner` — service token は PATCH で owner を変えられない(API が403)。担当の付け替えは claim の領分
13
+ * - `status` — 移動・報告・claim の領分(`move` / `report` / `claim`)。done は CLI から行えない
14
+ */
15
+ export const TASK_EDIT_OPTIONS = ["title", "body-file", "project", "due", "context-ref"];
16
+
17
+ /** `none` は「未記入へ戻す」指定(`hub infra update` と同じ語)。 */
18
+ const NONE = "none";
19
+ const DUE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
20
+
21
+ /**
22
+ * 形だけでなく**実在する日付**かまで見る(API の `validDue` と同じ基準)。`2026-02-30` を
23
+ * 通すと GET と PATCH を往復してから 400 になる(Codex レビュー Medium)。
24
+ */
25
+ function isCalendarDate(value) {
26
+ if (!DUE_PATTERN.test(value)) return false;
27
+ const date = new Date(`${value}T00:00:00Z`);
28
+ return !Number.isNaN(date.getTime()) && date.toISOString().slice(0, 10) === value;
29
+ }
30
+
31
+ /**
32
+ * 本文の全置換は**読んだ内容に依存する**ので、409 で自動的に取り直して再送しない。
33
+ * タイトル・期限・project・context_ref は値そのものを置く操作なので、取り直して1回だけ再送する。
34
+ */
35
+ const BODY_CONFLICT_GUIDANCE =
36
+ "本文の置き換えは自動で再送しません。hub task show で最新の本文を確認してから、もう一度実行してください";
37
+
38
+ /** オプションから PATCH の差分を組む。**API を呼ぶ前に**形の誤りを全部ここで止める。 */
39
+ async function prepareChanges(options, flags, { api, dependencies }) {
40
+ const changes = {};
41
+ if (flags.title) {
42
+ const title = options.title.trim();
43
+ if (title === "") throw usageError("--title に空文字は指定できません");
44
+ changes.title = title;
45
+ }
46
+ if (flags.due) {
47
+ const due = options.due.trim();
48
+ if (due === NONE) changes.due = null;
49
+ else if (isCalendarDate(due)) changes.due = due;
50
+ else throw usageError("--due は実在する日付の YYYY-MM-DD か none を指定してください");
51
+ }
52
+ if (flags["context-ref"]) {
53
+ const ref = options["context-ref"].trim();
54
+ if (ref === "") throw usageError("--context-ref に空文字は指定できません(外すときは none)");
55
+ changes.context_ref = ref === NONE ? null : ref;
56
+ }
57
+ if (flags["body-file"]) {
58
+ changes.body = await dependencies.readFileImpl(options["body-file"], "utf8");
59
+ }
60
+ if (flags.project) {
61
+ const project = options.project.trim();
62
+ if (project === "") throw usageError("--project に空文字は指定できません(外すときは none)");
63
+ // 名前の解決(slug → 正式名・未知名は --force)は起票と同じ関数に任せる
64
+ changes.project = project === NONE
65
+ ? null
66
+ : await resolveTaskProject(project, { force: flags.force === true, api, stderr: dependencies.stderr });
67
+ }
68
+ return changes;
69
+ }
70
+
71
+ async function getTaskVersion(id, api) {
72
+ const payload = await api(`/api/tasks/${encodeURIComponent(id)}`);
73
+ const version = payload?.item?.version;
74
+ if (!Number.isInteger(version)) throw usageError("タスクの version を取得できませんでした");
75
+ return version;
76
+ }
77
+
78
+ /** 再送のたびに最新の version で本文を組む。再取得自体の失敗は再送しない。 */
79
+ async function patchWithRetry(api, id, changes) {
80
+ let version = await getTaskVersion(id, api);
81
+ for (let attempt = 0; attempt < 2; attempt += 1) {
82
+ try {
83
+ return await api(`/api/tasks/${encodeURIComponent(id)}`, {
84
+ method: "PATCH",
85
+ body: JSON.stringify({ version, ...changes }),
86
+ });
87
+ } catch (error) {
88
+ // 付け替え先が Linear のプロジェクト(記録207)。version を取り直しても変わらないので再送しない
89
+ if (!isConflictError(error)) throw withProjectOnLinearGuidance(error);
90
+ if (Object.hasOwn(changes, "body")) throw withGuidance(error, BODY_CONFLICT_GUIDANCE);
91
+ if (attempt === 1) {
92
+ throw withGuidance(error, "再取得後にも競合しました。hub task show で最新の内容を確認してから、もう一度実行してください");
93
+ }
94
+ version = await getTaskVersion(id, api);
95
+ }
96
+ }
97
+ return undefined;
98
+ }
99
+
100
+ export const taskEditCommand = {
101
+ name: "edit",
102
+ options: { allowed: [...TASK_EDIT_OPTIONS, "force"], boolean: ["force"] },
103
+ async run({ options, positional, flags, dependencies, api }) {
104
+ const ref = requireSinglePositional(positional, "タスクID");
105
+ if (!TASK_EDIT_OPTIONS.some((name) => flags[name])) {
106
+ throw usageError(`直す項目を指定してください: ${TASK_EDIT_OPTIONS.map((name) => `--${name}`).join(" / ")}`);
107
+ }
108
+ if (flags.force && !flags.project) throw usageError("--force は --project と一緒に指定してください");
109
+
110
+ const changes = await prepareChanges(options, flags, { api, dependencies });
111
+ const id = await resolveTaskIdArg(ref, api, dependencies);
112
+ const payload = await patchWithRetry(api, id, changes);
113
+ printTaskResult(payload, options.json, dependencies.stdout, "task");
114
+ },
115
+ };
@@ -1,5 +1,12 @@
1
1
  import { cliError, requireSinglePositional, usageError } from "../lib/args.mjs";
2
- import { ApiError, describeFailure, isConflictError, withGuidance } from "../lib/api.mjs";
2
+ import {
3
+ ApiError,
4
+ describeFailure,
5
+ isConflictError,
6
+ isProjectOnLinearError,
7
+ withGuidance,
8
+ withProjectOnLinearGuidance,
9
+ } from "../lib/api.mjs";
3
10
  import { taskLines } from "../lib/format.mjs";
4
11
  import { newUlid } from "../lib/ulid.mjs";
5
12
  import {
@@ -28,6 +35,9 @@ async function postTask(api, body) {
28
35
  } catch (error) {
29
36
  // 409は「同じ操作IDが別の内容で使われている」。再送ではないので送り直しを勧めない
30
37
  // ——同じIDを付け直しても結果は変わらず、既存タスクを自分の起票と取り違える
38
+ // 行き先が Linear のプロジェクト(記録207)。操作IDを付け直しても結果は変わらないので、
39
+ // 再送も「--operation-id で送り直す」案内もしない。記録ファイルは起票の後に作るので作られない
40
+ if (isProjectOnLinearError(error)) throw withProjectOnLinearGuidance(error);
31
41
  if (isConflictError(error)) {
32
42
  throw withGuidance(error,
33
43
  `別の操作の id です(操作ID: ${body.id})。\n`
package/lib/api.mjs CHANGED
@@ -16,6 +16,25 @@ export function isConflictError(error) {
16
16
  return error instanceof ApiError && error.payload?.error?.code === "conflict";
17
17
  }
18
18
 
19
+ /**
20
+ * 行き先のプロジェクトがタスクを Linear で管理している(409 `project_on_linear`・記録207)。
21
+ *
22
+ * **競合(`conflict`)とは別物**として扱う。version を取り直しても、同じ操作IDで送り直しても
23
+ * 結果は変わらないので、`add` / `new` / `edit` はこの応答で再送せずに止まる。
24
+ */
25
+ export function isProjectOnLinearError(error) {
26
+ return error instanceof ApiError && error.payload?.error?.code === "project_on_linear";
27
+ }
28
+
29
+ /** 409 `project_on_linear` に添える案内。API の文面(1行目)の後ろに足す。 */
30
+ export const PROJECT_ON_LINEAR_GUIDANCE =
31
+ "このプロジェクトへは hub から起票も付け替えもできません。タスクは Linear で作ってください(この操作は再送しません)";
32
+
33
+ /** 409 `project_on_linear` なら案内を添えて返す。それ以外はそのまま返す。 */
34
+ export function withProjectOnLinearGuidance(error) {
35
+ return isProjectOnLinearError(error) ? withGuidance(error, PROJECT_ON_LINEAR_GUIDANCE) : error;
36
+ }
37
+
19
38
  export function defaultEnvFilePath(homedir = os.homedir()) {
20
39
  return path.join(homedir, ".config", "tamai", "hub-tasks.env");
21
40
  }
package/lib/args.mjs CHANGED
@@ -43,7 +43,10 @@ export const TASK_USAGE = `使い方:
43
43
  hub task next --owner <name> [--json]
44
44
  hub task show <id> [--json]
45
45
  hub task report <id> --note <text> [--json]
46
+ hub task accept <id> --verified production|no-deploy --summary <text> [--ref <text>]... [--json]
46
47
  hub task note <id> (--note <text> | --note-file <path>) [--json]
48
+ hub task edit <id> [--title <text>] [--body-file <path>] [--project <name>|none [--force]]
49
+ [--due <YYYY-MM-DD>|none] [--context-ref <path>|none] [--json]
47
50
  hub task add <title> [--project <name>] [--force] [--due <YYYY-MM-DD>] [--body-file <path>] [--json]
48
51
  hub task new <title> [--project <name>] [--due <YYYY-MM-DD>] [--body-file <path>]
49
52
  [--repo-card [<dir>]] [--slug <slug>] [--force] [--operation-id <ULID>] [--json]
@@ -52,12 +55,14 @@ export const TASK_USAGE = `使い方:
52
55
  hub task brief <id> [--role implement|review|design] [--worker <name>] [--commits <range>]
53
56
  [--note <text> | --note-file <path>] [--out <path>] [--sandboxed] [--json]
54
57
 
55
- show / claim / report / note の <id> には記録番号(150 / #150)も指定できる(context_ref が docs/records/150-… のタスクを一覧から引く。番号はrepoごとの採番なので、複数一致は作業ツリーに記録ファイルがある1件で割る。0件・それでも割れない複数一致はエラー)。
58
+ show / claim / report / note / edit の <id> には記録番号(150 / #150)も指定できる(context_ref が docs/records/150-… のタスクを一覧から引く。番号はrepoごとの採番なので、複数一致は作業ツリーに記録ファイルがある1件で割る。0件・それでも割れない複数一致はエラー)。
56
59
  hub task new は「D1へ起票 → repoに記録の雛形を作成 → context_ref で紐付け」を1コマンドで行う。
57
60
  通信切断時は同じ操作IDで1回再送する。手動再送は失敗時に出た --operation-id <ULID> を指定する。
58
61
  記録には status / owner / priority を書かない(状態の正本はD1だけ)。
59
62
  --repo-card はリポジトリ相対のディレクトリのみ。context_ref にはリポジトリルート相対のパスが入る。
60
63
  --repo-card で題名からslugを作れない場合は、3文字以上のkebab-caseで --slug <slug> が必要(例: --slug project-detail-pc-layout)。
64
+ hub task edit は起票済みタスクのタイトル・本文(全置換)・project・期限・context_ref を直す。none は未記入へ戻す。
65
+ version はCLIが取り直し、409は1回だけ再送する(--body-file を含む更新は再送しない)。owner と status は扱わない。
61
66
  hub task audit は done のタスクの context_ref を git と突き合わせ、記録が未コミット・
62
67
  未pushのまま done になっていないかを見る(「doneなのに本番に無い」の検出)。
63
68
  hub task brief は文脈ゼロのAIへ渡す依頼書をMarkdownで出す。既定はstdout。
@@ -66,6 +71,10 @@ hub task brief は文脈ゼロのAIへ渡す依頼書をMarkdownで出す。既
66
71
  -- 以降はすべて位置引数になる。-- で始まるタイトルは hub task new --project hub -- "--で始まる題" の順で渡す。
67
72
  オプションは --name=value の形でも書ける。値が -- で始まるとき(例 --note='--- 見出し')はこの形で渡す。
68
73
  report / note の長文は約2000字ごとに分割して送る。途中で失敗すると「n件中m件まで送信済み」と出る。
74
+ hub task accept は review のタスクを根拠つきで done にする(オーケストレーターだけ。HUB_ACTOR の名乗りを
75
+ API が許可リストと突き合わせ、許可されていなければ403)。--verified は本番で確かめた(production)か
76
+ デプロイが無い(no-deploy)か。--summary は1〜2000文字、--ref は commit・CI の run・記録のパス(1〜500文字・
77
+ 20個まで・繰り返し指定可)。再送しない。ワーカーは hub task report まで。
69
78
  `;
70
79
 
71
80
  export const PROJECT_USAGE = `使い方:
@@ -191,7 +200,7 @@ export const INFRA_USAGE = `使い方:
191
200
  `;
192
201
 
193
202
  export const USAGE = `使い方:
194
- hub task <verb> ... タスク操作(new / add / claim / next / show / report / note / list / brief)
203
+ hub task <verb> ... タスク操作(new / add / claim / next / show / edit / report / accept / note / list / audit / brief)
195
204
  hub task help
196
205
  hub project <verb> ... プロジェクト操作(list / show / create / update / move)
197
206
  hub project help
@@ -219,7 +228,8 @@ hub task new --repo-card の出力先は**cwd基準**である(gitリポジト
219
228
  例: repo直下なら docs/records/、dash/ で実行すると dash/docs/records/ に書く。
220
229
  解決した出力先は起票前にstderrへ1行出る。確認待ちや自動停止は行わない。
221
230
 
222
- done化(検収)はCLIから行えない。人間がdashで行う。
231
+ done化(検収)は人の owner が dash で行う。オーケストレーターだけは hub task accept で根拠を添えて閉じられる
232
+ (許可リストの名乗りのときだけ。人の確認が要る区分は人が dash で行う)。
223
233
  `;
224
234
 
225
235
  export function cliError(message) {
package/lib/cli.mjs CHANGED
@@ -49,10 +49,12 @@ import { projectListCommand } from "../commands/project-list.mjs";
49
49
  import { projectMoveCommand } from "../commands/project-move.mjs";
50
50
  import { projectShowCommand } from "../commands/project-show.mjs";
51
51
  import { projectUpdateCommand } from "../commands/project-update.mjs";
52
+ import { taskAcceptCommand } from "../commands/task-accept.mjs";
52
53
  import { taskAddCommand } from "../commands/task-add.mjs";
53
54
  import { taskAuditCommand } from "../commands/task-audit.mjs";
54
55
  import { taskBriefCommand } from "../commands/task-brief.mjs";
55
56
  import { taskClaimCommand } from "../commands/task-claim.mjs";
57
+ import { taskEditCommand } from "../commands/task-edit.mjs";
56
58
  import { taskListCommand } from "../commands/task-list.mjs";
57
59
  import { taskNewCommand } from "../commands/task-new.mjs";
58
60
  import { taskNextCommand } from "../commands/task-next.mjs";
@@ -84,10 +86,12 @@ const COMMAND_GROUPS = {
84
86
  task: {
85
87
  usage: TASK_USAGE,
86
88
  commands: commandMap([
89
+ taskAcceptCommand,
87
90
  taskAddCommand,
88
91
  taskAuditCommand,
89
92
  taskBriefCommand,
90
93
  taskClaimCommand,
94
+ taskEditCommand,
91
95
  taskListCommand,
92
96
  taskNewCommand,
93
97
  taskNextCommand,
package/lib/format.mjs CHANGED
@@ -59,6 +59,14 @@ export function projectLines(project, { includeLinks = false } = {}) {
59
59
  lines.push(`children: ${Number(project.children_count ?? 0)}`);
60
60
  }
61
61
  if (project.parent_slug) lines.push(`parent: ${project.parent_slug}`);
62
+ // タスクの置き場(記録207)。owner と service の応答にだけ載る列なので、無ければ出さない。
63
+ // `show` は hub でも出す(「hub のまま」と確かめられる)。一覧は `kind` と同じく既定でないときだけ
64
+ if (project.task_backend === "linear" || (includeLinks && typeof project.task_backend === "string")) {
65
+ lines.push(`task_backend: ${project.task_backend}`);
66
+ if (typeof project.linear_project_id === "string" && project.linear_project_id !== "") {
67
+ lines.push(`linear_project: ${project.linear_project_id}`);
68
+ }
69
+ }
62
70
  if (project.repo) lines.push(`repo: ${project.repo}`);
63
71
  if (project.memory_home) lines.push(`memory: ${project.memory_home}`);
64
72
  if (project.auto_policy && project.auto_policy !== "off") lines.push(`auto: ${project.auto_policy}`);
package/lib/git.mjs CHANGED
@@ -120,11 +120,32 @@ const AUDIT_REASON_LABELS = {
120
120
  unpushed: "記録の変更が origin/main に届いていない(ローカルコミット止まり)",
121
121
  };
122
122
 
123
+ const AGENT_VERIFIED_LABELS = { production: "本番で確認", no_deploy: "デプロイなし" };
124
+
125
+ /**
126
+ * エージェントが閉じた done(記録208)。owner の週1回の抜き取りの入口なので、
127
+ * 記録の検査で問題が無くても必ず出す。
128
+ */
129
+ function agentAcceptedLines(agent) {
130
+ // 0件なら何も足さない(問題なしの1行を崩さない)。経緯を引けなかった件数は stderr の警告に出る
131
+ if (agent === undefined || agent.items.length === 0) return [];
132
+ const lines = [`エージェントが閉じた done: ${agent.items.length}件(${agent.since} 以降に更新された done ${agent.checked}件を確認)`];
133
+ for (const entry of agent.items) {
134
+ const verified = AGENT_VERIFIED_LABELS[entry.verified] ?? entry.verified ?? "?";
135
+ lines.push(`- ${entry.id} ${entry.title ?? ""}`.trimEnd());
136
+ lines.push(` ${entry.at ?? "?"} ${entry.actor ?? "?"}(${verified})${entry.summary ?? ""}`);
137
+ if (entry.refs.length > 0) lines.push(` 参照: ${entry.refs.join("・")}`);
138
+ }
139
+ return lines;
140
+ }
141
+
123
142
  export function formatAuditReport(report) {
124
143
  const skipped = `context_ref なし ${report.skipped_no_context_ref}件`
125
144
  + `・このrepo外の記録 ${report.skipped_other_repo}件は対象外`;
145
+ const agent = agentAcceptedLines(report.agent_accepted);
146
+ const agentBlock = agent.length === 0 ? "" : `\n${agent.join("\n")}\n`;
126
147
  if (report.suspicious.length === 0) {
127
- return `done ${report.checked}件の記録を確認しました(${skipped})。問題は見つかりませんでした。\n`;
148
+ return `done ${report.checked}件の記録を確認しました(${skipped})。問題は見つかりませんでした。\n${agentBlock}`;
128
149
  }
129
150
  const lines = [`done ${report.checked}件のうち ${report.suspicious.length}件が疑わしい(${skipped}):`, ""];
130
151
  for (const entry of report.suspicious) {
@@ -134,5 +155,5 @@ export function formatAuditReport(report) {
134
155
  lines.push("");
135
156
  }
136
157
  lines.push("doneは「本番反映と検証まで終えた」状態です。手元にしか無い変更が残っていないか確認してください。");
137
- return `${lines.join("\n")}\n`;
158
+ return `${lines.join("\n")}\n${agentBlock}`;
138
159
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamai/hub-cli",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "CLI for the hub personal dashboard: D1-backed task board and project registry.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",