@fitlab-ai/agent-infra 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +44 -44
  2. package/README.zh-CN.md +44 -44
  3. package/lib/defaults.json +7 -9
  4. package/lib/init.js +1 -0
  5. package/lib/update.js +13 -1
  6. package/package.json +3 -3
  7. package/templates/.agents/QUICKSTART.md +7 -7
  8. package/templates/.agents/QUICKSTART.zh-CN.md +13 -13
  9. package/templates/.agents/README.md +31 -18
  10. package/templates/.agents/README.zh-CN.md +33 -20
  11. package/templates/.agents/rules/issue-sync.md +185 -0
  12. package/templates/.agents/rules/issue-sync.zh-CN.md +185 -0
  13. package/templates/.agents/scripts/validate-artifact.js +1280 -0
  14. package/templates/.agents/skills/analyze-task/SKILL.md +24 -1
  15. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +24 -1
  16. package/templates/.agents/skills/analyze-task/config/verify.json +41 -0
  17. package/templates/.agents/skills/archive-tasks/SKILL.md +40 -0
  18. package/templates/.agents/skills/archive-tasks/SKILL.zh-CN.md +40 -0
  19. package/templates/.agents/skills/archive-tasks/scripts/archive-tasks.sh +403 -0
  20. package/templates/.agents/skills/block-task/SKILL.md +25 -37
  21. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +25 -37
  22. package/templates/.agents/skills/block-task/config/verify.json +28 -0
  23. package/templates/.agents/skills/close-codescan/SKILL.md +7 -0
  24. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +7 -0
  25. package/templates/.agents/skills/close-dependabot/SKILL.md +7 -0
  26. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +7 -0
  27. package/templates/.agents/skills/commit/SKILL.md +17 -0
  28. package/templates/.agents/skills/commit/SKILL.zh-CN.md +17 -0
  29. package/templates/.agents/skills/commit/config/verify.json +22 -0
  30. package/templates/.agents/skills/commit/reference/task-status-update.md +3 -3
  31. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +3 -3
  32. package/templates/.agents/skills/complete-task/SKILL.md +24 -10
  33. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +24 -10
  34. package/templates/.agents/skills/complete-task/config/verify.json +30 -0
  35. package/templates/.agents/skills/create-issue/SKILL.md +41 -5
  36. package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +41 -5
  37. package/templates/.agents/skills/create-issue/config/verify.json +27 -0
  38. package/templates/.agents/skills/create-issue/reference/label-and-type.md +10 -11
  39. package/templates/.agents/skills/create-issue/reference/label-and-type.zh-CN.md +10 -11
  40. package/templates/.agents/skills/create-pr/SKILL.md +59 -16
  41. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +59 -16
  42. package/templates/.agents/skills/create-pr/config/verify.json +26 -0
  43. package/templates/.agents/skills/create-pr/reference/branch-strategy.md +3 -3
  44. package/templates/.agents/skills/create-pr/reference/branch-strategy.zh-CN.md +3 -3
  45. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.md +6 -6
  46. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.zh-CN.md +10 -10
  47. package/templates/.agents/skills/create-pr/reference/pr-body-template.md +15 -6
  48. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +15 -6
  49. package/templates/.agents/skills/create-task/SKILL.md +25 -3
  50. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +25 -3
  51. package/templates/.agents/skills/create-task/config/verify.json +24 -0
  52. package/templates/.agents/skills/implement-task/SKILL.md +44 -8
  53. package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +44 -8
  54. package/templates/.agents/skills/implement-task/config/verify.json +41 -0
  55. package/templates/.agents/skills/implement-task/reference/branch-management.md +48 -0
  56. package/templates/.agents/skills/implement-task/reference/branch-management.zh-CN.md +49 -0
  57. package/templates/.agents/skills/implement-task/reference/output-template.md +20 -0
  58. package/templates/.agents/skills/implement-task/reference/output-template.zh-CN.md +20 -0
  59. package/templates/.agents/skills/import-codescan/SKILL.md +18 -7
  60. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +18 -7
  61. package/templates/.agents/skills/import-codescan/config/verify.json +24 -0
  62. package/templates/.agents/skills/import-dependabot/SKILL.md +18 -7
  63. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +18 -7
  64. package/templates/.agents/skills/import-dependabot/config/verify.json +24 -0
  65. package/templates/.agents/skills/import-issue/SKILL.md +19 -1
  66. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +19 -1
  67. package/templates/.agents/skills/import-issue/config/verify.json +27 -0
  68. package/templates/.agents/skills/init-labels/SKILL.md +40 -10
  69. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +40 -10
  70. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +1 -22
  71. package/templates/.agents/skills/init-milestones/SKILL.md +13 -0
  72. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +13 -0
  73. package/templates/.agents/skills/plan-task/SKILL.md +29 -75
  74. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +29 -75
  75. package/templates/.agents/skills/plan-task/config/verify.json +42 -0
  76. package/templates/.agents/skills/refine-task/SKILL.md +51 -4
  77. package/templates/.agents/skills/refine-task/SKILL.zh-CN.md +51 -4
  78. package/templates/.agents/skills/refine-task/config/verify.json +37 -0
  79. package/templates/.agents/skills/refine-title/SKILL.md +10 -2
  80. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +10 -2
  81. package/templates/.agents/skills/restore-task/SKILL.md +159 -0
  82. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +159 -0
  83. package/templates/.agents/skills/restore-task/config/verify.json +24 -0
  84. package/templates/.agents/skills/review-task/SKILL.md +25 -1
  85. package/templates/.agents/skills/review-task/SKILL.zh-CN.md +25 -1
  86. package/templates/.agents/skills/review-task/config/verify.json +40 -0
  87. package/templates/.agents/skills/update-agent-infra/SKILL.md +11 -0
  88. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +11 -0
  89. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +8 -10
  90. package/templates/.claude/commands/archive-tasks.md +9 -0
  91. package/templates/.claude/commands/archive-tasks.zh-CN.md +9 -0
  92. package/templates/.claude/commands/create-pr.md +1 -1
  93. package/templates/.claude/commands/create-pr.zh-CN.md +1 -1
  94. package/templates/.claude/commands/restore-task.md +9 -0
  95. package/templates/.claude/commands/restore-task.zh-CN.md +9 -0
  96. package/templates/.gemini/commands/_project_/archive-tasks.toml +10 -0
  97. package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +10 -0
  98. package/templates/.gemini/commands/_project_/restore-task.toml +8 -0
  99. package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +8 -0
  100. package/templates/.github/workflows/status-label.yml +82 -0
  101. package/templates/.opencode/commands/archive-tasks.md +11 -0
  102. package/templates/.opencode/commands/archive-tasks.zh-CN.md +11 -0
  103. package/templates/.opencode/commands/restore-task.md +11 -0
  104. package/templates/.opencode/commands/restore-task.zh-CN.md +11 -0
  105. package/templates/.agents/skills/sync-issue/SKILL.md +0 -91
  106. package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +0 -91
  107. package/templates/.agents/skills/sync-issue/reference/comment-publish.md +0 -88
  108. package/templates/.agents/skills/sync-issue/reference/comment-publish.zh-CN.md +0 -88
  109. package/templates/.agents/skills/sync-issue/reference/delivery-detection.md +0 -42
  110. package/templates/.agents/skills/sync-issue/reference/delivery-detection.zh-CN.md +0 -42
  111. package/templates/.agents/skills/sync-issue/reference/label-sync.md +0 -63
  112. package/templates/.agents/skills/sync-issue/reference/label-sync.zh-CN.md +0 -63
  113. package/templates/.agents/skills/sync-issue/reference/milestone-sync.md +0 -37
  114. package/templates/.agents/skills/sync-issue/reference/milestone-sync.zh-CN.md +0 -37
  115. package/templates/.agents/skills/sync-pr/SKILL.md +0 -72
  116. package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +0 -72
  117. package/templates/.agents/skills/sync-pr/reference/delivery-detection.md +0 -54
  118. package/templates/.agents/skills/sync-pr/reference/delivery-detection.zh-CN.md +0 -54
  119. package/templates/.claude/CLAUDE.md +0 -138
  120. package/templates/.claude/CLAUDE.zh-CN.md +0 -138
  121. package/templates/.claude/commands/sync-issue.md +0 -8
  122. package/templates/.claude/commands/sync-issue.zh-CN.md +0 -8
  123. package/templates/.claude/commands/sync-pr.md +0 -8
  124. package/templates/.claude/commands/sync-pr.zh-CN.md +0 -8
  125. package/templates/.claude/project-rules.md +0 -65
  126. package/templates/.claude/project-rules.zh-CN.md +0 -65
  127. package/templates/.codex/README.md +0 -38
  128. package/templates/.codex/README.zh-CN.md +0 -37
  129. package/templates/.gemini/commands/_project_/sync-issue.toml +0 -8
  130. package/templates/.gemini/commands/_project_/sync-issue.zh-CN.toml +0 -8
  131. package/templates/.gemini/commands/_project_/sync-pr.toml +0 -8
  132. package/templates/.gemini/commands/_project_/sync-pr.zh-CN.toml +0 -8
  133. package/templates/.opencode/COMMAND_STYLE_GUIDE.md +0 -232
  134. package/templates/.opencode/COMMAND_STYLE_GUIDE.zh-CN.md +0 -232
  135. package/templates/.opencode/README.md +0 -76
  136. package/templates/.opencode/README.zh-CN.md +0 -77
  137. package/templates/.opencode/commands/sync-issue.md +0 -11
  138. package/templates/.opencode/commands/sync-issue.zh-CN.md +0 -11
  139. package/templates/.opencode/commands/sync-pr.md +0 -11
  140. package/templates/.opencode/commands/sync-pr.zh-CN.md +0 -11
  141. package/templates/AGENTS.md +0 -112
  142. package/templates/AGENTS.zh-CN.md +0 -112
