@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
@@ -28,7 +28,8 @@ Fallback label 映射:
28
28
  | `enhancement` | `type: enhancement` |
29
29
  | `docs`, `documentation` | `type: documentation` |
30
30
  | `dependency-upgrade` | `type: dependency-upgrade` |
31
- | `task`, `chore`, `refactor`, `refactoring` | `type: task` |
31
+ | `task`, `chore` | `type: task` |
32
+ | `refactor`, `refactoring` | `type: enhancement` |
32
33
  | 其他值 | 跳过 |
33
34
 
34
35
  Issue Type fallback 映射:
@@ -56,22 +57,20 @@ gh api "orgs/$owner/issue-types" --jq '.[].name'
56
57
  gh api "repos/$repo/issues/{issue-number}" -X PATCH -f type="{issue-type}" --silent
57
58
  ```
58
59
 
59
- `in:` label
60
+ `in:` label(粗选):
60
61
 
61
62
  ```bash
62
63
  gh label list --search "in:" --limit 50 --json name --jq '.[].name'
63
64
  gh issue edit {issue-number} --add-label "in: {module}"
64
65
  ```
65
66
 
66
- 只添加相关的 `in:` label。不要移除已有的 `in:` label,并且当 `in:` label 不可用或不相关时,不要让创建 Issue 流程失败。
67
+ 从查询结果中,根据 task.md 的标题和描述进行语义匹配:
68
+ - 任务描述**明确提及**某个模块(如"修复 CLI 参数解析"→ `in: cli`)→ 添加
69
+ - 任务描述**强烈暗示**某个模块 → 添加
70
+ - 无法确定或模糊 → **不添加**
67
71
 
68
- label、Issue Type milestone 不可用时,应跳过并继续,不要让 Issue 创建失败。
72
+ 原则:宁缺毋滥。粗选阶段不求精确,后续 implement-task / create-pr 阶段会基于实际改动文件精修。
69
73
 
70
- 最终给用户的输出必须包含所有 TUI `sync-issue` 命令格式:
74
+ 只添加相关的 `in:` label。当 `in:` label 不可用或不相关时,不要让创建 Issue 流程失败。
71
75
 
72
- ```text
73
- 下一步 - 同步进度到 Issue:
74
- - Claude Code / OpenCode: /sync-issue {task-id}
75
- - Gemini CLI: /agent-infra:sync-issue {task-id}
76
- - Codex CLI: $sync-issue {task-id}
77
- ```
76
+ 当 label、Issue Type 或 milestone 不可用时,应跳过并继续,不要让 Issue 创建失败。
@@ -5,42 +5,66 @@ description: "Create a Pull Request to a target branch"
5
5
 
6
6
  # Create Pull Request
7
7
 
8
- Create a Pull Request and, when task-related, sync the essential metadata immediately.
8
+ Create a Pull Request and, when task-related, sync the essential metadata and reviewer summary immediately.
9
9
 
10
10
  ## Execution Flow
11
11
 
12
- ### 1. Determine the Target Branch
12
+ ### 1. Parse Command Arguments
13
+
14
+ Identify arguments from the command input:
15
+ - arguments matching `TASK-{yyyyMMdd-HHmmss}` -> `{task-id}`
16
+ - remaining arguments -> `{target-branch}`
17
+
18
+ If `{task-id}` is provided, read `.agents/workspace/active/{task-id}/task.md` to load task metadata such as `issue_number` and `type`.
19
+ If `{task-id}` is omitted, try to resolve it from the current session context; if it still cannot be determined, skip task-association logic in later steps.
20
+
21
+ ### 2. Determine the Target Branch
13
22
 
14
23
  Use the explicit argument when provided. Otherwise infer the target branch from Git history and branch topology.
15
24
 
16
25
  > Detailed branch detection rules live in `reference/branch-strategy.md`. Read `reference/branch-strategy.md` before auto-detecting the base branch.
17
26
 
18
- ### 2. Prepare the PR Body
27
+ ### 3. Prepare the PR Body
19
28
 
20
29
  Read `.github/PULL_REQUEST_TEMPLATE.md` when it exists, review recent merged PRs for style, and gather all commits between `<target-branch>` and `HEAD`.
21
30
 
22
31
  > Template handling, HEREDOC body generation, and `Generated with AI assistance` requirements live in `reference/pr-body-template.md`. Read `reference/pr-body-template.md` before writing the PR body.
23
32
 
24
- ### 3. Check Remote Branch State
33
+ ### 4. Check Remote Branch State
25
34
 
26
35
  Confirm whether the current branch already has an upstream. Push with `git push -u origin <current-branch>` when required.
27
36
 
28
- ### 4. Create the PR
37
+ ### 5. Create the PR
38
+
39
+ Check whether the current branch already has a PR first; if one exists, show the PR URL and stop without repeating metadata sync or summary publication.
29
40
 
30
41
  Create the PR with `gh pr create --base <target-branch> --title "<title>" --assignee @me --body ...`.
31
42
 
32
- If a related task provides `issue_number`, keep `Closes #{issue-number}` in the PR body.
43
+ If `{task-id}` is available and the related task provides `issue_number`, keep `Closes #{issue-number}` in the PR body.
33
44
 
