@fitlab-ai/agent-infra 0.4.2 → 0.4.4

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.
Files changed (137) hide show
  1. package/README.md +24 -34
  2. package/README.zh-CN.md +24 -34
  3. package/lib/defaults.json +5 -0
  4. package/lib/init.js +1 -0
  5. package/lib/update.js +13 -1
  6. package/package.json +3 -3
  7. package/templates/.agents/README.md +16 -2
  8. package/templates/.agents/README.zh-CN.md +16 -2
  9. package/templates/.agents/rules/issue-sync.md +194 -0
  10. package/templates/.agents/rules/issue-sync.zh-CN.md +194 -0
  11. package/templates/.agents/rules/milestone-inference.md +102 -0
  12. package/templates/.agents/rules/milestone-inference.zh-CN.md +102 -0
  13. package/templates/.agents/scripts/validate-artifact.js +1444 -0
  14. package/templates/.agents/skills/analyze-task/SKILL.md +24 -1
  15. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +24 -1
  16. package/templates/.agents/skills/analyze-task/config/verify.json +43 -0
  17. package/templates/.agents/skills/archive-tasks/SKILL.md +40 -0
  18. package/templates/.agents/skills/archive-tasks/SKILL.zh-CN.md +40 -0
  19. package/templates/.agents/skills/archive-tasks/scripts/archive-tasks.sh +403 -0
  20. package/templates/.agents/skills/block-task/SKILL.md +25 -37
  21. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +25 -37
  22. package/templates/.agents/skills/block-task/config/verify.json +28 -0
  23. package/templates/.agents/skills/cancel-task/SKILL.md +142 -0
  24. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +142 -0
  25. package/templates/.agents/skills/cancel-task/config/verify.json +30 -0
  26. package/templates/.agents/skills/close-codescan/SKILL.md +7 -0
  27. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +7 -0
  28. package/templates/.agents/skills/close-dependabot/SKILL.md +7 -0
  29. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +7 -0
  30. package/templates/.agents/skills/commit/SKILL.md +17 -0
  31. package/templates/.agents/skills/commit/SKILL.zh-CN.md +17 -0
  32. package/templates/.agents/skills/commit/config/verify.json +22 -0
  33. package/templates/.agents/skills/complete-task/SKILL.md +25 -10
  34. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +25 -10
  35. package/templates/.agents/skills/complete-task/config/verify.json +35 -0
  36. package/templates/.agents/skills/create-issue/SKILL.md +42 -6
  37. package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +42 -6
  38. package/templates/.agents/skills/create-issue/config/verify.json +29 -0
  39. package/templates/.agents/skills/create-issue/reference/label-and-type.md +13 -12
  40. package/templates/.agents/skills/create-issue/reference/label-and-type.zh-CN.md +13 -12
  41. package/templates/.agents/skills/create-pr/SKILL.md +44 -10
  42. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +44 -10
  43. package/templates/.agents/skills/create-pr/config/verify.json +27 -0
  44. package/templates/.agents/skills/create-pr/reference/branch-strategy.md +3 -3
  45. package/templates/.agents/skills/create-pr/reference/branch-strategy.zh-CN.md +3 -3
  46. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.md +6 -6
  47. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.zh-CN.md +6 -6
  48. package/templates/.agents/skills/create-pr/reference/pr-body-template.md +8 -7
  49. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +8 -7
  50. package/templates/.agents/skills/create-task/SKILL.md +25 -3
  51. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +25 -3
  52. package/templates/.agents/skills/create-task/config/verify.json +24 -0
  53. package/templates/.agents/skills/implement-task/SKILL.md +47 -8
  54. package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +47 -8
  55. package/templates/.agents/skills/implement-task/config/verify.json +43 -0
  56. package/templates/.agents/skills/implement-task/reference/branch-management.md +48 -0
  57. package/templates/.agents/skills/implement-task/reference/branch-management.zh-CN.md +49 -0
  58. package/templates/.agents/skills/implement-task/reference/output-template.md +20 -0
  59. package/templates/.agents/skills/implement-task/reference/output-template.zh-CN.md +20 -0
  60. package/templates/.agents/skills/import-codescan/SKILL.md +18 -7
  61. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +18 -7
  62. package/templates/.agents/skills/import-codescan/config/verify.json +24 -0
  63. package/templates/.agents/skills/import-dependabot/SKILL.md +18 -7
  64. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +18 -7
  65. package/templates/.agents/skills/import-dependabot/config/verify.json +24 -0
  66. package/templates/.agents/skills/import-issue/SKILL.md +28 -1
  67. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +28 -1
  68. package/templates/.agents/skills/import-issue/config/verify.json +27 -0
  69. package/templates/.agents/skills/init-labels/SKILL.md +40 -10
  70. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +40 -10
  71. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +1 -22
  72. package/templates/.agents/skills/init-milestones/SKILL.md +13 -0
  73. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +13 -0
  74. package/templates/.agents/skills/plan-task/SKILL.md +29 -75
  75. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +29 -75
  76. package/templates/.agents/skills/plan-task/config/verify.json +44 -0
  77. package/templates/.agents/skills/refine-task/SKILL.md +41 -2
  78. package/templates/.agents/skills/refine-task/SKILL.zh-CN.md +41 -2
  79. package/templates/.agents/skills/refine-task/config/verify.json +39 -0
  80. package/templates/.agents/skills/refine-task/reference/fix-workflow.md +7 -7
  81. package/templates/.agents/skills/refine-task/reference/fix-workflow.zh-CN.md +7 -7
  82. package/templates/.agents/skills/refine-title/SKILL.md +10 -2
  83. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +10 -2
  84. package/templates/.agents/skills/restore-task/SKILL.md +159 -0
  85. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +159 -0
  86. package/templates/.agents/skills/restore-task/config/verify.json +24 -0
  87. package/templates/.agents/skills/review-task/SKILL.md +25 -1
  88. package/templates/.agents/skills/review-task/SKILL.zh-CN.md +25 -1
  89. package/templates/.agents/skills/review-task/config/verify.json +42 -0
  90. package/templates/.agents/skills/update-agent-infra/SKILL.md +11 -0
  91. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +11 -0
  92. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +6 -1
  93. package/templates/.agents/templates/task.md +3 -7
  94. package/templates/.agents/templates/task.zh-CN.md +3 -7
  95. package/templates/.claude/commands/archive-tasks.md +9 -0
  96. package/templates/.claude/commands/archive-tasks.zh-CN.md +9 -0
  97. package/templates/.claude/commands/cancel-task.md +9 -0
  98. package/templates/.claude/commands/cancel-task.zh-CN.md +9 -0
  99. package/templates/.claude/commands/restore-task.md +9 -0
  100. package/templates/.claude/commands/restore-task.zh-CN.md +9 -0
  101. package/templates/.gemini/commands/_project_/archive-tasks.toml +10 -0
  102. package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +10 -0
  103. package/templates/.gemini/commands/_project_/cancel-task.toml +8 -0
  104. package/templates/.gemini/commands/_project_/cancel-task.zh-CN.toml +8 -0
  105. package/templates/.gemini/commands/_project_/restore-task.toml +8 -0
  106. package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +8 -0
  107. package/templates/.github/workflows/status-label.yml +85 -0
  108. package/templates/.opencode/commands/archive-tasks.md +11 -0
  109. package/templates/.opencode/commands/archive-tasks.zh-CN.md +11 -0
  110. package/templates/.opencode/commands/cancel-task.md +11 -0
  111. package/templates/.opencode/commands/cancel-task.zh-CN.md +11 -0
  112. package/templates/.opencode/commands/restore-task.md +11 -0
  113. package/templates/.opencode/commands/restore-task.zh-CN.md +11 -0
  114. package/templates/.agents/skills/sync-issue/SKILL.md +0 -93
  115. package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +0 -93
  116. package/templates/.agents/skills/sync-issue/reference/comment-publish.md +0 -84
  117. package/templates/.agents/skills/sync-issue/reference/comment-publish.zh-CN.md +0 -84
  118. package/templates/.agents/skills/sync-issue/reference/label-sync.md +0 -62
  119. package/templates/.agents/skills/sync-issue/reference/label-sync.zh-CN.md +0 -62
  120. package/templates/.agents/skills/sync-issue/reference/milestone-sync.md +0 -37
  121. package/templates/.agents/skills/sync-issue/reference/milestone-sync.zh-CN.md +0 -37
  122. package/templates/.agents/skills/sync-pr/SKILL.md +0 -87
  123. package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +0 -87
  124. package/templates/.agents/skills/sync-pr/reference/delivery-detection.md +0 -54
  125. package/templates/.agents/skills/sync-pr/reference/delivery-detection.zh-CN.md +0 -54
  126. package/templates/.claude/commands/sync-issue.md +0 -8
  127. package/templates/.claude/commands/sync-issue.zh-CN.md +0 -8
  128. package/templates/.claude/commands/sync-pr.md +0 -8
  129. package/templates/.claude/commands/sync-pr.zh-CN.md +0 -8
  130. package/templates/.gemini/commands/_project_/sync-issue.toml +0 -8
  131. package/templates/.gemini/commands/_project_/sync-issue.zh-CN.toml +0 -8
  132. package/templates/.gemini/commands/_project_/sync-pr.toml +0 -8
  133. package/templates/.gemini/commands/_project_/sync-pr.zh-CN.toml +0 -8
  134. package/templates/.opencode/commands/sync-issue.md +0 -11
  135. package/templates/.opencode/commands/sync-issue.zh-CN.md +0 -11
  136. package/templates/.opencode/commands/sync-pr.md +0 -11
  137. package/templates/.opencode/commands/sync-pr.zh-CN.md +0 -11
