@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
@@ -1,6 +1,6 @@
1
1
  # PR Summary Comment Publication
2
2
 
3
- Read this file before creating or updating the single reviewer-facing PR summary comment.
3
+ Read this file before creating or updating the single reviewer-facing PR summary comment from `create-pr`.
4
4
 
5
5
  ## Create or Update the Single Idempotent Review Summary
6
6
 
@@ -54,7 +54,8 @@ Suggested summary body:
54
54
  <!-- sync-pr:{task-id}:summary -->
55
55
  ## Review Summary
56
56
 
57
- **Task**: {task-id}
57
+ > **{agent}** · {task-id}
58
+
58
59
  **Updated At**: {current-time}
59
60
 
60
61
  ### Key Technical Decisions
@@ -73,10 +74,9 @@ Suggested summary body:
73
74
  - {test-summary}
74
75
 
75
76
  ---
76
- *Generated by AI · Internal tracking: {task-id}*
77
+ *Generated by {agent} · Internal tracking: {task-id}*
77
78
  ```
78
79
 
79
- ## Update Task Status
80
+ ## Return the Result
80
81
 
81
- Append:
82
- `- {yyyy-MM-dd HH:mm:ss} — **Sync to PR** by {agent} — PR metadata synced, summary {created|updated|skipped} on PR #{pr-number}`
82
+ Return the summary outcome as `summary created`, `summary updated`, or `summary skipped` so `create-pr` can reuse it in user output and the PR Created Activity Log.
@@ -1,6 +1,6 @@
1
1
  # PR 摘要评论发布
2
2
 
3
- 在创建或更新面向 reviewer 的唯一 PR 摘要评论之前先读取本文件。
3
+ `create-pr` 中创建或更新面向 reviewer 的唯一 PR 摘要评论之前先读取本文件。
4
4
 
5
5
  ## 创建或更新唯一且幂等的审查摘要
6
6
 
@@ -54,7 +54,8 @@ EOF
54
54
  <!-- sync-pr:{task-id}:summary -->
55
55
  ## 审查摘要
56
56
 
57
- **任务**:{task-id}
57
+ > **{agent}** · {task-id}
58
+
58
59
  **更新时间**:{当前时间}
59
60
 
60
61
  ### 关键技术决策
@@ -73,10 +74,9 @@ EOF
73
74
  - {test-summary}
74
75
 
75
76
  ---
76
- *由 AI 自动生成 · 内部追踪:{task-id}*
77
+ *由 {agent} 自动生成 · 内部追踪:{task-id}*
77
78
  ```
78
79
 
79
- ## 更新任务状态
80
+ ## 结果回传
80
81
 
81
- 追加:
82
- `- {yyyy-MM-dd HH:mm:ss} — **Sync to PR** by {agent} — PR metadata synced, summary {created|updated|skipped} on PR #{pr-number}`
82
+ 将摘要结果整理为 `summary created`、`summary updated` 或 `summary skipped`,供 `create-pr` 在用户输出和 PR Created Activity Log 中复用。
@@ -50,14 +50,19 @@ Metadata sync order:
50
50
  1. query Issue labels and milestone best-effort with `gh issue view {issue-number} --json labels,milestone`
51
51
  2. add the mapped type label with `gh pr edit {pr-number} --add-label "{type-label}"`
52
52
  3. inherit non-`type:` and non-`status:` Issue labels with repeated `gh pr edit ... --add-label`
53
- 4. add relevant `in: {module}` labels without removing existing ones
54
- 5. resolve milestone in order: PR -> task.md -> Issue -> branch/tag inference -> `General Backlog`
53
+ 4. refine the PR `in:` labels by following `.agents/rules/issue-sync.md`, and keep the linked Issue `in:` labels in sync with the same result
54
+ 5. handle the milestone by following "Phase 3: `create-pr`" in `.agents/rules/milestone-inference.md`, reusing the Issue milestone directly
55
55
  6. ensure the PR body contains `Closes #{issue-number}` or an equivalent closing keyword
