@fitlab-ai/agent-infra 0.4.2 → 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 (122) hide show
  1. package/README.md +24 -34
  2. package/README.zh-CN.md +24 -34
  3. package/lib/defaults.json +4 -0
  4. package/lib/init.js +1 -0
  5. package/lib/update.js +13 -1
  6. package/package.json +3 -3
  7. package/templates/.agents/README.md +16 -2
  8. package/templates/.agents/README.zh-CN.md +16 -2
  9. package/templates/.agents/rules/issue-sync.md +185 -0
  10. package/templates/.agents/rules/issue-sync.zh-CN.md +185 -0
  11. package/templates/.agents/scripts/validate-artifact.js +1280 -0
  12. package/templates/.agents/skills/analyze-task/SKILL.md +24 -1
  13. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +24 -1
  14. package/templates/.agents/skills/analyze-task/config/verify.json +41 -0
  15. package/templates/.agents/skills/archive-tasks/SKILL.md +40 -0
  16. package/templates/.agents/skills/archive-tasks/SKILL.zh-CN.md +40 -0
  17. package/templates/.agents/skills/archive-tasks/scripts/archive-tasks.sh +403 -0
  18. package/templates/.agents/skills/block-task/SKILL.md +25 -37
  19. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +25 -37
  20. package/templates/.agents/skills/block-task/config/verify.json +28 -0
  21. package/templates/.agents/skills/close-codescan/SKILL.md +7 -0
  22. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +7 -0
  23. package/templates/.agents/skills/close-dependabot/SKILL.md +7 -0
  24. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +7 -0
  25. package/templates/.agents/skills/commit/SKILL.md +17 -0
  26. package/templates/.agents/skills/commit/SKILL.zh-CN.md +17 -0
  27. package/templates/.agents/skills/commit/config/verify.json +22 -0
  28. package/templates/.agents/skills/complete-task/SKILL.md +24 -10
  29. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +24 -10
  30. package/templates/.agents/skills/complete-task/config/verify.json +30 -0
  31. package/templates/.agents/skills/create-issue/SKILL.md +41 -5
  32. package/templates/.agents/skills/create-issue/SKILL.zh-CN.md +41 -5
  33. package/templates/.agents/skills/create-issue/config/verify.json +27 -0
  34. package/templates/.agents/skills/create-issue/reference/label-and-type.md +10 -11
  35. package/templates/.agents/skills/create-issue/reference/label-and-type.zh-CN.md +10 -11
  36. package/templates/.agents/skills/create-pr/SKILL.md +43 -9
  37. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +43 -9
  38. package/templates/.agents/skills/create-pr/config/verify.json +26 -0
  39. package/templates/.agents/skills/create-pr/reference/branch-strategy.md +3 -3
  40. package/templates/.agents/skills/create-pr/reference/branch-strategy.zh-CN.md +3 -3
  41. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.md +6 -6
  42. package/templates/.agents/skills/{sync-pr → create-pr}/reference/comment-publish.zh-CN.md +6 -6
  43. package/templates/.agents/skills/create-pr/reference/pr-body-template.md +15 -6
  44. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +15 -6
  45. package/templates/.agents/skills/create-task/SKILL.md +25 -3
  46. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +25 -3
  47. package/templates/.agents/skills/create-task/config/verify.json +24 -0
  48. package/templates/.agents/skills/implement-task/SKILL.md +43 -8
  49. package/templates/.agents/skills/implement-task/SKILL.zh-CN.md +43 -8
  50. package/templates/.agents/skills/implement-task/config/verify.json +41 -0
  51. package/templates/.agents/skills/implement-task/reference/branch-management.md +48 -0
  52. package/templates/.agents/skills/implement-task/reference/branch-management.zh-CN.md +49 -0
  53. package/templates/.agents/skills/implement-task/reference/output-template.md +20 -0
  54. package/templates/.agents/skills/implement-task/reference/output-template.zh-CN.md +20 -0
  55. package/templates/.agents/skills/import-codescan/SKILL.md +18 -7
  56. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +18 -7
  57. package/templates/.agents/skills/import-codescan/config/verify.json +24 -0
  58. package/templates/.agents/skills/import-dependabot/SKILL.md +18 -7
  59. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +18 -7
  60. package/templates/.agents/skills/import-dependabot/config/verify.json +24 -0
  61. package/templates/.agents/skills/import-issue/SKILL.md +18 -1
  62. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +18 -1
  63. package/templates/.agents/skills/import-issue/config/verify.json +27 -0
  64. package/templates/.agents/skills/init-labels/SKILL.md +40 -10
  65. package/templates/.agents/skills/init-labels/SKILL.zh-CN.md +40 -10
  66. package/templates/.agents/skills/init-labels/scripts/init-labels.sh +1 -22
  67. package/templates/.agents/skills/init-milestones/SKILL.md +13 -0
  68. package/templates/.agents/skills/init-milestones/SKILL.zh-CN.md +13 -0
  69. package/templates/.agents/skills/plan-task/SKILL.md +29 -75
  70. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +29 -75
  71. package/templates/.agents/skills/plan-task/config/verify.json +42 -0
  72. package/templates/.agents/skills/refine-task/SKILL.md +47 -2
  73. package/templates/.agents/skills/refine-task/SKILL.zh-CN.md +47 -2
  74. package/templates/.agents/skills/refine-task/config/verify.json +37 -0
  75. package/templates/.agents/skills/refine-title/SKILL.md +10 -2
  76. package/templates/.agents/skills/refine-title/SKILL.zh-CN.md +10 -2
  77. package/templates/.agents/skills/restore-task/SKILL.md +159 -0
  78. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +159 -0
  79. package/templates/.agents/skills/restore-task/config/verify.json +24 -0
  80. package/templates/.agents/skills/review-task/SKILL.md +25 -1
  81. package/templates/.agents/skills/review-task/SKILL.zh-CN.md +25 -1
  82. package/templates/.agents/skills/review-task/config/verify.json +40 -0
  83. package/templates/.agents/skills/update-agent-infra/SKILL.md +11 -0
  84. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +11 -0
  85. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +5 -1
  86. package/templates/.claude/commands/archive-tasks.md +9 -0
  87. package/templates/.claude/commands/archive-tasks.zh-CN.md +9 -0
  88. package/templates/.claude/commands/restore-task.md +9 -0
  89. package/templates/.claude/commands/restore-task.zh-CN.md +9 -0
  90. package/templates/.gemini/commands/_project_/archive-tasks.toml +10 -0
  91. package/templates/.gemini/commands/_project_/archive-tasks.zh-CN.toml +10 -0
  92. package/templates/.gemini/commands/_project_/restore-task.toml +8 -0
  93. package/templates/.gemini/commands/_project_/restore-task.zh-CN.toml +8 -0
  94. package/templates/.github/workflows/status-label.yml +82 -0
  95. package/templates/.opencode/commands/archive-tasks.md +11 -0
  96. package/templates/.opencode/commands/archive-tasks.zh-CN.md +11 -0
  97. package/templates/.opencode/commands/restore-task.md +11 -0
  98. package/templates/.opencode/commands/restore-task.zh-CN.md +11 -0
  99. package/templates/.agents/skills/sync-issue/SKILL.md +0 -93
  100. package/templates/.agents/skills/sync-issue/SKILL.zh-CN.md +0 -93
  101. package/templates/.agents/skills/sync-issue/reference/comment-publish.md +0 -84
  102. package/templates/.agents/skills/sync-issue/reference/comment-publish.zh-CN.md +0 -84
  103. package/templates/.agents/skills/sync-issue/reference/label-sync.md +0 -62
  104. package/templates/.agents/skills/sync-issue/reference/label-sync.zh-CN.md +0 -62
  105. package/templates/.agents/skills/sync-issue/reference/milestone-sync.md +0 -37
  106. package/templates/.agents/skills/sync-issue/reference/milestone-sync.zh-CN.md +0 -37
  107. package/templates/.agents/skills/sync-pr/SKILL.md +0 -87
  108. package/templates/.agents/skills/sync-pr/SKILL.zh-CN.md +0 -87
  109. package/templates/.agents/skills/sync-pr/reference/delivery-detection.md +0 -54
  110. package/templates/.agents/skills/sync-pr/reference/delivery-detection.zh-CN.md +0 -54
  111. package/templates/.claude/commands/sync-issue.md +0 -8
  112. package/templates/.claude/commands/sync-issue.zh-CN.md +0 -8
  113. package/templates/.claude/commands/sync-pr.md +0 -8
  114. package/templates/.claude/commands/sync-pr.zh-CN.md +0 -8
  115. package/templates/.gemini/commands/_project_/sync-issue.toml +0 -8
  116. package/templates/.gemini/commands/_project_/sync-issue.zh-CN.toml +0 -8
  117. package/templates/.gemini/commands/_project_/sync-pr.toml +0 -8
  118. package/templates/.gemini/commands/_project_/sync-pr.zh-CN.toml +0 -8
  119. package/templates/.opencode/commands/sync-issue.md +0 -11
  120. package/templates/.opencode/commands/sync-issue.zh-CN.md +0 -11
  121. package/templates/.opencode/commands/sync-pr.md +0 -11
  122. package/templates/.opencode/commands/sync-pr.zh-CN.md +0 -11
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <strong>Semi-automated programming, powered by AI agents.</strong> Define a requirement, let AI handle analysis, planning, coding, review, and delivery — you only step in when it matters.
12
+ <strong>From issue to merged PR in 9 commands.</strong> Define a requirement, let AI handle analysis, planning, coding, review, and delivery — you only step in when it matters.
13
13
  </p>
