@fitlab-ai/agent-infra 0.4.1 → 0.4.3

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 (142) hide show
  1. package/README.md +44 -44
  2. package/README.zh-CN.md +44 -44
  3. package/lib/defaults.json +7 -9
  4. package/lib/init.js +1 -0
  5. package/lib/update.js +13 -1
  6. package/package.json +3 -3
  7. package/templates/.agents/QUICKSTART.md +7 -7
  8. package/templates/.agents/QUICKSTART.zh-CN.md +13 -13
  9. package/templates/.agents/README.md +31 -18
  10. package/templates/.agents/README.zh-CN.md +33 -20
  11. package/templates/.agents/rules/issue-sync.md +185 -0
  12. package/templates/.agents/rules/issue-sync.zh-CN.md +185 -0
  13. package/templates/.agents/scripts/validate-artifact.js +1280 -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 +41 -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/close-codescan/SKILL.md +7 -0
  24. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +7 -0
  25. package/templates/.agents/skills/close-dependabot/SKILL.md +7 -0
  26. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +7 -0
  27. package/templates/.agents/skills/commit/SKILL.md +17 -0
  28. package/templates/.agents/skills/commit/SKILL.zh-CN.md +17 -0
  29. package/templates/.agents/skills/commit/config/verify.json +22 -0
  30. package/templates/.agents/skills/commit/reference/task-status-update.md +3 -3
  31. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +3 -3
  32. package/templates/.agents/skills/complete-task/SKILL.md +24 -10
  33. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +24 -10
  34. package/templates/.agents/skills/complete-task/config/verify.json +30 -0
  35. package/templates/.agents/skills/create-issue/SKILL.md +41 -5
  36. package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +41 -5
  37. package/templates/.agents/skills/create-issue/config/verify.json +27 -0
  38. package/templates/.agents/skills/create-issue/reference/label-and-type.md +10 -11
  39. package/templates/.agents/skills/create-issue/reference/label-and-type.zh-CN.md +10 -11
  40. package/templates/.agents/skills/create-pr/SKILL.md +59 -16
  41. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +59 -16
  42. package/templates/.agents/skills/create-pr/config/verify.json +26 -0
  43. package/templates/.agents/skills/create-pr/reference/branch-strategy.md +3 -3
  44. package/templates/.agents/skills/create-pr/reference/branch-strategy.zh-CN.md +3 -3
  45. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.md +6 -6
  46. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.zh-CN.md +10 -10
  47. package/templates/.agents/skills/create-pr/reference/pr-body-template.md +15 -6
  48. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +15 -6
  49. package/templates/.agents/skills/create-task/SKILL.md +25 -3
  50. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +25 -3
  51. package/templates/.agents/skills/create-task/config/verify.json +24 -0
  52. package/templates/.agents/skills/implement-task/SKILL.md +44 -8
  53. package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +44 -8
  54. package/templates/.agents/skills/implement-task/config/verify.json +41 -0
  55. package/templates/.agents/skills/implement-task/reference/branch-management.md +48 -0
  56. package/templates/.agents/skills/implement-task/reference/branch-management.zh-CN.md +49 -0
  57. package/templates/.agents/skills/implement-task/reference/output-template.md +20 -0
  58. package/templates/.agents/skills/implement-task/reference/output-template.zh-CN.md +20 -0
  59. package/templates/.agents/skills/import-codescan/SKILL.md +18 -7
  60. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +18 -7
  61. package/templates/.agents/skills/import-codescan/config/verify.json +24 -0
  62. package/templates/.agents/skills/import-dependabot/SKILL.md +18 -7
  63. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +18 -7
  64. package/templates/.agents/skills/import-dependabot/config/verify.json +24 -0
  65. package/templates/.agents/skills/import-issue/SKILL.md +19 -1
  66. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +19 -1
  67. package/templates/.agents/skills/import-issue/config/verify.json +27 -0
  68. package/templates/.agents/skills/init-labels/SKILL.md +40 -10
  69. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +40 -10
  70. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +1 -22
  71. package/templates/.agents/skills/init-milestones/SKILL.md +13 -0
  72. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +13 -0
  73. package/templates/.agents/skills/plan-task/SKILL.md +29 -75
  74. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +29 -75
  75. package/templates/.agents/skills/plan-task/config/verify.json +42 -0
  76. package/templates/.agents/skills/refine-task/SKILL.md +51 -4
  77. package/templates/.agents/skills/refine-task/SKILL.zh-CN.md +51 -4
  78. package/templates/.agents/skills/refine-task/config/verify.json +37 -0
  79. package/templates/.agents/skills/refine-title/SKILL.md +10 -2
  80. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +10 -2
  81. package/templates/.agents/skills/restore-task/SKILL.md +159 -0
  82. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +159 -0
  83. package/templates/.agents/skills/restore-task/config/verify.json +24 -0
  84. package/templates/.agents/skills/review-task/SKILL.md +25 -1
  85. package/templates/.agents/skills/review-task/SKILL.zh-CN.md +25 -1
  86. package/templates/.agents/skills/review-task/config/verify.json +40 -0
  87. package/templates/.agents/skills/update-agent-infra/SKILL.md +11 -0
  88. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +11 -0
  89. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +8 -10
  90. package/templates/.claude/commands/archive-tasks.md +9 -0
  91. package/templates/.claude/commands/archive-tasks.zh-CN.md +9 -0
  92. package/templates/.claude/commands/create-pr.md +1 -1
  93. package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
  94. package/templates/.claude/commands/restore-task.md +9 -0
  95. package/templates/.claude/commands/restore-task.zh-CN.md +9 -0
  96. package/templates/.gemini/commands/_project_/archive-tasks.toml +10 -0
  97. package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +10 -0
  98. package/templates/.gemini/commands/_project_/restore-task.toml +8 -0
  99. package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +8 -0
  100. package/templates/.github/workflows/status-label.yml +82 -0
  101. package/templates/.opencode/commands/archive-tasks.md +11 -0
  102. package/templates/.opencode/commands/archive-tasks.zh-CN.md +11 -0
  103. package/templates/.opencode/commands/restore-task.md +11 -0
  104. package/templates/.opencode/commands/restore-task.zh-CN.md +11 -0
  105. package/templates/.agents/skills/sync-issue/SKILL.md +0 -91
  106. package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +0 -91
  107. package/templates/.agents/skills/sync-issue/reference/comment-publish.md +0 -88
  108. package/templates/.agents/skills/sync-issue/reference/comment-publish.zh-CN.md +0 -88
  109. package/templates/.agents/skills/sync-issue/reference/delivery-detection.md +0 -42
  110. package/templates/.agents/skills/sync-issue/reference/delivery-detection.zh-CN.md +0 -42
  111. package/templates/.agents/skills/sync-issue/reference/label-sync.md +0 -63
  112. package/templates/.agents/skills/sync-issue/reference/label-sync.zh-CN.md +0 -63
  113. package/templates/.agents/skills/sync-issue/reference/milestone-sync.md +0 -37
  114. package/templates/.agents/skills/sync-issue/reference/milestone-sync.zh-CN.md +0 -37
  115. package/templates/.agents/skills/sync-pr/SKILL.md +0 -72
  116. package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +0 -72
  117. package/templates/.agents/skills/sync-pr/reference/delivery-detection.md +0 -54
  118. package/templates/.agents/skills/sync-pr/reference/delivery-detection.zh-CN.md +0 -54
  119. package/templates/.claude/CLAUDE.md +0 -138
  120. package/templates/.claude/CLAUDE.zh-CN.md +0 -138
  121. package/templates/.claude/commands/sync-issue.md +0 -8
  122. package/templates/.claude/commands/sync-issue.zh-CN.md +0 -8
  123. package/templates/.claude/commands/sync-pr.md +0 -8
  124. package/templates/.claude/commands/sync-pr.zh-CN.md +0 -8
  125. package/templates/.claude/project-rules.md +0 -65
  126. package/templates/.claude/project-rules.zh-CN.md +0 -65
  127. package/templates/.codex/README.md +0 -38
  128. package/templates/.codex/README.zh-CN.md +0 -37
  129. package/templates/.gemini/commands/_project_/sync-issue.toml +0 -8
  130. package/templates/.gemini/commands/_project_/sync-issue.zh-CN.toml +0 -8
  131. package/templates/.gemini/commands/_project_/sync-pr.toml +0 -8
  132. package/templates/.gemini/commands/_project_/sync-pr.zh-CN.toml +0 -8
  133. package/templates/.opencode/COMMAND_STYLE_GUIDE.md +0 -232
  134. package/templates/.opencode/COMMAND_STYLE_GUIDE.zh-CN.md +0 -232
  135. package/templates/.opencode/README.md +0 -76
  136. package/templates/.opencode/README.zh-CN.md +0 -77
  137. package/templates/.opencode/commands/sync-issue.md +0 -11
  138. package/templates/.opencode/commands/sync-issue.zh-CN.md +0 -11
  139. package/templates/.opencode/commands/sync-pr.md +0 -11
  140. package/templates/.opencode/commands/sync-pr.zh-CN.md +0 -11
  141. package/templates/AGENTS.md +0 -112
  142. package/templates/AGENTS.zh-CN.md +0 -112