56
56
 
57
+ Milestone rule:
58
+ - Follow "Phase 3: `create-pr`" in `.agents/rules/milestone-inference.md`
59
+ - Reuse the linked Issue milestone directly instead of inferring a new PR milestone
60
+
57
61
  ## Create the PR
58
62
 
59
63
  - Extract `issue_number` from task.md when this work belongs to an active task
60
64
  - If `issue_number` exists, query the Issue best-effort with `gh issue view {issue-number} --json number,title --jq '.number'`
65
+ - Before calling `gh pr create`, check whether the current branch already has a PR. If it does, report the PR URL and state, then stop without repeating metadata sync or summary publication
61
66
  - Use HEREDOC to pass the PR body
62
67
  - Replace `{$IssueNumber}` in the template when present
63
68
  - End the PR body with `Generated with AI assistance`
@@ -71,14 +76,10 @@ EOF
71
76
  )"
72
77
  ```
73
78
 
74
- Final user output should include both follow-up paths in order:
79
+ Final user output should include this follow-up path:
75
80
 
76
81
  ```text
77
82
  Next steps:
78
- - optional reviewer summary sync:
79
- - Claude Code / OpenCode: /sync-pr {task-id}
80
- - Gemini CLI: /agent-infra:sync-pr {task-id}
81
- - Codex CLI: $sync-pr {task-id}
82
83
  - complete the task after the workflow truly finishes:
83
84
  - Claude Code / OpenCode: /complete-task {task-id}
84
85
  - Gemini CLI: /agent-infra:complete-task {task-id}
@@ -50,14 +50,19 @@ Type label 映射:
50
50
  1. 用 `gh issue view {issue-number} --json labels,milestone` 尽力查询 Issue 的 labels 和 milestone
51
51
  2. 用 `gh pr edit {pr-number} --add-label "{type-label}"` 添加映射后的 type label
52
52
  3. 用重复的 `gh pr edit ... --add-label` 继承非 `type:`、非 `status:` 的 Issue labels
53
- 4. 添加相关的 `in: {module}` label,但不要移除已有 label
54
- 5. 按 `PR -> task.md -> Issue -> branch/tag inference -> General Backlog` 的顺序解析 milestone
53
+ 4. `.agents/rules/issue-sync.md` 的 `in:` label 同步规则精修 PR 的 `in:` label,同时同步更新关联 Issue 的 `in:` label 保持一致
54
+ 5. 按 `.agents/rules/milestone-inference.md` 的「阶段 3:`create-pr`」处理 milestone,直接复用 Issue milestone
55
55
  6. 确保 PR 正文包含 `Closes #{issue-number}` 或等价的 closing keyword
56
56
 
57
+ Milestone 规则:
58
+ - 按 `.agents/rules/milestone-inference.md` 的「阶段 3:`create-pr`」处理
59
+ - PR 直接复用 Issue milestone,不再独立推断
60
+
57
61
  ## 创建 PR
58
62
 
59
63
  - 当当前工作属于活动任务时,从 task.md 中提取 `issue_number`
60
64
  - 如果存在 `issue_number`,用 `gh issue view {issue-number} --json number,title --jq '.number'` 尽力查询对应 Issue
65
+ - 在调用 `gh pr create` 前,先检查当前分支是否已经存在 PR;如果已存在,直接告知用户 PR URL 和状态并结束,不要重复同步元数据或摘要
61
66
  - 使用 HEREDOC 传递 PR 正文
62
67
  - 如果模板中存在 `{$IssueNumber}`,替换它
63
68
  - PR 正文结尾必须带上 `Generated with AI assistance`
@@ -71,14 +76,10 @@ EOF
71
76
  )"
72
77
  ```
73
78
 
74
- 最终用户输出必须按顺序包含这两类后续动作:
79
+ 最终用户输出必须按顺序包含以下后续动作:
75
80
 
76
81
  ```text