14
14
 
15
15
  <p align="center">
@@ -182,40 +182,30 @@ agent-infra is intentionally simple: a bootstrap CLI creates the seed configurat
182
182
  1. **Install** — `npm install -g @fitlab-ai/agent-infra` (or use the shell script wrapper)
183
183
  2. **Initialize** — `ai init` in the project root to generate `.agents/.airc.json` and install the seed command
184
184
  3. **Render** — run `update-agent-infra` in any AI TUI to detect the bundled template version and generate all managed files
185
- 4. **Develop** — use 28 built-in skills to drive the full lifecycle: `analysis → design → implementation → review → fix → commit`
185
+ 4. **Develop** — use built-in skills to drive the full lifecycle: `analysis → design → implementation → review → fix → commit`
186
186
  5. **Update** — run `update-agent-infra` again whenever a new template version is available
187
187
 
188
188
  ### Layered Architecture
189
189
 
190
- ```mermaid
191
- block-beta
192
- columns 4
193
-
194
- block:tui:4
195
- columns 4
196
- claude["Claude Code"] codex["Codex"] gemini["Gemini CLI"] opencode["OpenCode"]
197
- end
198
-
199
- space:4
200
-
201
- block:shared:4
202
- columns 3
203
- skills["28 Skills"] workflows["4 Workflows"] templates["Templates"]
204
- end
205
-
206
- space:4
207
-
208
- block:project:4
209
- columns 4
210
- agents[".agents/"] config[".agents/.airc.json"] workspace[".agents/workspace/"] governance["AGENTS.md"]
211
- end
212
-
213
- tui -- "slash commands" --> shared
214
- shared -- "renders into" --> project
190
+ ```text
191
+ ┌───────────────────────────────────────────────────────┐
192
+ │ AI TUI Layer │
193
+ │ Claude Code · Codex · Gemini CLI · OpenCode │
194
+ └──────────────────────────┬────────────────────────────┘
195
+ slash commands
196
+
197
+ ┌───────────────────────────────────────────────────────┐
198
+ │ Shared Layer │
199
+ │ Skills · Workflows · Templates │
200
+ └──────────────────────────┬────────────────────────────┘
201
+ │ renders into
202
+
203
+ ┌───────────────────────────────────────────────────────┐
204
+ │ Project Layer │
205
+ │ .agents/ · AGENTS.md │
206
+ └───────────────────────────────────────────────────────┘
215
207
  ```
216
208
 
217
- GitHub renders Mermaid diagrams natively. If a downstream renderer does not, the text above still explains the system structure.
218
-
219
209
  <a id="what-you-get"></a>
220
210
 
221
211
  ## What You Get
@@ -227,7 +217,7 @@ my-project/
227
217
  ├── .agents/ # Shared AI collaboration config
228
218
  │ ├── .airc.json # Central configuration
229
219
  │ ├── workspace/ # Task workspace (git-ignored)
230
- │ ├── skills/ # 28 built-in AI skills
220
+ │ ├── skills/ # Built-in AI skills
231
221
  │ ├── workflows/ # 4 prebuilt workflows
232
222
  │ └── templates/ # Task and artifact templates
233
223
  ├── .claude/ # Claude Code config and commands
@@ -240,7 +230,7 @@ my-project/
240
230
 
241
231
  ## Built-in AI Skills
242
232
 
243
- agent-infra ships with **28 built-in AI skills**. They are organized by use case, but they all share the same design goal: every AI TUI should be able to execute the same workflow vocabulary in the same repository.
233
+ agent-infra ships with **a rich set of built-in AI skills**. They are organized by use case, but they all share the same design goal: every AI TUI should be able to execute the same workflow vocabulary in the same repository.
244
234
 
245
235
  <a id="task-lifecycle"></a>
246
236
 
@@ -265,6 +255,7 @@ agent-infra ships with **28 built-in AI skills**. They are organized by use case
265
255
  |-------|-------------|------------|----------------------|
266
256
  | `check-task` | Inspect the current task status, workflow progress, and next step. | `task-id` | Check progress without modifying task state. |
267
257
  | `block-task` | Move a task to blocked state and record the blocker reason. | `task-id`, `reason` (optional) | Pause work when an external dependency or decision is missing. |
258
+ | `restore-task` | Restore local task files from GitHub Issue sync comments. | `issue-number`, `task-id` (optional) | Recover a task workspace after switching machines or clearing local state. |
268
259
 
269
260
  <a id="issue-and-pr"></a>
270
261
 
@@ -273,9 +264,7 @@ agent-infra ships with **28 built-in AI skills**. They are organized by use case
273
264
  | Skill | Description | Parameters | Recommended use case |
274
265
  |-------|-------------|------------|----------------------|
275
266
  | `create-issue` | Create a GitHub Issue from a task file. | `task-id` | Push a local task into GitHub tracking. |
276
- | `sync-issue` | Post task progress updates back to the linked GitHub Issue. | `task-id` or `issue-number` | Keep stakeholders updated as the task evolves. |
277
267
  | `create-pr` | Open a Pull Request to an inferred or explicit target branch. | `task-id` (optional), `target-branch` (optional) | Publish reviewed changes for merge, with optional explicit task linkage after a fresh session. |
278
- | `sync-pr` | Sync task progress and review metadata into the Pull Request. | `task-id` or `pr-number` | Keep PR metadata aligned with the local task record from either task or PR entrypoints. |
279
268
 
280
269
  <a id="code-quality"></a>
281
270
 
@@ -317,6 +306,7 @@ agent-infra ships with **28 built-in AI skills**. They are organized by use case
317
306
  | `refine-title` | Rewrite an Issue or PR title into Conventional Commits format. | `number` | Normalize inconsistent GitHub titles. |
318
307
  | `init-labels` | Initialize the repository's standard GitHub label set. | None | Bootstrap labels in a new repository. |
319
308
  | `init-milestones` | Initialize the repository's milestone structure. | None | Bootstrap milestone tracking in a new repository. |
309
+ | `archive-tasks` | Archive completed tasks into a date-organized directory with a manifest index. | `[--days N \| --before DATE \| TASK-ID...]` | Periodically clean up the `completed/` directory. |
320
310
  | `update-agent-infra` | Update the project's collaboration infrastructure to the latest template version. | None | Refresh shared AI tooling without rebuilding local conventions. |
321
311
 
322
312
  > Every skill works across supported AI TUIs. The command prefix changes, but the workflow semantics stay the same.
@@ -390,7 +380,7 @@ The generated `.agents/.airc.json` file is the central contract between the boot
390
380
  "project": "my-project",
391
381
  "org": "my-org",
392
382
  "language": "en",
393
- "templateVersion": "v0.4.2",
383
+ "templateVersion": "v0.4.3",
394
384
  "files": {
395
385
  "managed": [
396
386
  ".agents/workspace/README.md",
package/README.zh-CN.md CHANGED
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <strong>AI Agent 半自动化编程神器。</strong> 定义需求,让 AI 完成分析、方案设计、编码、审查和交付 —— 你只需在关键节点介入。
12
+ <strong>从 Issue 到合并 PR,只需 9 条命令。</strong> 定义需求,让 AI 完成分析、方案设计、编码、审查和交付 —— 你只需在关键节点介入。
13
13
  </p>
14
14
 
15
15
  <p align="center">
@@ -182,40 +182,30 @@ agent-infra 的结构刻意保持简单:引导 CLI 负责生成种子配置,
182
182
  1. **安装** — `npm install -g @fitlab-ai/agent-infra`(或使用 shell 脚本便捷封装)
183
183
  2. **初始化** — 在项目根目录运行 `ai init`,生成 `.agents/.airc.json` 并安装种子命令
184
184
  3. **渲染** — 在任意 AI TUI 中执行 `update-agent-infra`,检测当前打包模板版本并生成所有受管理文件
185
- 4. **开发** — 使用 28 个内置 skill 驱动完整生命周期:`analysis → design → implementation → review → fix → commit`
185
+ 4. **开发** — 使用内置 skill 驱动完整生命周期:`analysis → design → implementation → review → fix → commit`
186
186
  5. **升级** — 有新模板版本时再次执行 `update-agent-infra` 即可
187
187
 
188
188
  ### 分层架构
189
189
 
190
- ```mermaid
191
- block-beta
192
- columns 4
193
-
194
- block:tui:4
195
- columns 4
196
- claude["Claude Code"] codex["Codex"] gemini["Gemini CLI"] opencode["OpenCode"]
197
- end
198
-
199
- space:4
200
-
201
- block:shared:4
202
- columns 3
203
- skills["28 Skills"] workflows["4 Workflows"] templates["Templates"]
204
- end
205
-
206
- space:4
207
-
208
- block:project:4
209
- columns 4
210
- agents[".agents/"] config[".agents/.airc.json"] workspace[".agents/workspace/"] governance["AGENTS.md"]
211
- end
212
-
213
- tui -- "slash commands" --> shared
214
- shared -- "renders into" --> project
190
+ ```text
191
+ ┌───────────────────────────────────────────────────────┐
192
+ │ AI TUI Layer │
193
+ │ Claude Code · Codex · Gemini CLI · OpenCode │
194
+ └──────────────────────────┬────────────────────────────┘
195
+ slash 命令
196
+
197
+ ┌───────────────────────────────────────────────────────┐
198
+ │ Shared Layer │
199
+ │ Skills · Workflows · Templates │
200
+ └──────────────────────────┬────────────────────────────┘
201
+ │ 渲染为
202
+
203
+ ┌───────────────────────────────────────────────────────┐
204
+ │ Project Layer │
205
+ │ .agents/ · AGENTS.md │
206
+ └───────────────────────────────────────────────────────┘
215
207
  ```
