@tamai/hub-cli 0.1.16 → 0.1.18

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
@@ -73,6 +73,8 @@ hub deploy help
73
73
  `deploy` が `list` / `show` / `link` / `unlink`。
74
74
  **正確なオプションは常に `--help` を見る**(ここにも、スキルにも写経しない)。
75
75
  全動詞が `--json` を受ける。機械が読むときは必ず `--json` を使い、人向けの整形を parse しない。
76
+ `--json` は API の応答をそのまま出す。タスクの形は `task list` が `{ items: [...] }`、`task show` が `{ item, events }`、
77
+ `task accept` が `{ item }`(`item` は `show` の `item` と同じ形で、`events` は含まない。閉じた結果は `item.status`)。
76
78
 
77
79
  `help` と `--version` は認証情報なしでも読める。
78
80
 
@@ -146,11 +148,13 @@ hub task brief 183 --role review --worker codex1 --out /tmp/brief-183.md --sandb
146
148
  - **台帳の口座欄(`account` / `account_ref` / `note` / `payer` / `holder`)は出ない。**
147
149
  依頼に要らないので素材の段階で落としてあり、`--json` にも現れない。
148
150
  `--out` のファイルの中身も、書く前に認証値の秘匿を通す。
151
+ 依頼書生成では32桁hexのアカウントIDも、本文・JSON・ファイル・警告・失敗の診断出力から秘匿する。
149
152
 
150
153
  `--out` は生成物なので既存ファイルを上書きするが、**git で追跡されているパスには書かない**
151
154
  (記録や指示書の上に依頼書を書かないため)。`--commits` は自由文で、`--role review` で省くと
152
155
  警告が出て「対象は依頼者から受け取る」と書かれる。案件が引けないときは案件の節を省いて警告し、
153
156
  依頼書そのものは出す(看板が引けないときだけ何も出さない)。
157
+ 台帳を取得した後にも案件IDを照合し、不一致・照合失敗なら台帳の小節だけを省いて警告する。
154
158
 
155
159
  ### デプロイ先を読む・案件に紐付ける
156
160
 
@@ -219,7 +223,8 @@ hub infra unlink example.jp # 紐付けを全部外す
219
223
 
220
224
  `--transfer-to` / `--transfer-stage` / `--transfer-due` は移管の進み。段階は
221
225
  `requested` / `awaiting_approval` / `approved` / `rejected` / `cancelled` で、`rejected` と `cancelled` は
222
- `provider` を変えない(移管しなかった)。`--transfer-due` は**時刻を含む** ISO 8601 だけを受ける。
226
+ `provider` を変えない(移管しなかった)。`--transfer-due` は**タイムゾーン(`Z` か `+09:00` の形)つきの**時刻を含む ISO 8601
227
+ (例 `2026-09-26T11:00:00+09:00`)。実在しない日付・タイムゾーンの無い日時は API が 400 を返す。
223
228
  移管の完了は `--provider <移管先> --transfer-to none --transfer-stage none --transfer-due none` を
224
229
  1回で送る(移管先が残ったまま `--provider` を変えると400)。