77
82
  下一步:
78
- - 可选:同步 reviewer 摘要:
79
- - Claude Code / OpenCode: /sync-pr {task-id}
80
- - Gemini CLI: /agent-infra:sync-pr {task-id}
81
- - Codex CLI: $sync-pr {task-id}
82
83
  - 工作流真正结束后完成任务:
83
84
  - Claude Code / OpenCode: /complete-task {task-id}
84
85
  - Gemini CLI: /agent-infra:complete-task {task-id}
@@ -24,7 +24,7 @@ After executing this skill, you **must** immediately update task status in task.
24
24
  ### 1. Parse the User Description
25
25
 
26
26
  Extract from the natural-language description:
27
- - **Task title**: a concise title (maximum 50 characters), in the same language as the user's description
27
+ - **Task title**: a concise title (maximum 50 characters), in the same language as the user's description - do not translate it to English or apply Conventional Commits formatting
28
28
  - **Task type**: `feature` | `bugfix` | `refactor` | `docs` | `chore` (infer from the description)
29
29
  - **Workflow**: `feature-development` | `bug-fix` | `refactoring` (infer from the type)
30
30
  - **Detailed description**: the cleaned-up original user request
@@ -92,7 +92,24 @@ Update `.agents/workspace/active/{task-id}/task.md`:
92
92
  - {yyyy-MM-dd HH:mm:ss} — **Task Created** by {agent} — Task created from description
93
93
  ```
94
94
 
95
- ### 4. Inform User
95
+ ### 4. Verification Gate
96
+
97
+ Run the verification gate to confirm the task artifact and sync state are valid:
98
+
99
+ ```bash
100
+ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/active/{task-id} --format text
101
+ ```
102
+
103
+ Handle the result as follows:
104
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
105
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
106
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
107
+
108
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
109
+
110
+ ### 5. Inform User
111
+
112
+ > Execute this step only after the verification gate passes.
96
113
 
97
114
  > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
98
115
 
@@ -113,6 +130,11 @@ Next step - run requirements analysis:
113
130
  - Claude Code / OpenCode: /analyze-task {task-id}
114
131
  - Gemini CLI: /{{project}}:analyze-task {task-id}
115
132
  - Codex CLI: $analyze-task {task-id}
133
+
134
+ Or create a GitHub Issue first:
135
+ - Claude Code / OpenCode: /create-issue {task-id}
136
+ - Gemini CLI: /{{project}}:create-issue {task-id}
137
+ - Codex CLI: $create-issue {task-id}
116
138
  ```
117
139
 
118
140
  ## Completion Checklist
@@ -134,7 +156,7 @@ Wait for the user to run the `analyze-task` skill.
134
156
 
135
157
  1. **Clarity**: if the user description is vague or missing key information, ask for clarification first
136
158
  2. **Difference from `import-issue`**: `import-issue` imports from a GitHub Issue; `create-task` creates from a free-form description
137
- 3. **Workflow order**: after creating a task, `analyze-task` must run before `plan-task`
159
+ 3. **Workflow order**: after creating a task, typically run `analyze-task` before `plan-task`; if you need GitHub tracking first, you may run `create-issue` first
138
160
 
139
161
  ## Error Handling
140
162
 
@@ -24,7 +24,7 @@ description: "根据自然语言描述创建任务"
24
24
  ### 1. 解析用户描述
25
25
 
26
26
  从自然语言描述中提取:
27
- - **任务标题**:简洁标题(最多 50 个字符),使用与用户描述相同的语言
27
+ - **任务标题**:简洁标题(最多 50 个字符),使用中文——不要翻译为英文,不要套用 Conventional Commits 格式
28
28
  - **任务类型**:`feature` | `bugfix` | `refactor` | `docs` | `chore`(从描述推断)
29
29
  - **工作流**:`feature-development` | `bug-fix` | `refactoring`(从类型推断)
