@tamai/hub-cli 0.1.12 → 0.1.13
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 +25 -5
- package/commands/task-edit.mjs +114 -0
- package/lib/args.mjs +6 -2
- package/lib/cli.mjs +2 -0
- package/package.json +1 -1
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` / `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
|
|
@@ -312,10 +325,17 @@ GitHub 側には `hub-cli-v*` タグの作成・変更・削除を release 担
|
|
|
312
325
|
|
|
313
326
|
## 配備(Mac mini)
|
|
314
327
|
|
|
315
|
-
|
|
316
|
-
|
|
328
|
+
Mac mini では Hermes(アシタカ)が `hub` を使う。npm の global install で入れ、更新も同じ
|
|
329
|
+
コマンドを手で打つ(自動の配布経路は無い。2026-09-26 に hub-runner とその配備 script を退役した)。
|
|
330
|
+
|
|
331
|
+
```sh
|
|
332
|
+
ssh mini-ts 'bash -lc "npm i -g @tamai/hub-cli@latest && command -v hub && hub --version"'
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
認証ファイル `~/.config/tamai/hub-tasks.env` の置き方は ops repo の `docs/環境 mini(Mac mini).md`。
|
|
317
336
|
repo 直参照のラッパー(`~/.local/bin/hub`)は Mac mini には置かない。PATH 上で先に当たると
|
|
318
|
-
|
|
337
|
+
旧実体を指すため、入れ直したら `command -v hub` と `hub --version` で実体を確かめる
|
|
338
|
+
(2026-09-16 に旧ラッパー `/opt/homebrew/bin/hub` を `hub.wrapper.bak` へ退避して切替済み)。
|
|
319
339
|
|
|
320
340
|
## ライセンス
|
|
321
341
|
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { isConflictError, withGuidance } 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
|
+
if (!isConflictError(error)) throw error;
|
|
89
|
+
if (Object.hasOwn(changes, "body")) throw withGuidance(error, BODY_CONFLICT_GUIDANCE);
|
|
90
|
+
if (attempt === 1) {
|
|
91
|
+
throw withGuidance(error, "再取得後にも競合しました。hub task show で最新の内容を確認してから、もう一度実行してください");
|
|
92
|
+
}
|
|
93
|
+
version = await getTaskVersion(id, api);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const taskEditCommand = {
|
|
100
|
+
name: "edit",
|
|
101
|
+
options: { allowed: [...TASK_EDIT_OPTIONS, "force"], boolean: ["force"] },
|
|
102
|
+
async run({ options, positional, flags, dependencies, api }) {
|
|
103
|
+
const ref = requireSinglePositional(positional, "タスクID");
|
|
104
|
+
if (!TASK_EDIT_OPTIONS.some((name) => flags[name])) {
|
|
105
|
+
throw usageError(`直す項目を指定してください: ${TASK_EDIT_OPTIONS.map((name) => `--${name}`).join(" / ")}`);
|
|
106
|
+
}
|
|
107
|
+
if (flags.force && !flags.project) throw usageError("--force は --project と一緒に指定してください");
|
|
108
|
+
|
|
109
|
+
const changes = await prepareChanges(options, flags, { api, dependencies });
|
|
110
|
+
const id = await resolveTaskIdArg(ref, api, dependencies);
|
|
111
|
+
const payload = await patchWithRetry(api, id, changes);
|
|
112
|
+
printTaskResult(payload, options.json, dependencies.stdout, "task");
|
|
113
|
+
},
|
|
114
|
+
};
|
package/lib/args.mjs
CHANGED
|
@@ -44,6 +44,8 @@ export const TASK_USAGE = `使い方:
|
|
|
44
44
|
hub task show <id> [--json]
|
|
45
45
|
hub task report <id> --note <text> [--json]
|
|
46
46
|
hub task note <id> (--note <text> | --note-file <path>) [--json]
|
|
47
|
+
hub task edit <id> [--title <text>] [--body-file <path>] [--project <name>|none [--force]]
|
|
48
|
+
[--due <YYYY-MM-DD>|none] [--context-ref <path>|none] [--json]
|
|
47
49
|
hub task add <title> [--project <name>] [--force] [--due <YYYY-MM-DD>] [--body-file <path>] [--json]
|
|
48
50
|
hub task new <title> [--project <name>] [--due <YYYY-MM-DD>] [--body-file <path>]
|
|
49
51
|
[--repo-card [<dir>]] [--slug <slug>] [--force] [--operation-id <ULID>] [--json]
|
|
@@ -52,12 +54,14 @@ export const TASK_USAGE = `使い方:
|
|
|
52
54
|
hub task brief <id> [--role implement|review|design] [--worker <name>] [--commits <range>]
|
|
53
55
|
[--note <text> | --note-file <path>] [--out <path>] [--sandboxed] [--json]
|
|
54
56
|
|
|
55
|
-
show / claim / report / note の <id> には記録番号(150 / #150)も指定できる(context_ref が docs/records/150-… のタスクを一覧から引く。番号はrepoごとの採番なので、複数一致は作業ツリーに記録ファイルがある1件で割る。0件・それでも割れない複数一致はエラー)。
|
|
57
|
+
show / claim / report / note / edit の <id> には記録番号(150 / #150)も指定できる(context_ref が docs/records/150-… のタスクを一覧から引く。番号はrepoごとの採番なので、複数一致は作業ツリーに記録ファイルがある1件で割る。0件・それでも割れない複数一致はエラー)。
|
|
56
58
|
hub task new は「D1へ起票 → repoに記録の雛形を作成 → context_ref で紐付け」を1コマンドで行う。
|
|
57
59
|
通信切断時は同じ操作IDで1回再送する。手動再送は失敗時に出た --operation-id <ULID> を指定する。
|
|
58
60
|
記録には status / owner / priority を書かない(状態の正本はD1だけ)。
|
|
59
61
|
--repo-card はリポジトリ相対のディレクトリのみ。context_ref にはリポジトリルート相対のパスが入る。
|
|
60
62
|
--repo-card で題名からslugを作れない場合は、3文字以上のkebab-caseで --slug <slug> が必要(例: --slug project-detail-pc-layout)。
|
|
63
|
+
hub task edit は起票済みタスクのタイトル・本文(全置換)・project・期限・context_ref を直す。none は未記入へ戻す。
|
|
64
|
+
version はCLIが取り直し、409は1回だけ再送する(--body-file を含む更新は再送しない)。owner と status は扱わない。
|
|
61
65
|
hub task audit は done のタスクの context_ref を git と突き合わせ、記録が未コミット・
|
|
62
66
|
未pushのまま done になっていないかを見る(「doneなのに本番に無い」の検出)。
|
|
63
67
|
hub task brief は文脈ゼロのAIへ渡す依頼書をMarkdownで出す。既定はstdout。
|
|
@@ -191,7 +195,7 @@ export const INFRA_USAGE = `使い方:
|
|
|
191
195
|
`;
|
|
192
196
|
|
|
193
197
|
export const USAGE = `使い方:
|
|
194
|
-
hub task <verb> ... タスク操作(new / add / claim / next / show / report / note / list / brief)
|
|
198
|
+
hub task <verb> ... タスク操作(new / add / claim / next / show / edit / report / note / list / audit / brief)
|
|
195
199
|
hub task help
|
|
196
200
|
hub project <verb> ... プロジェクト操作(list / show / create / update / move)
|
|
197
201
|
hub project help
|
package/lib/cli.mjs
CHANGED
|
@@ -53,6 +53,7 @@ import { taskAddCommand } from "../commands/task-add.mjs";
|
|
|
53
53
|
import { taskAuditCommand } from "../commands/task-audit.mjs";
|
|
54
54
|
import { taskBriefCommand } from "../commands/task-brief.mjs";
|
|
55
55
|
import { taskClaimCommand } from "../commands/task-claim.mjs";
|
|
56
|
+
import { taskEditCommand } from "../commands/task-edit.mjs";
|
|
56
57
|
import { taskListCommand } from "../commands/task-list.mjs";
|
|
57
58
|
import { taskNewCommand } from "../commands/task-new.mjs";
|
|
58
59
|
import { taskNextCommand } from "../commands/task-next.mjs";
|
|
@@ -88,6 +89,7 @@ const COMMAND_GROUPS = {
|
|
|
88
89
|
taskAuditCommand,
|
|
89
90
|
taskBriefCommand,
|
|
90
91
|
taskClaimCommand,
|
|
92
|
+
taskEditCommand,
|
|
91
93
|
taskListCommand,
|
|
92
94
|
taskNewCommand,
|
|
93
95
|
taskNextCommand,
|