225
230
  **移管の3項目を含む更新は409で自動再送しない**(`--reason` と同じ扱い。段階は人が申請・承認メールを
@@ -296,6 +301,8 @@ git root は探すが、出力先の基準にはしない(`context_ref` だけ
296
301
  これは現状の挙動で、実際そう使っている。取り違えると起票してしまってからでは戻しにくいので、
297
302
  **解決した出力先を起票前に stderr へ 1 行出す**。確認待ちや自動停止は行わない。
298
303
  `--repo-card <dir>` でディレクトリを明示できる(リポジトリ相対のみ。絶対パスは不可)。
304
+ 出力先の実体がrepo外へ出るsymlinkは起票前に拒否する。repo内へのsymlinkは実体のパスへ保存し、
305
+ `context_ref`もその実体を指すrepo相対パスになる。未作成の子ディレクトリも指定できる。
299
306
 
300
307
  ## done にする(`hub task accept`・オーケストレーターだけ)
301
308
 
@@ -314,10 +321,27 @@ HUB_ACTOR=orchestrator hub task accept <id> --verified production --summary "本
314
321
  `--ref` は commit・CI の run・記録のパス(1〜500文字・20個まで・繰り返し指定可)。欠けたら HTTP を送らずに止まる
315
322
  - API は `HUB_ACTOR` の名乗りを Worker の許可リスト(env `AGENT_ACCEPT_ACTORS`)と突き合わせる。
316
323
  許可されていなければ 403、review でなければ 409。**再送しない**
317
- - 成功すると結果(status: done)を表示する。経緯には「エージェントが閉じた」と根拠が残り、
324
+ - 成功すると結果(status: done)を表示する。`--json` の応答は `{ item }`(`hub task show --json` の `item` と同じ形・
325
+ `events` は含まない)なので、status は `item.status` で読む(`task` というキーは無い)。経緯には「エージェントが閉じた」と根拠が残り、
318
326
  `hub task audit` がエージェントの閉じた done を一覧にする(週1回の抜き取りの入口)
319
327
  - 間違えて閉じたら owner が review へ戻して理由を note に残す。成果物の復旧(コードの差し戻し・データの復元)は別の作業
320
328
 
329
+ ## 間違えたタスクを消す(`hub task delete`・オーケストレーターだけ)
330
+
331
+ 重複や誤起票など、**着手していないタスク**を片付けるための口(記録212)。
332
+
333
+ ```bash
334
+ HUB_ACTOR=orchestrator hub task delete <id> --reason "同じ題で2回起票した(01M… を残す)"
335
+ ```
336
+
337
+ - 消せるのは状態が Inbox・Ready・Iced で、経緯に claim・report・accept・取り込み(imported)が無く、Doing・Review・Done を
338
+ 経ていない(そこで起票・そこへ移動していない)タスクだけ。それ以外は 409
339
+ (作業中は「作業中のタスクは削除できません」)。着手したタスクを消すのは人(owner)が dash で行う
340
+ - `--reason` は1〜500文字で必須。API は `HUB_ACTOR` の名乗りを Worker の許可リスト(env `AGENT_DELETE_ACTORS`)と
341
+ 突き合わせ、許可されていなければ 403。**再送しない**
342
+ - 消す前に1度読み、消したタスク(ID・状態・題・project)と理由を表示する
343
+ - 消したタスクと全経緯は、サーバーの `task_deletions` 表に JSON で写して残る(owner の削除も同じ)。戻すときはここから
344
+
321
345
  ## リリース手順
322
346
 
323
347
  publish は GitHub Actions の **npm trusted publishing**(OIDC)で行う。`NPM_TOKEN` は置かない。
@@ -1,4 +1,3 @@
1
- import { withProjectOnLinearGuidance } from "../lib/api.mjs";
2
1
  import { requireSinglePositional } from "../lib/args.mjs";
3
2
  import { printTaskResult } from "../lib/format.mjs";
4
3
  import { resolveTaskProject } from "../lib/records.mjs";
@@ -17,12 +16,7 @@ export const taskAddCommand = {
17
16
  if (project) body.project = project;
18
17
  if (options.due) body.due = options.due;
19
18
  if (options["body-file"]) body.body = await dependencies.readFileImpl(options["body-file"], "utf8");
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
- }
19
+ const payload = await api("/api/tasks", { method: "POST", body: JSON.stringify(body) });
26
20
  printTaskResult(payload, options.json, dependencies.stdout, "task");
27
21
  },
28
22
  };