30
30
  - **详细描述**:整理后的用户原始描述
@@ -92,7 +92,24 @@ date "+%Y-%m-%d %H:%M:%S"
92
92
  - {yyyy-MM-dd HH:mm:ss} — **Task Created** by {agent} — Task created from description
93
93
  ```
94
94
 
95
- ### 4. 告知用户
95
+ ### 4. 完成校验
96
+
97
+ 运行完成校验,确认任务产物和同步状态符合规范:
98
+
99
+ ```bash
100
+ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/active/{task-id} --format text
101
+ ```
102
+
103
+ 处理结果:
104
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
105
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
106
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
107
+
108
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
109
+
110
+ ### 5. 告知用户
111
+
112
+ > 仅在校验通过后执行本步骤。
96
113
 
97
114
  > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
98
115
 
@@ -113,6 +130,11 @@ date "+%Y-%m-%d %H:%M:%S"
113
130
  - Claude Code / OpenCode:/analyze-task {task-id}
114
131
  - Gemini CLI:/agent-infra:analyze-task {task-id}
115
132
  - Codex CLI:$analyze-task {task-id}
133
+
134
+ 或先创建 GitHub Issue:
135
+ - Claude Code / OpenCode:/create-issue {task-id}
136
+ - Gemini CLI:/agent-infra:create-issue {task-id}
137
+ - Codex CLI:$create-issue {task-id}
116
138
  ```
117
139
 
118
140
  ## 完成检查清单
@@ -134,7 +156,7 @@ date "+%Y-%m-%d %H:%M:%S"
134
156
 
135
157
  1. **清晰度**:如果用户描述模糊或缺少关键信息,先要求澄清
136
158
  2. **与 import-issue 的区别**:`import-issue` 从 GitHub Issue 导入任务;`create-task` 从自由描述创建
137
- 3. **工作流顺序**:创建任务后,必须先执行 `analyze-task`,再进入 `plan-task`
159
+ 3. **工作流顺序**:创建任务后,通常先执行 `analyze-task` 再进入 `plan-task`;如需先建立 GitHub 跟踪,也可先执行 `create-issue`
138
160
 
139
161
  ## 错误处理
140
162
 
@@ -0,0 +1,24 @@
1
+ {
2
+ "skill": "create-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_step": "requirement-analysis",
16
+ "expected_status": "active"
17
+ },
18
+ "activity-log": {
19
+ "expected_action_pattern": "Task Created",
20
+ "freshness_minutes": 30
21
+ },
22
+ "github-sync": null
23
+ }
24
+ }
@@ -24,7 +24,24 @@ Check these files first:
24
24
 
25
25
  If either file is missing, stop and ask the user to complete the prerequisite step.
26
26
 
27
- ### 2. Determine the Input Plan and Implementation Round
27
+ ### 2. Ensure the Task Branch
28
+
29
+ Read the branch field in `## Context` from `task.md` and check whether the current Git branch matches it.
30
+
31
+ - if a task branch is already recorded, switch to it when the current branch does not match
32
+ - if no branch is recorded, check whether the current branch follows the naming convention and belongs to this task
33
+ - if yes: record the current branch and continue
34
+ - if no: create and switch to a new task branch that follows the naming rule
35
+
36
+ After this step, write the final branch name back to `task.md`.
37
+
38
+ > Branch naming rules, Git commands, and edge-case handling live in `reference/branch-management.md`. Read `reference/branch-management.md` before executing this step.
39
+
40
+ ### 3. Narrow the Milestone
41
+
42
+ If task.md contains a valid `issue_number`, read `.agents/rules/milestone-inference.md` and follow "Phase 2: `implement-task`" to narrow the Issue milestone before implementation starts.
43
+
44
+ ### 4. Determine the Input Plan and Implementation Round
28
45
 
29
46
  Scan `.agents/workspace/active/{task-id}/` and record:
30
47
  - the highest-round plan file as `{plan-artifact}`
@@ -33,7 +50,7 @@ Scan `.agents/workspace/active/{task-id}/` and record:
33
50
 
34
51
  If any `plan-r{N}.md` exists, read the highest-round plan file. Otherwise read `plan.md`.
35
52
 
36
- ### 3. Read the Technical Plan
53
+ ### 5. Read the Technical Plan
37
54
 
38
55
  Read `{plan-artifact}` carefully and extract:
39
56
  - implementation steps
@@ -41,25 +58,25 @@ Read `{plan-artifact}` carefully and extract:
41
58
  - test strategy
42
59
  - constraints, risks, and any approved tradeoffs
43
60
 
44
- ### 4. Implement the Code
61
+ ### 6. Implement the Code
45
62
 
46
63
  Follow `.agents/workflows/feature-development.yaml` and the plan in order.
47
64
 
48
65
  > Detailed implementation rules, testing discipline, and deviation handling live in `reference/implementation-rules.md`. Read `reference/implementation-rules.md` before executing this step.
49
66
 
50
- ### 5. Run Test Verification
67
+ ### 7. Run Test Verification
51
68
 
52
69
  Use the project test command from the `test` skill and keep iterating until all required tests pass.
53
70
 
54
71
  If tests fail, Attempt to fix the issue and re-run tests first. Only stop when you confirm an external blocker, missing environment, or unclear requirement that is out of scope for the task.
55
72
 
56
- ### 6. Write the Implementation Report
73
+ ### 8. Write the Implementation Report
57
74
 
58
75
  Create `.agents/workspace/active/{task-id}/{implementation-artifact}`.
59
76
 
60
77
  > Report structure, required sections, and the full template live in `reference/report-template.md`. Read `reference/report-template.md` before writing the report.
61
78
 
62
- ### 7. Update Task Status
79
+ ### 9. Update Task Status
63
80
 
64
81
  Get the current time:
65
82
 
@@ -76,9 +93,31 @@ Update `.agents/workspace/active/{task-id}/task.md`:
76
93
  - append:
77
94
  `- {yyyy-MM-dd HH:mm:ss} — **Implementation (Round {N})** by {agent} — Code implemented, {n} files modified, {n} tests passed → {implementation-artifact}`
78
95
 
79
- ### 8. Inform the User
96
+ If task.md contains a valid `issue_number`, perform these sync actions (skip and continue on any failure; read `.agents/rules/issue-sync.md` first):
97
+ - Set `status: in-progress` and refine `in:` labels from the branch diff by following `.agents/rules/issue-sync.md` (add/remove when a mapping exists, add-only when it does not)
98
+ - Sync checked `## Requirements` items to the Issue body and publish the `{implementation-artifact}` comment
99
+ - Create or update the `<!-- sync-issue:{task-id}:task -->` comment (follow the task.md comment sync rule in issue-sync.md)
100
+
101
+ ### 10. Verification Gate
102
+
103
+ Run the verification gate to confirm the task artifact and sync state are valid:
104
+
105
+ ```bash
106
+ node .agents/scripts/validate-artifact.js gate implement-task .agents/workspace/active/{task-id} {implementation-artifact} --format text
107
+ ```
108
+
109
+ Handle the result as follows:
110
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
111
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
112
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
113
+
114
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
115
+
116
+ ### 11. Inform User
117
+
118
+ > Execute this step only after the verification gate passes.
80
119
 
81
- Output the implementation summary and include all TUI command variants for the next review step.
120
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent. Use the output template in `reference/output-template.md`.
82
121
 
83
122
  ## Completion Checklist
84
123
 
@@ -24,7 +24,24 @@ description: "根据技术方案实施任务并输出报告"
24
24
 
25
25
  如果缺少任一文件,立即停止并提示用户先完成前置步骤。
26
26
 