@@ -54,12 +54,59 @@ description: "处理代码审查反馈并修复问题"
54
54
  date "+%Y-%m-%d %H:%M:%S"
55
55
  ```
56
56
 
57
- 更新 task.md,并追加:
58
- `- {yyyy-MM-dd HH:mm:ss} **Refinement (Round {N}, for {review-artifact})** by {agent} — Fixed {n} blockers, {n} major, {n} minor issues → {refinement-artifact}`
57
+ 更新 task.md
58
+ - 审查 `## 需求` 段落,仅把因本轮修复而新满足且有测试通过支撑的条目从 `- [ ]` 勾为 `- [x]`
59
+ - 追加:
60
+ `- {yyyy-MM-dd HH:mm:ss} — **Refinement (Round {N}, for {review-artifact})** by {agent} — Fixed {n} blockers, {n} major, {n} minor issues → {refinement-artifact}`
59
61
 
60
- ### 7. 告知用户
62
+ 如果 task.md 中存在有效的 `issue_number`,执行以下同步操作(任一失败则跳过并继续):
63
+ - 执行前先读取 `.agents/rules/issue-sync.md`
64
+ - 设置 `status: in-progress`
65
+ - 按 `.agents/rules/issue-sync.md` 的 `in:` label 同步规则,基于分支改动精修 `in:` label(有映射时可增可删,无映射时仅补充)
66
+ - 同步 `## 需求` 中已勾选项到 Issue body
67
+ - 发布 `{refinement-artifact}` 评论
68
+ - 创建或更新 `<!-- sync-issue:{task-id}:task -->` 评论(按 issue-sync.md 的 task.md 评论同步规则)
61
69
 