@@ -0,0 +1,57 @@
1
+ import { requireSinglePositional, usageError } from "../lib/args.mjs";
2
+ import { ApiError, withGuidance } from "../lib/api.mjs";
3
+ import { resolveTaskIdArg } from "../lib/task-ref.mjs";
4
+
5
+ // タスクの削除(記録212)。
6
+ //
7
+ // **エージェントが消せるのは、着手していない Inbox・Ready・Iced のタスクだけ**で、API が
8
+ // `HUB_ACTOR` の名乗りを許可リスト(Worker の env `AGENT_DELETE_ACTORS`)と突き合わせる。
9
+ // 理由(--reason)は必須。消した行と全経緯はサーバーの `task_deletions` に写して残る。
10
+ // 消す前に1度だけ読み、何を消したかを表示する。**再送しない**(削除は取り消しの効かない操作)。
11
+
12
+ const MAX_REASON = 500;
13
+
14
+ const FORBIDDEN_GUIDANCE = "この名乗り(HUB_ACTOR)はタスクの削除を許可されていません(この操作は再送しません)";
15
+ const CONFLICT_GUIDANCE = "hub task show で今の status と経緯を確かめてください(着手したタスクは人が dash で消します)";
16
+
17
+ function guided(error) {
18
+ if (!(error instanceof ApiError)) return error;
19
+ if (error.status === 403) return withGuidance(error, FORBIDDEN_GUIDANCE);
20
+ if (error.status === 409) return withGuidance(error, CONFLICT_GUIDANCE);
21
+ return error;
22
+ }
23
+
24
+ export const taskDeleteCommand = {
25
+ name: "delete",
26
+ options: { allowed: ["reason"] },
27
+ async run({ options, positional, dependencies, api }) {
28
+ const ref = requireSinglePositional(positional, "タスクID");
29
+ const reason = options.reason;
30
+ if (reason === undefined || reason.trim() === "") throw usageError("--reason(消す理由)を指定してください");
31
+ if (reason.length > MAX_REASON) throw usageError(`--reason は${MAX_REASON}文字までです`);
32
+ const id = await resolveTaskIdArg(ref, api, dependencies);
33
+
34
+ // 消す前に読む(何を消したかを表示するため)。読めなければ消さない
35
+ const before = await api(`/api/tasks/${encodeURIComponent(id)}`);
36
+ const item = before?.item;
37
+ try {
38
+ await api(`/api/tasks/${encodeURIComponent(id)}`, {
39
+ method: "DELETE",
40
+ body: JSON.stringify({ reason }),
41
+ });
42
+ } catch (error) {
43
+ throw guided(error);
44
+ }
45
+ const deleted = { id, title: item?.title ?? null, status: item?.status ?? null, project: item?.project ?? null };
46
+ if (options.json) {
47
+ dependencies.stdout.write(`${JSON.stringify({ deleted, reason }, null, 2)}\n`);
48
+ return;
49
+ }
50
+ dependencies.stdout.write([
51
+ `削除しました: ${id} [${deleted.status ?? "?"}] ${deleted.title ?? ""}`.trimEnd(),
52
+ ...(deleted.project ? [`project: ${deleted.project}`] : []),
53
+ `理由: ${reason}`,
54
+ "(消したタスクと経緯はサーバーの task_deletions に残ります)",
55
+ ].join("\n") + "\n");
56
+ },
57
+ };
@@ -1,4 +1,4 @@
1
- import { isConflictError, withGuidance, withProjectOnLinearGuidance } from "../lib/api.mjs";
1
+ import { isConflictError, withGuidance } from "../lib/api.mjs";
2
2
  import { requireSinglePositional, usageError } from "../lib/args.mjs";
3
3
  import { printTaskResult } from "../lib/format.mjs";
4
4
  import { resolveTaskProject } from "../lib/records.mjs";
@@ -85,8 +85,7 @@ async function patchWithRetry(api, id, changes) {
85
85
  body: JSON.stringify({ version, ...changes }),
86
86
  });