27
- ### 2. 确定输入方案与实现轮次
27
+ ### 2. 确保任务分支
28
+
29
+ 先读取 `task.md` 中 `## 上下文` 的分支字段,并检查当前 Git 分支是否匹配。
30
+
31
+ - 已记录任务分支:当前分支不匹配时切换到该分支
32
+ - 未记录任务分支:判断当前分支是否符合命名规范且属于当前任务
33
+ - 符合:记录当前分支并继续
34
+ - 不符合:按规范创建并切换到新的任务分支
35
+
36
+ 完成后,把最终使用的分支名回写到 `task.md`。
37
+
38
+ > 分支命名规则、Git 命令和边界处理见 `reference/branch-management.md`。执行此步骤前,先读取 `reference/branch-management.md`。
39
+
40
+ ### 3. 收窄里程碑
41
+
42
+ 如果 task.md 中存在有效的 `issue_number`,按 `.agents/rules/milestone-inference.md` 的「阶段 2:`implement-task`」收窄 Issue milestone。执行前先读取该文件。
43
+
44
+ ### 4. 确定输入方案与实现轮次
28
45
 
29
46
  扫描 `.agents/workspace/active/{task-id}/` 并记录:
30
47
  - 最高轮次的方案文件为 `{plan-artifact}`
@@ -33,7 +50,7 @@ description: "根据技术方案实施任务并输出报告"
33
50
 
34
51
  如果存在 `plan-r{N}.md`,读取最高轮次的方案文件;否则读取 `plan.md`。
35
52
 
36
- ### 3. 阅读技术方案
53
+ ### 5. 阅读技术方案
37
54
 
38
55
  仔细阅读 `{plan-artifact}`,提取:
39
56
  - 实施步骤
@@ -41,25 +58,25 @@ description: "根据技术方案实施任务并输出报告"
41
58
  - 测试策略
42
59
  - 约束、风险与已批准的取舍
43
60
 
44
- ### 4. 执行代码实现
61
+ ### 6. 执行代码实现
45
62
 
46
63
  按照 `.agents/workflows/feature-development.yaml` 和方案顺序实施。
47
64
 
48
65
  > 详细实现规则、测试纪律和偏离处理见 `reference/implementation-rules.md`。执行此步骤前,先读取 `reference/implementation-rules.md`。
49
66
 
50
- ### 5. 运行测试验证
67
+ ### 7. 运行测试验证
51
68
 
52
69
  使用 `test` 技能中的项目测试命令,直到所有必需测试通过。
53
70
 
54
71
  如果测试失败,先尝试修复并重新运行测试。只有在确认存在外部阻塞、环境缺失或需求不明确且超出任务范围时,才可以停止。
55
72
 
56
- ### 6. 编写实现报告
73
+ ### 8. 编写实现报告
57
74
 
58
75
  创建 `.agents/workspace/active/{task-id}/{implementation-artifact}`。
59
76
 
60
77
  > 报告结构、必填章节和完整模板见 `reference/report-template.md`。写报告前先读取 `reference/report-template.md`。
61
78
 
62
- ### 7. 更新任务状态
79
+ ### 9. 更新任务状态
63
80
 
64
81
  获取当前时间:
65
82
 
@@ -76,9 +93,31 @@ date "+%Y-%m-%d %H:%M:%S"
76
93
  - 追加:
77
94
  `- {yyyy-MM-dd HH:mm:ss} — **Implementation (Round {N})** by {agent} — Code implemented, {n} files modified, {n} tests passed → {implementation-artifact}`
78
95
 