@@ -68,20 +68,32 @@ ls .agents/workspace/blocked/{task-id}/task.md
68
68
 
69
69
  ### 6. 同步到 Issue(可选)
70
70
 
71
- 检查 `task.md` 中是否存在 `issue_number` 字段,且其值不为空也不为 `N/A`。如果没有,**跳过此步骤,不输出任何内容**。
71
+ 检查 `task.md` 中是否存在有效的 `issue_number`。如果没有,跳过。
72
72
 
73
- 如果存在有效的 `issue_number`,建议同步:
73
+ > Issue 同步的 status label 规则见 `.agents/rules/issue-sync.md`。执行同步前先读取该文件。
74
74
 
75
- > **重要**:以下列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
75
+ 如果存在有效的 `issue_number`,直接设置 `status: blocked`。
76
76
 
77
+ ### 7. 完成校验
78
+
79
+ 运行完成校验,确认任务产物和同步状态符合规范:
80
+
81
+ ```bash
82
+ node .agents/scripts/validate-artifact.js gate block-task .agents/workspace/blocked/{task-id} --format text
77
83
  ```
78
- (可选)同步阻塞状态到 Issue:
79
- - Claude Code / OpenCode:/sync-issue {issue_number}
80
- - Gemini CLI:/{{project}}:sync-issue {issue_number}
81
- - Codex CLI:$sync-issue {issue_number}
82
- ```
83
84
 
84
- ### 7. 告知用户
85
+ 处理结果:
86
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
87
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
88
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
89
+
90
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
91
+
92
+ ### 8. 告知用户
93
+
94
+ > 仅在校验通过后执行本步骤。
95
+
96
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
85
97
 
86
98
  输出格式:
87
99
  ```