87
87
  } catch (error) {
88
- // 付け替え先が Linear のプロジェクト(記録207)。version を取り直しても変わらないので再送しない
89
- if (!isConflictError(error)) throw withProjectOnLinearGuidance(error);
88
+ if (!isConflictError(error)) throw error;
90
89
  if (Object.hasOwn(changes, "body")) throw withGuidance(error, BODY_CONFLICT_GUIDANCE);
91
90
  if (attempt === 1) {
92
91
  throw withGuidance(error, "再取得後にも競合しました。hub task show で最新の内容を確認してから、もう一度実行してください");
@@ -1,12 +1,5 @@
1
1
  import { cliError, requireSinglePositional, usageError } from "../lib/args.mjs";
2
- import {
3
- ApiError,
4
- describeFailure,
5
- isConflictError,
6
- isProjectOnLinearError,
7
- withGuidance,
8
- withProjectOnLinearGuidance,
9
- } from "../lib/api.mjs";
2
+ import { ApiError, describeFailure, isConflictError, withGuidance } from "../lib/api.mjs";
10
3
  import { taskLines } from "../lib/format.mjs";
11
4
  import { newUlid } from "../lib/ulid.mjs";
12
5
  import {
@@ -35,9 +28,6 @@ async function postTask(api, body) {
35
28
  } catch (error) {
36
29
  // 409は「同じ操作IDが別の内容で使われている」。再送ではないので送り直しを勧めない
37
30
  // ——同じIDを付け直しても結果は変わらず、既存タスクを自分の起票と取り違える
38
- // 行き先が Linear のプロジェクト(記録207)。操作IDを付け直しても結果は変わらないので、
39
- // 再送も「--operation-id で送り直す」案内もしない。記録ファイルは起票の後に作るので作られない
40
- if (isProjectOnLinearError(error)) throw withProjectOnLinearGuidance(error);
41
31
  if (isConflictError(error)) {
42
32
  throw withGuidance(error,
43
33
  `別の操作の id です(操作ID: ${body.id})。\n`
package/lib/api.mjs CHANGED
@@ -16,25 +16,6 @@ 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
-
38
19
  export function defaultEnvFilePath(homedir = os.homedir()) {
39
20
  return path.join(homedir, ".config", "tamai", "hub-tasks.env");
40
21
  }
package/lib/args.mjs CHANGED
@@ -44,6 +44,7 @@ export const TASK_USAGE = `使い方:
44
44
  hub task show <id> [--json]
45
45
  hub task report <id> --note <text> [--json]
46
46
  hub task accept <id> --verified production|no-deploy --summary <text> [--ref <text>]... [--json]
47
+ hub task delete <id> --reason <text> [--json]
47
48
  hub task note <id> (--note <text> | --note-file <path>) [--json]
48
49
  hub task edit <id> [--title <text>] [--body-file <path>] [--project <name>|none [--force]]
49
50
  [--due <YYYY-MM-DD>|none] [--context-ref <path>|none] [--json]
@@ -60,6 +61,7 @@ hub task new は「D1へ起票 → repoに記録の雛形を作成 → context_r
60
61
  通信切断時は同じ操作IDで1回再送する。手動再送は失敗時に出た --operation-id <ULID> を指定する。
61
62
  記録には status / owner / priority を書かない(状態の正本はD1だけ)。
62
63
  --repo-card はリポジトリ相対のディレクトリのみ。context_ref にはリポジトリルート相対のパスが入る。
64
+ 出力先の実体がrepo外へ出るsymlinkは起票前に拒否する。repo内へのsymlinkは実体のパスへ保存する。
63
65
  --repo-card で題名からslugを作れない場合は、3文字以上のkebab-caseで --slug <slug> が必要(例: --slug project-detail-pc-layout)。
64
66
  hub task edit は起票済みタスクのタイトル・本文(全置換)・project・期限・context_ref を直す。none は未記入へ戻す。
65
67
  version はCLIが取り直し、409は1回だけ再送する(--body-file を含む更新は再送しない)。owner と status は扱わない。
@@ -75,6 +77,12 @@ hub task accept は review のタスクを根拠つきで done にする(オ
75
77
  API が許可リストと突き合わせ、許可されていなければ403)。--verified は本番で確かめた(production)か
76
78
  デプロイが無い(no-deploy)か。--summary は1〜2000文字、--ref は commit・CI の run・記録のパス(1〜500文字・
77
79
  20個まで・繰り返し指定可)。再送しない。ワーカーは hub task report まで。
80
+ --json の応答は { item }(item は hub task show --json の item と同じ形。events は含まない。閉じた結果は
81
+ item.status で読む)。hub task show --json は { item, events }、hub task list --json は { items: [...] }。
82
+ hub task delete は間違って起票したタスクを消す(オーケストレーターだけ。HUB_ACTOR の名乗りを API が
83
+ 許可リストと突き合わせる)。消せるのは着手していない Inbox・Ready・Iced のタスク(claim・report・accept・
84
+ 取り込みの経緯が無く、Doing・Review・Done を経ていないもの)だけで、それ以外は409。--reason は1〜500文字で必須。消したタスクと経緯はサーバーの
85
+ task_deletions に残る。消す前に1度読んで何を消したかを表示する。再送しない。
78
86
  `;
79
87
 
80
88
  export const PROJECT_USAGE = `使い方:
@@ -178,7 +186,8 @@ export const INFRA_USAGE = `使い方:
178
186
  **--auto-renew は別の軸**で、特典でも on には化けない(確認できた更新状態を書く)。
179
187
  --transfer-to / --transfer-stage / --transfer-due は移管の進み。段階は
180
188
  requested / awaiting_approval / approved / rejected / cancelled。
181
- --transfer-due は時刻を含むISO 8601(例 2026-09-26T11:00:00+09:00)。日付だけは受け付けない。
189
+ --transfer-due はタイムゾーン(Z か +09:00 の形)つきの時刻を含む ISO 8601
190
+ (例 2026-09-26T11:00:00+09:00)。実在しない日付・タイムゾーンの無い日時は API が 400 を返す。
182
191
  移管の完了は「--provider <移管先> --transfer-to none --transfer-stage none --transfer-due none」を
183
192
  1回で送る(移管先が残ったまま --provider を変えると400)。
184
193
  **移管の3項目を含む更新は409で自動再送しない**(--reason と同じ。段階は人が外の出来事を
@@ -214,7 +223,7 @@ export const BOOKMARK_USAGE = `使い方:
214
223
  `;
215
224
 
216
225
  export const USAGE = `使い方:
217
- hub task <verb> ... タスク操作(new / add / claim / next / show / edit / report / accept / note / list / audit / brief)
226
+ hub task <verb> ... タスク操作(new / add / claim / next / show / edit / report / accept / delete / note / list / audit / brief)
218
227
  hub task help
219
228
  hub project <verb> ... プロジェクト操作(list / show / create / update / move)
220
229
  hub project help
package/lib/brief.mjs CHANGED
@@ -222,9 +222,11 @@ function pickLink(link) {
222
222
  * 案件の素材。**引けなければ null を返して warnings へ積む**(依頼書そのものは出す)。
223
223
  * 看板の本文が一番大事なので、周辺の素材の失敗で1枚ごと止めない(`resolveTaskProject` と同じ理屈)。
224
224
  */
225
- async function collectProject(projectName, api, warnings) {
226
- if (projectName === null) {
227
- warnings.push("看板に案件が無いので案件の節を省きました");
225
+ async function collectProject(projectId, projectName, api, warnings) {
226
+ if (projectId === null) {
227
+ warnings.push(projectName === null
228
+ ? "看板に案件が無いので案件の節を省きました"
229
+ : `案件「${oneLine(projectName)}」のIDが無いので案件の節を省きました`);
228
230
  return null;
229
231
  }
230
232
 
@@ -238,7 +240,7 @@ async function collectProject(projectName, api, warnings) {
238
240
  return null;
239
241
  }
240
242
 
241
- const found = items.find((entry) => entry?.name === projectName);
243
+ const found = items.find((entry) => entry?.id === projectId);
242
244
  if (found === undefined || typeof found?.slug !== "string") {
243
245
  warnings.push(`案件「${oneLine(projectName)}」が一覧に無いので案件の節を省きました`);
244
246
  return null;
@@ -252,13 +254,27 @@ async function collectProject(projectName, api, warnings) {
252
254
  return null;
253
255
  }
254
256
  const item = detail?.item ?? found;
257
+ // 一覧の取得後に同じslugが作り直されても、別案件の内容は使わない。
258
+ if (item.id !== projectId) {
259
+ warnings.push("案件の詳細のIDが看板と一致しないので案件の節を省きました");
260
+ return null;
261
+ }
255
262
 
256
263
  let assets = [];
257
264
  try {
258
265
  const payload = await api(
259
266
  `/api/infra/assets?project=${encodeURIComponent(found.slug)}&management=all`,
260
267
  );
261
- assets = Array.isArray(payload?.items) ? payload.items.map(pickAsset) : [];
268
+ const candidates = Array.isArray(payload?.items) ? payload.items : [];
269
+ if (candidates.length > 0) {
270
+ // 台帳はslugでしか絞れず、projects[]にもIDが無い。取得の間にslugが
271
+ // 再利用されていないか、取得後の詳細IDで確かめてから台帳を採用する。
272
+ const current = await api(`/api/projects/${encodeURIComponent(found.slug)}`);
273
+ if (current?.item?.id !== projectId) {
274
+ throw cliError("台帳取得後の案件IDが看板と一致しません");
275
+ }
276
+ assets = candidates.map(pickAsset);
277
+ }
262
278
  } catch (error) {
263
279
  warnings.push(`台帳を引けなかったので台帳の小節を省きました(${describeFailure(error)})`);
264
280
  }
@@ -333,13 +349,14 @@ export async function collectBrief({ ref, id, api, dependencies, options, versio
333
349
  owner: textOrNull(item.owner),
334
350
  due: textOrNull(item.due),
335
351
  project: textOrNull(item.project),
352
+ project_id: textOrNull(item.project_id),
336
353
  context_ref: contextRef,
337
354
  record_number: recordNumberFromContextRef(contextRef),
338
355
  body: typeof item.body === "string" ? item.body : "",
339
356
  reports,
340
357
  };
341
358
 
342
- const project = await collectProject(task.project, api, warnings);
359
+ const project = await collectProject(task.project_id, task.project, api, warnings);
343
360
  const repo = await collectRepo(contextRef, dependencies);
344
361
 
345
362
  const fromBody = uniqueInOrder(extractDocPaths(task.body));
package/lib/cli.mjs CHANGED
@@ -55,6 +55,7 @@ import { projectMoveCommand } from "../commands/project-move.mjs";
55
55
  import { projectShowCommand } from "../commands/project-show.mjs";
56
56
  import { projectUpdateCommand } from "../commands/project-update.mjs";
57
57
  import { taskAcceptCommand } from "../commands/task-accept.mjs";
58
+ import { taskDeleteCommand } from "../commands/task-delete.mjs";
58
59
  import { taskAddCommand } from "../commands/task-add.mjs";
59
60
  import { taskAuditCommand } from "../commands/task-audit.mjs";
60
61
  import { taskBriefCommand } from "../commands/task-brief.mjs";
@@ -67,6 +68,7 @@ import { taskNoteCommand } from "../commands/task-note.mjs";
67
68
  import { taskReportCommand } from "../commands/task-report.mjs";
68
69
  import { taskShowCommand } from "../commands/task-show.mjs";
69
70
  import { defaultRunGit } from "./git.mjs";
71
+ import { redactAccountIds } from "./brief.mjs";
70
72
  import { packageVersion } from "./version.mjs";
71
73
 
72
74
  export { packageVersion } from "./version.mjs";
@@ -95,6 +97,7 @@ const COMMAND_GROUPS = {
95
97
  taskAddCommand,
96
98
  taskAuditCommand,
97
99
  taskBriefCommand,
100
+ taskDeleteCommand,
98
101
  taskClaimCommand,
99
102
  taskEditCommand,
100
103
  taskListCommand,
@@ -191,8 +194,15 @@ export async function runCli(argv, overrides = {}) {
191
194
  // `--json` の stdout にも出ないようにする。コマンド側に散らすと通し忘れるので、
192
195
  // stdout / stderr を包んで「書くもの全部」を通す。
193
196
  const redaction = { config: null };
197
+ // briefだけはアカウントIDも秘匿する。周辺APIの警告と、共通catchへ流れる取得失敗も
198
+ // 同じ出口を通す(通常のinfra show等のAPI応答は加工しない)。
199
+ const isBrief = argv[0] === "task" && argv[1] === "brief";
200
+ const redact = (text) => {
201
+ const safe = redactSecrets(text, redaction.config);
202
+ return isBrief ? redactAccountIds(safe) : safe;
203
+ };
194
204
  const guarded = (stream) => ({
195
- write: (text) => stream.write(redactSecrets(text, redaction.config)),
205
+ write: (text) => stream.write(redact(text)),
196
206
  });
197
207
 
198
208
  const dependencies = {
@@ -214,7 +224,7 @@ export async function runCli(argv, overrides = {}) {
214
224
  // **出口を通らない経路のための同じ関数**(記録183)。`hub task brief --out` が書くファイルは
215
225
  // stdout / stderr を通らないので、コマンドが書く直前に自分で通す。config はコマンドから
216
226
  // 見えないため、ここで閉じ込めて渡す。**新しい出力先を足すときだけ使うこと。**
217
- redact: (text) => redactSecrets(text, redaction.config),
227
+ redact,
218
228
  };
219
229
 
220
230
  try {
package/lib/format.mjs CHANGED
@@ -59,14 +59,6 @@ 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
- }
70
62
  if (project.repo) lines.push(`repo: ${project.repo}`);
71
63
  if (project.memory_home) lines.push(`memory: ${project.memory_home}`);
72
64
  if (project.auto_policy && project.auto_policy !== "off") lines.push(`auto: ${project.auto_policy}`);
package/lib/records.mjs CHANGED
@@ -58,7 +58,7 @@ function formatRecordNumber(number) {
58
58
  export function recordTemplate({ taskId, title }) {
59
59
  return `---
60
60
  task_id: ${taskId}
61
- title: ${title}
61
+ title: ${JSON.stringify(String(title))}
62
62
  related_commits: []
63
63
  ---
64
64
 
@@ -126,19 +126,50 @@ export async function findRepoRoot(startDir, statImpl) {
126
126
  }
127
127
  }
128
128
 
129
+ /** 未作成の子だけを外し、実在する祖先を実体化する。解決できないsymlinkは拒否する。 */
130
+ async function realRecordDirectory(dir, dependencies) {
131
+ const missing = [];
132
+ let current = dir;
133
+ for (;;) {
134
+ let entry;
135
+ try {
136
+ entry = await dependencies.lstatImpl(current);
137
+ } catch (error) {
138
+ if (error?.code !== "ENOENT") throw error;
139
+ const parent = path.dirname(current);
140
+ if (parent === current) throw error;
141
+ missing.unshift(path.basename(current));
142
+ current = parent;
143
+ continue;
144
+ }
145
+ // realpathのENOENTを「未作成」と扱うと、壊れたsymlinkからrepo外へ出られる。
146
+ const real = await dependencies.realpathImpl(current);
147
+ const directory = entry.isSymbolicLink() ? await dependencies.statImpl(current) : entry;
148
+ if (!directory.isDirectory()) throw cliError(`記録の出力先がディレクトリではありません: ${current}`);
149
+ return path.join(real, ...missing);
150
+ }
151
+ }
152
+
129
153
  export async function resolveRecordTarget(dir, dependencies) {
130
154
  if (path.isAbsolute(dir)) {
131
155
  throw cliError("--repo-card にはリポジトリ相対のディレクトリを指定してください(絶対パスは不可)");
132
156
  }
133
- const root = await findRepoRoot(dependencies.cwd(), dependencies.statImpl);
134
- if (root === null) {
157
+ const repoRoot = await findRepoRoot(dependencies.cwd(), dependencies.statImpl);
158
+ if (repoRoot === null) {
135
159
  throw cliError("gitリポジトリの中で実行してください(.gitが見つかりません)");
136
160
  }
137
- const absoluteDir = path.resolve(dependencies.cwd(), dir);
138
- const relativeDir = path.relative(root, absoluteDir).split(path.sep).join("/");
139
- if (relativeDir.startsWith("../")) {
161
+ const requested = path.resolve(dependencies.cwd(), dir);
162
+ const relativeDir = path.relative(repoRoot, requested).split(path.sep).join("/");
163
+ if (relativeDir === ".." || relativeDir.startsWith("../")) {
140
164
  throw cliError(`記録の出力先がリポジトリの外です: ${relativeDir}`);
141
165
  }
166
+ // root側も実体化し、macOSの/tmpや/varなどの別名と同じ基準で比較する。
167
+ const root = await dependencies.realpathImpl(repoRoot);
168
+ const absoluteDir = await realRecordDirectory(requested, dependencies);
169
+ const realRelative = path.relative(root, absoluteDir).split(path.sep).join("/");
170
+ if (realRelative === ".." || realRelative.startsWith("../")) {
171
+ throw cliError(`記録の出力先の実体がリポジトリの外です: ${relativeDir}`);
172
+ }
142
173
  return { root, absoluteDir };
143
174
  }
144
175
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamai/hub-cli",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "CLI for the hub personal dashboard: D1-backed task board and project registry.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",