@fitlab-ai/agent-infra 0.5.8 → 0.5.9

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 (40) hide show
  1. package/README.md +44 -4
  2. package/README.zh-CN.md +44 -4
  3. package/lib/sandbox/commands/vm.js +7 -1
  4. package/lib/sandbox/constants.js +3 -0
  5. package/lib/sandbox/engine.js +38 -3
  6. package/lib/sandbox/runtimes/base.dockerfile +9 -2
  7. package/package.json +3 -1
  8. package/templates/.agents/rules/create-issue.en.md +5 -0
  9. package/templates/.agents/rules/create-issue.github.en.md +178 -0
  10. package/templates/.agents/rules/create-issue.github.zh-CN.md +178 -0
  11. package/templates/.agents/rules/create-issue.zh-CN.md +5 -0
  12. package/templates/.agents/rules/issue-sync.github.en.md +1 -1
  13. package/templates/.agents/rules/issue-sync.github.zh-CN.md +1 -1
  14. package/templates/.agents/rules/milestone-inference.github.en.md +2 -2
  15. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +2 -2
  16. package/templates/.agents/scripts/platform-adapters/platform-sync.github.js +46 -1
  17. package/templates/.agents/skills/create-task/SKILL.en.md +69 -11
  18. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +70 -12
  19. package/templates/.agents/skills/create-task/config/verify.json +6 -1
  20. package/templates/.agents/skills/implement-task/reference/implementation-rules.en.md +7 -12
  21. package/templates/.agents/skills/implement-task/reference/implementation-rules.zh-CN.md +7 -12
  22. package/templates/.agents/skills/import-issue/SKILL.en.md +1 -1
  23. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
  24. package/templates/.agents/skills/refine-task/reference/fix-workflow.en.md +2 -2
  25. package/templates/.agents/skills/refine-task/reference/fix-workflow.zh-CN.md +2 -2
  26. package/templates/.agents/skills/test/SKILL.en.md +45 -6
  27. package/templates/.agents/skills/test/SKILL.zh-CN.md +45 -6
  28. package/templates/.agents/skills/create-issue/SKILL.en.md +0 -118
  29. package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +0 -118
  30. package/templates/.agents/skills/create-issue/config/verify.json +0 -30
  31. package/templates/.agents/skills/create-issue/reference/label-and-type.en.md +0 -71
  32. package/templates/.agents/skills/create-issue/reference/label-and-type.zh-CN.md +0 -71
  33. package/templates/.agents/skills/create-issue/reference/template-matching.en.md +0 -17
  34. package/templates/.agents/skills/create-issue/reference/template-matching.zh-CN.md +0 -17
  35. package/templates/.claude/commands/create-issue.en.md +0 -8
  36. package/templates/.claude/commands/create-issue.zh-CN.md +0 -8
  37. package/templates/.gemini/commands/_project_/create-issue.en.toml +0 -8
  38. package/templates/.gemini/commands/_project_/create-issue.zh-CN.toml +0 -8
  39. package/templates/.opencode/commands/create-issue.en.md +0 -11
  40. package/templates/.opencode/commands/create-issue.zh-CN.md +0 -11
@@ -115,7 +115,7 @@ If `gh` fails, skip and continue. Do not fail the skill.
115
115
 
116
116
  When a skill creates or imports an Issue, automatically add the current executor as assignee:
117
117
 
118
- - `create-issue`: use `--assignee @me` in `gh issue create` and include `-R "$upstream_repo"`
118
+ - When the `create-task` platform rule triggers Issue creation: use `--assignee @me` in `gh issue create` and include `-R "$upstream_repo"`
119
119
  - `import-issue`: run `gh issue edit {issue-number} -R "$upstream_repo" --add-assignee @me 2>/dev/null || true` after import
120
120
 
121
121
  `@me` is resolved by `gh` CLI to the authenticated user. The operation is idempotent. If the command fails, skip it directly and do not provide a fallback path.
@@ -115,7 +115,7 @@ fi
115
115
 
116
116
  当技能创建或导入 Issue 时,自动将当前执行者添加为 assignee:
117
117
 
118
- - `create-issue`:在 `gh issue create` 命令中使用 `--assignee @me` 参数,并附带 `-R "$upstream_repo"`
118
+ - `create-task` 的平台规则触发 Issue 创建时:在 `gh issue create` 命令中使用 `--assignee @me` 参数,并附带 `-R "$upstream_repo"`
119
119
  - `import-issue`:导入后执行 `gh issue edit {issue-number} -R "$upstream_repo" --add-assignee @me 2>/dev/null || true`
120
120
 
121
121
  `@me` 由 `gh` CLI 自动解析为当前认证用户。此操作是幂等的(重复添加不会报错)。如果命令失败(如权限不足),直接跳过,不做任何替代。