34
- ### 5. Sync PR Metadata
45
+ ### 6. Sync PR Metadata
35
46
 
36
- For task-related PRs, sync the core metadata immediately:
47
+ For PRs where `{task-id}` is available, sync the core metadata immediately:
37
48
  - run `gh label list --search "type:" --limit 1 --json name --jq 'length'`
38
49
  - add the mapped type label with `gh pr edit {pr-number} --add-label "{type-label}"`
39
50
  - add relevant `in: {module}` labels with `gh pr edit {pr-number} --add-label "in: {module}"`
51
+ - sync the linked Issue `in:` labels to match by following the `in:` label sync rule in `.agents/rules/issue-sync.md`
40
52
  - set the milestone with `gh pr edit {pr-number} --milestone "{milestone-title}"`
41
53
  - keep Development linking in the PR body with `Closes #{issue-number}` when applicable
42
54
 
43
- ### 6. Update Task Status
55
+ ### 7. Publish the Review Summary
56
+
57
+ Read the latest context artifacts when they exist: `plan.md` / `plan-r{N}.md`, `implementation.md` / `implementation-r{N}.md`, `review.md` / `review-r{N}.md`, and `refinement.md` / `refinement-r{N}.md`.
58
+
59
+ Aggregate a reviewer-facing summary from those artifacts and maintain a single idempotent summary comment via the hidden marker.
60
+
61
+ > Hidden marker handling, idempotent summary updates, review-history structure, and comment creation/update rules live in `reference/comment-publish.md`. Read `reference/comment-publish.md` before publishing the summary.
62
+ >
63
+ > **Shell safety rules** (required before publishing the comment):
64
+ > 1. Replace `{comment-body}` with the actual inline text. Read files first, then paste the full content into the heredoc body. Do **not** use `$(cat ...)`, `$(< ...)`, `$(...)`, or `${...}` inside `<<'EOF'`.
65
+ > 2. Do **not** use `echo` when constructing strings that contain `<!-- -->`. Use `cat <<'EOF'` heredoc or `printf '%s\n'` instead.
66
+
67
+ ### 8. Update Task Status
44
68
 
45
69
  Get the current time:
46
70
 
@@ -48,23 +72,42 @@ Get the current time:
48
72
  date "+%Y-%m-%d %H:%M:%S"
