@fitlab-ai/agent-infra 0.7.0 → 0.7.2

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 (156) hide show
  1. package/bin/cli.ts +12 -1
  2. package/dist/bin/cli.js +13 -1
  3. package/dist/lib/builtin-tuis.js +45 -0
  4. package/dist/lib/defaults.json +3 -0
  5. package/dist/lib/init.js +62 -23
  6. package/dist/lib/prompt.js +49 -1
  7. package/dist/lib/sandbox/commands/create.js +10 -2
  8. package/dist/lib/sandbox/commands/enter.js +8 -7
  9. package/dist/lib/sandbox/commands/list-running.js +62 -28
  10. package/dist/lib/sandbox/commands/ls.js +20 -22
  11. package/dist/lib/sandbox/commands/rebuild.js +3 -11
  12. package/dist/lib/sandbox/commands/rm.js +2 -0
  13. package/dist/lib/sandbox/image-prune.js +18 -0
  14. package/dist/lib/sandbox/index.js +7 -3
  15. package/dist/lib/sandbox/task-resolver.js +18 -0
  16. package/dist/lib/sandbox/tools.js +1 -1
  17. package/dist/lib/table.js +29 -0
  18. package/dist/lib/task/commands/ls.js +122 -0
  19. package/dist/lib/task/commands/show.js +135 -0
  20. package/dist/lib/task/frontmatter.js +32 -0
  21. package/dist/lib/task/index.js +41 -0
  22. package/dist/lib/task/short-id.js +80 -0
  23. package/dist/lib/update.js +59 -18
  24. package/lib/builtin-tuis.ts +55 -0
  25. package/lib/defaults.json +3 -0
  26. package/lib/init.ts +87 -35
  27. package/lib/prompt.ts +54 -1
  28. package/lib/sandbox/commands/create.ts +11 -2
  29. package/lib/sandbox/commands/enter.ts +8 -7
  30. package/lib/sandbox/commands/list-running.ts +70 -31
  31. package/lib/sandbox/commands/ls.ts +25 -25
  32. package/lib/sandbox/commands/rebuild.ts +3 -12
  33. package/lib/sandbox/commands/rm.ts +3 -0
  34. package/lib/sandbox/image-prune.ts +23 -0
  35. package/lib/sandbox/index.ts +7 -3
  36. package/lib/sandbox/task-resolver.ts +23 -1
  37. package/lib/sandbox/tools.ts +1 -1
  38. package/lib/table.ts +32 -0
  39. package/lib/task/commands/ls.ts +138 -0
  40. package/lib/task/commands/show.ts +139 -0
  41. package/lib/task/frontmatter.ts +30 -0
  42. package/lib/task/index.ts +44 -0
  43. package/lib/task/short-id.ts +97 -0
  44. package/lib/update.ts +71 -30
  45. package/package.json +1 -1
  46. package/templates/.agents/README.en.md +32 -0
  47. package/templates/.agents/README.zh-CN.md +32 -0
  48. package/templates/.agents/hooks/auto-resume.sh +87 -0
  49. package/templates/.agents/rules/create-issue.github.en.md +1 -1
  50. package/templates/.agents/rules/create-issue.github.zh-CN.md +1 -1
  51. package/templates/.agents/rules/milestone-inference.github.en.md +4 -1
  52. package/templates/.agents/rules/milestone-inference.github.zh-CN.md +4 -1
  53. package/templates/.agents/rules/next-step-output.en.md +59 -0
  54. package/templates/.agents/rules/next-step-output.zh-CN.md +59 -0
  55. package/templates/.agents/rules/task-short-id.en.md +133 -0
  56. package/templates/.agents/rules/task-short-id.zh-CN.md +105 -0
  57. package/templates/.agents/scripts/platform-adapters/platform-sync.github.js +17 -0
  58. package/templates/.agents/scripts/task-short-id.js +556 -0
  59. package/templates/.agents/skills/analyze-task/SKILL.en.md +13 -11
  60. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +13 -12
  61. package/templates/.agents/skills/analyze-task/config/verify.en.json +1 -1
  62. package/templates/.agents/skills/analyze-task/config/verify.zh-CN.json +1 -1
  63. package/templates/.agents/skills/block-task/SKILL.en.md +17 -5
  64. package/templates/.agents/skills/block-task/SKILL.zh-CN.md +17 -6
  65. package/templates/.agents/skills/block-task/config/verify.json +1 -1
  66. package/templates/.agents/skills/cancel-task/SKILL.en.md +17 -5
  67. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +17 -6
  68. package/templates/.agents/skills/cancel-task/config/verify.json +1 -1
  69. package/templates/.agents/skills/check-task/SKILL.en.md +15 -9
  70. package/templates/.agents/skills/check-task/SKILL.zh-CN.md +15 -10
  71. package/templates/.agents/skills/close-codescan/SKILL.en.md +16 -5
  72. package/templates/.agents/skills/close-codescan/SKILL.zh-CN.md +16 -5
  73. package/templates/.agents/skills/close-dependabot/SKILL.en.md +16 -5
  74. package/templates/.agents/skills/close-dependabot/SKILL.zh-CN.md +16 -5
  75. package/templates/.agents/skills/code-task/SKILL.en.md +13 -5
  76. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +14 -6
  77. package/templates/.agents/skills/code-task/config/verify.en.json +2 -1
  78. package/templates/.agents/skills/code-task/config/verify.zh-CN.json +2 -1
  79. package/templates/.agents/skills/code-task/reference/fix-mode.en.md +10 -5
  80. package/templates/.agents/skills/code-task/reference/fix-mode.zh-CN.md +10 -5
  81. package/templates/.agents/skills/code-task/reference/output-template.en.md +3 -3
  82. package/templates/.agents/skills/code-task/reference/output-template.zh-CN.md +3 -3
  83. package/templates/.agents/skills/code-task/reference/report-template.en.md +8 -0
  84. package/templates/.agents/skills/code-task/reference/report-template.zh-CN.md +8 -0
  85. package/templates/.agents/skills/commit/SKILL.en.md +5 -1
  86. package/templates/.agents/skills/commit/SKILL.zh-CN.md +5 -1
  87. package/templates/.agents/skills/commit/reference/task-status-update.en.md +9 -9
  88. package/templates/.agents/skills/commit/reference/task-status-update.zh-CN.md +9 -9
  89. package/templates/.agents/skills/complete-task/SKILL.en.md +17 -1
  90. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +17 -2
  91. package/templates/.agents/skills/complete-task/config/verify.en.json +1 -1
  92. package/templates/.agents/skills/complete-task/config/verify.zh-CN.json +1 -1
  93. package/templates/.agents/skills/create-pr/SKILL.en.md +9 -5
  94. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +9 -5
  95. package/templates/.agents/skills/create-pr/config/verify.json +2 -1
  96. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +1 -1
  97. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +1 -1
  98. package/templates/.agents/skills/create-pr/reference/pr-body-template.en.md +3 -3
  99. package/templates/.agents/skills/create-pr/reference/pr-body-template.zh-CN.md +3 -3
  100. package/templates/.agents/skills/create-task/SKILL.en.md +29 -15
  101. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +29 -16
  102. package/templates/.agents/skills/create-task/config/verify.json +1 -1
  103. package/templates/.agents/skills/import-codescan/SKILL.en.md +20 -6
  104. package/templates/.agents/skills/import-codescan/SKILL.zh-CN.md +20 -6
  105. package/templates/.agents/skills/import-codescan/config/verify.json +1 -1
  106. package/templates/.agents/skills/import-dependabot/SKILL.en.md +20 -6
  107. package/templates/.agents/skills/import-dependabot/SKILL.zh-CN.md +20 -6
  108. package/templates/.agents/skills/import-dependabot/config/verify.json +1 -1
  109. package/templates/.agents/skills/import-issue/SKILL.en.md +19 -5
  110. package/templates/.agents/skills/import-issue/SKILL.zh-CN.md +19 -5
  111. package/templates/.agents/skills/plan-task/SKILL.en.md +13 -11
  112. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +13 -12
  113. package/templates/.agents/skills/plan-task/config/verify.en.json +1 -1
  114. package/templates/.agents/skills/plan-task/config/verify.zh-CN.json +1 -1
  115. package/templates/.agents/skills/restore-task/SKILL.en.md +12 -0
  116. package/templates/.agents/skills/restore-task/SKILL.zh-CN.md +12 -1
  117. package/templates/.agents/skills/review-analysis/SKILL.en.md +7 -1
  118. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +7 -2
  119. package/templates/.agents/skills/review-analysis/config/verify.en.json +3 -2
  120. package/templates/.agents/skills/review-analysis/config/verify.zh-CN.json +3 -2
  121. package/templates/.agents/skills/review-analysis/reference/output-templates.en.md +15 -15
  122. package/templates/.agents/skills/review-analysis/reference/output-templates.zh-CN.md +15 -15
  123. package/templates/.agents/skills/review-analysis/reference/report-template.en.md +7 -1
  124. package/templates/.agents/skills/review-analysis/reference/report-template.zh-CN.md +7 -1
  125. package/templates/.agents/skills/review-analysis/reference/review-criteria.en.md +2 -0
  126. package/templates/.agents/skills/review-analysis/reference/review-criteria.zh-CN.md +2 -0
  127. package/templates/.agents/skills/review-code/SKILL.en.md +8 -1
  128. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +8 -2
  129. package/templates/.agents/skills/review-code/config/verify.en.json +3 -2
  130. package/templates/.agents/skills/review-code/config/verify.zh-CN.json +3 -2
  131. package/templates/.agents/skills/review-code/reference/output-templates.en.md +9 -9
  132. package/templates/.agents/skills/review-code/reference/output-templates.zh-CN.md +9 -9
  133. package/templates/.agents/skills/review-code/reference/report-template.en.md +7 -1
  134. package/templates/.agents/skills/review-code/reference/report-template.zh-CN.md +7 -1
  135. package/templates/.agents/skills/review-code/reference/review-criteria.en.md +2 -0
  136. package/templates/.agents/skills/review-code/reference/review-criteria.zh-CN.md +2 -0
  137. package/templates/.agents/skills/review-plan/SKILL.en.md +7 -1
  138. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +7 -2
  139. package/templates/.agents/skills/review-plan/config/verify.en.json +3 -2
  140. package/templates/.agents/skills/review-plan/config/verify.zh-CN.json +3 -2
  141. package/templates/.agents/skills/review-plan/reference/output-templates.en.md +15 -15
  142. package/templates/.agents/skills/review-plan/reference/output-templates.zh-CN.md +15 -15
  143. package/templates/.agents/skills/review-plan/reference/report-template.en.md +7 -1
  144. package/templates/.agents/skills/review-plan/reference/report-template.zh-CN.md +7 -1
  145. package/templates/.agents/skills/review-plan/reference/review-criteria.en.md +2 -0
  146. package/templates/.agents/skills/review-plan/reference/review-criteria.zh-CN.md +2 -0
  147. package/templates/.agents/skills/update-agent-infra/SKILL.en.md +1 -0
  148. package/templates/.agents/skills/update-agent-infra/SKILL.zh-CN.md +1 -0
  149. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +112 -21
  150. package/templates/.agents/workflows/bug-fix.en.yaml +1 -1
  151. package/templates/.agents/workflows/bug-fix.zh-CN.yaml +1 -1
  152. package/templates/.agents/workflows/feature-development.en.yaml +1 -1
  153. package/templates/.agents/workflows/feature-development.zh-CN.yaml +1 -1
  154. package/templates/.agents/workflows/refactoring.en.yaml +1 -1
  155. package/templates/.agents/workflows/refactoring.zh-CN.yaml +1 -1
  156. package/templates/.claude/settings.json +11 -0
