@fitlab-ai/agent-infra 0.7.2 → 0.7.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 (94) hide show
  1. package/README.md +7 -1
  2. package/README.zh-CN.md +9 -3
  3. package/dist/lib/defaults.json +0 -1
  4. package/dist/lib/init.js +0 -3
  5. package/dist/lib/sandbox/commands/enter.js +13 -15
  6. package/dist/lib/sandbox/commands/list-running.js +36 -1
  7. package/dist/lib/sandbox/commands/ls.js +9 -4
  8. package/dist/lib/sandbox/commands/start.js +36 -0
  9. package/dist/lib/sandbox/index.js +8 -0
  10. package/dist/lib/table.js +11 -2
  11. package/dist/lib/task/commands/ls.js +1 -1
  12. package/dist/lib/task/short-id.js +10 -0
  13. package/dist/lib/update.js +25 -8
  14. package/lib/defaults.json +0 -1
  15. package/lib/init.ts +0 -10
  16. package/lib/sandbox/commands/enter.ts +33 -14
  17. package/lib/sandbox/commands/list-running.ts +43 -1
  18. package/lib/sandbox/commands/ls.ts +12 -4
  19. package/lib/sandbox/commands/start.ts +61 -0
  20. package/lib/sandbox/index.ts +8 -0
  21. package/lib/table.ts +14 -2
  22. package/lib/task/commands/ls.ts +1 -1
  23. package/lib/task/short-id.ts +10 -0
  24. package/lib/update.ts +28 -10
  25. package/package.json +1 -1
  26. package/templates/.agents/hooks/auto-resume.sh +21 -4
  27. package/templates/.agents/rules/next-step-output.en.md +6 -3
  28. package/templates/.agents/rules/next-step-output.zh-CN.md +6 -3
  29. package/templates/.agents/rules/pr-checks-commands.en.md +5 -0
  30. package/templates/.agents/rules/pr-checks-commands.github.en.md +62 -0
  31. package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +62 -0
  32. package/templates/.agents/rules/pr-checks-commands.zh-CN.md +5 -0
  33. package/templates/.agents/rules/pr-sync.github.en.md +7 -0
  34. package/templates/.agents/rules/pr-sync.github.zh-CN.md +7 -0
  35. package/templates/.agents/skills/analyze-task/SKILL.en.md +1 -1
  36. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +1 -1
  37. package/templates/.agents/skills/block-task/SKILL.en.md +8 -1
  38. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +8 -1
  39. package/templates/.agents/skills/cancel-task/SKILL.en.md +8 -1
  40. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +8 -1
  41. package/templates/.agents/skills/check-task/SKILL.en.md +1 -1
  42. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +1 -1
  43. package/templates/.agents/skills/close-codescan/SKILL.en.md +8 -1
  44. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +8 -1
  45. package/templates/.agents/skills/close-dependabot/SKILL.en.md +8 -1
  46. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +8 -1
  47. package/templates/.agents/skills/code-task/SKILL.en.md +1 -1
  48. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +1 -1
  49. package/templates/.agents/skills/commit/SKILL.en.md +2 -3
  50. package/templates/.agents/skills/commit/SKILL.zh-CN.md +2 -3
  51. package/templates/.agents/skills/commit/reference/task-status-update.en.md +31 -23
  52. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +31 -23
  53. package/templates/.agents/skills/complete-task/SKILL.en.md +36 -3
  54. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +36 -3
  55. package/templates/.agents/skills/create-pr/SKILL.en.md +16 -7
  56. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +16 -7
  57. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -0
  58. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -0
  59. package/templates/.agents/skills/create-task/SKILL.en.md +1 -1
  60. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +1 -1
  61. package/templates/.agents/skills/import-codescan/SKILL.en.md +1 -1
  62. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +1 -1
  63. package/templates/.agents/skills/import-dependabot/SKILL.en.md +1 -1
  64. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +1 -1
  65. package/templates/.agents/skills/import-issue/SKILL.en.md +1 -1
  66. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +1 -1
  67. package/templates/.agents/skills/plan-task/SKILL.en.md +1 -1
  68. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +1 -1
  69. package/templates/.agents/skills/review-analysis/SKILL.en.md +1 -1
  70. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +1 -1
  71. package/templates/.agents/skills/review-code/SKILL.en.md +1 -1
  72. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +1 -1
  73. package/templates/.agents/skills/review-plan/SKILL.en.md +1 -1
  74. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +1 -1
  75. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +0 -1
  76. package/templates/.agents/skills/watch-pr/SKILL.en.md +131 -0
  77. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +131 -0
  78. package/templates/.agents/skills/watch-pr/config/verify.json +22 -0
  79. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +43 -0
  80. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +43 -0
  81. package/templates/.agents/templates/task.en.md +1 -0
  82. package/templates/.agents/templates/task.zh-CN.md +1 -0
  83. package/templates/.agents/workflows/bug-fix.en.yaml +6 -4
  84. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +5 -4
  85. package/templates/.agents/workflows/feature-development.en.yaml +6 -4
  86. package/templates/.agents/workflows/feature-development.zh-CN.yaml +5 -4
  87. package/templates/.agents/workflows/refactoring.en.yaml +6 -4
  88. package/templates/.agents/workflows/refactoring.zh-CN.yaml +5 -4
  89. package/templates/.claude/commands/watch-pr.en.md +8 -0
  90. package/templates/.claude/commands/watch-pr.zh-CN.md +8 -0
  91. package/templates/.gemini/commands/_project_/watch-pr.en.toml +8 -0
  92. package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +8 -0
  93. package/templates/.opencode/commands/watch-pr.en.md +11 -0
  94. package/templates/.opencode/commands/watch-pr.zh-CN.md +11 -0