216
208
 
217
- GitHub 原生支持 Mermaid 渲染。即使某些下游渲染器不支持,上方文字也足以传达系统结构。
218
-
219
209
  <a id="what-you-get"></a>
220
210
 
221
211
  ## 安装效果
@@ -227,7 +217,7 @@ my-project/
227
217
  ├── .agents/ # 共享 AI 协作配置
228
218
  │ ├── .airc.json # 中央配置文件
229
219
  │ ├── workspace/ # 任务工作区(git 忽略)
230
- │ ├── skills/ # 28 个内置 AI skills
220
+ │ ├── skills/ # 内置 AI skills
231
221
  │ ├── workflows/ # 4 个预置工作流
232
222
  │ └── templates/ # 任务与产物模板
233
223
  ├── .claude/ # Claude Code 配置与命令
@@ -240,7 +230,7 @@ my-project/
240
230
 
241
231
  ## 内置 AI Skills
242
232
 
243
- agent-infra 内置 **28 AI skills**。它们按使用场景分组,但共享同一个核心目标:无论使用哪种 AI TUI,都能在同一仓库里执行相同的工作流词汇和协作约定。
233
+ agent-infra 提供 **丰富的内置 AI skills**。它们按使用场景分组,但共享同一个核心目标:无论使用哪种 AI TUI,都能在同一仓库里执行相同的工作流词汇和协作约定。
244
234
 