@@ -94,35 +106,11 @@ ls .agents/workspace/blocked/{task-id}/task.md
94
106
  解除阻塞时执行:
95
107
  mv .agents/workspace/blocked/{task-id} .agents/workspace/active/{task-id}
96
108
  # 然后更新 task.md:status -> active,移除 blocked_at
97
- ```
98
-
99
- ## 输出模板
100
-
101
- 添加到 task.md 的阻塞信息部分:
102
-
103
- ```markdown
104
- ## 阻塞信息
105
-
106
- ### 摘要
107
- {阻塞原因的一行描述}
108
-
109
- ### 问题描述
110
- {阻塞问题的详细描述}
111
-
112
- ### 根本原因
113
- {分析为什么会被阻塞}
114
-
115
- ### 已尝试的解决方案
116
- - {尝试了什么以及为什么没有成功}
117
-
118
- ### 解除阻塞所需
119
- - {需要什么:信息、决策、资源等}
120
-
121
- ### 解除阻塞条件
122
- {允许恢复工作的具体条件}
123
109
 
124
- ### 备选方案
125
- {考虑过的任何变通方法或替代方案}
110
+ 下一步 - 检查任务状态(解除阻塞后):
111
+ - Claude Code / OpenCode:/check-task {task-id}
112
+ - Gemini CLI:/agent-infra:check-task {task-id}
113
+ - Codex CLI:$check-task {task-id}
126
114
  ```
127
115
 
128
116
  ## 完成检查清单
@@ -0,0 +1,28 @@
1
+ {
2
+ "skill": "block-task",
3
+ "checks": {
4
+ "task-meta": {
5
+ "required_fields": [
6
+ "id",
7
+ "type",
8
+ "workflow",
9
+ "status",
10
+ "created_at",
11
+ "updated_at",
12
+ "current_step",
13
+ "assigned_to",
14
+ "blocked_at"
15
+ ],
16
+ "expected_status": "blocked",
17
+ "require_blocked_at": true
18
+ },
19
+ "activity-log": {
20
+ "expected_action_pattern": "Blocked",
21
+ "freshness_minutes": 30
22
+ },
23
+ "github-sync": {
24
+ "when": "issue_number_exists",
25
+ "expected_status_label": "status: blocked"
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: cancel-task
3
+ description: "Cancel an unneeded task and archive it"
4
+ ---
5
+
6
+ # Cancel Task
7
+
8
+ ## Boundary / Critical Rules
9
+
10
+ - This command terminates a task that no longer needs to continue and archives it into `completed/`
11
+ - Cancel only when the task no longer needs implementation, review, or follow-up work
12
+ - When a valid `issue_number` exists, GitHub Issue sync is required
13
+
14
+ ## Steps
15
+
16
+ ### 1. Verify Task Exists
17
+
18
+ Check these directories in order:
19
+ - `.agents/workspace/active/{task-id}/`
20
+ - `.agents/workspace/blocked/{task-id}/`
21
+ - `.agents/workspace/completed/{task-id}/`
22
+
23
+ Handling rules:
24
+ - If found in `active/` or `blocked/`: continue
25
+ - If found only in `completed/`: inform the user the task is already archived and stop
26
+ - If not found anywhere: prompt `Task {task-id} not found`
27
+
28
+ ### 2. Choose the Cancellation Label
29
+
30
+ Infer the GitHub Issue closing label from the cancellation reason:
31
+ - `status: superseded`: reason implies duplicate, replaced, merged into, or already covered by another Issue or PR
32
+ - `status: invalid`: reason implies invalid report, no real problem, cannot reproduce, or no issue after investigation
33
+ - `status: declined`: reason implies not planned, deprioritized, or explicitly rejected
34
+ - If nothing matches: fall back to `status: declined`
35
+
36
+ When syncing to the Issue, replace any existing `status:` labels with the inferred label.
37
+
38
+ ### 3. Update Task Metadata
39
+
40
+ Get the current time:
41
+
42
+ ```bash
43
+ date "+%Y-%m-%d %H:%M:%S"
44
+ ```
45
+
46
+ Update `task.md` in the task directory:
47
+ - `status`: completed
48
+ - `cancelled_at`: {current timestamp}
49
+ - `cancel_reason`: {cancellation reason}
50
+ - `updated_at`: {current timestamp}
51
+ - **Append** to `## Activity Log` (do NOT overwrite previous entries):
52
+ ```
53
+ - {yyyy-MM-dd HH:mm:ss} — **Cancelled** by {agent} — {one-line cancellation reason}
54
+ ```
55
+
56
+ ### 4. Archive the Task
57
+
58
+ Move the task directory into `.agents/workspace/completed/{task-id}`.
59
+
60
+ If the source directory is `blocked/`, move it from `blocked/`; if it is `active/`, move it from `active/`.
61
+
62
+ ### 5. Verify the Archive
63
+
64
+ ```bash
65
+ ls .agents/workspace/completed/{task-id}/task.md
66
+ ```
67
+
68
+ Confirm the task directory was moved successfully.
69
+
70
+ ### 6. Sync to Issue
71
+
72
+ Check whether `task.md` contains a valid `issue_number`. If not, skip this step.
73
+
74
+ > Issue sync rules live in `.agents/rules/issue-sync.md`. Read that file before syncing.
75
+
76
+ If a valid `issue_number` exists:
77
+ - Replace all `status:` labels with the label inferred in Step 2
78
+ - Remove all `in:` labels
79
+ - Remove the milestone
80
+ - Remove all assignees
81
+ - Publish a cancellation comment using the marker `<!-- sync-issue:{task-id}:cancel -->`
82
+ - Create or update the `<!-- sync-issue:{task-id}:task -->` comment using the task-comment sync rules from `.agents/rules/issue-sync.md`
83
+ - Close the Issue: `gh issue close {issue-number} --reason "not planned"`
84
+
85
+ The cancellation comment must include at least:
86
+ - the cancellation reason
87
+ - the selected `status:` label
88
+
89
+ ### 7. Verification Gate
90
+
91
+ Run the verification gate to confirm the archived task and sync state are valid:
92
+
93
+ ```bash
94
+ node .agents/scripts/validate-artifact.js gate cancel-task .agents/workspace/completed/{task-id} --format text
95
+ ```
96
+
97
+ Handle the result as follows:
98
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
99
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
100
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
101
+
102
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
103
+
104
+ ### 8. Inform User
105
+
106
+ > Execute this step only after the verification gate passes.
107
+
108
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
109
+
110
+ Output format:
111
+ ```
112
+ Task {task-id} cancelled and archived.
113
+
114
+ Cancellation reason: {reason}
115
+ GitHub label: {status-label or skipped}
116
+ Archived to: .agents/workspace/completed/{task-id}/
117
+
118
+ Next step - inspect the archived task:
119
+ - Claude Code / OpenCode: /check-task {task-id}
120
+ - Gemini CLI: /{{project}}:check-task {task-id}
121
+ - Codex CLI: $check-task {task-id}
122
+ ```
123
+
124
+ ## Completion Checklist
125
+
126
+ - [ ] Recorded the cancellation reason and updated task.md
127
+ - [ ] Moved the task directory into `.agents/workspace/completed/`
128
+ - [ ] Completed GitHub sync when an Issue exists
129
+ - [ ] Ran and passed the verification gate
130
+ - [ ] Showed the full next-step command set to the user
131
+
132
+ ## Notes
133
+
134
+ 1. Cancelled tasks reuse the `completed` status instead of introducing `cancelled`
135
+ 2. Use `cancelled_at` and `cancel_reason` to distinguish cancellation from normal completion
136
+ 3. If closing the Issue fails, do not claim the cancellation is complete
137
+
138
+ ## Error Handling
139
+
140
+ - Task not found: `Task {task-id} not found`
141
+ - Task already archived: inform the user it is already in `completed/`
142
+ - Issue sync failed: keep the local archive result and tell the user manual GitHub follow-up is required
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: cancel-task
3
+ description: "取消不再需要的任务并归档"
4
+ ---
5
+
6
+ # 取消任务
7
+
8
+ ## 行为边界 / 关键规则
9
+
10
+ - 本命令用于终止一个不再需要继续执行的任务,并归档到 `completed/`
11
+ - 只有在确认该任务无需继续实现、审查或修复时才可取消
12
+ - 有效 `issue_number` 存在时,GitHub Issue 同步属于必做项
13
+
14
+ ## 执行步骤
15
+
16
+ ### 1. 验证任务存在
17
+
18
+ 依次检查以下目录:
19
+ - `.agents/workspace/active/{task-id}/`
20
+ - `.agents/workspace/blocked/{task-id}/`
21
+ - `.agents/workspace/completed/{task-id}/`
22
+
23
+ 处理规则:
24
+ - 如果在 `active/` 或 `blocked/` 中找到:继续
25
+ - 如果只在 `completed/` 中找到:告知用户任务已归档,停止
26
+ - 如果都不存在:提示 `Task {task-id} not found`
27
+
28
+ ### 2. 判断取消标签
29
+
30
+ 根据取消原因推断 GitHub Issue 关闭标签:
31
+ - `status: superseded`:原因包含“重复”、“替代”、“合并到”、“已由 #123 / PR 替代”等语义
32
+ - `status: invalid`:原因包含“误报”、“不存在”、“无法复现”、“排查后无问题”等语义
33
+ - `status: declined`:原因包含“不做”、“暂不实现”、“优先级调整”、“方案否决”等语义
34
+ - 以上都不匹配:回退到 `status: declined`
35
+
36
+ 后续同步到 Issue 时,使用最终推断结果替换现有 `status:` labels。
37
+
38
+ ### 3. 更新任务元数据
39
+
40
+ 获取当前时间:
41
+
42
+ ```bash
43
+ date "+%Y-%m-%d %H:%M:%S"
44
+ ```
45
+
46
+ 更新任务目录中的 `task.md`:
47
+ - `status`:completed
48
+ - `cancelled_at`:{当前时间戳}
49
+ - `cancel_reason`:{取消原因}
50
+ - `updated_at`:{当前时间戳}
51
+ - **追加**到 `## Activity Log`(不要覆盖之前记录):
52
+ ```
53
+ - {yyyy-MM-dd HH:mm:ss} — **Cancelled** by {agent} — {一行取消原因}
54
+ ```
55
+
56
+ ### 4. 归档任务
57
+
58
+ 将任务目录移动到 `.agents/workspace/completed/{task-id}`。
59
+
60
+ 如果源目录在 `blocked/`,从 `blocked/` 移动;如果源目录在 `active/`,从 `active/` 移动。
61
+
62
+ ### 5. 验证归档
63
+
64
+ ```bash
65
+ ls .agents/workspace/completed/{task-id}/task.md
66
+ ```
67
+
68
+ 确认任务目录已成功移动。
69
+
70
+ ### 6. 同步到 Issue
71
+
72
+ 检查 `task.md` 中是否存在有效的 `issue_number`。如果没有,跳过此步骤。
73
+
74
+ > Issue 同步规则见 `.agents/rules/issue-sync.md`。执行同步前先读取该文件。
75
+
76
+ 如果存在有效的 `issue_number`:
77
+ - 替换所有 `status:` labels,并设置步骤 2 推断出的标签
78
+ - 移除所有 `in:` labels
79
+ - 移除 milestone
80
+ - 移除全部 assignees
81
+ - 发布取消评论,隐藏标记使用 `<!-- sync-issue:{task-id}:cancel -->`
82
+ - 使用 `.agents/rules/issue-sync.md` 的 task.md 评论同步规则创建或更新 `<!-- sync-issue:{task-id}:task -->` 评论
83
+ - 关闭 Issue:`gh issue close {issue-number} --reason "not planned"`
84
+
85
+ 取消评论至少包含:
86
+ - 取消原因
87
+ - 选定的 `status:` label
88
+
89
+ ### 7. 完成校验
90
+
91
+ 运行完成校验,确认任务归档和同步状态符合规范:
92
+
93
+ ```bash
94
+ node .agents/scripts/validate-artifact.js gate cancel-task .agents/workspace/completed/{task-id} --format text
95
+ ```
96
+
97
+ 处理结果:
98
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
99
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
100
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
101
+
102
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
103
+
104
+ ### 8. 告知用户
105
+
106
+ > 仅在校验通过后执行本步骤。
107
+
108
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
109
+
110
+ 输出格式:
111
+ ```
112
+ 任务 {task-id} 已取消并归档。
113
+
114
+ 取消原因:{reason}
115
+ GitHub 标签:{status-label 或 skipped}
116
+ 归档路径:.agents/workspace/completed/{task-id}/
117
+
118
+ 下一步 - 查看归档任务:
119
+ - Claude Code / OpenCode:/check-task {task-id}
120
+ - Gemini CLI:/{{project}}:check-task {task-id}
121
+ - Codex CLI:$check-task {task-id}
122
+ ```
123
+
124
+ ## 完成检查清单
125
+
126
+ - [ ] 已记录取消原因并更新 task.md
127
+ - [ ] 已将任务目录移动到 `.agents/workspace/completed/`
128
+ - [ ] 已在存在 Issue 时完成 GitHub 同步
129
+ - [ ] 已运行 gate 校验并通过
130
+ - [ ] 已向用户展示完整的下一步命令
131
+
132
+ ## 注意事项
133
+
134
+ 1. 取消任务不会新增 `cancelled` 状态值,而是复用 `completed`
135
+ 2. 必须通过 `cancelled_at` 和 `cancel_reason` 区分“取消”与“正常完成”
136
+ 3. 如果 Issue 关闭失败,不要宣称取消完成
137
+
138
+ ## 错误处理
139
+
140
+ - 任务未找到:`Task {task-id} not found`
141
+ - 任务已归档:提示任务已在 `completed/` 中
142
+ - Issue 同步失败:保留本地归档结果,并告知用户需要人工补齐 GitHub 操作
@@ -0,0 +1,30 @@
1
+ {
2
+ "skill": "cancel-task",
3
+ "checks": {
4
+ "task-meta": {
5
+ "required_fields": [
6
+ "id",
7
+ "type",
8
+ "workflow",
9
+ "status",
10
+ "created_at",
11
+ "updated_at",
12
+ "current_step",
13
+ "assigned_to",
14
+ "cancelled_at",
15
+ "cancel_reason"
16
+ ],
17
+ "expected_status": "completed",
18
+ "require_cancelled_at": true
19
+ },
20
+ "activity-log": {
21
+ "expected_action_pattern": "Cancelled",
22
+ "freshness_minutes": 30
23
+ },
24
+ "github-sync": {
25
+ "when": "issue_number_exists",
26
+ "expected_comment_marker": "<!-- sync-issue:{task-id}:cancel -->",
27
+ "verify_task_comment_content": true
28
+ }
29
+ }
30
+ }
@@ -92,6 +92,8 @@ date "+%Y-%m-%d %H:%M:%S"
92
92
 