49
73
  ```
50
74
 
51
- If this PR is task-related, update task.md with `pr_number`, `updated_at`, and append the PR Created Activity Log entry.
75
+ If `{task-id}` is available, update task.md with `pr_number`, `updated_at`, and append the PR Created Activity Log entry including metadata-sync and summary results.
76
+
77
+ ### 9. Verification Gate
78
+
79
+ If this operation is associated with `{task-id}`, run the verification gate to confirm task metadata and sync state. If there is no task context, skip this step.
80
+
81
+ ```bash
82
+ node .agents/scripts/validate-artifact.js gate create-pr .agents/workspace/active/{task-id} --format text
83
+ ```
84
+
85
+ Handle the result as follows:
86
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
87
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
88
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
89
+
90
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
91
+
92
+ ### 10. Inform User
93
+
94
+ > Execute this step only after the verification gate passes.
52
95
 
53
- ### 7. Inform the User
96
+ > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
54
97
 
55
- Explain the created PR URL, summarize metadata sync results, and present both follow-up commands in order:
56
- - optional `sync-pr {task-id}` to publish reviewer-facing context
57
- - `complete-task {task-id}` once the workflow is truly done
98
+ Explain the created PR URL, summarize metadata sync and summary-comment results, and recommend `complete-task {task-id}` once the workflow is truly done.
58
99
 
59
100
  ## Notes
60
101
 
61
102
  - Review every commit in the branch, not only the latest one
62
- - `create-pr` must not defer type-label mapping to `sync-pr`; inline the mapping here
103
+ - `create-pr` must not defer type-label mapping to another skill; inline the mapping here when `{task-id}` is available
104
+ - Keep the hidden summary marker as `<!-- sync-pr:{task-id}:summary -->` for compatibility with existing PR comments
105
+ - If the current branch already has a PR, show its URL and stop without repeating sync work
63
106
  - When metadata inheritance from the Issue fails, continue with task.md and branch-based fallbacks
64
107
 
65
108
  ## Error Handling
66
109
 
67
110
  - No commits found between `{target}` and `HEAD`
68
111
  - Push rejected: suggest `git pull --rebase`
69
- - Existing PR found: show the current PR URL
112
+ - Existing PR found: show the current PR URL and stop
70
113
  - Inaccessible Issue metadata: skip inheritance and continue
@@ -5,42 +5,66 @@ description: "创建 Pull Request 到目标分支"
5
5
 
6
6
  # 创建 Pull Request
7
7
 
8
- 创建 Pull Request,并在与任务关联时立即补齐核心元数据。
8
+ 创建 Pull Request,并在与任务关联时立即补齐核心元数据和 reviewer 摘要。
9
9
 
10
10
  ## 执行流程
11
11
 
12
- ### 1. 确定目标分支
12
+ ### 1. 解析命令参数
13
+
14
+ 从命令参数中识别:
15
+ - 匹配 `TASK-{yyyyMMdd-HHmmss}` 格式的参数 -> `{task-id}`
16
+ - 其余参数 -> `{target-branch}`
17
+
18
+ 如果提供了 `{task-id}`,读取 `.agents/workspace/active/{task-id}/task.md` 获取任务信息(例如 `issue_number`、`type` 等)。
19
+ 如果未提供,可从当前 session 上下文获取;仍无法确定 `{task-id}` 时,后续步骤中的任务关联逻辑跳过。
20
+
21
+ ### 2. 确定目标分支
13
22
 
14
23
  如果用户显式提供参数就直接使用;否则根据 Git 历史和分支拓扑自动推断。
15
24
 
16
25
  > 详细分支判断规则见 `reference/branch-strategy.md`。自动推断 base 分支前,先读取 `reference/branch-strategy.md`。
17
26
 
18
- ### 2. 准备 PR 正文
27
+ ### 3. 准备 PR 正文
19
28
 
20
29
  读取 `.github/PULL_REQUEST_TEMPLATE.md`(如存在),参考最近合并的 PR 风格,并收集 `<target-branch>` 到 `HEAD` 的全部提交。
21
30
 
22
31
  > 模板处理、HEREDOC 正文生成和 `Generated with AI assistance` 要求见 `reference/pr-body-template.md`。编写正文前先读取 `reference/pr-body-template.md`。
23
32
 
24
- ### 3. 检查远程分支状态
33
+ ### 4. 检查远程分支状态
25
34
 
26
35
  确认当前分支是否已有 upstream;必要时执行 `git push -u origin <current-branch>`。
27
36
 
28
- ### 4. 创建 PR
37
+ ### 5. 创建 PR
38
+
39
+ 先检查当前分支是否已经存在 PR;如果已存在,直接告知用户 PR URL 并结束,不要重复执行元数据同步或摘要发布。
29
40
 
30
41
  使用 `gh pr create --base <target-branch> --title "<title>" --assignee @me --body ...` 创建 PR。
31
42
 
32
- 如果关联任务提供了 `issue_number`,必须在 PR 正文中保留 `Closes #{issue-number}`。
43
+ 如果获取到 `{task-id}` 且对应任务提供了 `issue_number`,必须在 PR 正文中保留 `Closes #{issue-number}`。
33
44
 
34
- ### 5. 同步 PR 元数据
45
+ ### 6. 同步 PR 元数据
35
46
 
36
- 对任务关联 PR,立即同步这些核心元数据:
47
+ 对获取到 `{task-id}` 的 PR,立即同步这些核心元数据:
37
48
  - 执行 `gh label list --search "type:" --limit 1 --json name --jq 'length'`
38
49
  - 使用 `gh pr edit {pr-number} --add-label "{type-label}"` 添加 type label
39
50
  - 使用 `gh pr edit {pr-number} --add-label "in: {module}"` 添加相关 `in:` labels
51
+ - 按 `.agents/rules/issue-sync.md` 的 `in:` label 同步规则,同步更新关联 Issue 的 `in:` label 保持一致
40
52
  - 使用 `gh pr edit {pr-number} --milestone "{milestone-title}"` 设置里程碑
41
53
  - 通过 `Closes #{issue-number}` 保持 Development 关联
42
54
 