@@ -1,6 +1,6 @@
1
1
  # Milestone Inference Rules
2
2
 
3
- Read this file before `create-issue`, `implement-task`, or `create-pr` handles a milestone.
3
+ Read this file before the `create-task` platform rule, `implement-task`, or `create-pr` handles a milestone.
4
4
 
5
5
  ## General Principles
6
6
 
@@ -21,7 +21,7 @@ git branch -r | grep -v 'HEAD' | grep -E 'origin/[0-9]+\.[0-9]+\.x$'
21
21
  - Any output: multi-version branch mode
22
22
  - No output: trunk mode
23
23
 
24
- ## Phase 1: `create-issue`
24
+ ## Phase 1: `create-task` (when the platform rule creates an Issue)
25
25
 
26
26
  Goal: choose a coarse-grained release line when the Issue is created.
27
27
 
@@ -1,6 +1,6 @@
1
1
  # Milestone 推断规则
2
2
 
3
- 在 `create-issue`、`implement-task` 或 `create-pr` 处理 milestone 之前先读取本文件。
3
+ 在 `create-task` 的平台规则、`implement-task` 或 `create-pr` 处理 milestone 之前先读取本文件。
4
4
 
5
5
  ## 通用原则
6
6
 
@@ -21,7 +21,7 @@ git branch -r | grep -v 'HEAD' | grep -E 'origin/[0-9]+\.[0-9]+\.x$'
21
21
  - 有输出:多版本分支模式
22
22
  - 无输出:主干模式
23
23
 
24
- ## 阶段 1:`create-issue`
24
+ ## 阶段 1:`create-task`(平台规则创建 Issue 时)
25
25
 
26
26
  目标:在创建 Issue 时先确定粗粒度版本线。
27
27
 
@@ -498,7 +498,7 @@ function checkPrCommentLastCommit(context, remoteData) {
498
498
  );
499
499
  }
500
500
 