245
235
  <a id="task-lifecycle"></a>
246
236
 
@@ -265,6 +255,7 @@ agent-infra 内置 **28 个 AI skills**。它们按使用场景分组,但共
265
255
  |-------|------|------|---------|
266
256
  | `check-task` | 查看当前任务状态、工作流进度和下一步建议。 | `task-id` | 不修改任务状态,仅检查当前进展。 |
267
257
  | `block-task` | 将任务标记为阻塞并记录阻塞原因。 | `task-id`、`reason`(可选) | 缺少外部依赖、决策或资源时暂停任务。 |
258
+ | `restore-task` | 从 GitHub Issue 同步评论中还原本地任务文件。 | `issue-number`、`task-id`(可选) | 换机器或清空本地状态后恢复任务工作区。 |
268
259
 
269
260
  <a id="issue-and-pr"></a>
270
261
 
@@ -273,9 +264,7 @@ agent-infra 内置 **28 个 AI skills**。它们按使用场景分组,但共
273
264
  | Skill | 描述 | 参数 | 推荐场景 |
274
265
  |-------|------|------|---------|
275
266
  | `create-issue` | 根据任务文件创建 GitHub Issue。 | `task-id` | 需要把本地任务同步到 GitHub 跟踪时。 |
276
- | `sync-issue` | 将任务进度同步回关联的 GitHub Issue。 | `task-id` 或 `issue-number` | 任务推进过程中持续同步状态。 |
277
267
  | `create-pr` | 向推断出的目标分支或显式指定分支创建 Pull Request。 | `task-id`(可选)、`target-branch`(可选) | 变更准备合入时创建 PR;清空上下文后也可显式传入任务关联。 |