93
93
  ### 8. Inform User
94
94
 
95
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
96
+
95
97
  ```
96
98
  Code Scanning alert #{alert-number} dismissed.
97
99
 
@@ -103,6 +105,11 @@ Explanation: {explanation}
103
105
  View: {html_url}
104
106
 
105
107
  Note: it can be reopened on GitHub if necessary.
108
+
109
+ Next step - complete and archive the task if a related task exists:
110
+ - Claude Code / OpenCode: /complete-task {task-id}
111
+ - Gemini CLI: /{{project}}:complete-task {task-id}
112
+ - Codex CLI: $complete-task {task-id}
106
113
  ```
107
114
 
108
115
  ## Notes
@@ -92,6 +92,8 @@ date "+%Y-%m-%d %H:%M:%S"
92
92
 
93
93
  ### 8. 告知用户
94
94
 
95
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
96
+
95
97
  ```
96
98
  Code Scanning 告警 #{alert-number} 已关闭。
97
99
 
@@ -103,6 +105,11 @@ Code Scanning 告警 #{alert-number} 已关闭。
103
105
  查看:{html_url}
104
106
 
105
107
  注意:如有需要,可在 GitHub 上重新打开。
108
+
109
+ 下一步 - 完成并归档任务(如有关联任务):
110
+ - Claude Code / OpenCode:/complete-task {task-id}
111
+ - Gemini CLI:/agent-infra:complete-task {task-id}
112
+ - Codex CLI:$complete-task {task-id}
106
113
  ```