501
- const headResult = withRetry(() => gitText(["rev-parse", "HEAD"], context.taskDir));
501
+ const headResult = resolvePrHeadSha(context);
502
502
  if (!headResult.ok) {
503
503
  return headResult.type === "check_failed"
504
504
  ? failResult(CHECK_TYPE, headResult.message, headResult.type)
@@ -1137,6 +1137,51 @@ function gitText(args, cwd) {
1137
1137
  return { ok: true, value: String(result.stdout || "").trim() };
1138
1138
  }
1139
1139
 
1140
+ function resolvePrHeadSha(context) {
1141
+ const fallback = () => withRetry(() => gitText(["rev-parse", "HEAD"], context.taskDir));
1142
+ const branch = String(context.task?.metadata?.branch || "").trim();
1143
+ if (!branch) {
1144
+ return fallback();
1145
+ }
1146
+
1147
+ const worktreeList = withRetry(() => gitText(["worktree", "list", "--porcelain"], context.taskDir));
1148
+ if (!worktreeList.ok) {
1149
+ return fallback();
1150
+ }
1151
+
1152
+ const matchedWorktree = findWorktreeForBranch(worktreeList.value, branch);
1153
+ if (!matchedWorktree) {
1154
+ return fallback();
1155
+ }
1156
+
1157
+ const headInWorktree = withRetry(() => gitText(["rev-parse", "HEAD"], matchedWorktree));
1158
+ if (!headInWorktree.ok) {
1159
+ return fallback();
1160
+ }
1161
+
1162
+ return headInWorktree;
1163
+ }
1164
+
1165
+ function findWorktreeForBranch(porcelainOutput, branch) {
1166
+ let currentWorktree = "";
1167
+ for (const rawLine of String(porcelainOutput || "").split("\n")) {
1168
+ const line = rawLine.trimEnd();
1169
+ if (line.startsWith("worktree ")) {
1170
+ currentWorktree = line.slice("worktree ".length).trim();
1171
+ continue;
1172
+ }
1173
+
1174
+ if (line.startsWith("branch refs/heads/")) {
1175
+ const usedBranch = line.slice("branch refs/heads/".length).trim();
1176
+ if (usedBranch === branch && currentWorktree) {
1177
+ return currentWorktree;
1178
+ }
1179
+ }
1180
+ }
1181
+
1182
+ return null;
1183
+ }
1184
+
1140
1185
  function withRetry(operation) {
1141
1186
  const delays = getRetryDelays();
1142
1187
  let lastFailure = null;
@@ -7,13 +7,14 @@ description: "Create a task from a natural-language description"
7
7
 
8
8
  ## Boundary / Critical Rules
9
9
 
10
- **The only output of this skill is `task.md`.**
10
+ **The core output of this skill is `task.md`.**
11
11
 
12
12
  - Do not write, modify, or create any business code or configuration files
13
13
  - Do not perform requirements analysis; analysis is handled separately by `analyze-task`
14
14
  - Do not directly implement the requested functionality
15
15
  - Do not skip the workflow and jump directly to planning or implementation
16
- - Only do this: parse the description -> create the task file -> update task status -> inform the user of the next step
16
+ - Only do this: parse the description -> create the task file -> update task status -> cascade Issue creation through `.agents/rules/create-issue.md` -> inform the user of the next step
17
+ - Issue creation is decided by the `.agents/rules/create-issue.md` rule; on custom or empty platforms (no platform-specific variant provided), the rule naturally degrades to a no-op
17
18
 
18
19
  The user's description is a **work item**, not an **instruction to execute immediately**.
19
20
 
@@ -98,7 +99,21 @@ Update `.agents/workspace/active/{task-id}/task.md`:
98
99
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Task Created** by {agent} — Task created from description
99
100
  ```
100
101
 
101
- ### 4. Verification Gate
102
+ ### 4. Cascade Issue Creation via `.agents/rules/create-issue.md`
103
+
104
+ After task.md is written and `Task Created` is recorded, read `.agents/rules/create-issue.md` first and follow the steps it describes to create an Issue.
105
+
106
+ The rule's content is determined by the configured code platform:
107
+ - A platform that supports Issue creation: contains the full flow for auth detection, template detection, label/type/milestone inference, the create-Issue call, and writing back to `task.md`
108
+ - Custom or empty platforms (no platform-specific variant provided): the rule body is a no-op notice, and this step is skipped entirely
109
+
110
+ Handle the result:
111
+ - Rule successfully created the Issue: `issue_number` has been written back to task.md per the rule; continue by reading `.agents/rules/issue-sync.md`, completing upstream repository and permission detection, then sync the task comment and set `status: waiting-for-triage` by rule
112
+ - Rule failed (auth / network / template parse / etc.): do not roll back task.md; get the current time and append an `Issue Creation Skipped` Activity Log entry with the reason
113
+ - Rule was a no-op (custom or empty platform): do not create comments, do not block the workflow, and do not write an Activity Log entry
114
+ - task.md already has `issue_number`: the rule's prerequisite check skips creation; `create-task` proceeds directly to step 5
115
+
116
+ ### 5. Verification Gate
102
117
 
103
118
  Run the verification gate to confirm the task artifact and sync state are valid:
104
119
 
@@ -113,13 +128,33 @@ Handle the result as follows:
113
128
 
114
129
  Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
115
130
 
116
- ### 5. Inform User
131
+ ### 6. Inform User
117
132
 
118
133
  > Execute this step only after the verification gate passes.
119
134
 
120
135
  > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent. If `.agents/.airc.json` configures custom TUIs (via `customTUIs`), read each tool's `name` and `invoke`, then add the matching command line in the same format (`${skillName}` becomes the skill name and `${projectName}` becomes the project name).
121
136
 
122
- Output format:
137
+ Scenario A: when an Issue was created, output:
138
+ ```
139
+ Task created and Issue creation cascaded successfully.
140
+
141
+ Task information:
142
+ - Task ID: {task-id}
143
+ - Title: {title}
144
+ - Type: {type}
145
+ - Workflow: {workflow}
146
+ - Issue: #{issue_number} {issue_url}
147
+
148
+ Output file:
149
+ - Task file: .agents/workspace/active/{task-id}/task.md
150
+
151
+ Next step - run requirements analysis:
152
+ - Claude Code / OpenCode: /analyze-task {task-id}
153
+ - Gemini CLI: /{{project}}:analyze-task {task-id}
154
+ - Codex CLI: $analyze-task {task-id}
155
+ ```
156
+
157
+ Scenario B: when no Issue was created, output:
123
158
  ```
124
159
  Task created.
125
160
 
@@ -132,15 +167,36 @@ Task information:
132
167
  Output file:
133
168
  - Task file: .agents/workspace/active/{task-id}/task.md
134
169
 
170
+ Next step - run requirements analysis:
171
+ - Claude Code / OpenCode: /analyze-task {task-id}
172
+ - Gemini CLI: /{{project}}:analyze-task {task-id}
173
+ - Codex CLI: $analyze-task {task-id}
174
+ ```
175
+
176
+ Scenario C: when Issue creation failed, output:
177
+ ```
178
+ Task created, but cascade Issue creation failed.
179
+
180
+ Task information:
181
+ - Task ID: {task-id}
182
+ - Title: {title}
183
+ - Type: {type}
184
+ - Workflow: {workflow}
185
+
186
+ Issue creation failed:
187
+ - Error code: {error_code}
188
+ - Reason: {error_message}
189
+ - Local task.md was kept and not rolled back
190
+
191
+ Output file:
192
+ - Task file: .agents/workspace/active/{task-id}/task.md
193
+
135
194
  Next step - run requirements analysis:
136
195
  - Claude Code / OpenCode: /analyze-task {task-id}
137
196
  - Gemini CLI: /{{project}}:analyze-task {task-id}
138
197
  - Codex CLI: $analyze-task {task-id}
139
198
 
140
- Or create an Issue first:
141
- - Claude Code / OpenCode: /create-issue {task-id}
142
- - Gemini CLI: /{{project}}:create-issue {task-id}
143
- - Codex CLI: $create-issue {task-id}
199
+ For later platform sync: after fixing auth / network / template issues, manually run the Issue creation flow in `.agents/rules/create-issue.md` for this task; or manually create/find an Issue and write `issue_number` into task.md so later skills can take over cascade sync.
144
200
  ```
145
201
 
146
202
  ## Completion Checklist
@@ -150,8 +206,9 @@ Or create an Issue first:
150
206
  - [ ] Updated `updated_at` to the current time in task.md
151
207
  - [ ] Updated `assigned_to` in task.md
152
208
  - [ ] Appended an Activity Log entry to task.md
209
+ - [ ] Tried cascading Issue creation through `.agents/rules/create-issue.md`; if it failed, kept task.md and recorded the reason
153
210
  - [ ] Informed the user of the next step (must include all TUI command formats, including any custom TUIs; do not filter)
154
- - [ ] **Did not modify any business code or configuration files** (only task.md)
211
+ - [ ] **Did not modify any business code or configuration files**
155
212
 
156
213
  ## STOP
157
214
 
@@ -162,7 +219,8 @@ Wait for the user to run the `analyze-task` skill.
162
219
 
163
220
  1. **Clarity**: if the user description is vague or missing key information, ask for clarification first
164
221
  2. **Difference from `import-issue`**: `import-issue` imports from an Issue; `create-task` creates from a free-form description
165
- 3. **Workflow order**: after creating a task, typically run `analyze-task` before `plan-task`; if you need platform tracking first, you may run `create-issue` first
222
+ 3. **Workflow order**: after creating a task, typically run `analyze-task` before `plan-task`
223
+ 4. **Issue cascade failure**: if the rule fails, task.md remains; when platform sync is needed later, manually write `issue_number` and continue the workflow
166
224
 
167
225
  ## Error Handling
168
226
 
@@ -7,13 +7,14 @@ description: "根据自然语言描述创建任务"
7
7
 
8
8
  ## 行为边界 / 关键规则
9
9
 
10
- **本技能的唯一产出是 `task.md`。**
10
+ **本技能的核心产出是 `task.md`。**
11
11
 
12
12
  - 不要编写、修改或创建任何业务代码或配置文件
13
13
  - 不要执行需求分析;分析由 `analyze-task` 独立完成
14
14
  - 不要直接实现所描述的功能
15
15
  - 不要跳过工作流直接进入计划/实现阶段
16
- - 仅执行:解析描述 -> 创建任务文件 -> 更新任务状态 -> 告知用户下一步
16
+ - 仅执行:解析描述 -> 创建任务文件 -> 更新任务状态 -> 按 `.agents/rules/create-issue.md` 级联尝试创建 Issue -> 告知用户下一步
17
+ - Issue 创建由 `.agents/rules/create-issue.md` 规则决定;自定义或空平台(未提供平台变体规则文件)时,规则会自然降级为 no-op
17
18
 
18
19
  用户的描述是一个**待办事项**,而不是**立即执行的指令**。
19
20
 
@@ -98,7 +99,21 @@ date "+%Y-%m-%d %H:%M:%S%:z"
98
99
  - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Task Created** by {agent} — Task created from description
99
100
  ```
100
101
 
101
- ### 4. 完成校验
102
+ ### 4. 按 `.agents/rules/create-issue.md` 级联创建 Issue
103
+
104
+ 在 task.md 落盘并记录 `Task Created` 后,先读取 `.agents/rules/create-issue.md` 并按其中描述的步骤执行 Issue 创建。
105
+
106
+ 规则文件由当前配置的代码平台决定其内容:
107
+ - 支持 Issue 创建的平台:包含完整的认证检测、模板检测、label/Issue Type/milestone 推断、Issue 创建调用、`task.md` 回写流程
108
+ - 自定义或空平台(未提供平台变体规则文件):内容为 no-op 说明,本步骤直接跳过
109
+
110
+ 处理结果:
111
+ - 规则成功创建 Issue:`issue_number` 已按规则回写到 task.md;继续读取 `.agents/rules/issue-sync.md`,完成 upstream 仓库检测和权限检测,然后同步 task 评论并按规则设置 `status: waiting-for-triage`
112
+ - 规则失败(认证 / 网络 / 模板解析等):不回滚 task.md;获取当前时间,追加 `Issue Creation Skipped` Activity Log,说明错误原因
113
+ - 规则为 no-op(自定义或空平台):不创建评论,不阻塞后续工作流,不写 Activity Log
114
+ - task.md 已存在 `issue_number`:规则中的前置检查会跳过;`create-task` 直接进入步骤 5
115
+
116
+ ### 5. 完成校验
102
117
 
103
118
  运行完成校验,确认任务产物和同步状态符合规范:
104
119
 
@@ -113,13 +128,33 @@ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/act
113
128
 
114
129
  将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
115
130
 
116
- ### 5. 告知用户
131
+ ### 6. 告知用户
117
132
 
118
133
  > 仅在校验通过后执行本步骤。
119
134
 
120
135
  > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。
121
136
 
122
- 输出格式:
137
+ 场景 A:已创建 Issue 时输出:
138
+ ```
139
+ 任务已创建,并已级联创建 Issue。
140
+
141
+ 任务信息:
142
+ - 任务 ID:{task-id}
143
+ - 标题:{title}
144
+ - 类型:{type}
145
+ - 工作流:{workflow}
146
+ - Issue:#{issue_number} {issue_url}
147
+
148
+ 产出文件:
149
+ - 任务文件:.agents/workspace/active/{task-id}/task.md
150
+
151
+ 下一步 - 执行需求分析:
152
+ - Claude Code / OpenCode:/analyze-task {task-id}
153
+ - Gemini CLI:/{{project}}:analyze-task {task-id}
154
+ - Codex CLI:$analyze-task {task-id}
155
+ ```
156
+
157
+ 场景 B:未创建 Issue 时输出:
123
158
  ```
124
159
  任务已创建。
125
160
 
@@ -134,13 +169,34 @@ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/act
134
169
 
135
170
  下一步 - 执行需求分析:
136
171
  - Claude Code / OpenCode:/analyze-task {task-id}
137
- - Gemini CLI:/agent-infra:analyze-task {task-id}
172
+ - Gemini CLI:/{{project}}:analyze-task {task-id}
173
+ - Codex CLI:$analyze-task {task-id}
174
+ ```
175
+
176
+ 场景 C:Issue 创建失败时输出:
177
+ ```
178
+ 任务已创建,但 Issue 级联创建失败。
179
+
180
+ 任务信息:
181
+ - 任务 ID:{task-id}
182
+ - 标题:{title}
183
+ - 类型:{type}
184
+ - 工作流:{workflow}
185
+
186
+ Issue 创建失败:
187
+ - 错误码:{error_code}
188
+ - 原因:{error_message}
189
+ - 本地 task.md 已保留,未回滚
190
+
191
+ 产出文件:
192
+ - 任务文件:.agents/workspace/active/{task-id}/task.md
193
+
194
+ 下一步 - 执行需求分析:
195
+ - Claude Code / OpenCode:/analyze-task {task-id}
196
+ - Gemini CLI:/{{project}}:analyze-task {task-id}
138
197
  - Codex CLI:$analyze-task {task-id}
139
198
 
140
- 或先创建 Issue
141
- - Claude Code / OpenCode:/create-issue {task-id}
142
- - Gemini CLI:/agent-infra:create-issue {task-id}
143
- - Codex CLI:$create-issue {task-id}
199
+ 后续如需平台同步:修复认证/网络/模板问题后,可按 `.agents/rules/create-issue.md` 对当前任务手动执行一次 Issue 创建;或手动创建/查找 Issue,并把 `issue_number` 写入 task.md,后续技能会接管级联同步。
144
200
  ```
145
201
 
146
202
  ## 完成检查清单
@@ -150,8 +206,9 @@ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/act
150
206
  - [ ] 更新了 task.md 中的 `updated_at` 为当前时间
151
207
  - [ ] 更新了 task.md 中的 `assigned_to`
152
208
  - [ ] 追加了 Activity Log 条目到 task.md
209
+ - [ ] 已按 `.agents/rules/create-issue.md` 尝试级联创建 Issue;失败时保留 task.md 并记录原因
153
210
  - [ ] 告知了用户下一步(必须展示所有 TUI 的命令格式,含自定义 TUI,不要筛选)
154
- - [ ] **没有修改任何业务代码或配置文件**(仅 task.md)
211
+ - [ ] **没有修改任何业务代码或配置文件**
155
212
 
156
213
  ## 停止
157
214
 
@@ -162,7 +219,8 @@ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/act
162
219
 
163
220
  1. **清晰度**:如果用户描述模糊或缺少关键信息,先要求澄清
164
221
  2. **与 import-issue 的区别**:`import-issue` 从 Issue 导入任务;`create-task` 从自由描述创建
165
- 3. **工作流顺序**:创建任务后,通常先执行 `analyze-task` 再进入 `plan-task`;如需先建立 平台跟踪,也可先执行 `create-issue`
222
+ 3. **工作流顺序**:创建任务后,通常先执行 `analyze-task` 再进入 `plan-task`
223
+ 4. **Issue 级联失败**:如果规则执行失败,task.md 仍保留;需要后续平台同步时,可手动写入 `issue_number` 后继续执行工作流
166
224
 
167
225
  ## 错误处理
168
226
 
@@ -20,6 +20,11 @@
20
20
  "expected_action_pattern": "Task Created",
21
21
  "freshness_minutes": 30
22
22
  },
23
- "platform-sync": null
23
+ "platform-sync": {
24
+ "when": "issue_number_exists",
25
+ "issue_must_exist": true,
26
+ "verify_task_comment_content": true,
27
+ "expected_status_label_key": "waitingForTriage"
28
+ }
24
29
  }