@@ -1,6 +1,6 @@
1
1
  # Multi-AI Collaboration Guide
2
2
 
3
- This project supports collaboration across multiple AI coding assistants, including Claude Code, OpenAI Codex CLI, Gemini CLI, Cursor, and others.
3
+ This project supports collaboration across multiple AI coding assistants, including Claude Code, OpenAI Codex CLI, Gemini CLI, OpenCode, and others.
4
4
 
5
5
  ## Dual-Config Architecture
6
6
 
@@ -8,10 +8,10 @@ Different AI tools read configuration from different locations:
8
8
 
9
9
  | AI Tool | Primary Config | Fallback |
10
10
  |---------|---------------|----------|
11
- | Claude Code | `.claude/` (CLAUDE.md, commands/, settings/) | - |
11
+ | Claude Code | `.claude/` (CLAUDE.md, commands/, settings.json) | - |
12
12
  | OpenAI Codex CLI | `AGENTS.md` | - |
13
13
  | Gemini CLI | `AGENTS.md` | - |
14
- | Cursor | `.cursorrules` or `.cursor/rules/` | `AGENTS.md` |
14
+ | OpenCode | `AGENTS.md` | - |
15
15
  | Other AI Tools | `AGENTS.md` | Project README |
16
16
 
17
17
  - **Claude Code** uses its dedicated `.claude/` directory for project instructions, slash commands, and settings.
