@fitlab-ai/agent-infra 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/README.zh-CN.md +9 -3
- package/bin/cli.ts +11 -0
- package/dist/bin/cli.js +12 -0
- package/dist/lib/defaults.json +0 -1
- package/dist/lib/init.js +0 -3
- package/dist/lib/sandbox/commands/create.js +10 -2
- package/dist/lib/sandbox/commands/enter.js +17 -18
- package/dist/lib/sandbox/commands/list-running.js +56 -32
- package/dist/lib/sandbox/commands/ls.js +27 -24
- package/dist/lib/sandbox/commands/start.js +36 -0
- package/dist/lib/sandbox/index.js +15 -3
- package/dist/lib/sandbox/task-resolver.js +1 -1
- package/dist/lib/sandbox/tools.js +1 -1
- package/dist/lib/table.js +38 -0
- package/dist/lib/task/commands/ls.js +122 -0
- package/dist/lib/task/commands/show.js +135 -0
- package/dist/lib/task/frontmatter.js +32 -0
- package/dist/lib/task/index.js +41 -0
- package/dist/lib/task/short-id.js +90 -0
- package/dist/lib/update.js +25 -8
- package/lib/defaults.json +0 -1
- package/lib/init.ts +0 -10
- package/lib/sandbox/commands/create.ts +11 -2
- package/lib/sandbox/commands/enter.ts +40 -20
- package/lib/sandbox/commands/list-running.ts +65 -37
- package/lib/sandbox/commands/ls.ts +35 -27
- package/lib/sandbox/commands/start.ts +61 -0
- package/lib/sandbox/index.ts +15 -3
- package/lib/sandbox/task-resolver.ts +1 -1
- package/lib/sandbox/tools.ts +1 -1
- package/lib/table.ts +44 -0
- package/lib/task/commands/ls.ts +138 -0
- package/lib/task/commands/show.ts +139 -0
- package/lib/task/frontmatter.ts +30 -0
- package/lib/task/index.ts +44 -0
- package/lib/task/short-id.ts +107 -0
- package/lib/update.ts +28 -10
- package/package.json +1 -1
- package/templates/.agents/hooks/auto-resume.sh +104 -0
- package/templates/.agents/rules/create-issue.github.en.md +1 -1
- package/templates/.agents/rules/create-issue.github.zh-CN.md +1 -1
- package/templates/.agents/rules/milestone-inference.github.en.md +4 -1
- package/templates/.agents/rules/milestone-inference.github.zh-CN.md +4 -1
- package/templates/.agents/rules/next-step-output.en.md +62 -0
- package/templates/.agents/rules/next-step-output.zh-CN.md +62 -0
- package/templates/.agents/rules/pr-checks-commands.en.md +5 -0
- package/templates/.agents/rules/pr-checks-commands.github.en.md +62 -0
- package/templates/.agents/rules/pr-checks-commands.github.zh-CN.md +62 -0
- package/templates/.agents/rules/pr-checks-commands.zh-CN.md +5 -0
- package/templates/.agents/rules/pr-sync.github.en.md +7 -0
- package/templates/.agents/rules/pr-sync.github.zh-CN.md +7 -0
- package/templates/.agents/rules/task-short-id.en.md +54 -62
- package/templates/.agents/rules/task-short-id.zh-CN.md +35 -54
- package/templates/.agents/scripts/platform-adapters/platform-sync.github.js +17 -0
- package/templates/.agents/scripts/task-short-id.js +32 -189
- package/templates/.agents/skills/analyze-task/SKILL.en.md +10 -12
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +10 -12
- package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/block-task/SKILL.en.md +13 -6
- package/templates/.agents/skills/block-task/SKILL.zh-CN.md +13 -6
- package/templates/.agents/skills/block-task/config/verify.json +1 -1
- package/templates/.agents/skills/cancel-task/SKILL.en.md +13 -6
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +13 -6
- package/templates/.agents/skills/cancel-task/config/verify.json +1 -1
- package/templates/.agents/skills/check-task/SKILL.en.md +12 -10
- package/templates/.agents/skills/check-task/SKILL.zh-CN.md +12 -10
- package/templates/.agents/skills/close-codescan/SKILL.en.md +13 -6
- package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +13 -6
- package/templates/.agents/skills/close-dependabot/SKILL.en.md +13 -6
- package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +13 -6
- package/templates/.agents/skills/code-task/SKILL.en.md +10 -6
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +11 -6
- package/templates/.agents/skills/code-task/config/verify.en.json +2 -1
- package/templates/.agents/skills/code-task/config/verify.zh-CN.json +2 -1
- package/templates/.agents/skills/code-task/reference/fix-mode.en.md +10 -5
- package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +10 -5
- package/templates/.agents/skills/code-task/reference/output-template.en.md +3 -3
- package/templates/.agents/skills/code-task/reference/output-template.zh-CN.md +3 -3
- package/templates/.agents/skills/code-task/reference/report-template.en.md +8 -0
- package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +8 -0
- package/templates/.agents/skills/commit/SKILL.en.md +3 -4
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +3 -4
- package/templates/.agents/skills/commit/reference/task-status-update.en.md +37 -29
- package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +37 -29
- package/templates/.agents/skills/complete-task/SKILL.en.md +41 -4
- package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +41 -4
- package/templates/.agents/skills/complete-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/create-pr/SKILL.en.md +20 -11
- package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +20 -11
- package/templates/.agents/skills/create-pr/config/verify.json +2 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +2 -1
- package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +2 -1
- package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +3 -3
- package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +3 -3
- package/templates/.agents/skills/create-task/SKILL.en.md +17 -17
- package/templates/.agents/skills/create-task/SKILL.zh-CN.md +17 -17
- package/templates/.agents/skills/create-task/config/verify.json +1 -1
- package/templates/.agents/skills/import-codescan/SKILL.en.md +8 -8
- package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/import-codescan/config/verify.json +1 -1
- package/templates/.agents/skills/import-dependabot/SKILL.en.md +8 -8
- package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +8 -8
- package/templates/.agents/skills/import-dependabot/config/verify.json +1 -1
- package/templates/.agents/skills/import-issue/SKILL.en.md +7 -7
- package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +7 -7
- package/templates/.agents/skills/plan-task/SKILL.en.md +10 -12
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +10 -12
- package/templates/.agents/skills/plan-task/config/verify.en.json +1 -1
- package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -1
- package/templates/.agents/skills/restore-task/SKILL.en.md +1 -1
- package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/review-analysis/SKILL.en.md +4 -2
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +4 -2
- package/templates/.agents/skills/review-analysis/config/verify.en.json +3 -2
- package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +3 -2
- package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +15 -15
- package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +15 -15
- package/templates/.agents/skills/review-analysis/reference/report-template.en.md +7 -1
- package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +7 -1
- package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +2 -0
- package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +2 -0
- package/templates/.agents/skills/review-code/SKILL.en.md +5 -2
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -2
- package/templates/.agents/skills/review-code/config/verify.en.json +3 -2
- package/templates/.agents/skills/review-code/config/verify.zh-CN.json +3 -2
- package/templates/.agents/skills/review-code/reference/output-templates.en.md +9 -9
- package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +9 -9
- package/templates/.agents/skills/review-code/reference/report-template.en.md +7 -1
- package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +7 -1
- package/templates/.agents/skills/review-code/reference/review-criteria.en.md +2 -0
- package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +2 -0
- package/templates/.agents/skills/review-plan/SKILL.en.md +4 -2
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +4 -2
- package/templates/.agents/skills/review-plan/config/verify.en.json +3 -2
- package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +3 -2
- package/templates/.agents/skills/review-plan/reference/output-templates.en.md +15 -15
- package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +15 -15
- package/templates/.agents/skills/review-plan/reference/report-template.en.md +7 -1
- package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +7 -1
- package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +2 -0
- package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +2 -0
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +0 -1
- package/templates/.agents/skills/watch-pr/SKILL.en.md +131 -0
- package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +131 -0
- package/templates/.agents/skills/watch-pr/config/verify.json +22 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +43 -0
- package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +43 -0
- package/templates/.agents/templates/task.en.md +1 -1
- package/templates/.agents/templates/task.zh-CN.md +1 -1
- package/templates/.agents/workflows/bug-fix.en.yaml +7 -5
- package/templates/.agents/workflows/bug-fix.zh-CN.yaml +6 -5
- package/templates/.agents/workflows/feature-development.en.yaml +7 -5
- package/templates/.agents/workflows/feature-development.zh-CN.yaml +6 -5
- package/templates/.agents/workflows/refactoring.en.yaml +7 -5
- package/templates/.agents/workflows/refactoring.zh-CN.yaml +6 -5
- package/templates/.claude/commands/watch-pr.en.md +8 -0
- package/templates/.claude/commands/watch-pr.zh-CN.md +8 -0
- package/templates/.claude/settings.json +11 -0
- package/templates/.gemini/commands/_project_/watch-pr.en.toml +8 -0
- package/templates/.gemini/commands/_project_/watch-pr.zh-CN.toml +8 -0
- package/templates/.opencode/commands/watch-pr.en.md +11 -0
- package/templates/.opencode/commands/watch-pr.zh-CN.md +11 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# PR 检查平台命令(GitHub)
|
|
2
|
+
|
|
3
|
+
在监控 PR 的 required checks、解析失败 run、拉取失败日志或读取当前分支 PR 前先读取本文件。`watch-pr` 技能的平台专属命令集中在此,技能正文与 `reference/` 保持平台无关。
|
|
4
|
+
|
|
5
|
+
## 当前分支 PR / 仓库信息
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gh pr view --json number -q .number # 当前分支对应的 PR 号
|
|
9
|
+
gh pr view {pr#} --json headRefOid -q .headRefOid # PR head SHA
|
|
10
|
+
gh repo view --json nameWithOwner -q .nameWithOwner # {owner}/{repo}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`gh` 未认证或命令失败时,按调用方技能的错误处理停止或降级。
|
|
14
|
+
|
|
15
|
+
## 监控 required checks
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
gh pr checks {pr#} --required --watch --fail-fast -i 30 \
|
|
19
|
+
--json name,bucket,link,workflow
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- `--required`:只纳入仓库分支保护标记为 required 的 checks。
|
|
23
|
+
- `--watch`:阻塞直到这些 checks 全部跑完;`--fail-fast`:出现首个失败即退出 watch。
|
|
24
|
+
- `-i 30`:轮询间隔 30 秒(退避)。**总时长上限默认 30 分钟(1800 秒)**:按执行环境选用对应的超时方式,超时即按「挂起」处理(退出码 8)。
|
|
25
|
+
- POSIX shell:`timeout 1800 gh pr checks {pr#} --required --watch --fail-fast -i 30 …`
|
|
26
|
+
- PowerShell(Windows):用作业超时——
|
|
27
|
+
```powershell
|
|
28
|
+
$job = Start-Job { gh pr checks {pr#} --required --watch --fail-fast -i 30 }
|
|
29
|
+
if (Wait-Job $job -Timeout 1800) { Receive-Job $job } else { Stop-Job $job; <按「挂起」处理> }
|
|
30
|
+
```
|
|
31
|
+
- 平台中立回退(无外部超时工具时):记录开始时间,循环执行**不带** `--watch` 的 `gh pr checks {pr#} --required --json name,bucket,link,workflow`,每轮 sleep `-i` 秒并检查 `bucket` 是否仍有 `pending`;累计时长 ≥ 1800 秒仍未结束 → 退出循环按「挂起」处理。
|
|
32
|
+
- `--json` 的 `bucket` 字段把每个 check 归类为 `pass` / `fail` / `pending` / `skipping` / `cancel`。
|
|
33
|
+
|
|
34
|
+
退出码语义:
|
|
35
|
+
|
|
36
|
+
| 退出码 | 含义 | 结果分类 |
|
|
37
|
+
|--------|------|----------|
|
|
38
|
+
| 0 | 全部 required checks 通过 | 全绿 |
|
|
39
|
+
| 1 | 至少一个失败 / 出错 | 失败 |
|
|
40
|
+
| 8 | 仍有 pending(watch 超时或被 `timeout` 截断) | 挂起 |
|
|
41
|
+
|
|
42
|
+
旧版 `gh`(< 2.93)若不支持 `--required`:回退为 `gh pr checks {pr#} --watch --fail-fast`(即「所有 check 必须 success」),并在求助/报告中注明该降级、建议升级 `gh`。
|
|
43
|
+
|
|
44
|
+
## 解析失败 run id 并拉日志
|
|
45
|
+
|
|
46
|
+
`gh pr checks --json` 不直接返回 run id,但返回失败 check 的 `link`(指向 run/job 的 URL)。按确定性顺序解析:
|
|
47
|
+
|
|
48
|
+
1. 从失败 check 的 `link` 用正则提取:`https://github.com/{owner}/{repo}/actions/runs/(\d+)(?:/job/(\d+))?` → 第 1 组为 run id(可选第 2 组为 job id)。
|
|
49
|
+
2. `link` 非 run URL 或无法解析时,用 head SHA 查 check-runs:
|
|
50
|
+
```bash
|
|
51
|
+
sha=$(gh pr view {pr#} --json headRefOid -q .headRefOid)
|
|
52
|
+
gh api "repos/{owner}/{repo}/commits/$sha/check-runs" \
|
|
53
|
+
--jq '.check_runs[] | select(.name=="{failed-check-name}") | .details_url'
|
|
54
|
+
```
|
|
55
|
+
再从 `details_url` 同法提取 run id。
|
|
56
|
+
3. 两路都拿不到 run id → 视为「不可定位」,按技能的求助出口处理,不盲目自愈。
|
|
57
|
+
|
|
58
|
+
拿到 run id 后拉失败日志:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
gh run view {run-id} --log-failed
|
|
62
|
+
```
|
|
@@ -32,6 +32,7 @@ Aggregation rules:
|
|
|
32
32
|
- build the review-history table from `review-code*` and `code*`
|
|
33
33
|
- extract the test summary from `code*`
|
|
34
34
|
- if one artifact class is missing, treat it as "no data for this stage" and continue
|
|
35
|
+
- Manual verification section: extract items requiring human confirmation/fallback from the "Assumptions"/"Open Questions" of the latest `plan*` and the "Environment-Blocked Findings"/"Self-Doubt" sections (i.e. env-blocked items) of the latest `review-code*`; when there are none, write the explicit placeholder `- None — no items require manual verification`, never leave it empty
|
|
35
36
|
|
|
36
37
|
## Comment Body Template
|
|
37
38
|
|
|
@@ -46,6 +47,12 @@ Use this canonical comment body template:
|
|
|
46
47
|
|
|
47
48
|
**Updated At**: {current-time}
|
|
48
49
|
|
|
50
|
+
### ⚠️ Manual Verification Required
|
|
51
|
+
|
|
52
|
+
> Items in this change that need human confirmation/fallback; reviewers can reply under this comment once verified.
|
|
53
|
+
|
|
54
|
+
- {manual-verify-item}
|
|
55
|
+
|
|
49
56
|
### Key Technical Decisions
|
|
50
57
|
|
|
51
58
|
- {decision-1}
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
- 用 `review-code*` 与 `code*` 构建审查历程表
|
|
33
33
|
- 从 `code*` 提取测试结果摘要
|
|
34
34
|
- 某一类产物缺失时,按“无该阶段数据”处理并继续生成
|
|
35
|
+
- 需人工校验段落:从最新 `plan*` 的「假设」「未决问题」与最新 `review-code*` 的「环境性遗留」「自我质疑」提取需人工确认/兜底事项;无任何事项时写显式占位 `- 无需人工校验事项`,不得留空
|
|
35
36
|
|
|
36
37
|
## 评论体模板
|
|
37
38
|
|
|
@@ -46,6 +47,12 @@
|
|
|
46
47
|
|
|
47
48
|
**更新时间**:{当前时间}
|
|
48
49
|
|
|
50
|
+
### ⚠️ 需人工校验
|
|
51
|
+
|
|
52
|
+
> 本次改动中需人工确认/兜底的事项;reviewer 校验后可在本评论下回复收尾。
|
|
53
|
+
|
|
54
|
+
- {manual-verify-item}
|
|
55
|
+
|
|
49
56
|
### 关键技术决策
|
|
50
57
|
|
|
51
58
|
- {decision-1}
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
# Task short id
|
|
2
2
|
|
|
3
3
|
Task short ids let mobile-style SKILL invocations replace the full 22-char
|
|
4
|
-
`TASK-YYYYMMDD-HHMMSS` with `#NN` while a
|
|
4
|
+
`TASK-YYYYMMDD-HHMMSS` with bare numeric `N` (recommended) or `#NN` while a
|
|
5
|
+
task is active.
|
|
5
6
|
|
|
6
7
|
## Syntax
|
|
7
8
|
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
9
|
+
- Two equivalent literal forms are accepted:
|
|
10
|
+
- **Bare numeric `N`** (recommended; no shell quoting needed): e.g. `1`, `7`, `42`.
|
|
11
|
+
- **`#`-prefixed `#N` / `#NN`** (also accepted; bash needs `'...'` quoting): e.g. `#1`, `#01`, `#42`.
|
|
12
|
+
- Resolution: drop leading zeros and take the numeric value `n`; if `n == 0`,
|
|
13
|
+
reject (reserved); if `n > 10^shortIdLength - 1`, reject (over capacity);
|
|
14
|
+
otherwise canonicalize to `#${n.padStart(shortIdLength, '0')}` as the
|
|
15
|
+
registry key.
|
|
16
|
+
- With the default `shortIdLength=2`, capacity is `n ∈ [1, 99]`; registry keys
|
|
17
|
+
look like `01`, `07`, `42`.
|
|
12
18
|
- `#00` (or `#0` when `shortIdLength=1`) is reserved and never allocated; digits
|
|
13
19
|
only, no letters.
|
|
14
|
-
- The plain `TASK-…` form keeps working everywhere; `#NN` is an
|
|
15
|
-
persisted task id.
|
|
20
|
+
- The plain `TASK-…` form keeps working everywhere; bare numeric / `#NN` is an
|
|
21
|
+
alias, not the persisted task id.
|
|
16
22
|
|
|
17
23
|
## Lifecycle
|
|
18
24
|
|
|
19
|
-
| Action | When | Effect on registry
|
|
25
|
+
| Action | When | Effect on registry |
|
|
20
26
|
|------------|-----------------------------------------------------------------------|---------------------------------------------------------------|
|
|
21
|
-
| alloc | `create-task`, `import-issue`, `import-codescan`, `import-dependabot` | Assigns lowest free `#NN
|
|
27
|
+
| alloc | `create-task`, `import-issue`, `import-codescan`, `import-dependabot` | Assigns lowest free `#NN` in the registry. |
|
|
22
28
|
| resolve | Lifecycle SKILLs (`analyze-task`, `plan-task`, `code-task`, …) | Looks up `#NN` → full task id. Does not allocate. |
|
|
23
|
-
| release | `complete-task`, `cancel-task`, `block-task`, `close-codescan`, `close-dependabot` | Removes the registry entry
|
|
24
|
-
| re-alloc | `restore-task` | Re-allocates a (possibly new) `#NN`
|
|
29
|
+
| release | `complete-task`, `cancel-task`, `block-task`, `close-codescan`, `close-dependabot` | Removes the registry entry. |
|
|
30
|
+
| re-alloc | `restore-task` | Re-allocates a (possibly new) `#NN` in the registry. |
|
|
25
31
|
|
|
26
32
|
Short ids are valid only while a task lives in `.agents/workspace/active/`.
|
|
27
33
|
Once it is moved to `completed/`, `blocked/`, or `archive/`, the `#NN` slot is
|
|
@@ -48,22 +54,23 @@ archiving all active tasks first (the registry key width depends on it).
|
|
|
48
54
|
| Entrypoint | Hit | Miss |
|
|
49
55
|
|-------------------------------------------------------------|----------------------|------------------------------------------------------|
|
|
50
56
|
| SKILL parameter resolver (lifecycle SKILLs) | resolve to full id | **strict error** — short id not found / invalid |
|
|
51
|
-
| `ai sandbox
|
|
57
|
+
| `ai sandbox exec <N \| '#N'>` / `ai sandbox create <N \| '#N'>` | resolve to full id, then read `branch` from task.md | **strict error** — no ls-index fallback, no literal-branch fallback; hint the user to pass a short id / `TASK-id` / branch name |
|
|
52
58
|
|
|
53
|
-
`list --verify` is strictly read-only: it reports discrepancies between
|
|
54
|
-
dir
|
|
59
|
+
`list --verify` is strictly read-only: it reports discrepancies between the
|
|
60
|
+
active dir and the registry, but never writes.
|
|
55
61
|
|
|
56
62
|
## SKILL parameter resolver
|
|
57
63
|
|
|
58
64
|
Any SKILL (alloc / resolve / release / re-alloc lifecycle entry-points) that
|
|
59
65
|
receives a `{task-id}` argument must follow this contract:
|
|
60
66
|
|
|
61
|
-
1. If `{task-id}`
|
|
67
|
+
1. If `{task-id}` matches `^[#]?[0-9]+$` (bare numeric `N` or `#`-prefixed `#N`):
|
|
62
68
|
|
|
63
69
|
```bash
|
|
64
|
-
if [[ "{task-id}"
|
|
65
|
-
# The script writes the full error message (
|
|
66
|
-
#
|
|
70
|
+
if [[ "{task-id}" =~ ^[#]?[0-9]+$ ]]; then
|
|
71
|
+
# The script writes the full error message (covering reserved / exceeds
|
|
72
|
+
# shortIdLength capacity / malformed input) to stderr; callers only forward
|
|
73
|
+
# the exit.
|
|
67
74
|
task_id=$(node .agents/scripts/task-short-id.js resolve "{task-id}") || exit 1
|
|
68
75
|
else
|
|
69
76
|
task_id="{task-id}"
|
|
@@ -77,14 +84,8 @@ fi
|
|
|
77
84
|
|
|
78
85
|
## Storage
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
| Location | Written by | Read by | Removed by |
|
|
83
|
-
|---|---|---|---|
|
|
84
|
-
| `.agents/workspace/active/.short-ids.json` (registry) | `alloc` / cold-start migration | `resolve` (authoritative) / `list` / `list --verify` | `release` / cold-start stale cleanup |
|
|
85
|
-
| `short_id` frontmatter field in each task.md | `alloc` / cold-start migration | `list --verify` (consistency check) | **never** (kept as historical value after archive) |
|
|
86
|
-
|
|
87
|
-
**Registry**:
|
|
87
|
+
Short ids are pure local state, persisted only in the registry
|
|
88
|
+
`.agents/workspace/active/.short-ids.json`; task.md does not hold the short id:
|
|
88
89
|
|
|
89
90
|
- Path: `<repo-root>/.agents/workspace/active/.short-ids.json`
|
|
90
91
|
- Schema: `{ "version": 1, "ids": { "01": "TASK-20260609-192644", "02": "TASK-…" } }`
|
|
@@ -92,50 +93,41 @@ The short id system persists state in two places that stay in sync at rest:
|
|
|
92
93
|
full `TASK-…` task ids.
|
|
93
94
|
- Automatically git-ignored (the whole active workspace is ignored; no new
|
|
94
95
|
ignore entry needed).
|
|
95
|
-
- Created on demand by the first `alloc
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- Lives in frontmatter, immediately after `id`; formatted `short_id: #01`.
|
|
101
|
-
- Matches the registry key byte-for-byte (including the `#` prefix).
|
|
96
|
+
- Created on demand by the first `alloc`; an absent file is treated as an empty
|
|
97
|
+
registry.
|
|
98
|
+
- Short ids are assigned only by an explicit `alloc` (`create-task` /
|
|
99
|
+
`import-*` / `restore-task`); `resolve` / `list` / `release` never allocate —
|
|
100
|
+
they only clean up stale entries pointing at non-active tasks.
|
|
102
101
|
- After archive (complete-task / cancel-task / block-task / close-*) the
|
|
103
|
-
registry entry is deleted immediately
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
② look up `NN` directly as the registry `ids` key → ③ return full task id on
|
|
113
|
-
hit; on miss, exit 1 with the `list --verify` repair hint.
|
|
102
|
+
registry entry is deleted immediately and the short id may be reused; archived
|
|
103
|
+
tasks are referenced by their full `TASK-…` id.
|
|
104
|
+
|
|
105
|
+
`resolve(<N|'#N'>)` workflow: ① validate arg matches `^[#]?[0-9]+$` →
|
|
106
|
+
② strip leading zeros and take the numeric value `n`; classify as reserved
|
|
107
|
+
(`n == 0`) / over capacity (`n > 10^shortIdLength - 1`) / normal → ③ on
|
|
108
|
+
normal, use `n.padStart(shortIdLength, '0')` as the registry `ids` key
|
|
109
|
+
→ ④ return full task id on hit; on miss, exit 1 with the `list --verify`
|
|
110
|
+
repair hint.
|
|
114
111
|
|
|
115
112
|
## Error scenarios
|
|
116
113
|
|
|
117
|
-
- **Short id not found**: the registry has no entry for
|
|
118
|
-
was archived (release freed the slot) or the input is
|
|
114
|
+
- **Short id not found**: the registry has no entry for the resolved key.
|
|
115
|
+
Either the task was archived (release freed the slot) or the input is
|
|
116
|
+
wrong. Exit code 1.
|
|
119
117
|
- **Registry corruption** (duplicate registry entries for the same task id, or
|
|
120
118
|
the JSON is unparsable): exit code 2; manual cleanup required.
|
|
121
|
-
- **
|
|
122
|
-
|
|
119
|
+
- **Reserved key**: the resolved `n == 0` (inputs like `0`, `#0`, `#00`). Exit code 1.
|
|
120
|
+
- **Over capacity**: the resolved `n > 10^shortIdLength - 1` (e.g. `100` or
|
|
121
|
+
`#100` when `shortIdLength=2`). Exit code 1.
|
|
122
|
+
- **Parameter format error**: input matches neither `^[#]?[0-9]+$` nor a
|
|
123
|
+
`TASK-id` (e.g. `#abc`, `#`, `5.5`). Exit code 1.
|
|
123
124
|
|
|
124
125
|
## Cross-TUI quoting
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
Bare numeric `N` is safe in every shell and TUI without quoting (recommended):
|
|
128
|
+
`ai sandbox exec 11 'npm test'`, `/review-analysis 11`.
|
|
129
|
+
|
|
130
|
+
The `#N` / `#NN` form is also accepted; but bash treats `#` as a comment
|
|
131
|
+
marker, so it must be single-quoted: `ai sandbox exec '#03' 'npm test'`.
|
|
127
132
|
Claude Code / Codex / Gemini CLI / OpenCode all forward `#NN` to SKILL
|
|
128
133
|
`ARGUMENTS` literally when quoted.
|
|
129
|
-
|
|
130
|
-
## Cold-start migration
|
|
131
|
-
|
|
132
|
-
When a project upgrades to a version with this feature, the first call to
|
|
133
|
-
`alloc` / `resolve` runs the cold-start path:
|
|
134
|
-
|
|
135
|
-
- Active tasks whose `task.md` lacks `short_id` get one allocated and written
|
|
136
|
-
back (the only frontmatter mutation; `updated_at` / `agent_infra_version`
|
|
137
|
-
are **not** refreshed and Activity Log is **not** appended).
|
|
138
|
-
- If active task count exceeds `shortIdLength` capacity, the migration aborts
|
|
139
|
-
**before any write** with a capacity error.
|
|
140
|
-
- If a partial write fails midway, `tx.commit()` rolls all task.md files back to
|
|
141
|
-
their original content (including `mtime` / `atime`).
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
# 任务短号
|
|
2
2
|
|
|
3
|
-
短号让所有 SKILL 在 active 任务生命周期内可以用 `#NN`
|
|
4
|
-
`TASK-YYYYMMDD-HHMMSS`。
|
|
3
|
+
短号让所有 SKILL 在 active 任务生命周期内可以用 `#NN` 或裸数字 `N`(推荐)替代
|
|
4
|
+
完整的 22 字符 `TASK-YYYYMMDD-HHMMSS`。
|
|
5
5
|
|
|
6
6
|
## 语法
|
|
7
7
|
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
8
|
+
- 字面接受两种等价形式:
|
|
9
|
+
- **裸数字 `N`**(推荐,无需 shell 引号):如 `1`、`7`、`42`。
|
|
10
|
+
- **`#`-前缀 `#N` / `#NN`**(也接受;但 bash 需 `'...'` 引号):如 `#1`、`#01`、`#42`。
|
|
11
|
+
- 解析规则:去前导零后取数值 `n`,若 `n == 0` 报错(保留);若 `n > 10^shortIdLength - 1`
|
|
12
|
+
报错(超容量);否则归一化为 `#${n.padStart(shortIdLength, '0')}`,作为注册表 key。
|
|
13
|
+
- 默认 `shortIdLength=2` 时容量 `n ∈ [1, 99]`,注册表 key 形如 `01`、`07`、`42`。
|
|
12
14
|
- `#00`(或 `shortIdLength=1` 时 `#0`)保留、永不分配;纯数字、不引入字母。
|
|
13
|
-
- 完整 `TASK-…` 入参在所有路径下行为与现状等价;`#NN`
|
|
15
|
+
- 完整 `TASK-…` 入参在所有路径下行为与现状等价;`#NN` / 裸数字只是别名,不是持久化任务 ID。
|
|
14
16
|
|
|
15
17
|
## 生命周期
|
|
16
18
|
|
|
17
|
-
| 动作 | 触发时机 |
|
|
19
|
+
| 动作 | 触发时机 | 注册表效应 |
|
|
18
20
|
|-----------|---------------------------------------------------------------------------------------------|------------------------------------------------------------------|
|
|
19
|
-
| alloc | `create-task`、`import-issue`、`import-codescan`、`import-dependabot` | 分配最小可用 `#NN
|
|
21
|
+
| alloc | `create-task`、`import-issue`、`import-codescan`、`import-dependabot` | 分配最小可用 `#NN`,写入注册表。 |
|
|
20
22
|
| resolve | 生命周期 SKILL(`analyze-task` / `plan-task` / `code-task` / `review-*` / `commit` / …) | `#NN` → 完整 task id 查询,不分配。 |
|
|
21
|
-
| release | `complete-task`、`cancel-task`、`block-task`、`close-codescan`、`close-dependabot` |
|
|
22
|
-
| re-alloc | `restore-task` |
|
|
23
|
+
| release | `complete-task`、`cancel-task`、`block-task`、`close-codescan`、`close-dependabot` | 从注册表移除。 |
|
|
24
|
+
| re-alloc | `restore-task` | 重新分配(可能与历史不同),写入注册表。 |
|
|
23
25
|
|
|
24
26
|
短号仅在任务处于 `.agents/workspace/active/` 期间有效;任务移动到
|
|
25
27
|
`completed/` / `blocked/` / `archive/` 后短号立即释放,可被新任务复用。
|
|
@@ -44,21 +46,20 @@
|
|
|
44
46
|
| 入口 | 注册表命中 | 注册表未命中 |
|
|
45
47
|
|-----------------------------------------------------------|----------------------|--------------------------------------------------------|
|
|
46
48
|
| SKILL 入参解析器(生命周期 SKILL) | 解析为完整 task id | **严格报错** —— 短号不存在 / 格式错误 |
|
|
47
|
-
| `ai sandbox
|
|
49
|
+
| `ai sandbox exec <N \| '#N'>` / `ai sandbox create <N \| '#N'>` | 解析为完整 task id 后查 task.md 取 `branch` | **严格报错** —— 不再回退到 ls 行号或字面分支名;提示用任务短号 / `TASK-id` / 分支名 |
|
|
48
50
|
|
|
49
|
-
`list --verify` 严格只读:报告 active 目录 / 注册表
|
|
50
|
-
三者差异,但不修改任何状态。
|
|
51
|
+
`list --verify` 严格只读:报告 active 目录 / 注册表 两者差异,但不修改任何状态。
|
|
51
52
|
|
|
52
53
|
## SKILL 入参解析
|
|
53
54
|
|
|
54
55
|
任意 SKILL(含 alloc / resolve / release / re-alloc 四类生命周期入口)在收到
|
|
55
56
|
`{task-id}` 入参后,必须按以下契约处理:
|
|
56
57
|
|
|
57
|
-
1. 如果 `{task-id}`
|
|
58
|
+
1. 如果 `{task-id}` 字面匹配 `^[#]?[0-9]+$`(裸数字 `N` 或 `#`-前缀 `#N`):
|
|
58
59
|
|
|
59
60
|
```bash
|
|
60
|
-
if [[ "{task-id}"
|
|
61
|
-
#
|
|
61
|
+
if [[ "{task-id}" =~ ^[#]?[0-9]+$ ]]; then
|
|
62
|
+
# 脚本本身已输出完整错误(含 reserved / exceeds shortIdLength capacity 等场景);
|
|
62
63
|
# 调用方只需透传退出码
|
|
63
64
|
task_id=$(node .agents/scripts/task-short-id.js resolve "{task-id}") || exit 1
|
|
64
65
|
else
|
|
@@ -71,54 +72,34 @@ fi
|
|
|
71
72
|
|
|
72
73
|
## 存储位置
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
| 位置 | 写入时机 | 读取时机 | 删除时机 |
|
|
77
|
-
|---|---|---|---|
|
|
78
|
-
| `.agents/workspace/active/.short-ids.json`(注册表) | `alloc` / 冷启动迁移 | `resolve` 唯一权威源 / `list` / `list --verify` | `release` / 冷启动 stale 清理 |
|
|
79
|
-
| 各 task.md frontmatter 的 `short_id` 字段 | `alloc` / 冷启动迁移 | `list --verify`(比对一致性) | **永不删除**(归档后保留为历史值) |
|
|
80
|
-
|
|
81
|
-
**注册表**:
|
|
75
|
+
短号是纯本地状态,唯一持久化在注册表 `.agents/workspace/active/.short-ids.json`,task.md 不持有短号:
|
|
82
76
|
|
|
83
77
|
- 路径:`<repo-root>/.agents/workspace/active/.short-ids.json`
|
|
84
78
|
- Schema:`{ "version": 1, "ids": { "01": "TASK-20260609-192644", "02": "TASK-…" } }`
|
|
85
79
|
- key 是零填充到 `task.shortIdLength` 位的字符串,value 是完整 `TASK-…` task id
|
|
86
80
|
- 自动 git ignore(active 工作区整体 ignore;无需新增 ignore 条目)
|
|
87
|
-
- 首次 `alloc`
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
- 首次 `alloc` 时按需自动创建;不存在时按空注册表处理
|
|
82
|
+
- 短号只由显式 `alloc`(`create-task` / `import-*` / `restore-task`)分配;`resolve` / `list` / `release` 不分配,仅在执行时自动清理指向非 active 任务的 stale entry
|
|
83
|
+
- 归档(complete-task / cancel-task / block-task / close-*)后注册表 entry 立即删除,短号可被新任务复用;归档后引用任务一律用完整 `TASK-…` id
|
|
90
84
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
只信任注册表
|
|
96
|
-
- 冷启动迁移:升级 agent-infra 后首次 alloc / resolve 路径会扫描所有 active
|
|
97
|
-
目录并为缺字段的 task.md 补发短号;补发受字段保护约束(不刷新
|
|
98
|
-
`updated_at` / `agent_infra_version`、不追加 Activity Log)
|
|
99
|
-
|
|
100
|
-
`resolve('#NN')` 工作流:① 校验入参严格匹配 `^#\d{shortIdLength}$` → ② 直接以
|
|
101
|
-
`NN` 作为 key 查注册表 `ids` → ③ 命中返回完整 task id,未命中按 `list --verify`
|
|
102
|
-
给出修复指引退出 1。
|
|
85
|
+
`resolve(<N|'#N'>)` 工作流:① 校验入参匹配 `^[#]?[0-9]+$` → ② 去前导零取
|
|
86
|
+
数值 `n`,按 `n` 是否 `== 0`(保留)/ `> 10^shortIdLength - 1`(超容量)/
|
|
87
|
+
正常 三类处理 → ③ 正常时以 `n.padStart(shortIdLength, '0')` 作为 key 查
|
|
88
|
+
注册表 `ids` → ④ 命中返回完整 task id,未命中按 `list --verify` 给出修复指引退出 1。
|
|
103
89
|
|
|
104
90
|
## 错误场景
|
|
105
91
|
|
|
106
|
-
-
|
|
92
|
+
- **短号不存在**:注册表中无对应 key。可能是任务已归档(短号已释放)或输入错误。退出码 1。
|
|
107
93
|
- **注册表损坏**(同一 taskId 出现多次或 JSON 无法解析):退出码 2,需人工处理。
|
|
108
|
-
-
|
|
94
|
+
- **保留键**:解析后 `n == 0`(输入如 `0`、`#0`、`#00`)。退出码 1。
|
|
95
|
+
- **超容量**:解析后 `n > 10^shortIdLength - 1`(如 `shortIdLength=2` 下 `100` 或 `#100`)。退出码 1。
|
|
96
|
+
- **参数格式错误**:入参既不是 `^[#]?[0-9]+$` 也不是 `TASK-id`(如 `#abc`、`#`、`5.5`)。退出码 1。
|
|
109
97
|
|
|
110
98
|
## 跨 TUI 引号要求
|
|
111
99
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
SKILL 的 `ARGUMENTS`。
|
|
115
|
-
|
|
116
|
-
## 冷启动迁移
|
|
117
|
-
|
|
118
|
-
升级 agent-infra 后,首次 `alloc` / `resolve` 调用会触发冷启动迁移:
|
|
100
|
+
裸数字 `N` 在所有 shell 与 TUI 中都安全无需引号,推荐写法:
|
|
101
|
+
`ai sandbox exec 11 'npm test'`、`/review-analysis 11`。
|
|
119
102
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
- 若 task.md 写入中途失败,`tx.commit()` 按缓存的原内容回滚所有已写文件(含
|
|
124
|
-
`mtime` / `atime` 恢复)。
|
|
103
|
+
`#N` / `#NN` 写法也接受;但 bash 中 `#` 是注释起始符,必须单引号:
|
|
104
|
+
`ai sandbox exec '#03' 'npm test'`。Claude Code / Codex / Gemini CLI / OpenCode
|
|
105
|
+
在加引号时都能把 `#NN` 字面传递到 SKILL 的 `ARGUMENTS`。
|
|
@@ -5,6 +5,7 @@ import spawn from "cross-spawn";
|
|
|
5
5
|
|
|
6
6
|
const CHECK_TYPE = "platform-sync";
|
|
7
7
|
const DEFAULT_RETRY_DELAYS_MS = [3000, 10000];
|
|
8
|
+
const VERSION_LINE_REGEX = /^[0-9]+\.[0-9]+\.x$/;
|
|
8
9
|
const FRONTMATTER_FIELD_MAP = {
|
|
9
10
|
priority: "Priority",
|
|
10
11
|
effort: "Effort",
|
|
@@ -811,6 +812,22 @@ function checkMilestone(context, remoteData) {
|
|
|
811
812
|
);
|
|
812
813
|
}
|
|
813
814
|
|
|
815
|
+
if (context.config.verify_milestone_specific) {
|
|
816
|
+
const issueTitle = remoteData.issue.milestone.title;
|
|
817
|
+
if (VERSION_LINE_REGEX.test(issueTitle)) {
|
|
818
|
+
return failResult(CHECK_TYPE,
|
|
819
|
+
`Issue #${context.issueNumber} milestone '${issueTitle}' is a release line; narrow to a specific version (e.g. ${issueTitle.replace(/\.x$/, ".N")}) before continuing`,
|
|
820
|
+
"check_failed"
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
if (context.prNumber && remoteData.prMilestone?.title && VERSION_LINE_REGEX.test(remoteData.prMilestone.title)) {
|
|
824
|
+
return failResult(CHECK_TYPE,
|
|
825
|
+
`PR #${context.prNumber} milestone '${remoteData.prMilestone.title}' is a release line; narrow to a specific version before continuing`,
|
|
826
|
+
"check_failed"
|
|
827
|
+
);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
|
|
814
831
|
return null;
|
|
815
832
|
}
|
|
816
833
|
|