25
30
  }
@@ -16,31 +16,26 @@ Follow the `implementation` step in `.agents/workflows/feature-development.yaml`
16
16
  **Implementation principles**:
17
17
  1. **Follow the plan strictly**: do not deviate from the technical plan
18
18
  2. **Work step by step**: execute the planned sequence
19
- 3. **Keep testing continuously**: re-run tests as work progresses
19
+ 3. **Keep testing continuously**: run the **smoke subset** continuously as work progresses (see the `test` skill)
20
20
  4. **Keep it simple**: do not add unplanned features
21
21
 
22
22
  ## Run Test Verification
23
23
 
24
- Run the project test command. Refer to the `test` skill for project-specific commands.
24
+ During implementation:
25
+ - **Inner loop**: after each change, run the project's **smoke subset** (see the `test` skill) for fast feedback
26
+ - **Before writing the implementation report**: run the **core subset** as final verification so code entering review has passed the complete core checks
25
27
 
26
- ```bash
27
- # See .agents/skills/test/SKILL.md for the project's test command
28
- # Common patterns:
29
- # npm test (Node.js)
30
- # mvn test (Maven)
31
- # pytest (Python)
32
- # go test ./... (Go)
33
- ```
28
+ > Refer to the `test` skill for project-specific commands; downstream projects without layered scripts should fall back to the full project test command.
34
29
 