43
- ### 6. 更新任务状态
55
+ ### 7. 发布审查摘要
56
+
57
+ 读取最新的上下文产物:`plan.md` / `plan-r{N}.md`、`implementation.md` / `implementation-r{N}.md`、`review.md` / `review-r{N}.md`、`refinement.md` / `refinement-r{N}.md`(存在时)。
58
+
59
+ 基于这些产物聚合 reviewer 摘要,并使用隐藏标记维护唯一且幂等的摘要评论。
60
+
61
+ > 隐藏标记、幂等 summary 评论更新、review history 格式,以及评论创建/更新规则见 `reference/comment-publish.md`。发布摘要前先读取 `reference/comment-publish.md`。
62
+ >
63
+ > **Shell 安全规则**(发布评论前必读):
64
+ > 1. `{comment-body}` 必须替换为**实际的内联文本**。先读取文件,再将全文粘贴到 heredoc body 中。**禁止**在 `<<'EOF'` 内部使用 `$(cat ...)`、`$(< ...)`、`$(...)`、`${...}`。
65
+ > 2. 构造含 `<!-- -->` 的字符串时,**禁止使用 `echo`**。统一使用 `cat <<'EOF'` heredoc 或 `printf '%s\n'` 构造。
66
+
67
+ ### 8. 更新任务状态
44
68
 
45
69
  获取当前时间:
46
70
 
@@ -48,23 +72,42 @@ description: "创建 Pull Request 到目标分支"
48
72
  date "+%Y-%m-%d %H:%M:%S"
49
73
  ```
50
74
 
51
- 如果当前 PR 关联任务,更新 task.md 的 `pr_number`、`updated_at`,并追加 PR Created 的 Activity Log
75
+ 如果获取到了 `{task-id}`,更新 task.md 的 `pr_number`、`updated_at`,并追加 PR Created 的 Activity Log,记录元数据同步和摘要发布结果。
76
+
77
+ ### 9. 完成校验
78
+
79
+ 如果本次操作关联了 `{task-id}`,运行完成校验,确认任务元数据和同步状态符合规范;如果没有任务上下文,跳过本步骤。
80
+
81
+ ```bash
82
+ node .agents/scripts/validate-artifact.js gate create-pr .agents/workspace/active/{task-id} --format text
83
+ ```
84
+
85
+ 处理结果:
86
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
87
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
88
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
89
+
90
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
91
+
92
+ ### 10. 告知用户
93
+
94
+ > 仅在校验通过后执行本步骤。
52
95
 
53
- ### 7. 告知用户
96
+ > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
54
97
 
55
- 说明 PR URL、元数据同步结果,并按顺序给出两个后续动作:
56
- - 可选执行 `sync-pr {task-id}`,发布面向 reviewer 的上下文摘要
57
- - 当整个工作流真正完成后执行 `complete-task {task-id}`
98
+ 说明 PR URL、元数据同步结果、摘要评论结果,并在工作流真正完成后推荐执行 `complete-task {task-id}`。
58
99
 
59
100
  ## 注意事项
60
101
 
61
102
  - 必须检查分支中的全部提交,而不是只看最后一个
62
- - `create-pr` 不能把 type label 映射委托给 `sync-pr`,必须在本技能内内联处理
103
+ - `create-pr` 不能把 type label 映射委托给其他技能,必须在获取到 `{task-id}` 时于本技能内内联处理
104
+ - 隐藏 summary 标记必须保持 `<!-- sync-pr:{task-id}:summary -->` 以兼容已有 PR 评论
105
+ - 如果当前分支已存在 PR,直接告知用户 PR URL 并结束,不做重复同步
63
106
  - 如果从 Issue 继承元数据失败,继续使用 task.md 和分支推断兜底
64
107
 
65
108
  ## 错误处理
66
109
 
67
110
  - `{target}` 与 `HEAD` 之间没有可提交内容
68
111
  - 推送被拒绝:建议执行 `git pull --rebase`
69
- - 已存在 PR:直接输出当前 PR URL
112
+ - 已存在 PR:直接输出当前 PR URL 并结束
70
113
  - 无法访问 Issue 元数据:跳过继承并继续
@@ -0,0 +1,26 @@
1
+ {
2
+ "skill": "create-pr",
3
+ "checks": {
4
+ "task-meta": {
5
+ "required_fields": [
6
+ "id",
7
+ "type",
8
+ "workflow",
9
+ "status",
10
+ "created_at",
11
+ "updated_at",
12
+ "current_step",
13
+ "assigned_to"
14
+ ]
15
+ },
16
+ "activity-log": {
17
+ "expected_action_pattern": "PR Created",
18
+ "freshness_minutes": 30
19
+ },
20
+ "github-sync": {
21
+ "when": "issue_number_exists",
22
+ "expected_pr_comment_marker": "<!-- sync-pr:{task-id}:summary -->",
23
+ "verify_in_labels_match_pr": true
24
+ }
25
+ }
26
+ }
@@ -24,6 +24,6 @@ Feature-branch parent inference details:
24
24
  - if no reliable parent can be inferred, stop and ask the user instead of guessing
25
25
 
26
26
  Next-step rule after PR creation:
27
- - if `issue_number` exists and reviewer-facing context still needs publishing, recommend `sync-pr {task-id}` first
28
- - if all workflow work is complete after PR creation, recommend `complete-task {task-id}` second
29
- - never present `complete-task` as the only next step when PR context still needs syncing
27
+ - `create-pr` already publishes the reviewer summary inline, so do not recommend an extra PR sync command
28
+ - if all workflow work is complete after PR creation, recommend `complete-task {task-id}`
29
+ - if the workflow is not complete yet, report the current result without inventing extra commands
@@ -24,6 +24,6 @@ Feature branch 父分支推断细则:
24
24
  - 如果无法可靠推断父分支,不要猜测,直接停止并询问用户
25
25
 
26
26
  创建 PR 后的下一步规则:
27
- - 如果存在 `issue_number`,且面向 reviewer 的上下文还未发布,优先推荐 `sync-pr {task-id}`
28
- - 如果 PR 创建后工作流已经真正结束,再把 `complete-task {task-id}` 作为第二步推荐
29
- - 当 PR 上下文仍需同步时,绝对不要把 `complete-task` 作为唯一下一步
27
+ - `create-pr` 已内联发布 reviewer 摘要,不再推荐额外的 PR 同步命令
28
+ - 如果 PR 创建后工作流已经真正结束,推荐 `complete-task {task-id}`
29
+ - 如果工作流尚未结束,只说明当前结果,不要虚构额外命令
@@ -1,6 +1,6 @@
1
1
  # PR Summary Comment Publication
2
2
 
3
- Read this file before creating or updating the single reviewer-facing PR summary comment.
3
+ Read this file before creating or updating the single reviewer-facing PR summary comment from `create-pr`.
4
4
 
5
5
  ## Create or Update the Single Idempotent Review Summary
6
6
 
@@ -54,7 +54,8 @@ Suggested summary body:
54
54
  <!-- sync-pr:{task-id}:summary -->
55
55
  ## Review Summary
56
56
 
57
- **Task**: {task-id}
57
+ > **{agent}** · {task-id}
58
+
58
59
  **Updated At**: {current-time}
59
60
 
60
61
  ### Key Technical Decisions
@@ -73,10 +74,9 @@ Suggested summary body:
73
74
  - {test-summary}
74
75
 
75
76
  ---
76
- *Generated by AI · Internal tracking: {task-id}*
77
+ *Generated by {agent} · Internal tracking: {task-id}*
77
78
  ```