62
- 如果本轮修复了 Blocker 或 Major,默认推荐重新审查。只有在风险确实很低且只修复 Minor 时,才可把直接提交作为备选项。
70
+ ### 7. 完成校验
71
+
72
+ 运行完成校验,确认任务产物和同步状态符合规范:
73
+
74
+ ```bash
75
+ node .agents/scripts/validate-artifact.js gate refine-task .agents/workspace/active/{task-id} {refinement-artifact} --format text
76
+ ```
77
+
78
+ 处理结果:
79
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
80
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
81
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
82
+
83
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
84
+
85
+ ### 8. 告知用户
86
+
87
+ > 仅在校验通过后执行本步骤。
88
+
89
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
90
+
91
+ 输出修复摘要后,根据修复的问题严重程度选择下一步:
92
+
93
+ 如果修复了 Blocker 或 Major(推荐重新审查):
94
+
95
+ ```
96
+ 下一步 - 代码审查:
97
+ - Claude Code / OpenCode:/review-task {task-id}
98
+ - Gemini CLI:/agent-infra:review-task {task-id}
99
+ - Codex CLI:$review-task {task-id}
100
+ ```
101
+
102
+ 如果仅修复 Minor(可直接提交):
103
+
104
+ ```
105
+ 下一步 - 提交代码:
106
+ - Claude Code / OpenCode:/commit
107
+ - Gemini CLI:/agent-infra:commit
108
+ - Codex CLI:$commit
109
+ ```
63
110
 
64
111
  ## 完成检查清单
65
112
 
@@ -0,0 +1,37 @@
1
+ {
2
+ "skill": "refine-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
+ ]
15
+ },
16
+ "artifact": {
17
+ "file_pattern": "refinement.md|refinement-r{N}.md",
18
+ "required_sections": [
19
+ "审查反馈处理",
20
+ "修复后的测试结果"
21
+ ],
22
+ "freshness_minutes": 30
23
+ },
24
+ "activity-log": {
25
+ "expected_action_pattern": "Refinement \\(Round \\d+, for .+\\)",
26
+ "freshness_minutes": 30
27
+ },
28
+ "github-sync": {
29
+ "when": "issue_number_exists",
30
+ "expected_status_label": "status: in-progress",
31
+ "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
32
+ "verify_comment_content": true,
33
+ "verify_task_comment_content": true,
34
+ "sync_checked_requirements": true
35
+ }
36
+ }
37
+ }
@@ -37,7 +37,7 @@ Based on the fetched data:
37
37
 