107
114
 
108
115
  ## 注意事项
@@ -100,6 +100,8 @@ date "+%Y-%m-%d %H:%M:%S"
100
100
 
101
101
  ### 8. Inform User
102
102
 
103
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
104
+
103
105
  ```
104
106
  Security alert #{alert-number} dismissed.
105
107
 
@@ -111,6 +113,11 @@ Explanation: {explanation}
111
113
  View: https://github.com/{owner}/{repo}/security/dependabot/{alert-number}
112
114
 
113
115
  Note: it can be reopened on GitHub if necessary.
116
+
117
+ Next step - complete and archive the task if a related task exists:
118
+ - Claude Code / OpenCode: /complete-task {task-id}
119
+ - Gemini CLI: /{{project}}:complete-task {task-id}
120
+ - Codex CLI: $complete-task {task-id}
114
121
  ```
115
122
 
116
123
  ## Notes
@@ -100,6 +100,8 @@ date "+%Y-%m-%d %H:%M:%S"
100
100
 
101
101
  ### 8. 告知用户
102
102
 
103
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
104
+
103
105
  ```
104
106
  安全告警 #{alert-number} 已关闭。
105
107
 
@@ -111,6 +113,11 @@ date "+%Y-%m-%d %H:%M:%S"
111
113
  查看:https://github.com/{owner}/{repo}/security/dependabot/{alert-number}
112
114
 
113
115
  注意:如有需要,可在 GitHub 上重新打开。
116
+
117
+ 下一步 - 完成并归档任务(如有关联任务):
118
+ - Claude Code / OpenCode:/complete-task {task-id}
119
+ - Gemini CLI:/agent-infra:complete-task {task-id}
120
+ - Codex CLI:$complete-task {task-id}
114
121
  ```