78
79
 
79
- ## Update Task Status
80
+ ## Return the Result
80
81
 
81
- Append:
82
- `- {yyyy-MM-dd HH:mm:ss} — **Sync to PR** by {agent} — PR metadata synced, summary {created|updated|skipped} on PR #{pr-number}`
82
+ Return the summary outcome as `summary created`, `summary updated`, or `summary skipped` so `create-pr` can reuse it in user output and the PR Created Activity Log.
@@ -1,6 +1,6 @@
1
1
  # PR 摘要评论发布
2
2
 
3
- 在创建或更新面向 reviewer 的唯一 PR 摘要评论之前先读取本文件。
3
+ `create-pr` 中创建或更新面向 reviewer 的唯一 PR 摘要评论之前先读取本文件。
4
4
 
5
5
  ## 创建或更新唯一且幂等的审查摘要
6
6
 
@@ -13,10 +13,10 @@
13
13
  已有评论必须通过 Issues comments API 获取,而不是单独的 PR comments API。
14
14
 
15
15
  推荐摘要章节:
16
- - `## Review Summary`
17
- - `### Key Technical Decisions`
18
- - `### Review History`
19
- - `### Test Results`
16
+ - `## 审查摘要`
17
+ - `### 关键技术决策`
18
+ - `### 审查历程`
19
+ - `### 测试结果`
20
20
 
21
21
  摘要内容规则:
22
22
  - 面向 reviewer 编写,而不是面向终端用户
@@ -54,7 +54,8 @@ EOF
54
54
  <!-- sync-pr:{task-id}:summary -->
55
55
  ## 审查摘要
56
56
 
57
- **任务**:{task-id}
57
+ > **{agent}** · {task-id}
58
+
58
59
  **更新时间**:{当前时间}
59
60
 
60
61
  ### 关键技术决策
@@ -73,10 +74,9 @@ EOF
73
74
  - {test-summary}
74
75
 
75
76
  ---