38
38
  **Generate Subject**:
39
39
  - **Ignore the original title** (avoid bias) - extract core intent from body
40
- - Keep concise (under 50 characters), English imperative mood, no trailing period
40
+ - Keep concise (under 50 characters), use the content's original language (Chinese content stays Chinese, English content stays English), no trailing period
41
41
 
42
42
  ### 3. Present Suggestion
43
43
 
@@ -68,10 +68,18 @@ gh issue edit <id> --title "<new-title>"
68
68
  gh pr edit <id> --title "<new-title>"
69
69
  ```
70
70
 
71
+ ### 5. Inform User
72
+
73
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
74
+
75
+ If the skill updated an Issue title, explain that no extra sync command is required; continue with the workflow skill that matches the task's current stage.
76
+
77
+ If the skill updated a PR title, explain that `create-pr` now publishes the reviewer summary inline, so no extra sync command is needed; continue with the workflow skill that matches the task's current stage.
78
+
71
79
  ## Advantages
72
80
 
73
81
  This skill:
74
- 1. **Fixes misleading titles**: Even if the original title is "Help me", it reads the body and generates a proper title like `fix(core): resolve startup error`
82
+ 1. **Fixes misleading titles**: Even if the original title is "Help me", it reads the body and generates a proper title like `fix(core): resolve startup error` while keeping the subject in the content's original language
75
83
  2. **Accurate scope**: By analyzing PR file changes, it can automatically infer the correct scope without manual specification
76
84
 
77
85
  ## Notes
@@ -37,7 +37,7 @@ gh pr view <id> --json number,title,body,labels,state,files
37
37
 
38
38
  **生成 Subject**:
39
39
  - **忽略原始标题**(避免偏见)- 从 body 中提取核心意图
40
- - 保持简洁(不超过 50 字符),英文祈使语气,末尾无句号
40
+ - 保持简洁(不超过 50 字符),使用内容原始语言(中文内容用中文,英文内容用英文),末尾无句号
41
41
 
42
42
  ### 3. 展示建议
43
43
 
@@ -68,10 +68,18 @@ gh issue edit <id> --title "<new-title>"
68
68
  gh pr edit <id> --title "<new-title>"
69
69
  ```
70
70
 
71
+ ### 5. 告知用户
72
+
73
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
74
+
75
+ 如果修改了 Issue 标题,提示无需额外同步命令;后续按任务当前阶段继续执行对应工作流技能。
76
+
77
+ 如果修改了 PR 标题,提示 `create-pr` 已内联发布 reviewer 摘要,无需额外同步命令;后续按任务当前阶段继续执行对应工作流技能。
78
+
71
79
  ## 优势
72
80
 
73
81
  本技能的优势:
74
- 1. **修复误导性标题**:即使原始标题是"Help me",也能读取 body 并生成合适的标题,如 `fix(core): resolve startup error`
82
+ 1. **修复误导性标题**:即使原始标题是"Help me",也能读取 body 并生成合适的标题,如 `fix(core): 修复启动错误` 或 `fix(core): resolve startup error`
75
83
  2. **精确 scope**:通过分析 PR 文件变更,可以自动推断正确的 scope,无需手动指定
76
84
 