35
30
  If tests fail:
36
31
  - analyze the failure first and prioritize fixing issues introduced by this implementation
37
- - re-run tests after each fix until they pass, or confirm that the problem is an external blocker
32
+ - after each fix, re-run at least the smoke subset, then upgrade to core for the next full-pass verification
38
33
  - only stop without producing the implementation artifact when the failure is caused by an external blocker, missing environment, or unclear requirement that cannot be resolved inside the task
39
34
 
40
35
  Two-way failure handling:
41
36
  1. implementation-caused failures:
42
37
  - fix the code, tests, docs, or fixtures introduced by this implementation
43
- - re-run the test command after each fix
38
+ - re-run tests after each fix (smoke for the immediate fix verification, core for the round-level verification)
44
39
  - continue until all required tests pass
45
40
  2. external blockers:
46
41
  - confirm the failure comes from missing environment, unrelated upstream breakage, or unclear requirements outside this task
@@ -16,31 +16,26 @@
16
16
  **实现原则**:
17
17
  1. **严格遵循方案**:不要偏离技术方案
18
18
  2. **按步骤推进**:按计划顺序执行
19
- 3. **持续测试**:实现过程中持续重新运行测试
19
+ 3. **持续测试**:实现过程中持续运行 **smoke 子集**(参见 `test` skill)
20
20
  4. **保持简单**:不要加入未计划的功能