278
- | `sync-pr` | 将任务进度和审查元数据同步到 Pull Request。 | `task-id` 或 `pr-number` | 允许从任务入口或 PR 入口同步,让 PR 元数据与本地任务记录保持一致。 |
279
268
 
280
269
  <a id="code-quality"></a>
281
270
 
@@ -317,6 +306,7 @@ agent-infra 内置 **28 个 AI skills**。它们按使用场景分组,但共
317
306
  | `refine-title` | 将 Issue 或 PR 标题重构为 Conventional Commits 格式。 | `number` | GitHub 标题格式不规范时。 |
318
307
  | `init-labels` | 初始化仓库标准 GitHub labels 体系。 | 无 | 新仓库首次配置 labels 时。 |
319
308
  | `init-milestones` | 初始化仓库 milestones 结构。 | 无 | 新仓库首次建立里程碑时。 |
309
+ | `archive-tasks` | 将已完成任务按日期归档到目录中,并生成 `manifest` 索引。 | `[--days N \| --before DATE \| TASK-ID...]` | 需要定期清理 `completed/` 目录时。 |
320
310
  | `update-agent-infra` | 将项目协作基础设施升级到最新模板版本。 | 无 | 需要刷新共享 AI 工具层时。 |
321
311
 
322
312
  > 所有 skills 都可跨支持的 AI TUI 复用。变化的只是命令前缀,工作流语义保持一致。