77
85
  ## 注意事项
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: restore-task
3
+ description: "Restore local task files from GitHub Issue comments"
4
+ ---
5
+
6
+ # Restore Task
7
+
8
+ Restore local task workspace files from GitHub Issue comments that contain sync markers.
9
+
10
+ ## Boundary / Critical Rules
11
+
12
+ - Restore files only from comments marked with `<!-- sync-issue:{task-id}:... -->`
13
+ - Restore into `.agents/workspace/active/{task-id}/` by default
14
+ - Stop immediately if the target directory already exists and ask the user to resolve the conflict first
15
+ - After executing this skill, you **must** immediately update the restored `task.md`
16
+
17
+ ## Steps
18
+
19
+ ### 1. Verify Input and Environment
20
+
21
+ Check:
22
+ - required `{issue-number}`
23
+ - optional `{task-id}`
24
+ - `gh auth status`
25
+
26
+ If the user provided `{task-id}`, validate the `TASK-{yyyyMMdd-HHmmss}` format.
27
+
28
+ ### 2. Fetch Issue Comments
29
+
30
+ Read all Issue comments while preserving the original order and comment IDs.
31
+
32
+ Suggested command:
33
+
34
+ ```bash
35
+ gh api "repos/{owner}/{repo}/issues/{issue-number}/comments" --paginate
36
+ ```
37
+
38
+ ### 3. Determine the task-id and Files to Restore
39
+
40
+ Filter comments by these hidden markers:
41
+
42
+ ```html
43
+ <!-- sync-issue:{task-id}:{file-stem} -->
44
+ <!-- sync-issue:{task-id}:{file-stem}:{part}/{total} -->
45
+ ```
46
+
47
+ Rules:
48
+ - when `{task-id}` was provided, match only that task
49
+ - when `{task-id}` was omitted, infer it from the `<!-- sync-issue:{task-id}:task -->` comment first
50
+ - if you cannot determine a unique task-id, stop and tell the user
51
+ - ignore `summary` marker comments because they are complete-task aggregate output rather than restorable local task files
52
+ - map `{file-stem}` back to filenames:
53
+ - `task` -> `task.md`
54
+ - `analysis` / `analysis-r{N}` -> matching `.md`
55
+ - `plan` / `plan-r{N}` -> matching `.md`
56
+ - `implementation` / `implementation-r{N}` -> matching `.md`
57
+ - `review` / `review-r{N}` -> matching `.md`
58
+ - `refinement` / `refinement-r{N}` -> matching `.md`
59
+
60
+ ### 4. Process Chunks and Check the Local Directory
61
+
62
+ Read `.agents/rules/issue-sync.md` before executing this step.
63
+
64
+ For each file:
65
+ - collect its single comment or chunked comments
66
+ - for `task.md` comments, reverse the `<details>` frontmatter wrapper described in issue-sync.md before reassembling the file body
67
+ - when `{part}/{total}` exists, sort by part and verify the set is complete
68
+ - extract the file body by removing the hidden marker, heading, and footer
69
+ - concatenate chunk bodies into the final file content
70
+
71
+ Before writing any file, verify that:
72
+ - `.agents/workspace/active/{task-id}/` does not exist
73
+
74
+ If the directory already exists, stop immediately and tell the user to handle it manually first.
75
+
76
+ ### 5. Write the Local Files
77
+
78
+ Create `.agents/workspace/active/{task-id}/` and write files back in this order:
79
+
80
+ 1. `task.md`
81
+ 2. every other restored artifact file in filename order
82
+
83
+ Write only files that were actually recovered from Issue comments. Do not invent missing files.
84
+
85
+ ### 6. Update the Restored task.md
86
+
87
+ Get the current time:
88
+
89
+ ```bash
90
+ date "+%Y-%m-%d %H:%M:%S"
91
+ ```
92
+
93
+ Update the restored `task.md`:
94
+ - `status`: `active`
95
+ - `assigned_to`: {current AI agent}
96
+ - `updated_at`: {current time}
97
+ - keep the original `current_step`
98
+ - append this entry to `## Activity Log`:
99
+ ```
100
+ - {yyyy-MM-dd HH:mm:ss} — **Restore Task** by {agent} — Restored task from Issue #{issue-number}
101
+ ```
102
+
103
+ ### 7. Verification Gate
104
+
105
+ Run the verification gate:
106
+
107
+ ```bash
108
+ node .agents/scripts/validate-artifact.js gate restore-task .agents/workspace/active/{task-id} --format text
109
+ ```
110
+
111
+ Handle the result as follows:
112
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
113
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
114
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
115
+
116
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
117
+
118
+ ### 8. Inform User
119
+
120
+ > Execute this step only after the verification gate passes.
121
+
122
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
123
+
124
+ Output format:
125
+
126
+ ```text
127
+ Task {task-id} was restored from Issue #{issue-number}.
128
+
129
+ Summary:
130
+ - Restored files: {count}
131
+ - Task directory: .agents/workspace/active/{task-id}/
132
+ - Current step: {current_step}
133
+
134
+ Next step - check task status:
135
+ - Claude Code / OpenCode: /check-task {task-id}
136
+ - Gemini CLI: /{{project}}:check-task {task-id}
137
+ - Codex CLI: $check-task {task-id}
138
+ ```
139
+
140
+ ## Completion Checklist
141
+
142
+ - [ ] Fetched and parsed Issue comments
143
+ - [ ] Restored `task.md` and every available artifact file
144
+ - [ ] Updated the restored task.md
145
+ - [ ] Ran and passed the verification gate
146
+ - [ ] Showed the next-step commands in every TUI format
147
+
148
+ ## STOP
149
+
150
+ Stop after completing the checklist. Do not continue the workflow automatically.
151
+
152
+ ## Error Handling
153
+
154
+ - Issue missing or inaccessible
155
+ - `gh` unavailable or unauthenticated
156
+ - No sync-marked comments found
157
+ - Unable to determine a unique `task-id`
158
+ - Target directory already exists
159
+ - Missing chunks or incomplete chunk ordering
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: restore-task
3
+ description: "从 GitHub Issue 评论还原本地任务文件"
4
+ ---
5
+
6
+ # 还原任务
7
+
8
+ 从带有 sync 标记的 GitHub Issue 评论中恢复本地任务工作区文件。
9
+
10
+ ## 行为边界 / 关键规则
11
+
12
+ - 只从带 `<!-- sync-issue:{task-id}:... -->` 标记的评论恢复文件
13
+ - 默认恢复到 `.agents/workspace/active/{task-id}/`
14
+ - 如果目标目录已存在,立即停止并提示用户先处理目录冲突
15
+ - 执行本技能后,你**必须**立即更新恢复出的 `task.md`
16
+
17
+ ## 执行步骤
18
+
19
+ ### 1. 验证输入与环境
20
+
21
+ 检查:
22
+ - 必填参数 `{issue-number}`
23
+ - 可选参数 `{task-id}`
24
+ - `gh auth status`
25
+
26
+ 如果用户传入了 `{task-id}`,校验其格式为 `TASK-{yyyyMMdd-HHmmss}`。
27
+
28
+ ### 2. 获取 Issue 评论
29
+
30
+ 读取 Issue 的全部评论,保留原始顺序和评论 ID。
31
+
32
+ 建议命令:
33
+
34
+ ```bash
35
+ gh api "repos/{owner}/{repo}/issues/{issue-number}/comments" --paginate
36
+ ```
37
+
38
+ ### 3. 确定 task-id 与待恢复文件
39
+
40
+ 从评论中筛选隐藏标记:
41
+
42
+ ```html
43
+ <!-- sync-issue:{task-id}:{file-stem} -->
44
+ <!-- sync-issue:{task-id}:{file-stem}:{part}/{total} -->
45
+ ```
46
+
47
+ 处理规则:
48
+ - 用户提供了 `{task-id}` 时,仅匹配该任务
49
+ - 未提供时,优先从 `<!-- sync-issue:{task-id}:task -->` 评论推断
50
+ - 若找不到唯一 task-id,立即停止并告知用户
51
+ - 忽略 `summary` 标记评论;它是 complete-task 的聚合产物,不对应本地任务文件
52
+ - 将 `{file-stem}` 映射回文件名:
53
+ - `task` -> `task.md`
54
+ - `analysis` / `analysis-r{N}` -> 对应 `.md`
55
+ - `plan` / `plan-r{N}` -> 对应 `.md`
56
+ - `implementation` / `implementation-r{N}` -> 对应 `.md`
57
+ - `review` / `review-r{N}` -> 对应 `.md`
58
+ - `refinement` / `refinement-r{N}` -> 对应 `.md`
59
+
60
+ ### 4. 处理分片并检查本地目录
61
+
62
+ 执行本步骤前先读取 `.agents/rules/issue-sync.md`。
63
+
64
+ 对每个文件执行:
65
+ - 收集单条评论或分片评论
66
+ - 对 `task.md` 评论按 issue-sync.md 中的 `<details>` frontmatter 格式反向拆解,提取 frontmatter 后再与正文拼合
67
+ - 如存在 `{part}/{total}`,按 part 升序排序并校验分片完整
68
+ - 从评论正文中提取文件内容,去掉隐藏标记、标题和页脚
69
+ - 拼接得到最终文件内容
70
+
71
+ 在写文件前检查:
72
+ - `.agents/workspace/active/{task-id}/` 不存在
73
+
74
+ 如果目录已存在,立即停止并提示用户先手动处理。
75
+
76
+ ### 5. 写回本地文件
77
+
78
+ 创建 `.agents/workspace/active/{task-id}/`,按以下顺序写回:
79
+
80
+ 1. `task.md`
81
+ 2. 其余产物文件(按文件名排序)
82
+
83
+ 仅写回从 Issue 评论中实际恢复出的文件,不补造缺失文件。
84
+
85
+ ### 6. 更新恢复后的 task.md
86
+
87
+ 获取当前时间:
88
+
89
+ ```bash
90
+ date "+%Y-%m-%d %H:%M:%S"
91
+ ```
92
+
93
+ 更新恢复出的 `task.md`:
94
+ - `status`:`active`
95
+ - `assigned_to`:{当前 AI 代理}
96
+ - `updated_at`:{当前时间}
97
+ - 保留原 `current_step`
98
+ - 在 `## 活动日志` 追加:
99
+ ```
100
+ - {yyyy-MM-dd HH:mm:ss} — **Restore Task** by {agent} — Restored task from Issue #{issue-number}
101
+ ```
102
+
103
+ ### 7. 完成校验
104
+
105
+ 运行完成校验:
106
+
107
+ ```bash
108
+ node .agents/scripts/validate-artifact.js gate restore-task .agents/workspace/active/{task-id} --format text
109
+ ```
110
+
111
+ 处理结果:
112
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
113
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
114
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
115
+
116
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
117
+
118
+ ### 8. 告知用户
119
+
120
+ > 仅在校验通过后执行本步骤。
121
+
122
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
123
+
124
+ 输出格式:
125
+
126
+ ```text
127
+ 任务 {task-id} 已从 Issue #{issue-number} 还原。
128
+
129
+ 摘要:
130
+ - 恢复文件:{数量}
131
+ - 任务目录:.agents/workspace/active/{task-id}/
132
+ - 当前步骤:{current_step}
133
+
134
+ 下一步 - 查看任务状态:
135
+ - Claude Code / OpenCode:/check-task {task-id}
136
+ - Gemini CLI:/{{project}}:check-task {task-id}
137
+ - Codex CLI:$check-task {task-id}
138
+ ```
139
+
140
+ ## 完成检查清单
141
+
142
+ - [ ] 已获取并解析 Issue 评论
143
+ - [ ] 已还原 `task.md` 和所有可用产物文件
144
+ - [ ] 已更新恢复后的 task.md
145
+ - [ ] 已运行并通过完成校验
146
+ - [ ] 已向用户展示所有 TUI 格式的下一步命令
147
+
148
+ ## 停止
149
+
150
+ 完成检查清单后立即停止。不要自动继续执行工作流。
151
+
152
+ ## 错误处理
153
+
154
+ - Issue 不存在或无权访问
155
+ - `gh` 未认证
156
+ - 找不到带 sync 标记的评论
157
+ - 无法唯一确定 `task-id`
158
+ - 目标目录已存在
159
+ - 分片缺失或顺序不完整
@@ -0,0 +1,24 @@
1
+ {
2
+ "skill": "restore-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
+ ],
15
+ "expected_status": "active",
16
+ "require_issue_number": true
17
+ },
18
+ "activity-log": {
19
+ "expected_action_pattern": "Restore Task",
20
+ "freshness_minutes": 30
21
+ },
22
+ "github-sync": null
23
+ }
24
+ }
@@ -53,7 +53,30 @@ date "+%Y-%m-%d %H:%M:%S"
53
53
  Update task.md and append:
54
54
  `- {yyyy-MM-dd HH:mm:ss} — **Code Review (Round {N})** by {agent} — Verdict: {Approved/Changes Requested/Rejected}, blockers: {n}, major: {n}, minor: {n} → {artifact-filename}`
55
55
 
56
- ### 7. Inform User
56
+ If task.md contains a valid `issue_number`, perform these sync actions (skip and continue on any failure):
57
+ - Read `.agents/rules/issue-sync.md` before syncing
58
+ - Set `status: in-progress`
59
+ - Publish the `{review-artifact}` comment
60
+ - Create or update the `<!-- sync-issue:{task-id}:task -->` comment (follow the task.md comment sync rule in issue-sync.md)
61
+
62
+ ### 7. Verification Gate
63
+
64
+ Run the verification gate to confirm the task artifact and sync state are valid:
65
+
66
+ ```bash
67
+ node .agents/scripts/validate-artifact.js gate review-task .agents/workspace/active/{task-id} {review-artifact} --format text
68
+ ```
69
+
70
+ Handle the result as follows:
71
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
72
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
73
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
74
+
75
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
76
+
77
+ ### 8. Inform User
78
+
79
+ > Execute this step only after the verification gate passes.
57
80
 
58
81
  Choose exactly one branch based on the findings:
59
82
  - no blockers, no major, no minor -> approved with no issues
@@ -71,6 +94,7 @@ Include all TUI command formats in the next-step output.
71
94
  - [ ] Created `{review-artifact}`
72
95
  - [ ] Updated task.md and appended the Activity Log entry
73
96
  - [ ] Chose exactly one verdict branch in the user output
97
+ - [ ] Informed the user of the next step (must include all TUI command formats; do not filter)
74
98
 
75
99
  ## Notes
76
100
 
@@ -53,7 +53,30 @@ date "+%Y-%m-%d %H:%M:%S"
53
53
  更新 task.md,并追加:
54
54
  `- {yyyy-MM-dd HH:mm:ss} — **Code Review (Round {N})** by {agent} — Verdict: {Approved/Changes Requested/Rejected}, blockers: {n}, major: {n}, minor: {n} → {artifact-filename}`
55
55
 
56
- ### 7. 告知用户
56
+ 如果 task.md 中存在有效的 `issue_number`,执行以下同步操作(任一失败则跳过并继续):
57
+ - 执行前先读取 `.agents/rules/issue-sync.md`
58
+ - 设置 `status: in-progress`
59
+ - 发布 `{review-artifact}` 评论
60
+ - 创建或更新 `<!-- sync-issue:{task-id}:task -->` 评论(按 issue-sync.md 的 task.md 评论同步规则)
61
+
62
+ ### 7. 完成校验
63
+
64
+ 运行完成校验,确认任务产物和同步状态符合规范:
65
+
66
+ ```bash
67
+ node .agents/scripts/validate-artifact.js gate review-task .agents/workspace/active/{task-id} {review-artifact} --format text
68
+ ```
69
+
70
+ 处理结果:
71
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
72
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
73
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
74
+
75
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
76
+
77
+ ### 8. 告知用户
78
+
79
+ > 仅在校验通过后执行本步骤。
57
80
 