76
- *由 AI 自动生成 · 内部追踪:{task-id}*
77
+ *由 {agent} 自动生成 · 内部追踪:{task-id}*
77
78
  ```
78
79
 
79
- ## 更新任务状态
80
+ ## 结果回传
80
81
 
81
- 追加:
82
- `- {yyyy-MM-dd HH:mm:ss} — **Sync to PR** by {agent} — PR metadata synced, summary {created|updated|skipped} on PR #{pr-number}`
82
+ 将摘要结果整理为 `summary created`、`summary updated` 或 `summary skipped`,供 `create-pr` 在用户输出和 PR Created Activity Log 中复用。
@@ -50,14 +50,27 @@ Metadata sync order:
50
50
  1. query Issue labels and milestone best-effort with `gh issue view {issue-number} --json labels,milestone`
51
51
  2. add the mapped type label with `gh pr edit {pr-number} --add-label "{type-label}"`
52
52
  3. inherit non-`type:` and non-`status:` Issue labels with repeated `gh pr edit ... --add-label`
53
- 4. add relevant `in: {module}` labels without removing existing ones
53
+ 4. refine the PR `in:` labels by following `.agents/rules/issue-sync.md`, and keep the linked Issue `in:` labels in sync with the same result
54
54
  5. resolve milestone in order: PR -> task.md -> Issue -> branch/tag inference -> `General Backlog`
55
55
  6. ensure the PR body contains `Closes #{issue-number}` or an equivalent closing keyword
56
56
 
57
+ Milestone inference algorithm:
58
+ 1. keep the PR's current milestone when one is already set
59
+ 2. otherwise use the explicit `milestone` from task.md
60
+ 3. otherwise inherit the Issue milestone
61
+ 4. otherwise infer from branches and tags:
62
+ - if the current branch matches `{major}.{minor}.x`, use that release line directly
63
+ - if the current branch is `main` or `master`, inspect existing `{major}.{minor}.x` branches and target `(X+1).0.x`
64
+ - if no release line exists, inspect the latest `vX.Y.Z` tag and fall back to `X.Y.x`
65
+ - if none of the above yields a result, fall back to `General Backlog`
66
+ 5. if the inferred milestone is unavailable, fall back to `General Backlog`
67
+ 6. if `General Backlog` is also unavailable, report `Milestone: skipped (not found)`
68
+
57
69
  ## Create the PR
58
70
 
59
71
  - Extract `issue_number` from task.md when this work belongs to an active task
60
72
  - If `issue_number` exists, query the Issue best-effort with `gh issue view {issue-number} --json number,title --jq '.number'`
73
+ - Before calling `gh pr create`, check whether the current branch already has a PR. If it does, report the PR URL and state, then stop without repeating metadata sync or summary publication
61
74
  - Use HEREDOC to pass the PR body
62
75
  - Replace `{$IssueNumber}` in the template when present
63
76
  - End the PR body with `Generated with AI assistance`
@@ -71,14 +84,10 @@ EOF
71
84
  )"
72
85
  ```
73
86
 
74
- Final user output should include both follow-up paths in order:
87
+ Final user output should include this follow-up path:
75
88
 
76
89
  ```text
77
90
  Next steps:
78
- - optional reviewer summary sync:
79
- - Claude Code / OpenCode: /sync-pr {task-id}
80
- - Gemini CLI: /agent-infra:sync-pr {task-id}
81
- - Codex CLI: $sync-pr {task-id}
82
91
  - complete the task after the workflow truly finishes:
83
92
  - Claude Code / OpenCode: /complete-task {task-id}
84
93
  - Gemini CLI: /agent-infra:complete-task {task-id}
@@ -50,14 +50,27 @@ Type label 映射:
50
50
  1. 用 `gh issue view {issue-number} --json labels,milestone` 尽力查询 Issue 的 labels 和 milestone
51
51
  2. 用 `gh pr edit {pr-number} --add-label "{type-label}"` 添加映射后的 type label
52
52
  3. 用重复的 `gh pr edit ... --add-label` 继承非 `type:`、非 `status:` 的 Issue labels
53
- 4. 添加相关的 `in: {module}` label,但不要移除已有 label
53
+ 4. `.agents/rules/issue-sync.md` 的 `in:` label 同步规则精修 PR 的 `in:` label,同时同步更新关联 Issue 的 `in:` label 保持一致
54
54
  5. 按 `PR -> task.md -> Issue -> branch/tag inference -> General Backlog` 的顺序解析 milestone
55
55
  6. 确保 PR 正文包含 `Closes #{issue-number}` 或等价的 closing keyword
56
56
 