115
122
 
116
123
  ## 注意事项
@@ -44,12 +44,29 @@ date "+%Y-%m-%d %H:%M:%S"
44
44
 
45
45
  > The full four-case status matrix, prerequisite checks, and multi-TUI next-step commands live in `reference/task-status-update.md`. Read `reference/task-status-update.md` before updating task state.
46
46
 
47
+ > **IMPORTANT**: When showing the next step, output every TUI command format in full and directly use the standard template from `reference/task-status-update.md`.
48
+
47
49
  Append the Commit Activity Log entry and choose exactly one next-step case:
48
50
  - final commit -> `complete-task {task-id}`
49
51
  - more work remains -> update task.md and stop
50
52
  - ready for review -> `review-task {task-id}`
51
53
  - ready for PR -> `create-pr`
52
54
 
55
+ ## 6. Verification Gate
56
+
57
+ If this operation is associated with `{task-id}`, run the verification gate to confirm task metadata and sync state. If there is no task context, skip this step.
58
+
59
+ ```bash
60
+ node .agents/scripts/validate-artifact.js gate commit .agents/workspace/active/{task-id}
61
+ ```
62
+
63
+ Handle the result as follows:
64
+ - exit code 0 (all checks passed) -> continue the remaining wrap-up steps
65
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
66
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
67
+
68
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
69
+
53
70
  ## Notes