58
81
  必须先判断结果,再只选择一个输出分支:
59
82
  - 无 blocker、major、minor -> 通过且无问题
@@ -71,6 +94,7 @@ date "+%Y-%m-%d %H:%M:%S"
71
94
  - [ ] 已创建 `{review-artifact}`
72
95
  - [ ] 已更新 task.md 并追加 Activity Log
73
96
  - [ ] 用户输出中只选择了一个审查结论分支
97
+ - [ ] 告知了用户下一步(必须展示所有 TUI 的命令格式,不要筛选)
74
98
 
75
99
  ## 注意事项
76
100
 
@@ -0,0 +1,40 @@
1
+ {
2
+ "skill": "review-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
+ ]
15
+ },
16
+ "artifact": {
17
+ "file_pattern": "review.md|review-r{N}.md",
18
+ "required_sections": [
19
+ "审查摘要",
20
+ "问题清单",
21
+ "结论与建议"
22
+ ],
23
+ "required_patterns": [
24
+ "^### 审查决定$"
25
+ ],
26
+ "freshness_minutes": 30
27
+ },
28
+ "activity-log": {
29
+ "expected_action_pattern": "Code Review \\(Round \\d+\\)",
30
+ "freshness_minutes": 30
31
+ },
32
+ "github-sync": {
33
+ "when": "issue_number_exists",
34
+ "expected_status_label": "status: in-progress",
35
+ "expected_comment_marker": "<!-- sync-issue:{task-id}:{artifact-stem} -->",
36
+ "verify_comment_content": true,
37
+ "verify_task_comment_content": true
38
+ }
39
+ }
40
+ }
@@ -129,4 +129,15 @@ Based on the script report and merged results, output a complete update report i
129
129
  - Ejected file processing
130
130
  - Self-update detection result
131
131
 
132
+ If there are changes to submit, add:
133
+
134
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
135
+
136
+ ```
137
+ Next step - commit changes:
138
+ - Claude Code / OpenCode: /commit
139
+ - Gemini CLI: /{{project}}:commit
140
+ - Codex CLI: $commit
141
+ ```
142
+
132
143
  Output the report, then **STOP** — do not make other changes to the project.
@@ -119,4 +119,15 @@ node .agents/skills/update-agent-infra/scripts/sync-templates.js
119
119
  - ejected 文件处理
120
120
  - 自身更新检测结果
121
121
 
122
+ 如有变更需要提交,追加:
123
+
124
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
125
+
126
+ ```
127
+ 下一步 - 提交代码:
128
+ - Claude Code / OpenCode:/commit
129
+ - Gemini CLI:/agent-infra:commit
130
+ - Codex CLI:$commit
131
+ ```
132
+
122
133
  输出报告后**停止**,不要对项目做其他更改。