57
+ Milestone 推断算法:
58
+ 1. 如果 PR 当前已经设置了 milestone,优先保留
59
+ 2. 否则使用 task.md 中显式设置的 `milestone`
60
+ 3. 否则继承 Issue milestone
61
+ 4. 否则按以下分支 / tag 规则推断:
62
+ - 当前分支匹配 `{major}.{minor}.x`,直接使用该 release line
63
+ - 当前分支是 `main` 或 `master`,检查现有 `{major}.{minor}.x` 分支,并目标设为 `(X+1).0.x`
64
+ - 如果不存在 release line 分支,则检查最新的 `vX.Y.Z` tag,并回退到 `X.Y.x`
65
+ - 如果以上都无法得出结果,则回退到 `General Backlog`
66
+ 5. 如果推断出的 milestone 不可用,则回退到 `General Backlog`
67
+ 6. 如果连 `General Backlog` 都不可用,则记录 `Milestone: skipped (not found)`
68
+
57
69
  ## 创建 PR
58
70
 
59
71
  - 当当前工作属于活动任务时,从 task.md 中提取 `issue_number`
60
72
  - 如果存在 `issue_number`,用 `gh issue view {issue-number} --json number,title --jq '.number'` 尽力查询对应 Issue
73
+ - 在调用 `gh pr create` 前,先检查当前分支是否已经存在 PR;如果已存在,直接告知用户 PR URL 和状态并结束,不要重复同步元数据或摘要
61
74
  - 使用 HEREDOC 传递 PR 正文
62
75
  - 如果模板中存在 `{$IssueNumber}`,替换它
63
76
  - PR 正文结尾必须带上 `Generated with AI assistance`
@@ -71,14 +84,10 @@ EOF
71
84
  )"
72
85
  ```
73
86
 
74
- 最终用户输出必须按顺序包含这两类后续动作:
87
+ 最终用户输出必须按顺序包含以下后续动作:
75
88
 
76
89
  ```text
77
90
  下一步:
78
- - 可选:同步 reviewer 摘要:
79
- - Claude Code / OpenCode: /sync-pr {task-id}
80
- - Gemini CLI: /agent-infra:sync-pr {task-id}
81
- - Codex CLI: $sync-pr {task-id}
82
91
  - 工作流真正结束后完成任务:
83
92
  - Claude Code / OpenCode: /complete-task {task-id}
84
93
  - Gemini CLI: /agent-infra:complete-task {task-id}
@@ -24,7 +24,7 @@ After executing this skill, you **must** immediately update task status in task.
24
24
  ### 1. Parse the User Description
25
25
 
26
26
  Extract from the natural-language description:
27
- - **Task title**: a concise title (maximum 50 characters)
27
+ - **Task title**: a concise title (maximum 50 characters), in the same language as the user's description - do not translate it to English or apply Conventional Commits formatting
28
28
  - **Task type**: `feature` | `bugfix` | `refactor` | `docs` | `chore` (infer from the description)
29
29
  - **Workflow**: `feature-development` | `bug-fix` | `refactoring` (infer from the type)
30
30
  - **Detailed description**: the cleaned-up original user request
@@ -92,7 +92,24 @@ Update `.agents/workspace/active/{task-id}/task.md`:
92
92
  - {yyyy-MM-dd HH:mm:ss} — **Task Created** by {agent} — Task created from description
93
93
  ```
94
94
 
95
- ### 4. Inform User
95
+ ### 4. Verification Gate
96
+
97
+ Run the verification gate to confirm the task artifact and sync state are valid:
98
+
99
+ ```bash
100
+ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/active/{task-id} --format text
101
+ ```
102
+
103
+ Handle the result as follows:
104
+ - exit code 0 (all checks passed) -> continue to the "Inform User" step
105
+ - exit code 1 (validation failed) -> fix the reported issues and run the gate again
106
+ - exit code 2 (network blocked) -> stop and tell the user that human intervention is required
107
+
108
+ Keep the gate output in your reply as fresh evidence. Do not claim completion without output from this run.
109
+
110
+ ### 5. Inform User
111
+
112
+ > Execute this step only after the verification gate passes.
96
113
 
97
114
  > **IMPORTANT**: All TUI command formats listed below must be output in full. Do not show only the format for the current AI agent.
98
115
 
@@ -113,6 +130,11 @@ Next step - run requirements analysis:
113
130
  - Claude Code / OpenCode: /analyze-task {task-id}
114
131
  - Gemini CLI: /{{project}}:analyze-task {task-id}
115
132
  - Codex CLI: $analyze-task {task-id}
133
+
134
+ Or create a GitHub Issue first:
135
+ - Claude Code / OpenCode: /create-issue {task-id}
136
+ - Gemini CLI: /{{project}}:create-issue {task-id}
137
+ - Codex CLI: $create-issue {task-id}
116
138
  ```
117
139
 