@@ -390,7 +380,7 @@ import-issue #42 从 GitHub Issue 导入任务
390
380
  "project": "my-project",
391
381
  "org": "my-org",
392
382
  "language": "en",
393
- "templateVersion": "v0.4.2",
383
+ "templateVersion": "v0.4.3",
394
384
  "files": {
395
385
  "managed": [
396
386
  ".agents/workspace/README.md",
package/lib/defaults.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
+ "labels": {
3
+ "in": {}
4
+ },
2
5
  "files": {
3
6
  "managed": [
4
7
  ".agents/QUICKSTART.md",
5
8
  ".agents/README.md",
6
9
  ".agents/skills/",
10
+ ".agents/scripts/",
7
11
  ".agents/templates/",
8
12
  ".agents/workflows/",
9
13
  ".agents/workspace/README.md",
package/lib/init.js CHANGED
@@ -162,6 +162,7 @@ async function cmdInit() {
162
162
  org: orgName,
163
163
  language,
164
164
  templateVersion: VERSION,
165
+ labels: structuredClone(defaults.labels),
165
166
  files: structuredClone(defaults.files)
166
167
  };
167
168
 
package/lib/update.js CHANGED
@@ -139,8 +139,15 @@ async function cmdUpdate() {
139
139
  // sync file registry
140
140
  const { added, changed } = syncFileRegistry(config);
141
141
  const hasNewEntries = added.managed.length > 0 || added.merged.length > 0;
142
+ const labelsAdded = !config.labels;
143
+ let configChanged = changed;
142
144
 
143
- if (changed) {
145
+ if (labelsAdded) {
146
+ config.labels = structuredClone(defaults.labels);
147
+ configChanged = true;
148
+ }
149
+
150
+ if (configChanged) {
144
151
  console.log('');
145
152
  if (hasNewEntries) {
146
153
  info(`New file entries synced to ${CONFIG_PATH}:`);
@@ -150,9 +157,14 @@ async function cmdUpdate() {
150
157
  for (const entry of added.merged) {
151
158
  ok(` merged: ${entry}`);
152
159
  }
160
+ } else if (labelsAdded) {
161
+ info(`Default labels.in config added to ${CONFIG_PATH}.`);
153
162
  } else {
154
163
  info(`File registry changed in ${CONFIG_PATH}.`);
155
164
  }
165
+ if (hasNewEntries && labelsAdded) {
166
+ info(`Default labels.in config added to ${CONFIG_PATH}.`);
167
+ }
156
168
  fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2) + '\n', 'utf8');
157
169
  ok(`Updated ${CONFIG_PATH}`);
158
170
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fitlab-ai/agent-infra",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Bootstrap tool for AI multi-tool collaboration infrastructure — works with Claude Code, Codex, Gemini CLI, and OpenCode",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,7 +43,7 @@
43
43
  "scripts": {
44
44
  "build": "node scripts/build-inline.js",
45
45
  "prepare": "git config core.hooksPath .github/hooks || true",
46
- "test": "node scripts/build-inline.js --check && node --test tests/*.test.js",
47
- "prepublishOnly": "node scripts/build-inline.js --check && node --test tests/*.test.js"
46
+ "test": "node scripts/build-inline.js --check && node --test tests/cli/*.test.js tests/templates/*.test.js tests/core/*.test.js",
47
+ "prepublishOnly": "node scripts/build-inline.js --check && node --test tests/cli/*.test.js tests/templates/*.test.js tests/core/*.test.js"
48
48
  }
49
49
  }
@@ -124,11 +124,25 @@ When writing or updating `.agents/skills/*/SKILL.md` files and their templates,
124
124
 
125
125
  ### SKILL.md Size Control
126
126
 
127
- - Keep the SKILL.md body within about 500 tokens (roughly 80 lines / 2KB).
128
- - 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`.
129
129
  - Use explicit navigation in the skeleton, such as: `Read reference/xxx.md before executing this step.`
130
130
  - Keep scripts in `scripts/` and execute them instead of inlining long bash blocks.
131
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
+
132
146
  ## FAQ
133
147
 
134
148
  ### Q: Do I need to configure every AI tool separately?
@@ -124,11 +124,25 @@
124
124
 
125
125
  ### SKILL.md 体积控制
126
126
 
127
- - SKILL.md 正文控制在约 500 tokens(约 80 行 / 2KB)以内。
128
- - 超过阈值的内容拆分到同级 `reference/` 目录。
127
+ - SKILL.md 正文尽可能精简,把详细规则、长模板和大段脚本拆分到同级 `reference/` `scripts/` 目录。
128
+ - 声明式配置统一放在同级 `config/` 目录,例如 `config/verify.json`。
129
129
  - 骨架中使用明确导航,例如:`执行此步骤前,先读取 reference/xxx.md。`
130
130
  - 长脚本继续放在 `scripts/` 目录,优先执行脚本而不是内联大段 bash。
131
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
+
132
146
  ## 常见问题
133
147
 
134
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.