79
- ### 8. 告知用户
96
+ 如果 task.md 中存在有效的 `issue_number`,执行以下同步操作(任一失败则跳过并继续;执行前先读取 `.agents/rules/issue-sync.md`):
97
+ - 设置 `status: in-progress`,并按 `.agents/rules/issue-sync.md` 的 `in:` label 同步规则,基于分支改动精修 `in:` label(有映射时可增可删,无映射时仅补充)
98
+ - 同步 `## 需求` 中已勾选项到 Issue body,并发布 `{implementation-artifact}` 评论
99
+ - 创建或更新 `<!-- sync-issue:{task-id}:task -->` 评论(按 issue-sync.md 的 task.md 评论同步规则)
100
+
101
+ ### 10. 完成校验
102
+
103
+ 运行完成校验,确认任务产物和同步状态符合规范:
104
+
105
+ ```bash
106
+ node .agents/scripts/validate-artifact.js gate implement-task .agents/workspace/active/{task-id} {implementation-artifact} --format text
107
+ ```
108
+
109
+ 处理结果:
110
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
111
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
112
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
113
+
114
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
115
+
116
+ ### 11. 告知用户
117
+
118
+ > 仅在校验通过后执行本步骤。
80
119
 
81
- 输出实现摘要,并完整展示下一步代码审查的所有 TUI 命令格式。
120
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。输出格式见 `reference/output-template.md`。
82
121
 
83
122
  ## 完成检查清单
84
123
 