118
140
  ## Completion Checklist
@@ -134,7 +156,7 @@ Wait for the user to run the `analyze-task` skill.
134
156
 
135
157
  1. **Clarity**: if the user description is vague or missing key information, ask for clarification first
136
158
  2. **Difference from `import-issue`**: `import-issue` imports from a GitHub Issue; `create-task` creates from a free-form description
137
- 3. **Workflow order**: after creating a task, `analyze-task` must run before `plan-task`
159
+ 3. **Workflow order**: after creating a task, typically run `analyze-task` before `plan-task`; if you need GitHub tracking first, you may run `create-issue` first
138
160
 
139
161
  ## Error Handling
140
162
 
@@ -24,7 +24,7 @@ description: "根据自然语言描述创建任务"
24
24
  ### 1. 解析用户描述
25
25
 
26
26
  从自然语言描述中提取:
27
- - **任务标题**:简洁标题(最多 50 个字符)
27
+ - **任务标题**:简洁标题(最多 50 个字符),使用中文——不要翻译为英文,不要套用 Conventional Commits 格式
28
28
  - **任务类型**:`feature` | `bugfix` | `refactor` | `docs` | `chore`(从描述推断)
29
29
  - **工作流**:`feature-development` | `bug-fix` | `refactoring`(从类型推断)
30
30
  - **详细描述**:整理后的用户原始描述
@@ -92,7 +92,24 @@ date "+%Y-%m-%d %H:%M:%S"
92
92
  - {yyyy-MM-dd HH:mm:ss} — **Task Created** by {agent} — Task created from description
93
93
  ```
94
94
 
95
- ### 4. 告知用户
95
+ ### 4. 完成校验
96
+
97
+ 运行完成校验,确认任务产物和同步状态符合规范:
98
+
99
+ ```bash
100
+ node .agents/scripts/validate-artifact.js gate create-task .agents/workspace/active/{task-id} --format text
101
+ ```
102
+
103
+ 处理结果:
104
+ - 退出码 0(全部通过)-> 继续到「告知用户」步骤
105
+ - 退出码 1(校验失败)-> 根据输出修复问题后重新运行校验
106
+ - 退出码 2(网络中断)-> 停止执行并告知用户需要人工介入
107
+
108
+ 将校验输出保留在回复中作为当次验证输出。没有当次校验输出,不得声明完成。
109
+
110
+ ### 5. 告知用户
111
+
112
+ > 仅在校验通过后执行本步骤。
96
113
 
97
114
  > **重要**:以下「下一步」中列出的所有 TUI 命令格式必须完整输出,不要只展示当前 AI 代理对应的格式。
98
115
 
@@ -113,6 +130,11 @@ date "+%Y-%m-%d %H:%M:%S"
113
130
  - Claude Code / OpenCode:/analyze-task {task-id}
114
131
  - Gemini CLI:/agent-infra:analyze-task {task-id}
115
132
  - Codex CLI:$analyze-task {task-id}
133
+
134
+ 或先创建 GitHub Issue:
135
+ - Claude Code / OpenCode:/create-issue {task-id}
136
+ - Gemini CLI:/agent-infra:create-issue {task-id}
137
+ - Codex CLI:$create-issue {task-id}
116
138
  ```
117
139
 
118
140
  ## 完成检查清单
@@ -134,7 +156,7 @@ date "+%Y-%m-%d %H:%M:%S"
134
156
 
135
157
  1. **清晰度**:如果用户描述模糊或缺少关键信息,先要求澄清
136
158
  2. **与 import-issue 的区别**:`import-issue` 从 GitHub Issue 导入任务;`create-task` 从自由描述创建
137
- 3. **工作流顺序**:创建任务后,必须先执行 `analyze-task`,再进入 `plan-task`
159
+ 3. **工作流顺序**:创建任务后,通常先执行 `analyze-task` 再进入 `plan-task`;如需先建立 GitHub 跟踪,也可先执行 `create-issue`
138
160
 
139
161
  ## 错误处理
140
162
 
@@ -0,0 +1,24 @@
1
+ {
2
+ "skill": "create-task",
3
+ "checks": {
4
+ "task-meta": {
5
+ "required_fields": [
6
+ "id",
7
+ "type",
8
+ "workflow",
9
+ "status",
10
+ "created_at",
11
+ "updated_at",
12
+ "current_step",
13
+ "assigned_to"
14
+ ],
15
+ "expected_step": "requirement-analysis",
16
+ "expected_status": "active"
17
+ },
18
+ "activity-log": {
19
+ "expected_action_pattern": "Task Created",
20
+ "freshness_minutes": 30
21
+ },
22
+ "github-sync": null
23
+ }
24
+ }