54
71
 
55
72
  - Never commit secrets such as `.env`, credentials, or keys
@@ -44,12 +44,29 @@ date "+%Y-%m-%d %H:%M:%S"
44
44
 
45
45
  > 完整的 4 种状态分支、前置条件检查和多 TUI 下一步命令见 `reference/task-status-update.md`。更新任务状态前,先读取 `reference/task-status-update.md`。
46
46
 
47
+ > **重要**:向用户展示下一步时,必须完整输出所有 TUI 命令格式,并直接使用 `reference/task-status-update.md` 中对应场景的标准模板。
48
+
47
49
  追加 Commit 的 Activity Log,并且只能选择一个下一步分支:
48
50
  - 最终提交 -> `complete-task {task-id}`
49
51
  - 还有后续工作 -> 更新 task.md 后停止
50
52
  - 准备审查 -> `review-task {task-id}`
51
53
  - 准备创建 PR -> `create-pr`
52
54
 
55
+ ## 6. 完成校验
56
+
57
+ 如果本次操作关联了 `{task-id}`,运行完成校验,确认任务元数据和同步状态符合规范;如果没有任务上下文,跳过本步骤。
58
+
59
+ ```bash
60
+ node .agents/scripts/validate-artifact.js gate commit .agents/workspace/active/{task-id}
61
+ ```
62
+
63
+ 处理结果:
64
+ - 退出码 0(全部通过)-> 继续后续收尾步骤
65
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
66
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
67
+
68
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
69
+
53
70
  ## 注意事项