@@ -0,0 +1,133 @@
1
+ # Task short id
2
+
3
+ Task short ids let mobile-style SKILL invocations replace the full 22-char
4
+ `TASK-YYYYMMDD-HHMMSS` with bare numeric `N` (recommended) or `#NN` while a
5
+ task is active.
6
+
7
+ ## Syntax
8
+
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`.
18
+ - `#00` (or `#0` when `shortIdLength=1`) is reserved and never allocated; digits
19
+ only, no letters.
20
+ - The plain `TASK-…` form keeps working everywhere; bare numeric / `#NN` is an
21
+ alias, not the persisted task id.
22
+
23
+ ## Lifecycle
24
+
25
+ | Action | When | Effect on registry |
26
+ |------------|-----------------------------------------------------------------------|---------------------------------------------------------------|
27
+ | alloc | `create-task`, `import-issue`, `import-codescan`, `import-dependabot` | Assigns lowest free `#NN` in the registry. |
28
+ | resolve | Lifecycle SKILLs (`analyze-task`, `plan-task`, `code-task`, …) | Looks up `#NN` → full task id. Does not allocate. |
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. |
31
+
32
+ Short ids are valid only while a task lives in `.agents/workspace/active/`.
33
+ Once it is moved to `completed/`, `blocked/`, or `archive/`, the `#NN` slot is
34
+ freed and may be reused by a new task.
35
+
36
+ ## Configuration
37
+
38
+ ```jsonc
39
+ // .agents/.airc.json
40
+ {
41
+ "task": {
42
+ "shortIdLength": 2 // default; capacity = 99 (#01–#99). Set to 3 for #001–#999.
43
+ }
44
+ }
45
+ ```
46
+
47
+ When all slots for the configured width are in use, `alloc` fails with a clear
48
+ error suggesting either archiving some tasks or raising `task.shortIdLength`.
49
+ There is no silent extension or truncation. Changing `shortIdLength` requires
50
+ archiving all active tasks first (the registry key width depends on it).
51
+
52
+ ## `#NN` resolution scope (split by entrypoint)
53
+
54
+ | Entrypoint | Hit | Miss |
55
+ |-------------------------------------------------------------|----------------------|------------------------------------------------------|
56
+ | SKILL parameter resolver (lifecycle SKILLs) | resolve to full id | **strict error** — short id not found / invalid |
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 |
58
+
59
+ `list --verify` is strictly read-only: it reports discrepancies between the
60
+ active dir and the registry, but never writes.
61
+
62
+ ## SKILL parameter resolver
63
+
64
+ Any SKILL (alloc / resolve / release / re-alloc lifecycle entry-points) that
65
+ receives a `{task-id}` argument must follow this contract:
66
+
67
+ 1. If `{task-id}` matches `^[#]?[0-9]+$` (bare numeric `N` or `#`-prefixed `#N`):
68
+
69
+ ```bash
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.
74
+ task_id=$(node .agents/scripts/task-short-id.js resolve "{task-id}") || exit 1
75
+ else
76
+ task_id="{task-id}"
77
+ fi
78
+ ```
79
+
80
+ 2. Every downstream command treats `{task-id}` as `$task_id` (already the full
81
+ `TASK-YYYYMMDD-HHMMSS` form).
82
+ 3. Error-code semantics for resolve are documented under "Error scenarios"; do
83
+ not reimplement error handling inside each SKILL.
84
+
85
+ ## Storage
86
+
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:
89
+
90
+ - Path: `<repo-root>/.agents/workspace/active/.short-ids.json`
91
+ - Schema: `{ "version": 1, "ids": { "01": "TASK-20260609-192644", "02": "TASK-…" } }`
92
+ - Keys are zero-padded decimal strings of `task.shortIdLength` digits; values are
93
+ full `TASK-…` task ids.
94
+ - Automatically git-ignored (the whole active workspace is ignored; no new
95
+ ignore entry needed).
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.
101
+ - After archive (complete-task / cancel-task / block-task / close-*) the
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.
111
+
112
+ ## Error scenarios
113
+
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.
117
+ - **Registry corruption** (duplicate registry entries for the same task id, or
118
+ the JSON is unparsable): exit code 2; manual cleanup required.
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.
124
+
125
+ ## Cross-TUI quoting
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'`.
132
+ Claude Code / Codex / Gemini CLI / OpenCode all forward `#NN` to SKILL
133
+ `ARGUMENTS` literally when quoted.
@@ -0,0 +1,105 @@
1
+ # 任务短号
2
+
3
+ 短号让所有 SKILL 在 active 任务生命周期内可以用 `#NN` 或裸数字 `N`(推荐)替代
4
+ 完整的 22 字符 `TASK-YYYYMMDD-HHMMSS`。
5
+
6
+ ## 语法
7
+
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`。
14
+ - `#00`(或 `shortIdLength=1` 时 `#0`)保留、永不分配;纯数字、不引入字母。
15
+ - 完整 `TASK-…` 入参在所有路径下行为与现状等价;`#NN` / 裸数字只是别名,不是持久化任务 ID。
16
+
17
+ ## 生命周期
18
+
19
+ | 动作 | 触发时机 | 注册表效应 |
20
+ |-----------|---------------------------------------------------------------------------------------------|------------------------------------------------------------------|
21
+ | alloc | `create-task`、`import-issue`、`import-codescan`、`import-dependabot` | 分配最小可用 `#NN`,写入注册表。 |
22
+ | resolve | 生命周期 SKILL(`analyze-task` / `plan-task` / `code-task` / `review-*` / `commit` / …) | `#NN` → 完整 task id 查询,不分配。 |
23
+ | release | `complete-task`、`cancel-task`、`block-task`、`close-codescan`、`close-dependabot` | 从注册表移除。 |
24
+ | re-alloc | `restore-task` | 重新分配(可能与历史不同),写入注册表。 |
25
+
26
+ 短号仅在任务处于 `.agents/workspace/active/` 期间有效;任务移动到
27
+ `completed/` / `blocked/` / `archive/` 后短号立即释放,可被新任务复用。
28
+
29
+ ## 配置
30
+
31
+ ```jsonc
32
+ // .agents/.airc.json
33
+ {
34
+ "task": {
35
+ "shortIdLength": 2 // 默认;容量 = 99(#01–#99)。改为 3 时容量 = #001–#999。
36
+ }
37
+ }
38
+ ```
39
+
40
+ 当前位宽容量耗尽时,`alloc` 给出明确错误并建议「归档若干任务」或「调高
41
+ `task.shortIdLength`」两种修复路径;不静默扩位、不静默截断。
42
+ 切换 `shortIdLength` 配置需要先归档所有 active 任务(注册表 key 宽度依赖配置)。
43
+
44
+ ## `#NN` 解析作用域(按入口二分)
45
+
46
+ | 入口 | 注册表命中 | 注册表未命中 |
47
+ |-----------------------------------------------------------|----------------------|--------------------------------------------------------|
48
+ | SKILL 入参解析器(生命周期 SKILL) | 解析为完整 task id | **严格报错** —— 短号不存在 / 格式错误 |
49
+ | `ai sandbox exec <N \| '#N'>` / `ai sandbox create <N \| '#N'>` | 解析为完整 task id 后查 task.md 取 `branch` | **严格报错** —— 不再回退到 ls 行号或字面分支名;提示用任务短号 / `TASK-id` / 分支名 |
50
+
51
+ `list --verify` 严格只读:报告 active 目录 / 注册表 两者差异,但不修改任何状态。
52
+
53
+ ## SKILL 入参解析
54
+
55
+ 任意 SKILL(含 alloc / resolve / release / re-alloc 四类生命周期入口)在收到
56
+ `{task-id}` 入参后,必须按以下契约处理:
57
+
58
+ 1. 如果 `{task-id}` 字面匹配 `^[#]?[0-9]+$`(裸数字 `N` 或 `#`-前缀 `#N`):
59
+
60
+ ```bash
61
+ if [[ "{task-id}" =~ ^[#]?[0-9]+$ ]]; then
62
+ # 脚本本身已输出完整错误(含 reserved / exceeds shortIdLength capacity 等场景);
63
+ # 调用方只需透传退出码
64
+ task_id=$(node .agents/scripts/task-short-id.js resolve "{task-id}") || exit 1
65
+ else
66
+ task_id="{task-id}"
67
+ fi
68
+ ```
69
+
70
+ 2. 后续所有命令把 `{task-id}` 视为 `$task_id`(已是完整 `TASK-YYYYMMDD-HHMMSS` 形式)
71
+ 3. 解析失败的退出码语义参见「错误场景」段;不要在 SKILL 中重写错误处理
72
+
73
+ ## 存储位置
74
+
75
+ 短号是纯本地状态,唯一持久化在注册表 `.agents/workspace/active/.short-ids.json`,task.md 不持有短号:
76
+
77
+ - 路径:`<repo-root>/.agents/workspace/active/.short-ids.json`
78
+ - Schema:`{ "version": 1, "ids": { "01": "TASK-20260609-192644", "02": "TASK-…" } }`
79
+ - key 是零填充到 `task.shortIdLength` 位的字符串,value 是完整 `TASK-…` task id
80
+ - 自动 git ignore(active 工作区整体 ignore;无需新增 ignore 条目)
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
84
+
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。
89
+
90
+ ## 错误场景
91
+
92
+ - **短号不存在**:注册表中无对应 key。可能是任务已归档(短号已释放)或输入错误。退出码 1。
93
+ - **注册表损坏**(同一 taskId 出现多次或 JSON 无法解析):退出码 2,需人工处理。
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。
97
+
98
+ ## 跨 TUI 引号要求
99
+
100
+ 裸数字 `N` 在所有 shell 与 TUI 中都安全无需引号,推荐写法:
101
+ `ai sandbox exec 11 'npm test'`、`/review-analysis 11`。
102
+
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