@@ -23,10 +23,8 @@ This dual-config approach ensures every AI tool receives appropriate project con
23
23
 
24
24
  ```
25
25
  .agents/ # AI collaboration config (version-controlled)
26
- README.md # This file (English)
27
- README.zh-CN.md # Chinese version
26
+ README.md # Collaboration guide
28
27
  QUICKSTART.md # Quick start guide
29
- QUICKSTART.zh-CN.md # Quick start guide (Chinese)
30
28
  templates/ # Task and document templates
31
29
  task.md # Task template
32
30
  handoff.md # AI-to-AI handoff template
@@ -45,7 +43,7 @@ This dual-config approach ensures every AI tool receives appropriate project con
45
43
  .claude/ # Claude Code specific config
46
44
  CLAUDE.md # Project instructions for Claude
47
45
  commands/ # Slash commands
48
- settings/ # Claude settings
46
+ settings.json # Claude settings
49
47
  ```
50
48
 
51
49
  ## Collaboration Model
@@ -76,21 +74,21 @@ When one AI completes a phase, it produces a **handoff document** (see `.agents/
76
74
 
77
75
  Each AI tool has different strengths. Use them accordingly:
78
76
 
79
- | Capability | Claude Code | Codex CLI | Gemini CLI | Cursor |
80
- |-----------|-------------|-----------|------------|--------|
77
+ | Capability | Claude Code | Codex CLI | Gemini CLI | OpenCode |
78
+ |-----------|-------------|-----------|------------|----------|
81
79
  | Codebase analysis | Excellent | Good | Excellent | Good |
82
- | Code review | Excellent | Good | Good | Fair |
80
+ | Code review | Excellent | Good | Good | Good |
83
81
  | Implementation | Good | Excellent | Good | Excellent |
84
- | Large context | Good | Fair | Excellent | Good |
85
- | Refactoring | Good | Good | Good | Excellent |
86
- | Documentation | Excellent | Good | Good | Fair |
82
+ | Large context | Good | Fair | Excellent | Fair |
83
+ | Refactoring | Good | Good | Good | Good |
84
+ | Documentation | Excellent | Good | Good | Good |
87
85
 
88
86
  ### Recommended Assignments
89
87
 
90
88
  - **Analysis & Review** - Claude Code (strong reasoning, thorough exploration)
91
- - **Implementation** - Codex CLI or Cursor (fast code generation, inline editing)
89
+ - **Implementation** - Codex CLI or OpenCode (fast code generation, command-driven editing)
92
90
  - **Large Context Tasks** - Gemini CLI (large context window for cross-file analysis)
93
- - **Quick Edits** - Cursor (IDE integration, fast iteration)
91
+ - **Command-Driven Iteration** - OpenCode (workflow-friendly TUI execution)
94
92
 
95
93
  ## Quick Start
96
94
 
@@ -118,18 +116,33 @@ When writing or updating `.agents/skills/*/SKILL.md` files and their templates,
118
116
 
119
117
  1. Use consecutive integers for top-level steps: `1.`, `2.`, `3.`.
120
118
  2. Use nested numbering only for child actions that belong to a parent step: `1.1`, `1.2`, `2.1`.
121
- 3. Use `a`, `b`, and `c` markers for branches, conditions, or alternative paths within the same step.
119
+ 3. Use `a`, `b`, and `c` markers for branches, conditions, or alternative paths within the same step; keep them scoped to child options rather than standalone decision tracks or output templates.
122
120
  4. Do not use intermediate numbers such as `1.5` or `2.5`; if a new standalone step is needed, renumber the following top-level steps.
123
121
  5. When renumbering, update every in-document step reference so the instructions remain accurate.
124
122
  6. Extract long bash scripts into a sibling `scripts/` directory; the SKILL.md should contain only a single-line invocation (e.g., `bash .agents/skills/<skill>/scripts/<script>.sh`) and a brief summary of the script's responsibilities.
123
+ 7. In SKILL.md files and their `reference/` templates, use “Scenario” naming for standalone condition branches, decision paths, or output templates (for example, “Scenario A”).
125
124
 
126
125
  ### SKILL.md Size Control
127
126
 
128
- - Keep the SKILL.md body within about 500 tokens (roughly 80 lines / 2KB).
129
- - Move content beyond that threshold into a sibling `reference/` directory.
127
+ - Keep SKILL.md as concise as possible; move detailed rules, long templates, and large script blocks into a sibling `reference/` or `scripts/` directory.
128
+ - Store declarative configuration in a sibling `config/` directory, for example `config/verify.json`.
130
129
  - Use explicit navigation in the skeleton, such as: `Read reference/xxx.md before executing this step.`
131
130
  - Keep scripts in `scripts/` and execute them instead of inlining long bash blocks.
132
131
 
132
+ ## Verification Gate
133
+
134
+ For skills that produce structured artifacts or mutate task state, run the verification gate before claiming completion:
135
+
136
+ ```bash
137
+ node .agents/scripts/validate-artifact.js gate <skill-name> <task-dir> [artifact-file] [--format json|text]
138
+ ```
139
+
140
+ - Each skill declares its own checks in `config/verify.json`; keep the file focused on what that skill must validate
141
+ - If a skill also prints next-step guidance, run the gate first and only show those instructions after the gate passes
142
+ - For user-facing final validation, prefer `--format text` so the reply contains a readable summary instead of raw JSON
143
+ - Shared validation logic belongs in `.agents/scripts/validate-artifact.js`; do not move detailed rules back into SKILL.md
144
+ - Keep the gate output in the reply as fresh evidence; without output from the current run, do not claim completion
145
+
133
146
  ## FAQ
134
147
 
135
148
  ### Q: Do I need to configure every AI tool separately?
@@ -1,6 +1,6 @@
1
1
  # 多 AI 协作指南
2
2
 
3
- 本项目支持多个 AI 编程助手协同工作,包括 Claude Code、OpenAI Codex CLI、Gemini CLI、Cursor 等。
3
+ 本项目支持多个 AI 编程助手协同工作,包括 Claude Code、OpenAI Codex CLI、Gemini CLI、OpenCode 等。
4
4
 
5
5
  ## 双配置架构
6
6
 
@@ -8,10 +8,10 @@
8
8
 
9
9
  | AI 工具 | 主要配置 | 备选配置 |
10
10
  |---------|---------|---------|
11
- | Claude Code | `.claude/`(CLAUDE.md、commands/、settings/) | - |
11
+ | Claude Code | `.claude/`(CLAUDE.md、commands/、settings.json) | - |
12
12
  | OpenAI Codex CLI | `AGENTS.md` | - |
13
13
  | Gemini CLI | `AGENTS.md` | - |
14
- | Cursor | `.cursorrules` 或 `.cursor/rules/` | `AGENTS.md` |
14
+ | OpenCode | `AGENTS.md` | - |
15
15
  | 其他 AI 工具 | `AGENTS.md` | 项目 README |
16
16
 
17
17
  - **Claude Code** 使用专属的 `.claude/` 目录存放项目指令、斜杠命令和设置。
@@ -23,10 +23,8 @@
23
23
 
24
24
  ```
25
25
  .agents/ # AI 协作配置(版本控制)
26
- README.md # 本文件(英文)
27
- README.zh-CN.md # 中文版本
26
+ README.md # 协作指南
28
27
  QUICKSTART.md # 快速入门指南
29
- QUICKSTART.zh-CN.md # 快速入门指南(中文)
30
28
  templates/ # 任务和文档模板
31
29
  task.md # 任务模板
32
30
  handoff.md # AI 间交接模板
@@ -45,7 +43,7 @@
45
43
  .claude/ # Claude Code 专属配置
46
44
  CLAUDE.md # Claude 项目指令
47
45
  commands/ # 斜杠命令
48
- settings/ # Claude 设置
46
+ settings.json # Claude 设置
49
47
  ```
50
48
 
51
49
  ## 协作模型
@@ -76,26 +74,26 @@
76
74
 
77
75
  每个 AI 工具有不同的优势,请据此分配任务:
78
76
 
79
- | 能力 | Claude Code | Codex CLI | Gemini CLI | Cursor |
80
- |-----|-------------|-----------|------------|--------|
77
+ | 能力 | Claude Code | Codex CLI | Gemini CLI | OpenCode |
78
+ |-----|-------------|-----------|------------|----------|
81
79
  | 代码库分析 | 优秀 | 良好 | 优秀 | 良好 |
82
- | 代码审查 | 优秀 | 良好 | 良好 | 一般 |
80
+ | 代码审查 | 优秀 | 良好 | 良好 | 良好 |
83
81
  | 代码实现 | 良好 | 优秀 | 良好 | 优秀 |
84
- | 大上下文处理 | 良好 | 一般 | 优秀 | 良好 |
85
- | 重构 | 良好 | 良好 | 良好 | 优秀 |
86
- | 文档编写 | 优秀 | 良好 | 良好 | 一般 |
82
+ | 大上下文处理 | 良好 | 一般 | 优秀 | 一般 |
83
+ | 重构 | 良好 | 良好 | 良好 | 良好 |
84
+ | 文档编写 | 优秀 | 良好 | 良好 | 良好 |
87
85
 
88
86
  ### 推荐分配
89
87
 
90
88
  - **分析和审查** - Claude Code(推理能力强,探索全面)
91
- - **代码实现** - Codex CLI 或 Cursor(代码生成快,内联编辑)
89
+ - **代码实现** - Codex CLI 或 OpenCode(代码生成快,命令式工作流顺手)
92
90
  - **大上下文任务** - Gemini CLI(大上下文窗口,适合跨文件分析)
93
- - **快速编辑** - Cursor(IDE 集成,快速迭代)
91
+ - **命令式迭代** - OpenCode(适合按工作流连续推进)
94
92
 
95
93
  ## 快速入门
96
94
 
97
- 1. **阅读快速入门指南**:参见 `QUICKSTART.zh-CN.md` 获取分步说明。
98
- 2. **创建任务**:将 `.agents/templates/task.zh-CN.md` 复制到 `.agents/workspace/active/`。
95
+ 1. **阅读快速入门指南**:参见 `QUICKSTART.md` 获取分步说明。
96
+ 2. **创建任务**:将 `.agents/templates/task.md` 复制到 `.agents/workspace/active/`。
99
97
  3. **分配给 AI**:更新任务元数据中的 `assigned_to` 字段。
100
98
  4. **执行工作流**:按照 `.agents/workflows/` 中相应的工作流执行。
101
99
  5. **交接**:切换 AI 时,从模板创建交接文档。
@@ -118,18 +116,33 @@
118
116
 
119
117
  1. 顶级步骤使用连续整数:`1.`、`2.`、`3.`。
120
118
  2. 只有父步骤下的从属动作才使用子步骤:`1.1`、`1.2`、`2.1`。
121
- 3. 同一步中的分支、条件或多种可能性使用 `a`、`b`、`c` 标记。
119
+ 3. 同一步中的从属选项、条件分支或并列可能性使用 `a`、`b`、`c` 标记;仅用于步骤内部的子项展开,不用于命名独立的决策路径或输出模板。
122
120
  4. 不要使用 `1.5`、`2.5` 这类中间编号;如新增独立步骤,应整体顺延后续编号。
123
121
  5. 调整编号时,必须同步更新文中的步骤引用,确保说明、命令和检查点一致。
124
122
  6. 长 bash 脚本应从 SKILL.md 提取到同级 `scripts/` 目录中,SKILL.md 只保留单行调用(如 `bash .agents/skills/<skill>/scripts/<script>.sh`)和对脚本职责的概要说明。
123
+ 7. 在 SKILL.md 及其 `reference/` 模板中,如需为独立的条件分流、决策路径或输出模板命名,统一使用“场景”命名(例如使用“场景 A”)。
125
124
 
126
125
  ### SKILL.md 体积控制
127
126
 
128
- - SKILL.md 正文控制在约 500 tokens(约 80 行 / 2KB)以内。
129
- - 超过阈值的内容拆分到同级 `reference/` 目录。
127
+ - SKILL.md 正文尽可能精简,把详细规则、长模板和大段脚本拆分到同级 `reference/` `scripts/` 目录。
128
+ - 声明式配置统一放在同级 `config/` 目录,例如 `config/verify.json`。
130
129
  - 骨架中使用明确导航,例如:`执行此步骤前,先读取 reference/xxx.md。`
131
130
  - 长脚本继续放在 `scripts/` 目录,优先执行脚本而不是内联大段 bash。
132
131
 
132
+ ## 完成校验
133
+
134
+ 对会产生结构化产物或任务状态变更的 skill,统一在结束前运行完成校验:
135
+
136
+ ```bash
137
+ node .agents/scripts/validate-artifact.js gate <skill-name> <task-dir> [artifact-file] [--format json|text]
138
+ ```
139
+
140
+ - 每个 skill 在自己的 `config/verify.json` 中声明需要检查的事项
141
+ - 如果 skill 还会展示“下一步”提示,必须先通过完成校验,再输出这些指引
142
+ - 面向用户展示最终校验结果时,优先使用 `--format text` 输出可读摘要,而不是原始 JSON
143
+ - 共享逻辑集中在 `.agents/scripts/validate-artifact.js`,不要把详细校验规则重新塞回 SKILL.md
144
+ - 在回复中保留当次校验输出作为当次验证输出;没有当次校验输出,不得声明完成
145
+
133
146
  ## 常见问题
134
147
 
135
148
  ### Q:我需要单独配置每个 AI 工具吗?
@@ -0,0 +1,185 @@
1
+ # Issue Sync Rules
2
+
3
+ Read this file before a task skill updates a GitHub Issue.
4
+
5
+ ## Direct `status:` Label Updates
6
+
7
+ If task.md contains a valid `issue_number` (not empty and not `N/A`) and the Issue state is `OPEN`, replace every existing `status:` label and add the target one:
8
+
9
+ ```bash
10
+ state=$(gh issue view {issue-number} --json state --jq '.state' 2>/dev/null)
11
+ if [ "$state" = "OPEN" ]; then
12
+ gh issue view {issue-number} --json labels \
13
+ --jq '.labels[].name | select(startswith("status:"))' 2>/dev/null \
14
+ | while IFS= read -r label; do
15
+ [ -z "$label" ] && continue
16
+ gh issue edit {issue-number} --remove-label "$label" 2>/dev/null || true
17
+ done
18
+ gh issue edit {issue-number} --add-label "{target-status-label}" 2>/dev/null || true
19
+ fi
20
+ ```
21
+
22
+ Use `while IFS= read -r label` so labels like `status: in-progress` are handled line-by-line instead of being split on spaces.
23
+
24
+ If `gh` fails, skip and continue. Do not fail the skill.
25
+
26
+ ## `in:` Label Sync
27
+
28
+ Read the `labels.in` mapping from `.agents/.airc.json`.
29
+
30
+ ```bash
31
+ git diff {base-branch}...HEAD --name-only
32
+ ```
33
+
34
+ `{base-branch}` is usually `main`; in PR context, use the PR's base branch.
35
+
36
+ ### When a mapping exists (precise add/remove)
37
+
38
+ 1. Collect the full set of changed files in the branch
39
+ 2. Match each file against the directory prefixes in `labels.in` to compute the expected `in:` label set
40
+ 3. Query the current `in:` labels on the Issue or PR
41
+ 4. Apply the diff:
42
+ - expected but missing -> `gh issue edit {issue-number} --add-label "in: {module}" 2>/dev/null || true`
43
+ - present but no longer expected -> `gh issue edit {issue-number} --remove-label "in: {module}" 2>/dev/null || true`
44
+
45
+ ### When no mapping exists (add-only fallback)
46
+
47
+ If `.airc.json` has no `labels.in` field or it is empty:
48
+ 1. query existing repository `in:` labels
49
+ 2. derive the top-level directory from each changed file
50
+ 3. add matching labels only and never remove existing `in:` labels
51
+
52
+ ## Artifact Comment Publishing
53
+
54
+ The hidden marker must remain compatible:
55
+
56
+ ```html
57
+ <!-- sync-issue:{task-id}:{file-stem} -->
58
+ ```
59
+
60
+ Check for an existing comment before publishing:
61
+
62
+ ```bash
63
+ gh api "repos/{owner}/{repo}/issues/{issue-number}/comments" \
64
+ --paginate --jq '.[].body' \
65
+ | grep -qF "<!-- sync-issue:{task-id}:{file-stem} -->"
66
+ ```
67
+
68
+ Skip publishing when the marker already exists.
69
+
70
+ Publishing flow:
71
+
72
+ 1. Read the local artifact file in full first
73
+ 2. Inline the full file contents as `{artifact body}`
74
+ 3. Do not summarize, rewrite, or truncate the artifact body
75
+
76
+ Use this format:
77
+
78
+ ```markdown
79
+ <!-- sync-issue:{task-id}:{file-stem} -->
80
+ ## {artifact-title}
81
+
82
+ {artifact body}
83
+
84
+ ---
85
+ *Generated by AI · Internal tracking: {task-id}*
86
+ ```
87
+
88
+ `summary` comments need extra handling:
89
+ - find an existing `<!-- sync-issue:{task-id}:summary -->` comment ID first
90
+ - create the comment when none exists
91
+ - patch the existing comment in place when the body changed
92
+
93
+ ```bash
94
+ summary_comment_id=$(gh api "repos/{owner}/{repo}/issues/{issue-number}/comments" \
95
+ --paginate --jq '.[] | select(.body | startswith("<!-- sync-issue:{task-id}:summary -->")) | .id' \
96
+ | head -n 1)
97
+ gh api "repos/{owner}/{repo}/issues/comments/{comment-id}" -X PATCH -f body="$(cat <<'EOF'
98
+ {comment-body}
99
+ EOF
100
+ )"
101
+ ```
102
+
103
+ ## task.md Comment Sync
104
+
105
+ Hidden marker:
106
+
107
+ ```html
108
+ <!-- sync-issue:{task-id}:task -->
109
+ ```
110
+
111
+ Use an idempotent update path for `task.md`:
112
+
113
+ 1. Read the full `task.md`
114
+ 2. Wrap the YAML frontmatter (content between the `---` delimiters) inside a `<details><summary>Metadata (frontmatter)</summary>` block with a `yaml` code fence; render the remaining body as normal Markdown
115
+ 3. Use `task` as `{file-stem}`
116
+ 4. Find an existing comment ID for the marker
117
+ 5. Create the comment when none exists
118
+ 6. PATCH the comment in place when the body changed
119
+ 7. Skip when the body is unchanged
120
+
121
+ task.md comment format:
122
+
123
+ ```markdown
124
+ <!-- sync-issue:{task-id}:task -->
125
+ ## Task File
126
+
127
+ <details><summary>Metadata (frontmatter)</summary>
128
+
129
+ ​```yaml
130
+ ---
131
+ {frontmatter fields}
132
+ ---
133
+ ​```
134
+
135
+ </details>
136
+
137
+ {task.md body after frontmatter}
138
+
139
+ ---
140
+ *Generated by AI · Internal tracking: {task-id}*
141
+ ```
142
+
143
+ When restoring, extract the frontmatter from the `<details>` block and reassemble with the body to recover the original `task.md`.
144
+
145
+ Title mapping:
146
+ - `task` -> `Task File`
147
+
148
+ ## Backfill Rules (run before `/complete-task` archives)
149
+
150
+ - Scan `task.md`, `analysis*.md`, `plan*.md`, `implementation*.md`, `review*.md`, and `refinement*.md` in the task directory
151
+ - Check whether each `{file-stem}` was already published by its hidden marker; publish only missing artifacts
152
+ - Backfill only appends missing comments; never delete or reorder existing comments
153
+ - Derive the previous and next neighbors from Activity Log order and add this note below the title:
154
+
155
+ ```markdown
156
+ > ⚠️ This comment was backfilled. In the timeline it belongs after "{previous-artifact-title}" and before "{next-artifact-title}".
157
+ ```
158
+
159
+ - If only one neighbor exists, keep only that side of the note; if neither exists, omit the note
160
+
161
+ Title mapping:
162
+ - `task` -> `Task File`
163
+ - `analysis` / `analysis-r{N}` -> `Requirements Analysis` / `Requirements Analysis (Round {N})`
164
+ - `plan` / `plan-r{N}` -> `Technical Plan` / `Technical Plan (Round {N})`
165
+ - `implementation` / `implementation-r{N}` -> `Implementation Report (Round 1)` / `Implementation Report (Round {N})`
166
+ - `review` / `review-r{N}` -> `Review Report (Round 1)` / `Review Report (Round {N})`
167
+ - `refinement` / `refinement-r{N}` -> `Refinement Report (Round 1)` / `Refinement Report (Round {N})`
168
+ - `summary` -> `Delivery Summary`
169
+
170
+ ## Requirement Checkbox Sync
171
+
172
+ Extract checked `- [x]` items from the `## Requirements` section in task.md. Skip when none exist.
173
+
174
+ Read the current Issue body:
175
+
176
+ ```bash
177
+ gh issue view {issue-number} --json body --jq '.body'
178
+ ```
179
+
180
+ Replace matching `- [ ] {text}` lines with `- [x] {text}` only when the body actually changes, then PATCH the full body with `gh api`.
181
+
182
+ ## Shell Safety Rules
183
+
184
+ 1. Read the artifact first, then inline the real text into the heredoc body. Do not use command substitution or variable expansion inside `<<'EOF'`.
185
+ 2. Do not use `echo` to build content containing `<!-- -->`. Use `cat <<'EOF'` or `printf '%s\n'` instead.
@@ -0,0 +1,185 @@
1
+ # Issue 同步规则
2
+
3
+ 在任务技能需要更新 GitHub Issue 时先读取本文件。
4
+
5
+ ## status: label 直设
6
+
7
+ 如果 task.md 中存在有效的 `issue_number`(非空、非 `N/A`),且 Issue 状态为 `OPEN`,则替换所有 `status:` label 并设置目标值:
8
+
9
+ ```bash
10
+ state=$(gh issue view {issue-number} --json state --jq '.state' 2>/dev/null)
11
+ if [ "$state" = "OPEN" ]; then
12
+ gh issue view {issue-number} --json labels \
13
+ --jq '.labels[].name | select(startswith("status:"))' 2>/dev/null \
14
+ | while IFS= read -r label; do
15
+ [ -z "$label" ] && continue
16
+ gh issue edit {issue-number} --remove-label "$label" 2>/dev/null || true
17
+ done
18
+ gh issue edit {issue-number} --add-label "{target-status-label}" 2>/dev/null || true
19
+ fi
20
+ ```
21
+
22
+ 使用 `while IFS= read -r label` 按行处理,可避免 `status: in-progress` 这类含空格 label 被 shell 按空格拆开。
23
+
24
+ 如果 `gh` 命令失败,跳过并继续,不中断技能执行。
25
+
26
+ ## `in:` label 同步
27
+
28
+ 读取 `.agents/.airc.json` 的 `labels.in` 映射。
29
+
30
+ ```bash
31
+ git diff {base-branch}...HEAD --name-only
32
+ ```
33
+
34
+ `{base-branch}` 通常为 `main`;如果在 PR 上下文中,则使用 PR 的 base branch。
35
+
36
+ ### 有映射时(精确增删)
37
+
38
+ 1. 获取分支全部改动文件
39
+ 2. 对每个文件按目录前缀匹配 `labels.in` 中的值,得到"应有的 `in:` labels"集合
40
+ 3. 查询 Issue/PR 当前的 `in:` labels
41
+ 4. 差集比较:
42
+ - 应有但没有 → `gh issue edit {issue-number} --add-label "in: {module}" 2>/dev/null || true`
43
+ - 有但不应有 → `gh issue edit {issue-number} --remove-label "in: {module}" 2>/dev/null || true`
44
+
45
+ ### 无映射时(只增不删回退)
46
+
47
+ 如果 `.airc.json` 中不存在 `labels.in` 或为空对象:
48
+ 1. 查询仓库已有 `in:` labels
49
+ 2. 从改动文件提取第一级目录
50
+ 3. 仅添加匹配的 label,不移除已有 `in:` label
51
+
52
+ ## 产物评论发布
53
+
54
+ 隐藏标记必须保持兼容:
55
+
56
+ ```html
57
+ <!-- sync-issue:{task-id}:{file-stem} -->
58
+ ```
59
+
60
+ 发布前先检查是否已存在同标记评论:
61
+
62
+ ```bash
63
+ gh api "repos/{owner}/{repo}/issues/{issue-number}/comments" \
64
+ --paginate --jq '.[].body' \
65
+ | grep -qF "<!-- sync-issue:{task-id}:{file-stem} -->"
66
+ ```
67
+
68
+ 如果已存在则跳过。
69
+
70
+ 发布流程:
71
+
72
+ 1. 先读取本地产物文件全文
73
+ 2. 将文件全文作为 `{artifact body}` 原文内联到评论中
74
+ 3. 禁止自行组织摘要、改写或截断正文
75
+
76
+ 评论格式统一为:
77
+
78
+ ```markdown
79
+ <!-- sync-issue:{task-id}:{file-stem} -->
80
+ ## {artifact-title}
81
+
82
+ {artifact body}
83
+
84
+ ---
85
+ *由 AI 自动生成 · 内部追踪:{task-id}*
86
+ ```
87
+
88
+ `summary` 评论需要额外处理:
89
+ - 先查找已有 `<!-- sync-issue:{task-id}:summary -->` 评论的 ID
90
+ - 不存在则创建
91
+ - 已存在且正文有变化时,使用 `gh api "repos/{owner}/{repo}/issues/comments/{comment-id}" -X PATCH -f body=...` 原地更新
92
+
93
+ ```bash
94
+ summary_comment_id=$(gh api "repos/{owner}/{repo}/issues/{issue-number}/comments" \
95
+ --paginate --jq '.[] | select(.body | startswith("<!-- sync-issue:{task-id}:summary -->")) | .id' \
96
+ | head -n 1)
97
+ gh api "repos/{owner}/{repo}/issues/comments/{comment-id}" -X PATCH -f body="$(cat <<'EOF'
98
+ {comment-body}
99
+ EOF
100
+ )"
101
+ ```
102
+
103
+ ## task.md 评论同步
104
+
105
+ 隐藏标记:
106
+
107
+ ```html
108
+ <!-- sync-issue:{task-id}:task -->
109
+ ```
110
+
111
+ `task.md` 使用幂等更新路径:
112
+
113
+ 1. 读取 `task.md` 全文
114
+ 2. 将 YAML frontmatter(`---` 到 `---` 之间的内容)包裹在 `<details><summary>元数据 (frontmatter)</summary>` 和 `` ```yaml `` 代码块中,其余正文保持原样作为 Markdown 渲染
115
+ 3. 使用 `task` 作为 `{file-stem}`
116
+ 4. 查找已有标记评论 ID
117
+ 5. 不存在则创建
118
+ 6. 已存在且正文有变化则 PATCH 原地更新
119
+ 7. 已存在且正文相同则跳过
120
+
121
+ task.md 评论格式:
122
+
123
+ ```markdown
124
+ <!-- sync-issue:{task-id}:task -->
125
+ ## 任务文件
126
+
127
+ <details><summary>元数据 (frontmatter)</summary>
128
+
129
+ ​```yaml
130
+ ---
131
+ {frontmatter fields}
132
+ ---
133
+ ​```
134
+
135
+ </details>
136
+
137
+ {task.md body after frontmatter}
138
+
139
+ ---
140
+ *由 AI 自动生成 · 内部追踪:{task-id}*
141
+ ```
142
+
143
+ 还原时,从 `<details>` 块中提取 frontmatter,与正文拼合恢复为原始 `task.md`。
144
+
145
+ 评论标题映射:
146
+ - `task` -> `任务文件`
147
+
148
+ ## 补发规则(`/complete-task` 归档前执行)
149
+
150
+ - 扫描任务目录中的 `task.md`、`analysis*.md`、`plan*.md`、`implementation*.md`、`review*.md`、`refinement*.md`
151
+ - 对每个 `{file-stem}` 用隐藏标记检查是否已发布;未发布则补发,已发布则跳过
152
+ - 补发只追加缺失评论,不删除或重排已有评论
153
+ - 位置说明从 Activity Log 推导时间线中的前后邻居,并加在评论标题下方:
154
+
155
+ ```markdown
156
+ > ⚠️ 本评论为补发产物,按时间线应位于「{前一个产物标题}」之后、「{后一个产物标题}」之前。
157
+ ```
158
+
159
+ - 如果只有前邻居或后邻居,仅保留存在的一侧说明;如果两侧都不存在,则不添加位置说明
160
+
161
+ 标题映射:
162
+ - `task` -> `任务文件`
163
+ - `analysis` / `analysis-r{N}` -> `需求分析` / `需求分析(Round {N})`
164
+ - `plan` / `plan-r{N}` -> `技术方案` / `技术方案(Round {N})`
165
+ - `implementation` / `implementation-r{N}` -> `实现报告(Round 1)` / `实现报告(Round {N})`
166
+ - `review` / `review-r{N}` -> `审查报告(Round 1)` / `审查报告(Round {N})`
167
+ - `refinement` / `refinement-r{N}` -> `修复报告(Round 1)` / `修复报告(Round {N})`
168
+ - `summary` -> `交付摘要`
169
+
170
+ ## 需求复选框同步
171
+
172
+ 从 task.md 的 `## 需求` 段落提取已勾选的 `- [x]` 条目;如果没有,跳过。
173
+
174
+ 读取 Issue 当前正文:
175
+
176
+ ```bash
177
+ gh issue view {issue-number} --json body --jq '.body'
178
+ ```
179
+
180
+ 按复选框文本匹配,将对应的 `- [ ] {text}` 单向替换为 `- [x] {text}`。只有正文实际变化时,才使用 `gh api` PATCH 更新完整 body。
181
+
182
+ ## Shell 安全规则
183
+
184
+ 1. 先用 Read 工具读取产物全文,再把实际文本内联到 heredoc 中;禁止在 `<<'EOF'` 内使用命令替换或变量展开。
185
+ 2. 构造含 `<!-- -->` 的内容时禁止使用 `echo`;统一使用 `cat <<'EOF'` heredoc 或 `printf '%s\n'`。