@tamai/hub-cli 0.1.16 → 0.1.17
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 +16 -0
- package/commands/task-delete.mjs +57 -0
- package/lib/args.mjs +6 -1
- package/lib/cli.mjs +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -318,6 +318,22 @@ HUB_ACTOR=orchestrator hub task accept <id> --verified production --summary "本
|
|
|
318
318
|
`hub task audit` がエージェントの閉じた done を一覧にする(週1回の抜き取りの入口)
|
|
319
319
|
- 間違えて閉じたら owner が review へ戻して理由を note に残す。成果物の復旧(コードの差し戻し・データの復元)は別の作業
|
|
320
320
|
|
|
321
|
+
## 間違えたタスクを消す(`hub task delete`・オーケストレーターだけ)
|
|
322
|
+
|
|
323
|
+
重複や誤起票など、**着手していないタスク**を片付けるための口(記録212)。
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
HUB_ACTOR=orchestrator hub task delete <id> --reason "同じ題で2回起票した(01M… を残す)"
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
- 消せるのは状態が Inbox・Ready・Iced で、経緯に claim・report・accept・取り込み(imported)が無く、Doing・Review・Done を
|
|
330
|
+
経ていない(そこで起票・そこへ移動していない)タスクだけ。それ以外は 409
|
|
331
|
+
(作業中は「作業中のタスクは削除できません」)。着手したタスクを消すのは人(owner)が dash で行う
|
|
332
|
+
- `--reason` は1〜500文字で必須。API は `HUB_ACTOR` の名乗りを Worker の許可リスト(env `AGENT_DELETE_ACTORS`)と
|
|
333
|
+
突き合わせ、許可されていなければ 403。**再送しない**
|
|
334
|
+
- 消す前に1度読み、消したタスク(ID・状態・題・project)と理由を表示する
|
|
335
|
+
- 消したタスクと全経緯は、サーバーの `task_deletions` 表に JSON で写して残る(owner の削除も同じ)。戻すときはここから
|
|
336
|
+
|
|
321
337
|
## リリース手順
|
|
322
338
|
|
|
323
339
|
publish は GitHub Actions の **npm trusted publishing**(OIDC)で行う。`NPM_TOKEN` は置かない。
|
|
@@ -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
|
+
};
|
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]
|
|
@@ -75,6 +76,10 @@ hub task accept は review のタスクを根拠つきで done にする(オ
|
|
|
75
76
|
API が許可リストと突き合わせ、許可されていなければ403)。--verified は本番で確かめた(production)か
|
|
76
77
|
デプロイが無い(no-deploy)か。--summary は1〜2000文字、--ref は commit・CI の run・記録のパス(1〜500文字・
|
|
77
78
|
20個まで・繰り返し指定可)。再送しない。ワーカーは hub task report まで。
|
|
79
|
+
hub task delete は間違って起票したタスクを消す(オーケストレーターだけ。HUB_ACTOR の名乗りを API が
|
|
80
|
+
許可リストと突き合わせる)。消せるのは着手していない Inbox・Ready・Iced のタスク(claim・report・accept・
|
|
81
|
+
取り込みの経緯が無く、Doing・Review・Done を経ていないもの)だけで、それ以外は409。--reason は1〜500文字で必須。消したタスクと経緯はサーバーの
|
|
82
|
+
task_deletions に残る。消す前に1度読んで何を消したかを表示する。再送しない。
|
|
78
83
|
`;
|
|
79
84
|
|
|
80
85
|
export const PROJECT_USAGE = `使い方:
|
|
@@ -214,7 +219,7 @@ export const BOOKMARK_USAGE = `使い方:
|
|
|
214
219
|
`;
|
|
215
220
|
|
|
216
221
|
export const USAGE = `使い方:
|
|
217
|
-
hub task <verb> ... タスク操作(new / add / claim / next / show / edit / report / accept / note / list / audit / brief)
|
|
222
|
+
hub task <verb> ... タスク操作(new / add / claim / next / show / edit / report / accept / delete / note / list / audit / brief)
|
|
218
223
|
hub task help
|
|
219
224
|
hub project <verb> ... プロジェクト操作(list / show / create / update / move)
|
|
220
225
|
hub project help
|
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";
|
|
@@ -95,6 +96,7 @@ const COMMAND_GROUPS = {
|
|
|
95
96
|
taskAddCommand,
|
|
96
97
|
taskAuditCommand,
|
|
97
98
|
taskBriefCommand,
|
|
99
|
+
taskDeleteCommand,
|
|
98
100
|
taskClaimCommand,
|
|
99
101
|
taskEditCommand,
|
|
100
102
|
taskListCommand,
|