54
71
 
55
72
  - 不要提交 `.env`、凭据、密钥等敏感文件
@@ -0,0 +1,22 @@
1
+ {
2
+ "skill": "commit",
3
+ "checks": {
4
+ "task-meta": {
5
+ "required_fields": [
6
+ "id",
7
+ "type",
8
+ "workflow",
9
+ "status",
10
+ "created_at",
11
+ "updated_at",
12
+ "current_step",
13
+ "assigned_to"
14
+ ]
15
+ },
16
+ "activity-log": {
17
+ "expected_action_pattern": "Commit",
18
+ "freshness_minutes": 30
19
+ },
20
+ "github-sync": null
21
+ }
22
+ }
@@ -61,6 +61,7 @@ Update `.agents/workspace/active/{task-id}/task.md`:
61
61
  - `completed_at`: {current timestamp}
62
62
  - `updated_at`: {current timestamp}
63
63
  - Mark all workflow steps as complete
64
+ - Verify and check off all items in `## Completion Checklist` (change `- [ ]` to `- [x]`)
64
65
  - **Append** to `## Activity Log` (do NOT overwrite previous entries):
65
66
  ```
66
67
  - {yyyy-MM-dd HH:mm:ss} — **Completed** by {agent} — Task archived to completed/
@@ -82,22 +83,36 @@ ls .agents/workspace/completed/{task-id}/task.md
82
83
 
83
84
  Confirm the task directory was successfully moved.
84
85
 
85
- ### 6. Sync to Issue (Optional)
86
+ ### 6. Sync to Issue
86
87
 
87
- Check whether `task.md` includes an `issue_number` field whose value is neither empty nor `N/A`. If not, **skip this step and output nothing**.
88
+ Check whether `task.md` includes a valid `issue_number`. If not, skip this step and output nothing.
88
89
 
89
- If a valid `issue_number` exists, optionally sync the completion status:
90
+ > Issue sync rules live in `.agents/rules/issue-sync.md`. Read that file before syncing.
90
91
 
91
- > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
92
+ If a valid `issue_number` exists:
93
+ - First scan and backfill unpublished `task.md`, `analysis*.md`, `plan*.md`, `implementation*.md`, `review*.md`, and `refinement*.md` comments using the backfill rules in `.agents/rules/issue-sync.md` (`task.md` uses the idempotent update path)
94
+ - Backfill checked `## Requirements` items to the Issue body
95
+ - Do not set any `status:` label — status labels are automatically cleared when the Issue is closed
96
+ - Finally create or update the summary comment marked with `<!-- sync-issue:{task-id}:summary -->`
92
97
 
98
+ ### 7. Verification Gate
99
+
100
+ Run the verification gate to confirm the task artifact and sync state are valid:
101
+
102
+ ```bash
103
+ node .agents/scripts/validate-artifact.js gate complete-task .agents/workspace/completed/{task-id} --format text
93
104
  ```
94
- (Optional) Sync completion status to the GitHub Issue:
95
- - Claude Code / OpenCode: /sync-issue {issue_number}
96
- - Gemini CLI: /{{project}}:sync-issue {issue_number}
97
- - Codex CLI: $sync-issue {issue_number}
98
- ```
99
105
 
100
- ### 7. Inform User
106
+ Handle the result as follows:
107
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
108
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
109
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
110
+
111
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
112
+
113
+ ### 8. Inform User
114
+
115
+ > Execute this step only after the verification gate passes.
101
116
 
102
117
  Output format:
103
118
  ```