21
21
 
22
22
  ## 运行测试验证
23
23
 
24
- 运行项目测试命令。项目特定命令请参考 `test` skill。
24
+ 实现过程中:
25
+ - **内循环**:每次修改后运行项目测试的 **smoke 子集**(参见 `test` skill),快速反馈
26
+ - **写实现报告前**:运行 **core 子集**做最终验证,确保进入审查的代码已通过完整的核心测试
25
27
 
26
- ```bash
27
- # 参考 .agents/skills/test/SKILL.md 中的项目测试命令
28
- # 常见模式:
29
- # npm test (Node.js)
30
- # mvn test (Maven)
31
- # pytest (Python)
32
- # go test ./... (Go)
33
- ```
28
+ > 项目特定命令请参考 `test` skill;不存在分层 script 的下游项目回退到完整项目测试命令。
34
29
 
35
30
  如果测试失败:
36
31
  - 先分析失败原因,并优先修复由本次实现引入的问题
37
- - 每次修复后重新运行测试,直到通过,或者确认问题属于外部阻塞
32
+ - 每次修复后重新运行至少 smoke 子集,进入下一轮再升级到 core
38
33
  - 只有当失败由外部阻塞、环境缺失或当前任务内无法澄清的需求问题导致时,才允许在不生成实现产物的情况下停止