@@ -155,7 +155,7 @@ Keep the gate output in your reply as fresh evidence. Do not claim completion wi
155
155
 
156
156
  > Execute this step only after the verification gate passes.
157
157
 
158
- > **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). Before rendering the "Next steps" commands, read `.agents/rules/next-step-output.md` and use its short-id snippet to render `{task-ref}` in the commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released).
158
+ > **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). Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released); (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
159
159
 
160
160
  Scenario A: when an Issue was created, output:
161
161
  ```
@@ -154,7 +154,7 @@ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/act
154
154
 
155
155
  > 仅在校验通过后执行本步骤。
156
156
 
157
- > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染「下一步」命令前,先读取 `.agents/rules/next-step-output.md`,按其取短号片段把命令中的 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id)。
157
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染最终输出前,先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令把 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id);(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
158
158
 
159
159
  场景 A:已创建 Issue 时输出:
160
160
  ```
@@ -87,7 +87,7 @@ Keep the gate output in your reply as fresh evidence. Do not claim completion wi
87
87
 
88
88
  > Execute this step only after the verification gate passes.
89
89
 
90
- > **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). Before rendering the "Next steps" commands, read `.agents/rules/next-step-output.md` and use its short-id snippet to render `{task-ref}` in the commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released).
90
+ > **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). Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released); (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
91
91
 
92
92
  ```
93
93
  Code Scanning alert #{alert-number} imported.
@@ -87,7 +87,7 @@ node .agents/scripts/validate-artifact.js gate import-codescan .agents/workspace
87
87
 
88
88
  > 仅在校验通过后执行本步骤。
89
89
 
90
- > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染「下一步」命令前,先读取 `.agents/rules/next-step-output.md`,按其取短号片段把命令中的 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id)。
90
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染最终输出前,先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令把 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id);(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
91
91
 
92
92
  ```
93
93
  Code Scanning 告警 #{alert-number} 已导入。
@@ -88,7 +88,7 @@ Keep the gate output in your reply as fresh evidence. Do not claim completion wi
88
88
 
89
89
  > Execute this step only after the verification gate passes.
90
90
 
91
- > **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). Before rendering the "Next steps" commands, read `.agents/rules/next-step-output.md` and use its short-id snippet to render `{task-ref}` in the commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released).
91
+ > **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). Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released); (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
92
92
 
93
93
  ```
94
94
  Security alert #{alert-number} imported.
@@ -88,7 +88,7 @@ node .agents/scripts/validate-artifact.js gate import-dependabot .agents/workspa
88
88
 
89
89
  > 仅在校验通过后执行本步骤。
90
90
 
91
- > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染「下一步」命令前,先读取 `.agents/rules/next-step-output.md`,按其取短号片段把命令中的 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id)。
91
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染最终输出前,先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令把 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id);(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
92
92
 
93
93
  ```
94
94
  安全告警 #{alert-number} 已导入。
@@ -148,7 +148,7 @@ Keep the gate output in your reply as fresh evidence. Do not claim completion wi
148
148
 
149
149
  > Execute this step only after the verification gate passes.
150
150
 
151
- > **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). Before rendering the "Next steps" commands, read `.agents/rules/next-step-output.md` and use its short-id snippet to render `{task-ref}` in the commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released).
151
+ > **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). Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released); (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
152
152
 
153
153
  ```
154
154
  Issue #{number} imported.
@@ -148,7 +148,7 @@ node .agents/scripts/validate-artifact.js gate import-issue .agents/workspace/ac
148
148
 
149
149
  > 仅在校验通过后执行本步骤。
150
150
 
151
- > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染「下一步」命令前,先读取 `.agents/rules/next-step-output.md`,按其取短号片段把命令中的 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id)。
151
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染最终输出前,先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令把 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id);(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
152
152
 
153
153
  ```
154
154
  Issue #{number} 已导入。
@@ -150,7 +150,7 @@ Keep the gate output in your reply as fresh evidence. Do not claim completion wi
150
150
 
151
151
  > Execute this step only after the verification gate passes.
152
152
 
153
- > **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). Before rendering the "Next steps" commands, read `.agents/rules/next-step-output.md` and use its short-id snippet to render `{task-ref}` in the commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released).
153
+ > **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). Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released); (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
154
154
 
155
155
  Output format:
156
156
  ```
@@ -149,7 +149,7 @@ node .agents/scripts/validate-artifact.js gate plan-task .agents/workspace/activ
149
149
 
150
150
  > 仅在校验通过后执行本步骤。
151
151
 
152
- > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染「下一步」命令前,先读取 `.agents/rules/next-step-output.md`,按其取短号片段把命令中的 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id)。
152
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染最终输出前,先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令把 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id);(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
153
153
 
154
154
  输出格式:
155
155
  ```
@@ -79,4 +79,4 @@ node .agents/scripts/validate-artifact.js gate review-analysis .agents/workspace
79
79
 
80
80
  Use the conclusion branch in `reference/output-templates.md` and show all TUI command formats.
81
81
 
82
- > When rendering "Next steps" commands, `{task-ref}` is the current task's short id `#NN` (see `.agents/rules/next-step-output.md` for lookup and fallback; read it before rendering). Other `{task-id}` placeholders (report titles, paths) keep the full TASK-id form.
82
+ > Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the current task's short id `#NN` (see that file for lookup and fallback), while other `{task-id}` placeholders (report titles, paths) keep the full TASK-id form; (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
@@ -92,7 +92,7 @@ node .agents/scripts/validate-artifact.js gate review-analysis .agents/workspace
92
92
 
93
93
  按 `reference/output-templates.md` 的结论分支输出,并展示所有 TUI 的下一步命令。
94
94
 
95
- > 渲染「下一步」命令时,`{task-ref}` 为当前任务短号 `#NN`(取值与回退见 `.agents/rules/next-step-output.md`,渲染前先读取)。其他 `{task-id}` 占位(报告标题、路径)保持完整 TASK-id 形式。
95
+ > 渲染最终输出前先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令的 `{task-ref}` 渲染为当前任务短号 `#NN`(取值与回退见该文件),其他 `{task-id}` 占位(报告标题、路径)保持完整 TASK-id 形式;(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
96
96
 
97
97
  ## 完成检查清单
98
98
 
@@ -122,7 +122,7 @@ env-blocked counts do not influence branch selection; they are appended to the s
122
122
 
123
123
  > The full four-branch output templates, selection rules, and prohibition clauses live in `reference/output-templates.md`. Read `reference/output-templates.md` before reporting the review result.
124
124
 
125
- > When rendering "Next steps" commands, `{task-ref}` is the current task's short id `#NN` (see `.agents/rules/next-step-output.md` for lookup and fallback; read it before rendering). Other `{task-id}` placeholders (report titles, paths) keep the full TASK-id form.
125
+ > Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the current task's short id `#NN` (see that file for lookup and fallback), while other `{task-id}` placeholders (report titles, paths) keep the full TASK-id form; (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
126
126
 
127
127
  Include all TUI command formats in the next-step output. 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).
128
128
 
@@ -125,7 +125,7 @@ env-blocked 的数量不参与分支选择,仅在数字摘要末尾附带显
125
125
 
126
126
  > 完整的 4 分支输出模板、判断规则和禁止条款见 `reference/output-templates.md`。向用户汇报审查结论前先读取 `reference/output-templates.md`。
127
127
 
128
- > 渲染「下一步」命令时,`{task-ref}` 为当前任务短号 `#NN`(取值与回退见 `.agents/rules/next-step-output.md`,渲染前先读取)。其他 `{task-id}` 占位(报告标题、路径)保持完整 TASK-id 形式。
128
+ > 渲染最终输出前先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令的 `{task-ref}` 渲染为当前任务短号 `#NN`(取值与回退见该文件),其他 `{task-id}` 占位(报告标题、路径)保持完整 TASK-id 形式;(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
129
129
 
130
130
  向用户展示下一步时,必须包含所有 TUI 命令格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。
131
131
 
@@ -79,4 +79,4 @@ node .agents/scripts/validate-artifact.js gate review-plan .agents/workspace/act
79
79
 
80
80
  Use the conclusion branch in `reference/output-templates.md` and show all TUI command formats.
81
81
 
82
- > When rendering "Next steps" commands, `{task-ref}` is the current task's short id `#NN` (see `.agents/rules/next-step-output.md` for lookup and fallback; read it before rendering). Other `{task-id}` placeholders (report titles, paths) keep the full TASK-id form.
82
+ > Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the current task's short id `#NN` (see that file for lookup and fallback), while other `{task-id}` placeholders (report titles, paths) keep the full TASK-id form; (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
@@ -92,7 +92,7 @@ node .agents/scripts/validate-artifact.js gate review-plan .agents/workspace/act
92
92
 
93
93
  按 `reference/output-templates.md` 的结论分支输出,并展示所有 TUI 的下一步命令。
94
94
 
95
- > 渲染「下一步」命令时,`{task-ref}` 为当前任务短号 `#NN`(取值与回退见 `.agents/rules/next-step-output.md`,渲染前先读取)。其他 `{task-id}` 占位(报告标题、路径)保持完整 TASK-id 形式。
95
+ > 渲染最终输出前先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令的 `{task-ref}` 渲染为当前任务短号 `#NN`(取值与回退见该文件),其他 `{task-id}` 占位(报告标题、路径)保持完整 TASK-id 形式;(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
96
96
 
97
97
  ## 完成检查清单
98
98
 
@@ -23,7 +23,6 @@ const DEFAULTS = {
23
23
  "platform": {
24
24
  "type": "github"
25
25
  },
26
- "requiresPullRequest": true,
27
26
  "sandbox": {
28
27
  "engine": null,
29
28
  "runtimes": [
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: watch-pr
3
+ description: "Watch a PR's required checks and self-heal on failure"
4
+ ---
5
+
6
+ # Watch Pull Request
7
+
8
+ After `create-pr`, continuously watch the PR's required CI checks: when everything is green, guide toward merge; when a required check fails, pull the logs, fix and push locally, then re-poll; when the fix attempt limit is reached or the failure is non-code / unlocatable, stop and ask the user for help. Platform-specific commands live in `.agents/rules/pr-checks-commands.md`; this skill body stays platform-agnostic.
9
+
10
+ ## Behavior Boundaries / Key Rules
11
+
12
+ - Only watch + self-heal the current PR's required checks; make no changes unrelated to the failing check.
13
+ - Self-heal modifies code and `git push`es to the PR branch, but **local tests for the affected area must pass before pushing**; fix attempts have a hard cap (default 2); only self-heal locatable code-layer failures (lint / format / test / type / build), and always route non-code failures (network / permission / external service / flaky) to the help exit.
14
+ - The help exit is "produce-then-stop": end this round, output the blocker explanation, and wait for the user to trigger the next step — **never** ask mid-flow.
15
+ - Bare numbers / `#NN` / `TASK-id` arguments are always resolved as task short ids (see `.agents/rules/task-short-id.md`); a PR number is passed only via `--pr <number>` / a PR URL / omission (current branch), never reusing the bare-number syntax.
16
+ - After running this skill (task-anchored path), you must update task.md.
17
+
18
+ Version stamp rule: before creating or updating `task.md` frontmatter, read `.agents/rules/version-stamp.md` and write or refresh `agent_infra_version`.
19
+
20
+ ## Task Argument Short-ID Alias
21
+
22
+ > If the `{task-id}` argument matches `^[#]?[0-9]+$` (a bare number or `#`-prefixed), first read the "SKILL argument parsing" section of `.agents/rules/task-short-id.md` to resolve it; subsequent commands treat `{task-id}` as the resolved full `TASK-YYYYMMDD-HHMMSS` form.
23
+
24
+ ## Steps
25
+
26
+ ### 1. Resolve Arguments
27
+
28
+ Resolve the target PR number `{pr#}` and an optional `{task-id}` via these deterministic branches:
29
+
30
+ - Scenario A (argument omitted): use the current branch's PR number per `.agents/rules/pr-checks-commands.md`; then determine `{task-id}` via "Reverse-lookup task" below.
31
+ - Scenario B (`#NN` / bare number / `TASK-id`, **task-anchored primary path**): when matching `^[#]?[0-9]+$`, resolve to the full `{task-id}` via "Task Argument Short-ID Alias" (on failure pass through the exit code; do not rewrite error handling); a `TASK-id` is used directly. Read `.agents/workspace/active/{task-id}/task.md` for `pr_number` as `{pr#}`; if `pr_number` is empty, follow "Error Handling" to prompt running `create-pr` first, then stop.
32
+ - Scenario C (`--pr <number>` or a PR URL): use that PR number directly as `{pr#}`; then determine `{task-id}` via "Reverse-lookup task".
33
+ - Reverse-lookup task (scenarios A / C): search `.agents/workspace/active/*/task.md` for a task whose `pr_number == {pr#}`; on a hit, take that `{task-id}` (task-anchored); on a miss, enter the "watch-only" degraded path (no `{task-id}`, skip steps 5/6).
34
+
35
+ ### 2. Watch Required Checks
36
+
37
+ Before running this step, read `reference/monitor-and-heal.md` and `.agents/rules/pr-checks-commands.md`.
38
+
39
+ Using the watch command in `.agents/rules/pr-checks-commands.md`, poll `{pr#}`'s required checks (with an overall time cap, default 30 minutes), and classify the outcome per the "Outcome Classification" of `reference/monitor-and-heal.md` into the "all green" / "failure" / "pending" scenarios, routing to step 7 (green exit), step 3 (self-heal), or step 4 (help exit) respectively.
40
+
41
+ ### 3. Failure Self-Heal Loop
42
+
43
+ Before running this step, read the "Self-Heal Decision Tree" of `reference/monitor-and-heal.md` and "Resolve a Failing Run id and Pull Logs" of `.agents/rules/pr-checks-commands.md`.
44
+
45
+ For a failing check: first deterministically resolve its failing run and pull the failure logs per the rule, then classify the failure; only when it is a locatable code-layer failure, make a minimal local fix, run the relevant tests until they pass, then **stage, commit, and push the fix** (`git add` only the related files → `git commit` per `.agents/rules/commit-and-pr.md` → `git push` to the current PR branch, recording the commit SHA), and return to step 2 to re-watch. Count fix attempts; on reaching the hard cap (default 2) or when the run is unlocatable, go to step 4.
46
+
47
+ ### 4. Help Exit (Produce-Then-Stop)
48
+
49
+ When self-heal hits the cap, the failure is non-code, the run id is unlocatable, or step 2 times out while pending, stop this round and summarize for the user: the blocker, the fixes attempted (including each fix commit), and the relevant failing job and run/log links (report shape in the "Help report template" of `reference/monitor-and-heal.md`). Do **not** render a next-step command; wait for the user. Then, on the task-anchored path, run steps 5/6 to record this round's outcome.
50
+
51
+ ### 5. Update Task State
52
+
53
+ > Task-anchored path only; the "watch-only" degraded path skips this step and step 6.
54
+
55
+ Get the current time:
56
+
57
+ ```bash
58
+ date "+%Y-%m-%d %H:%M:%S%:z"
59
+ ```
60
+
61
+ Update `.agents/workspace/active/{task-id}/task.md`:
62
+ - `assigned_to`: {current agent}
63
+ - `updated_at`: {current time}
64
+ - `agent_infra_version`: per `.agents/rules/version-stamp.md`
65
+ - **Do not change** `pr_status` (keep `created`) or `current_step`
66
+ - **Append** to `## Activity Log` (do not overwrite prior entries; `{N}` = number of existing Watch PR entries for this task + 1):
67
+ ```
68
+ - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Watch PR (Round {N})** by {agent} — {green: all required checks green / blocked: blocked: {summary}}
69
+ ```
70
+
71
+ ### 6. Verification Gate
72
+
73
+ > Task-anchored path only.
74
+
75
+ Run the verification gate:
76
+
77
+ ```bash
78
+ node .agents/scripts/validate-artifact.js gate watch-pr .agents/workspace/active/{task-id} --format text
79
+ ```
80
+
81
+ Handle the result:
82
+ - exit code 0 (all passed) -> continue to "Inform User"
83
+ - exit code 1 (verification failed) -> fix per the output and re-run the gate
84
+ - exit code 2 (network interruption) -> stop and tell the user manual intervention is needed
85
+
86
+ Keep the gate output in your reply as the verification evidence. Without current gate output, do not declare completion.
87
+
88
+ ### 7. Inform User
89
+
90
+ > On the task-anchored path, execute this step only after the gate passes.
91
+
92
+ > **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). Before rendering the final output, read `.agents/rules/next-step-output.md` and apply both of its rules: (1) render `{task-ref}` in the "Next steps" commands as the short id `#NN` (falling back to the full TASK-id when unallocated or released); (2) append the `Completed at` line as the very last line of the user-facing output (this applies to every user-facing output — success, error, and early-return paths alike, not only the success path).
93
+
94
+ Output per scenario:
95
+ - "All green" + task-anchored: state that all required checks passed and the PR is ready to merge, then render the next step from the template below (`{task-ref}` becomes the short id):
96
+
97
+ ```
98
+ Next step - Complete and archive the task:
99
+ - Claude Code / OpenCode: /complete-task {task-ref}
100
+ - Gemini CLI: /agent-infra:complete-task {task-ref}
101
+ - Codex CLI: $complete-task {task-ref}
102
+ ```
103
+
104
+ - "All green" + watch-only: state the PR is ready to merge; there is no linked task this run, so run `complete-task` against the relevant task (do not force a short-id command block when no `{task-ref}` is available).
105
+ - "Blocked": output only the step 4 blocker explanation; do not recommend a next-step command.
106
+
107
+ ## Completion Checklist
108
+
109
+ - [ ] Resolved the target PR (and any task context)
110
+ - [ ] Completed required-checks watching with an all-green / blocked conclusion
111
+ - [ ] Self-heal limited to locatable code-layer failures, with local tests passing before push and within the fix cap
112
+ - [ ] Task-anchored path: updated task.md and appended the Watch PR Activity Log entry
113
+ - [ ] Task-anchored path: verification gate passed
114
+ - [ ] Showed the user all TUI next-step command formats (green exit; the blocked exit renders no next step)
115
+
116
+ ## Stop
117
+
118
+ Stop immediately after the checklist. The green exit waits for the user to run `complete-task`; the blocked exit waits for the user's decision.
119
+
120
+ ## Notes
121
+
122
+ 1. **Precondition**: the PR exists (created by `create-pr`, or locatable via explicit `--pr` / the current branch).
123
+ 2. **Bare numbers are always task short ids**: do not treat a bare number as a PR number; use `--pr <number>` for a PR number.
124
+ 3. **Self-heal safety**: local tests must pass before pushing; always ask for help on non-code / unlocatable failures rather than blindly retrying.
125
+ 4. **Re-runnable**: watch-pr may run multiple times within a task lifecycle; the Round count increments by the number of existing Watch PR Activity Log entries.
126
+
127
+ ## Error Handling
128
+
129
+ - Cannot locate a PR (task short id resolves but task.md has no `pr_number`, and no `--pr` was passed and the current branch has no PR): prompt "Run `create-pr` first, or specify the PR with `--pr <number>`", then stop.
130
+ - Platform CLI not authenticated or API unavailable: prompt that manual intervention is needed, then stop.
131
+ - Short-id resolution failure: pass through `task-short-id.js`'s exit code and error message; do not rewrite it.
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: watch-pr
3
+ description: "监控 PR 的 required checks 并在失败时自愈"
4
+ ---
5
+
6
+ # 监控 Pull Request
7
+
8
+ 在 `create-pr` 之后持续监控 PR 的 required CI checks:全绿则引导合入,required check 失败则自动拉日志、本地修复并推送、重新轮询;达修复上限或属非代码层/不可定位失败则停止并向用户求助。平台专属命令集中在 `.agents/rules/pr-checks-commands.md`,本技能正文保持平台无关。
9
+
10
+ ## 行为边界 / 关键规则
11
+
12
+ - 仅监控 + 自愈当前 PR 的 required checks;不做与失败 check 无关的改动。
13
+ - 自愈会修改业务代码并 `git push` 到 PR 分支,但**推送前必须本地跑通相关测试**;修复尝试有硬上限(默认 2);仅对可定位的代码层失败(lint / format / test / 类型 / 构建)自愈,非代码层(网络 / 权限 / 外部服务 / flaky)一律转求助出口。
14
+ - 求助出口是「产出后停止」语义:停止本轮、输出阻塞说明、等待用户主动触发,**不**中途提问。
15
+ - 裸数字 / `#NN` / `TASK-id` 入参一律按任务短号解析(见 `.agents/rules/task-short-id.md`);PR 号只走 `--pr <number>` / PR URL / 省略(当前分支),不复用裸数字语法。
16
+ - 执行本技能(任务锚定路径)后,必须更新 task.md。
17
+
18
+ 版本戳规则:创建或更新 `task.md` frontmatter 时,先读取 `.agents/rules/version-stamp.md`,并写入或刷新 `agent_infra_version`。
19
+
20
+ ## 任务入参短号别名
21
+
22
+ > 如果 `{task-id}` 入参匹配 `^[#]?[0-9]+$`(裸数字或带 `#` 前缀),先读取 `.agents/rules/task-short-id.md` 的「SKILL 入参解析」段执行解析;后续命令视 `{task-id}` 为解析后的全长 `TASK-YYYYMMDD-HHMMSS` 形式。
23
+
24
+ ## 执行步骤
25
+
26
+ ### 1. 解析入参
27
+
28
+ 按以下确定性分支解析出目标 PR 号 `{pr#}` 与可选 `{task-id}`:
29
+
30
+ - 场景 A(省略入参):按 `.agents/rules/pr-checks-commands.md` 取当前分支的 PR 号;随后按下方「反查任务」确定 `{task-id}`。
31
+ - 场景 B(`#NN` / 裸数字 / `TASK-id`,**任务锚定主路径**):匹配 `^[#]?[0-9]+$` 时按「任务入参短号别名」解析为完整 `{task-id}`(解析失败直接透传退出码,不重写错误处理);`TASK-id` 直接采用。读 `.agents/workspace/active/{task-id}/task.md` 取 `pr_number` 作为 `{pr#}`;`pr_number` 为空时按「错误处理」提示先 `create-pr`,停止。
32
+ - 场景 C(`--pr <number>` 或 PR URL):直接取该 PR 号为 `{pr#}`;随后按「反查任务」确定 `{task-id}`。
33
+ - 反查任务(场景 A / C):在 `.agents/workspace/active/*/task.md` 中查找 `pr_number == {pr#}` 的任务;命中则取该 `{task-id}`(任务锚定);未命中则进入「仅监控」降级路径(无 `{task-id}`,跳过步骤 5/6)。
34
+
35
+ ### 2. 监控 required checks
36
+
37
+ 执行此步骤前,先读取 `reference/monitor-and-heal.md` 与 `.agents/rules/pr-checks-commands.md`。
38
+
39
+ 按 `.agents/rules/pr-checks-commands.md` 的监控命令对 `{pr#}` 的 required checks 轮询(含总时长上限,默认 30 分钟),按 `reference/monitor-and-heal.md` 的「结果分类」分为「全绿」/「失败」/「挂起」三个场景,分别进入步骤 7 全绿出口、步骤 3 自愈、或步骤 4 求助。
40
+
41
+ ### 3. 失败自愈循环
42
+
43
+ 执行此步骤前,先读取 `reference/monitor-and-heal.md` 的「自愈决策树」与 `.agents/rules/pr-checks-commands.md` 的「解析失败 run id 并拉日志」。
44
+
45
+ 对失败 check:先按规则确定性解析其失败 run 并拉取失败日志、判定失败类别;仅当属可定位的代码层失败时,本地最小化修复、运行对应测试通过后**暂存并提交本次修复再推送**(`git add` 仅相关文件 → 按 `.agents/rules/commit-and-pr.md` `git commit` → `git push` 到当前 PR 分支,并记录 commit SHA),再回到步骤 2 重新监控。修复尝试计数,达硬上限(默认 2)或 run 不可定位 → 转步骤 4。
46
+
47
+ ### 4. 求助出口(产出后停止)
48
+
49
+ 当自愈达上限、失败属非代码层、run id 不可定位、或步骤 2 挂起超时时,停止本轮并向用户汇总:阻塞原因、已尝试的修复(含每次修复 commit)、相关失败 job 与 run/log 链接(报告结构见 `reference/monitor-and-heal.md` 的「求助报告模板」)。**不**渲染下一步命令,等待用户裁定。随后在任务锚定路径下执行步骤 5/6 记录本轮结果。
50
+
51
+ ### 5. 更新任务状态
52
+
53
+ > 仅任务锚定路径执行;「仅监控」降级路径跳过本步骤与步骤 6。
54
+
55
+ 获取当前时间:
56
+
57
+ ```bash
58
+ date "+%Y-%m-%d %H:%M:%S%:z"
59
+ ```
60
+
61
+ 更新 `.agents/workspace/active/{task-id}/task.md`:
62
+ - `assigned_to`:{当前代理}
63
+ - `updated_at`:{当前时间}
64
+ - `agent_infra_version`:按 `.agents/rules/version-stamp.md` 取值
65
+ - **不改** `pr_status`(保持 `created`)与 `current_step`
66
+ - **追加**到 `## 活动日志`(不要覆盖之前的记录;`{N}` = 本任务已有 Watch PR 条目数 + 1):
67
+ ```
68
+ - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Watch PR (Round {N})** by {agent} — {全绿:all required checks green / 阻塞:blocked: {简述}}
69
+ ```
70
+
71
+ ### 6. 完成校验
72
+
73
+ > 仅任务锚定路径执行。
74
+
75
+ 运行完成校验:
76
+
77
+ ```bash
78
+ node .agents/scripts/validate-artifact.js gate watch-pr .agents/workspace/active/{task-id} --format text
79
+ ```
80
+
81
+ 处理结果:
82
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
83
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
84
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
85
+
86
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
87
+
88
+ ### 7. 告知用户
89
+
90
+ > 任务锚定路径仅在校验通过后执行本步骤。
91
+
92
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。如果 `.agents/.airc.json` 中配置了自定义 TUI(`customTUIs`),读取每个工具的 `name` 和 `invoke`,按同样格式补充对应命令行(`${skillName}` 替换为技能名,`${projectName}` 替换为项目名)。 渲染最终输出前,先读取 `.agents/rules/next-step-output.md` 并落实其两类规则:(1) 「下一步」命令把 `{task-ref}` 渲染为短号 `#NN`(未分配/已释放时回退完整 TASK-id);(2) 在面向用户输出的绝对最后一行追加 `Completed at` 收尾行(成功、错误、早退等任何面向用户输出都适用,不限于校验通过的成功态)。
93
+
94
+ 按场景输出:
95
+ - 「全绿」+ 任务锚定:说明所有 required checks 已通过、PR 可合入,并按下方模板渲染下一步(`{task-ref}` 替换为短号):
96
+
97
+ ```
98
+ 下一步 - 完成并归档任务:
99
+ - Claude Code / OpenCode:/complete-task {task-ref}
100
+ - Gemini CLI:/agent-infra:complete-task {task-ref}
101
+ - Codex CLI:$complete-task {task-ref}
102
+ ```
103
+
104
+ - 「全绿」+ 仅监控降级:说明 PR 可合入;本次无关联任务,请对相应任务运行 `complete-task`(无 `{task-ref}` 可渲染时不强行输出短号命令块)。
105
+ - 「阻塞」:仅输出步骤 4 的阻塞说明,不推荐下一步命令。
106
+
107
+ ## 完成检查清单
108
+
109
+ - [ ] 解析出目标 PR(及可能的任务上下文)
110
+ - [ ] 完成 required checks 监控,得到全绿 / 阻塞结论
111
+ - [ ] 自愈仅限可定位的代码层失败,且推送前本地测试通过、未超修复上限
112
+ - [ ] 任务锚定路径:更新了 task.md 并追加 Watch PR 的 Activity Log
113
+ - [ ] 任务锚定路径:完成校验通过
114
+ - [ ] 向用户展示了所有 TUI 格式的下一步命令(全绿出口;阻塞出口不渲染下一步)
115
+
116
+ ## 停止
117
+
118
+ 完成检查清单后立即停止。全绿出口等待用户运行 `complete-task`;阻塞出口等待用户裁定。
119
+
120
+ ## 注意事项
121
+
122
+ 1. **前置条件**:PR 已存在(由 `create-pr` 创建或显式 `--pr` / 当前分支可定位)。
123
+ 2. **裸数字恒为任务短号**:不要把裸数字当作 PR 号;PR 号用 `--pr <number>`。
124
+ 3. **自愈安全**:推送前必须本地测试通过;非代码层 / 不可定位失败一律求助,不盲目重试。
125
+ 4. **可多次运行**:watch-pr 可在一次任务生命周期多次运行,Round 计数按已有 Watch PR Activity Log 条目数递增。
126
+
127
+ ## 错误处理
128
+
129
+ - 无法定位 PR(任务短号命中但 task.md 无 `pr_number`,且未传 `--pr`、当前分支也无 PR):提示「请先运行 `create-pr`,或用 `--pr <number>` 指定 PR」,停止。
130
+ - 平台 CLI 未认证或 API 不可用:提示需人工介入,停止。
131
+ - 短号解析失败:透传 `task-short-id.js` 的退出码与错误信息,不重写。
@@ -0,0 +1,22 @@
1
+ {
2
+ "skill": "watch-pr",
3
+ "checks": {
4
+ "task-meta": {
5
+ "required_fields": [
6
+ "id",
7
+ "type",
8
+ "workflow",
9
+ "status",
10
+ "created_at",
11
+ "updated_at",
12
+ "agent_infra_version",
13
+ "current_step",
14
+ "assigned_to"
15
+ ]
16
+ },
17
+ "activity-log": {
18
+ "expected_action_pattern": "(Watch PR|Watching PR) \\(Round \\d+\\)",
19
+ "freshness_minutes": 30
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,43 @@
1
+ # Monitoring & Self-Heal Details
2
+
3
+ Platform-agnostic decision logic for `watch-pr` steps 2/3/4. The concrete platform commands (watch, resolve a failing run, pull logs, read the PR number) live in `.agents/rules/pr-checks-commands.md`; this file only describes platform-independent classification and decisions.
4
+
5
+ ## Outcome Classification
6
+
7
+ After running the watch command from `.agents/rules/pr-checks-commands.md`, classify by its exit code into three buckets:
8
+
9
+ - All required checks passed → "all green" (SKILL step 7 green exit).
10
+ - At least one failed / errored → "failure" (SKILL step 3 self-heal).
11
+ - Still pending or the overall time cap was reached → "pending" (SKILL step 4 help exit).
12
+
13
+ ## Self-Heal Decision Tree
14
+
15
+ For each failing check, decide "self-heal" vs "ask for help" in this order:
16
+
17
+ 1. **Can the corresponding CI run be located** (per the rule's "Resolve a failing run id")? No → ask for help.
18
+ 2. **Which layer is the failure?**
19
+ - Code layer (self-healable): lint / format / type check / unit or integration test assertions / build-compile errors — locatable to a specific file and cause in this repo from the logs.
20
+ - Non-code layer (not self-healable): network flakiness, permissions / tokens, external service outages, dependency-source failures, obvious flakiness (a re-run might go green but it was not introduced by this change) → ask for help.
21
+ 3. **Has the fix cap been reached** (default 2 push-fixes)? Yes → ask for help.
22
+ 4. When "locatable + code layer + under cap" holds, perform one self-heal:
23
+ - Before fixing, run `git status -s` to record the working tree and ensure only changes related to this failure are included.
24
+ - Locate and make a minimal fix per the logs (touch only code / tests / config related to that failure).
25
+ - Run the relevant tests: prefer the local command for the failing job; fall back to `npm run test:core` repo-wide. **Do not commit or push before tests pass.**
26
+ - After tests pass, publish the fix: per `.agents/rules/commit-and-pr.md` stage only the related files (`git add <paths>`, avoid `git add -A` pulling in unrelated changes) → create the fix commit (`git commit`) → `git push` to the current PR branch.
27
+ - Record the fix commit SHA, increment the fix count, and return to SKILL step 2 to re-watch.
28
+ - Never make unrelated "drive-by" optimizations; never loosen / skip the failing assertion to "make it green".
29
+
30
+ ## Help Report Template
31
+
32
+ When entering the help exit, output the following fixed structure to the user (not written to any artifact file):
33
+
34
+ ```
35
+ PR #{pr#} monitoring is blocked; manual intervention needed.
36
+
37
+ Blocker: {non-code layer / fix cap reached / run unlocatable / poll timeout}
38
+ Failing check: {name} (workflow: {workflow})
39
+ Failing run / logs: {run/job link}
40
+ Fixes attempted ({k} total):
41
+ - {commit summary}: {change summary} → still failing after re-watch
42
+ Suggestion: {upgrade platform CLI / check permissions / re-run external dependency / inspect logs manually, etc.}
43
+ ```
@@ -0,0 +1,43 @@
1
+ # 监控与自愈细则
2
+
3
+ `watch-pr` 步骤 2/3/4 的平台无关判定逻辑。具体平台命令(监控、解析失败 run、拉日志、读取 PR 号)见 `.agents/rules/pr-checks-commands.md`;本文件只描述与平台无关的分类与决策。
4
+
5
+ ## 结果分类
6
+
7
+ 按 `.agents/rules/pr-checks-commands.md` 的监控命令执行后,依其退出码归为三类:
8
+
9
+ - 全部 required checks 通过 → 「全绿」(SKILL 步骤 7 全绿出口)。
10
+ - 至少一个失败 / 出错 → 「失败」(SKILL 步骤 3 自愈)。
11
+ - 仍有 pending 或达到总时长上限 → 「挂起」(SKILL 步骤 4 求助)。
12
+
13
+ ## 自愈决策树
14
+
15
+ 对每个失败 check,按下列顺序判定「自愈」还是「求助」:
16
+
17
+ 1. **能否定位到对应的 CI run**(按规则的「解析失败 run id」)?否 → 求助。
18
+ 2. **失败属于哪一层**?
19
+ - 代码层(可自愈):lint / format / 类型检查 / 单元或集成测试断言 / 构建编译错误等,能从日志定位到本仓库具体文件与原因。
20
+ - 非代码层(不可自愈):网络抖动、权限 / 令牌、外部服务不可用、依赖源故障、明显的 flaky(重跑可能变绿但非本次改动引入)→ 求助。
21
+ 3. **是否已达修复上限**(默认 2 次推送修复)?是 → 求助。
22
+ 4. 满足「可定位 + 代码层 + 未达上限」时执行一次自愈:
23
+ - 自愈前先 `git status -s` 记录当前工作树,确保后续只纳入与本次失败相关的改动。
24
+ - 在本地按日志定位并最小化修复(只动与该失败相关的代码 / 测试 / 配置)。
25
+ - 运行对应测试:优先失败 job 对应的本地命令;仓库统一回退 `npm run test:core`。**测试通过前不得提交或推送。**
26
+ - 测试通过后发布修复:按 `.agents/rules/commit-and-pr.md` 仅暂存本次相关文件(`git add <相关路径>`,避免 `git add -A` 卷入无关改动)→ 创建修复 commit(`git commit`)→ `git push` 到当前 PR 分支。
27
+ - 记录本次修复的 commit SHA,修复计数 +1,回到 SKILL 步骤 2 重新监控。
28
+ - 绝不执行与失败无关的「顺手优化」;不放宽 / 跳过失败的断言来「修绿」。
29
+
30
+ ## 求助报告模板
31
+
32
+ 进入求助出口时,向用户输出以下固定结构(不写入产物文件):
33
+
34
+ ```
35
+ PR #{pr#} 监控阻塞,需人工介入。
36
+
37
+ 阻塞原因:{非代码层 / 达修复上限 / run 不可定位 / 轮询超时}
38
+ 失败 check:{name}(workflow:{workflow})
39
+ 失败 run / 日志:{run/job 链接}
40
+ 已尝试的修复(共 {k} 次):
41
+ - {commit 简述}:{改动概述} → 重新监控后仍失败
42
+ 建议:{升级平台 CLI / 检查权限 / 重跑外部依赖 / 人工查看日志 等}
43
+ ```
@@ -13,6 +13,7 @@ start_date: # Optional Issue field for Feature: YYYY-MM-DD
13
13
  target_date: # Optional Issue field for Feature: YYYY-MM-DD
14
14
  current_step: requirement-analysis # requirement-analysis | requirement-analysis-review | technical-design | technical-design-review | code | code-review | completed
15
15
  assigned_to: # claude | codex | gemini | opencode | human
16
+ pr_status: pending # PR status: pending (default) | created (PR created) | skipped (explicitly skipped)
16
17
  ---
17
18
 
18
19
  # Task: [Title]
@@ -13,6 +13,7 @@ start_date: # Feature 可选 Issue 字段:YYYY-MM-DD
13
13
  target_date: # Feature 可选 Issue 字段:YYYY-MM-DD
14
14
  current_step: requirement-analysis # requirement-analysis | requirement-analysis-review | technical-design | technical-design-review | code | code-review | completed
15
15
  assigned_to: # claude | codex | gemini | opencode | human
16
+ pr_status: pending # PR 状态:pending(默认)| created(已创建 PR)| skipped(显式跳过)
16
17
  ---
17
18
 
18
19
  # 任务:[标题]