@@ -0,0 +1,43 @@
1
+ {
2
+ "skill": "implement-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_step": "implementation"
16
+ },
17
+ "artifact": {
18
+ "file_pattern": "implementation.md|implementation-r{N}.md",
19
+ "required_sections": [
20
+ "变更文件",
21
+ "关键代码说明",
22
+ "测试结果",
23
+ "与方案的差异",
24
+ "供审查关注的内容"
25
+ ],
26
+ "freshness_minutes": 30
27
+ },
28
+ "activity-log": {
29
+ "expected_action_pattern": "Implementation \\(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
+ "sync_checked_requirements": true,
39
+ "verify_issue_type": true,
40
+ "verify_milestone": true
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,48 @@
1
+ # Branch Management
2
+
3
+ Read this file before ensuring the task branch.
4
+
5
+ ## Branch Naming Rule
6
+
7
+ - Format: `{{project}}-{type}-{slug}`
8
+ - project prefix: read the `project` field from `.agents/.airc.json`
9
+ - `{type}`: read the `type` field from the task frontmatter
10
+ - `{slug}`: derive a 3-6 word English kebab-case phrase from the task title
11
+
12
+ ## Branch Detection Flow
13
+
14
+ Read these inputs first:
15
+ - the `- **Branch**:` field under `## Context` in `task.md`
16
+ - the current branch from `git branch --show-current`
17
+
18
+ A recorded branch is valid when it has a non-empty value other than `TBD`, `to be created`, or `N/A`.
19
+
20
+ Scenario A: `task.md` already records the task branch
21
+ - if the current branch matches, continue
22
+ - if it does not match, follow the "Create and Switch Commands" section below to switch to the recorded branch
23
+
24
+ Scenario B: `task.md` has no task branch recorded
25
+ - check whether the current branch follows the project naming convention (`{{project}}-{type}-{slug}`) and semantically belongs to this task
26
+ - if yes: write the current branch name back to `task.md` and continue
27
+ - if no: generate a new task branch name, create and switch using the "Create and Switch Commands" section below, then write it back to `task.md`
28
+
29
+ ## Create and Switch Commands
30
+
31
+ Check branches in this order:
32
+
33
+ ```bash
34
+ git branch --list {branch-name}
35
+ git ls-remote --heads origin {branch-name}
36
+ ```
37
+
38
+ - local branch exists: `git switch {branch-name}`
39
+ - only remote branch exists: `git switch --track origin/{branch-name}`
40
+ - neither exists: `git switch -c {branch-name}`
41
+
42
+ If switching fails, stop and ask the user to resolve the branch or working tree conflict first.
43
+
44
+ ## task.md Write-back
45
+
46
+ - update `- **Branch**: {branch-name}` under `## Context`
47
+ - do not modify the other context fields
48
+ - preserve the recorded branch value when updating task status later
@@ -0,0 +1,49 @@
1
+ # 分支管理
2
+
3
+ 在确保任务分支之前先读取本文件。
4
+
5
+ ## 分支名规则
6
+
7
+ - 格式:`{{project}}-{type}-{slug}`
8
+ - 项目前缀:读取 `.agents/.airc.json` 中的 `project`
9
+ - `{type}`:读取 `task.md` frontmatter 中的 `type`
10
+ - `{slug}`:根据任务标题提取 3-6 个英文关键词,转为 kebab-case
11
+
12
+ ## 分支检测流程
13
+
14
+ 先读取:
15
+ - `task.md` 中 `## 上下文` 下的 `- **分支**:`
16
+ - 当前分支:`git branch --show-current`
17
+
18
+ 有效已记录分支:
19
+ - 有值,且不是 `待定`、`待创建`、`N/A` 或空字符串
20
+
21
+ 场景 A:`task.md` 已记录任务分支
22
+ - 当前分支与记录值一致:直接继续
23
+ - 当前分支不一致:按下方”创建与切换命令”章节切换到已记录分支
24
+
25
+ 场景 B:`task.md` 未记录任务分支
26
+ - 判断当前分支是否符合项目分支命名规范(`{{project}}-{type}-{slug}`)且语义上属于当前任务
27
+ - 符合:将当前分支名回写到 `task.md`,继续
28
+ - 不符合:生成新的任务分支名,按下方”创建与切换命令”章节创建并切换,回写到 `task.md`
29
+
30
+ ## 创建与切换命令
31
+
32
+ 按以下顺序处理:
33
+
34
+ ```bash
35
+ git branch --list {branch-name}
36
+ git ls-remote --heads origin {branch-name}
37
+ ```
38
+
39
+ - 本地分支已存在:`git switch {branch-name}`
40
+ - 仅远程分支存在:`git switch --track origin/{branch-name}`
41
+ - 本地和远程都不存在:`git switch -c {branch-name}`
42
+
43
+ 如果切换失败,立即停止并提示用户先处理工作区冲突或未解决的分支问题。
44
+
45
+ ## task.md 回写要求
46
+
47
+ - 更新 `## 上下文` 中的 `- **分支**:{branch-name}`
48
+ - 不修改其他上下文字段
49
+ - 若本步骤已回写 `task.md`,后续更新任务状态时保留该分支值
@@ -0,0 +1,20 @@
1
+ # Output Template
2
+
3
+ When reporting that implementation is complete, use the following standard format:
4
+
5
+ ```text
6
+ Task {task-id} implementation complete.
7
+
8
+ Summary:
9
+ - Implementation round: Round {implementation-round}
10
+ - Files modified: {count}
11
+ - All tests passed: {yes/no}
12
+
13
+ Output files:
14
+ - Implementation report: .agents/workspace/active/{task-id}/{implementation-artifact}
15
+
16
+ Next step - code review:
17
+ - Claude Code / OpenCode: /review-task {task-id}
18
+ - Gemini CLI: /{{project}}:review-task {task-id}
19
+ - Codex CLI: $review-task {task-id}
20
+ ```
@@ -0,0 +1,20 @@
1
+ # 输出模板
2
+
3
+ 向用户汇报实现完成时,使用以下标准格式:
4
+
5
+ ```text
6
+ 任务 {task-id} 实现完成。
7
+
8
+ 摘要:
9
+ - 实现轮次:Round {implementation-round}
10
+ - 修改文件:{数量}
11
+ - 所有测试通过:{是/否}
12
+
13
+ 产出文件:
14
+ - 实现报告:.agents/workspace/active/{task-id}/{implementation-artifact}
15
+
16
+ 下一步 - 代码审查:
17
+ - Claude Code / OpenCode:/review-task {task-id}
18
+ - Gemini CLI:/{{project}}:review-task {task-id}
19
+ - Codex CLI:$review-task {task-id}
20
+ ```