39
34
 
40
35
  双分支失败处理:
41
36
  1. 本次实现引入的失败:
42
37
  - 修复由本次实现引入的代码、测试、文档或 fixture 问题
43
- - 每次修复后重新运行测试命令
38
+ - 每次修复后重新运行测试(smoke 用于本次修复验证,core 用于本轮整体验证)
44
39
  - 持续处理直到所有必需测试通过
45
40
  2. 外部阻塞:
46
41
  - 确认失败来自缺失环境、无关的上游损坏,或任务范围外的需求不明确
@@ -108,7 +108,7 @@ If task.md contains a valid `issue_number`, use the Issue update command from `.
108
108
 
109
109
  If task.md contains a valid `issue_number`, perform these sync actions (skip and continue on any failure):
110
110
  - Read `.agents/rules/issue-sync.md` before syncing, and complete upstream repository detection plus permission detection
111
- - Check the Issue's current milestone; if it is unset, read `.agents/rules/milestone-inference.md` and infer plus set the milestone using "Stage 1: `create-issue`". If `has_triage=false` or the inference is uncertain, skip and continue
111
+ - Check the Issue's current milestone; if it is unset, read `.agents/rules/milestone-inference.md` and infer plus set the milestone using "Phase 1: `create-task` (when the platform rule creates an Issue)". If `has_triage=false` or the inference is uncertain, skip and continue
112
112
  - After every scenario, task comment sync is mandatory: create or update the task comment marker defined in `.agents/rules/issue-sync.md` so the remote `:task` comment exists and matches the local `task.md` content (follow the task.md comment sync rule in issue-sync.md)
113
113
 
114
114
  ### 7. Verification Gate
@@ -108,7 +108,7 @@ date "+%Y-%m-%d %H:%M:%S%:z"
108
108
 
109
109
  如果 task.md 中存在有效的 `issue_number`,执行以下同步操作(任一失败则跳过并继续):
110
110
  - 执行前先读取 `.agents/rules/issue-sync.md`,完成 upstream 仓库检测和权限检测
111
- - 检查 Issue 当前 milestone;如果未设置,先读取 `.agents/rules/milestone-inference.md`,按其中的「阶段 1:`create-issue`」规则推断并设置 milestone;如果 `has_triage=false` 或推断不确定,跳过并继续
111
+ - 检查 Issue 当前 milestone;如果未设置,先读取 `.agents/rules/milestone-inference.md`,按其中的「阶段 1:`create-task`(平台规则创建 Issue 时)」规则推断并设置 milestone;如果 `has_triage=false` 或推断不确定,跳过并继续
112
112
  - 所有场景结束后,必须执行一次 task 留言同步,创建或更新 `.agents/rules/issue-sync.md` 中定义的 task 评论标记,确保远端 `:task` 评论存在且内容与本地 `task.md` 一致(按 issue-sync.md 的 task.md 评论同步规则)
113
113
 
114
114
  ### 7. 完成校验
@@ -26,11 +26,11 @@ For each fix:
26
26
  1. read the affected files
27
27
  2. apply the smallest necessary change
28
28
  3. verify the change addresses the review feedback
29
- 4. run the relevant tests
29
+ 4. run the project's **smoke subset** for immediate feedback (see the `test` skill)
30
30
 
31
31
  ## Run Test Verification
32
32
 
33
- Run the project test command from the `test` skill and confirm that all required tests still pass.
33
+ Before writing the refinement report, run the project's **core subset** as final verification and confirm that all required tests still pass. If the project does not have layered scripts, fall back to the full project test command.
34
34
 
35
35
  ## Choose the Next-Step Branch
36
36
 
@@ -26,11 +26,11 @@
26
26
  1. 读取受影响文件
27
27
  2. 施加最小必要改动
28
28
  3. 验证改动确实解决了审查反馈
29
- 4. 运行相关测试
29
+ 4. 运行项目测试的 **smoke 子集**做即时反馈(参见 `test` skill)
30
30
 
31
31
  ## 运行测试验证
32
32
 
33
- 运行项目测试命令。项目测试命令以 `test` skill 为准,并确认所有必需测试仍然通过。
33
+ refinement 报告前,运行项目测试的 **core 子集**做最终验证,确保所有必需测试仍然通过。如果项目没有分层 script,回退到完整项目测试命令。
34
34
 
35
35
  ## 选择下一步分支
36
36
 
@@ -21,16 +21,55 @@ Execute the project's full test workflow including compilation checks and unit t
21
21
 
22
22
  Confirm no compilation errors.
23
23
 
24
- ## 2. Run All Unit Tests
24
+ ## 2. Run Unit Tests by Layer
25
+
26
+ This project uses three test layers as an optional optimization; if the test suite is small, all layers may map to the same full test command.
27
+
28
+ ### smoke (target <5s)
29
+
30
+ ```bash
31
+ # TODO: Replace with this project's smoke subset command
32
+ # npm run test:smoke (Node.js)
33
+ # pytest -m "not slow" (Python)
34
+ # go test -short ./... (Go)
35
+ ```
36
+
37
+ Use for:
38
+ - implement-task / refine-task inner loops
39
+ - save-and-run / frequent feedback
40
+ - project structure, configuration, and template contract checks
41
+
42
+ ### core (target <15s)
25
43
 
26
44
  ```bash
27
- # TODO: Replace with your project's test command
28
- # npm test (Node.js)
29
- # mvn test (Maven)
30
- # pytest (Python)
31
- # go test ./... (Go)
45
+ # TODO: Replace with this project's core subset command
46
+ # npm run test:core (Node.js)
47
+ # pytest -m "not contract" (Python)
48
+ # go test ./... (Go)
32
49
  ```
33
50
 
51
+ Use for:
52
+ - pre-commit hook (automatic)
53
+ - final verification before writing implementation.md / refinement.md
54
+ - local gate before pushing a PR
55
+
56
+ ### full (complete test suite)
57
+
58
+ ```bash
59
+ # TODO: Replace with this project's full test command
60
+ # npm test (Node.js)
61
+ # mvn test (Maven)
62
+ # pytest (Python)
63
+ # go test ./... (Go)
64
+ ```
65
+
66
+ Use for:
67
+ - before release / tag
68
+ - CI
69
+ - final gate before merging to main
70
+
71
+ If the project is not layered yet, smoke / core / full may all map to the same full test command; layering is a feedback-speed optimization, not a prerequisite for using the collaboration workflow.
72
+
34
73
  ## 3. Output Results
35
74
 
36
75
  Report test result summary:
@@ -21,16 +21,55 @@ description: "执行项目完整测试流程"
21
21
 
22
22
  确认无编译错误。
23
23
 
24
- ## 2. 运行所有单元测试
24
+ ## 2. 运行单元测试(按层级选择)
25
+
26
+ 本项目把测试分为三层(可选优化);如果项目测试规模较小,可以全部映射到同一个完整测试命令。
27
+
28
+ ### smoke(目标 <5s)
29
+
30
+ ```bash
31
+ # TODO: 替换为本项目的 smoke 子集命令
32
+ # npm run test:smoke (Node.js)
33
+ # pytest -m "not slow" (Python)
34
+ # go test -short ./... (Go)
35
+ ```
36
+
37
+ 适用场景:
38
+ - implement-task / refine-task 内循环
39
+ - 保存即跑 / 频繁反馈
40
+ - 仅断言项目结构、配置、模板契约
41
+
42
+ ### core(目标 <15s)
25
43
 
26
44
  ```bash
27
- # TODO: 替换为你的项目测试命令
28
- # npm test (Node.js)
29
- # mvn test (Maven)
30
- # pytest (Python)
31
- # go test ./... (Go)
45
+ # TODO: 替换为本项目的 core 子集命令
46
+ # npm run test:core (Node.js)
47
+ # pytest -m "not contract" (Python)
48
+ # go test ./... (Go)
32
49
  ```
33
50
 
51
+ 适用场景:
52
+ - pre-commit hook(自动调用)
53
+ - 写 implementation.md / refinement.md 报告前的最终验证
54
+ - 推送 PR 前的本地把关
55
+
56
+ ### full(完整测试)
57
+
58
+ ```bash
59
+ # TODO: 替换为本项目的完整测试命令
60
+ # npm test (Node.js)
61
+ # mvn test (Maven)
62
+ # pytest (Python)
63
+ # go test ./... (Go)
64
+ ```
65
+
66
+ 适用场景:
67
+ - release / tag 前
68
+ - CI
69
+ - main 合并前的最终把关
70
+
71
+ 如果项目暂不分层,smoke / core / full 可以全部映射到同一个完整测试命令;分层是反馈速度优化项,不是使用协作工作流的前置条件。
72
+
34
73
  ## 3. 输出结果
35
74
 
36
75
  报告测试结果摘要: