@fitlab-ai/agent-infra 0.9.4 → 0.9.5

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 (56) hide show
  1. package/README.md +1 -1
  2. package/README.zh-CN.md +1 -1
  3. package/dist/bin/internal-cli.js +10 -0
  4. package/dist/lib/agent-clients/adapter.js +2 -2
  5. package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +382 -0
  6. package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +163 -0
  7. package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +211 -0
  8. package/dist/lib/agent-clients/adapters/codex.js +2 -2
  9. package/dist/lib/git/worktree-identity.js +64 -0
  10. package/dist/lib/internal/codex-lifecycle.js +202 -0
  11. package/dist/lib/internal/task-create.js +48 -0
  12. package/dist/lib/internal/task-orchestration.js +68 -29
  13. package/dist/lib/sandbox/commands/create.js +1 -0
  14. package/dist/lib/sandbox/control/client.js +29 -15
  15. package/dist/lib/sandbox/control/protocol.js +23 -4
  16. package/dist/lib/sandbox/control/server.js +53 -18
  17. package/dist/lib/sandbox/workspace-view.js +8 -2
  18. package/dist/lib/task/activity-log.js +32 -5
  19. package/dist/lib/task/commit-finalization.js +14 -3
  20. package/dist/lib/task/create-service.js +137 -0
  21. package/dist/lib/task/create.js +333 -0
  22. package/dist/lib/task/orchestration.js +151 -15
  23. package/dist/lib/task/review-fingerprint.js +4 -0
  24. package/dist/lib/task/workspace-snapshot.js +78 -3
  25. package/lib/agent-clients/adapter.ts +4 -4
  26. package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +442 -0
  27. package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +307 -0
  28. package/lib/agent-clients/adapters/codex-lifecycle/store.ts +250 -0
  29. package/lib/agent-clients/adapters/codex.ts +2 -2
  30. package/lib/git/worktree-identity.ts +86 -0
  31. package/lib/internal/codex-lifecycle.ts +204 -0
  32. package/lib/internal/task-create.ts +49 -0
  33. package/lib/internal/task-orchestration.ts +54 -28
  34. package/lib/sandbox/commands/create.ts +1 -0
  35. package/lib/sandbox/control/client.ts +42 -18
  36. package/lib/sandbox/control/protocol.ts +43 -8
  37. package/lib/sandbox/control/server.ts +60 -22
  38. package/lib/sandbox/workspace-view.ts +9 -2
  39. package/lib/task/activity-log.ts +46 -7
  40. package/lib/task/commit-finalization.ts +23 -3
  41. package/lib/task/create-service.ts +171 -0
  42. package/lib/task/create.ts +372 -0
  43. package/lib/task/orchestration.ts +182 -18
  44. package/lib/task/review-fingerprint.ts +9 -0
  45. package/lib/task/workspace-snapshot.ts +98 -4
  46. package/package.json +7 -7
  47. package/templates/.agents/hooks/lifecycle-delegation.js +47 -3
  48. package/templates/.agents/rules/task-management.en.md +1 -0
  49. package/templates/.agents/rules/task-management.zh-CN.md +1 -0
  50. package/templates/.agents/skills/commit/SKILL.en.md +3 -9
  51. package/templates/.agents/skills/commit/SKILL.zh-CN.md +6 -10
  52. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +4 -3
  53. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +5 -4
  54. package/templates/.agents/skills/create-task/SKILL.en.md +26 -43
  55. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +26 -43
  56. package/templates/.codex/hooks.json +50 -0
@@ -31,21 +31,17 @@ description: >
31
31
 
32
32
  未显式指定 task scope 时,只有 `TASK_CONTEXT_NOT_FOUND` 可继续既有纯提交路径;detached HEAD、损坏候选或多匹配属于歧义,必须失败。显式 task scope 解析失败时一律失败。
33
33
 
34
- ## 步骤开始:先恢复,再写 started 标记
34
+ ## 步骤开始:恢复或创建受控 attempt
35
35
 
36
36
  已解析出 `{task-id}` 时,先调用 `agent-infra-internal task-orchestration {task-id} commit-status`:
37
37
 
38
- - `recoverable` / `prepared`:调用 `commit-recover --agent {standard-agent-token}`;不得追加第二条 started、重复 commit 或重复 push。recoverable 完成后直接进入同步与完成校验;prepared 清理后复用既有 open started 并继续正常提交。
38
+ - `recoverable`:调用 `commit-recover --agent {standard-agent-token}` 完成收尾,不得重复 commit 或 push。
39
+ - `prepared`:调用 `commit-recover --agent {standard-agent-token}` 安全清理 intent,再次查询 status 并复用返回的 `retryable-start` attempt。
40
+ - `retryable-start`:调用 `commit-recover --agent {standard-agent-token}` 取得原 attempt,不追加第二条 started。
39
41
  - `invalid` / `conflict` / `orphaned-start`:输出结构化 code 与状态证据并停止。
40
- - `idle`:继续下方正常流程。
42
+ - `idle`:调用 `commit-start --agent {standard-agent-token}`,由核心在任务锁内原子写入结构化 started 并返回 attempt/baseline。
41
43
 
42
- 开始检查本地修改之前,向 task.md `## 活动日志` 追加一条 started 标记(与本步骤 done 条目同基名 + ` [started]` 后缀,note 用 `started`):
43
-
44
- ```
45
- - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Commit [started]** by {agent} — started
46
- ```
47
-
48
- `ai task log` 会把它与提交完成时写入的 done 条目配对成一行(进行中 → 已完成)。格式与配对规则见 `.agents/rules/task-management.md` 的「Activity Log started / done 双标记约定」。仅当本任务存在 task.md 时写入(无任务上下文的纯提交可跳过)。
44
+ 只从 `commit-start` / `commit-recover` 的结构化输出读取 `{commit-attempt}`;不得手写、复制或猜测 attempt。无任务上下文的纯提交跳过本协议。
49
45
 
50
46
  ## 1. 检查本地修改(关键)
51
47
 
@@ -9,12 +9,12 @@ This protocol applies only when `{task-id}` was resolved. A taskless Git-only co
9
9
 
10
10
  ## Begin before side effects
11
11
 
12
- Call `commit-status` whenever the commit skill starts. For `recoverable` / `prepared`, call `commit-recover --agent {standard-agent-token}`; fail closed for every other non-`idle` state. The recovery intent accepts no token, head, or `--orchestrated` flag.
12
+ Call `commit-status` whenever the commit skill starts. Use `commit-recover --agent {standard-agent-token}` for `recoverable` / `prepared` / `retryable-start`; use `commit-start --agent {standard-agent-token}` for `idle`; fail closed for every other state. Read `commit_attempt` only from `finalization.attempt.attempt` in start/recover output.
13
13
 
14
14
  After read-only preparation of status, copyright, message, review snapshot, and push routing, record `baseline_head=$(git rev-parse HEAD)` and run this before any commit, push, success log, or platform success sync:
15
15
 
16
16
  ```bash
17
- commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head")
17
+ commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head" --attempt "$commit_attempt")
18
18
  commit_intent_token=$(printf '%s' "$commit_intent_result" | node -e 'let input = ""; process.stdin.on("data", chunk => input += chunk).on("end", () => process.stdout.write(JSON.parse(input).token))')
19
19
  ```
20
20
 
@@ -44,6 +44,7 @@ After the committed/pushed checkpoint and before task synchronization or `task-v
44
44
  agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
45
45
  ```
46
46
 
47
- - Before the first side effect, abort only while HEAD still equals the baseline by using `commit-abort --token ... --expected-head ...`.
47
+ - If an intent exists but no side effect occurred, use `commit-abort --token ... --expected-head ...` while HEAD still equals baseline; when abandoning the attempt, then close it with `commit-terminate --attempt "$commit_attempt" --agent {standard-agent-token} --code <STABLE_CODE>`.
48
+ - If begin failed before intent creation, retain the attempt for retry or terminate it only while HEAD is unchanged.
48
49
  - After a commit or push, never abort. Retain the intent and use `commit-status` / `commit-recover` for cross-session recovery.
49
50
  - Stop when `commit-complete` fails. Do not repeat commit/push or mark a run complete without its full receipt lifecycle.
@@ -9,18 +9,18 @@
9
9
 
10
10
  ## 副作用前 begin
11
11
 
12
- 每次进入 commit 技能先调用 `commit-status`。`recoverable` / `prepared` 调用以下无 token 恢复入口,其他非 `idle` 状态 fail closed:
12
+ 每次进入 commit 技能先调用 `commit-status`。`recoverable` / `prepared` / `retryable-start` 调用以下无 token 恢复入口,`idle` 调用 `commit-start --agent {standard-agent-token}`;其他状态 fail closed:
13
13
 
14
14
  ```bash
15
15
  agent-infra-internal task-orchestration {task-id} commit-recover --agent {standard-agent-token}
16
16
  ```
17
17
 
18
- 恢复入口只接受 `--agent`;不得传 token、head 或 `--orchestrated`。recoverable 会幂等补齐 task/run 并最后删除 intent;prepared 仅在 HEAD=baseline 且恰有一个 open Commit started 时安全清理,随后复用该 started 继续正常流程。
18
+ 恢复入口只接受 `--agent`;不得传 token、head 或 `--orchestrated`。从 start/recover 结构化输出读取 `finalization.attempt.attempt` 为 `commit_attempt`,不得手写 attempt。
19
19
 
20
20
  完成状态、版权、提交信息、review snapshot 和 push 场景的只读准备后,记录 `baseline_head=$(git rev-parse HEAD)`,并在任何 commit、push、任务成功日志或平台成功同步之前调用:
21
21
 
22
22
  ```bash
23
- commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head")
23
+ commit_intent_result=$(agent-infra-internal task-orchestration {task-id} commit-begin --agent {standard-agent-token} {execution-flag} --baseline-head "$baseline_head" --attempt "$commit_attempt")
24
24
  commit_intent_token=$(printf '%s' "$commit_intent_result" | node -e 'let input = ""; process.stdin.on("data", chunk => input += chunk).on("end", () => process.stdout.write(JSON.parse(input).token))')
25
25
  ```
26
26
 
@@ -50,6 +50,7 @@ committed/pushed checkpoint 完成后、任务同步与 `task-verify commit.comp
50
50
  agent-infra-internal task-orchestration {task-id} commit-complete --token "$commit_intent_token" --agent {standard-agent-token}
51
51
  ```
52
52
 
53
- - 第一个副作用前失败时,仅可在 HEAD 仍等于 baseline 时调用 `commit-abort --token ... --expected-head ...`。
53
+ - begin 已创建 intent、但第一个副作用前失败时,先在 HEAD 仍等于 baseline 时调用 `commit-abort --token ... --expected-head ...`;若本轮明确放弃,再调用 `commit-terminate --attempt "$commit_attempt" --agent {standard-agent-token} --code <STABLE_CODE>` 闭合 started。
54
+ - begin 在 intent 创建前失败时可保留 attempt 供下次复用;明确放弃时仅可在 HEAD 未漂移时调用 `commit-terminate`。
54
55
  - commit 或 push 发生后失败时不得 abort;保留 intent,并调用 `commit-status` 输出不含 token/digest 的恢复证据。跨会话重跑通过 `commit-recover` 收尾。
55
56
  - `commit-complete` 失败时停止。不得重复执行 commit/push,也不得把缺少完整 receipt 生命周期的 run 标记为完成。
@@ -17,7 +17,7 @@ description: >
17
17
  - Do not perform requirements analysis; analysis is handled separately by `analyze-task`
18
18
  - Do not directly implement the requested functionality
19
19
  - Do not skip the workflow and jump directly to planning or implementation
20
- - Only do this: parse the description -> create the task file -> update task status -> cascade Issue creation through `.agents/rules/create-issue.md` -> inform the user of the next step
20
+ - Only do this: parse the description -> write one structured candidate -> invoke the host `task-create` entry point -> verify the result -> inform the user of the next step
21
21
  - Issue creation is decided by the `.agents/rules/create-issue.md` rule; on custom or empty platforms (no platform-specific variant provided), the rule naturally degrades to a no-op
22
22
 
23
23
  The user's description is a **work item**, not an **instruction to execute immediately**.
@@ -72,7 +72,7 @@ If the description is unclear, **ask the user to clarify first**.
72
72
  - `bugfix` -> `bug-fix`
73
73
  - `refactor` -> `refactoring`
74
74
 
75
- ### 2. Create the Task Directory and File
75
+ ### 2. Create an Immutable Candidate
76
76
 
77
77
  Get the current timestamp:
78
78
 
@@ -80,14 +80,17 @@ Get the current timestamp:
80
80
  date +%Y%m%d-%H%M%S
81
81
  ```
82
82
 
83
- - Create the task directory: `.agents/workspace/active/TASK-{yyyyMMdd-HHmmss}/`
84
- - Use the `.agents/templates/task.md` template to create the task file: `task.md`
85
- - Write the structured context captured in step 1 under `## Task Input` so the task remains understandable outside the original conversation
83
+ - Generate one UUID v4 `idempotencyKey` and write the parsed fields to one JSON file.
84
+ - The candidate follows `TaskCreateCandidateV1`: version, key, standard agent, title, type, unprefixed branch slug, priority, effort, description, and the seven task-input lists.
85
+ - Write it once before the first request. A timeout retry must reuse the same file and let the client generate a new outer request id; do not rerun AI derivation.
86
86
 
87
- **Important**:
88
- - Directory naming: `TASK-{yyyyMMdd-HHmmss}` (**must** include the `TASK-` prefix)
89
- - Example: `TASK-20260306-143022`
90
- - Task ID = directory name
87
+ Invoke the single entry point:
88
+
89
+ ```bash
90
+ agent-infra-internal task-create --input "$candidate_file"
91
+ ```
92
+
93
+ The host owns TASK-id/timestamps/version, workflow and branch derivation, template rendering, atomic persistence, short ids, Issue sync, and warnings. The skill must not create task directories, copy templates, allocate short ids, or call platform subcommands directly.
91
94
 
92
95
  Task metadata (`task.md` YAML front matter):
93
96
  ```yaml
@@ -109,7 +112,7 @@ assigned_to: {current AI agent}
109
112
 
110
113
  priority / effort are required: the AI infers them from the task title and description (candidates in `.agents/rules/issue-fields.md`; normalize localized input). Leave start_date / target_date empty at creation: `start_date` is written by the analyze stage and `target_date` by the complete stage; do not invent dates.
111
114
 
112
- ### 3. Update Task Status
115
+ ### 3. Handle the Structured Result
113
116
 
114
117
  Get the current time:
115
118
 
@@ -117,43 +120,25 @@ Get the current time:
117
120
  date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
118
121
  ```
119
122
 
120
- Update `.agents/workspace/active/{task-id}/task.md`:
121
- - `current_step`: requirement-analysis
122
- - `assigned_to`: {current AI agent}
123
- - `updated_at`: {current time}
124
- - `agent_infra_version`: value from `.agents/rules/version-stamp.md`
125
- - `## Context` -> `- **Branch**:`: update it to the generated branch name
126
- - **Append** to `## Activity Log` (do NOT overwrite previous entries):
127
- ```
128
- - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Create Task** by {agent} — Task created from description
129
- ```
123
+ - `applied` / `no-op`: use the returned task id, short id, and optional Issue identity; do not discover them by scanning directories.
124
+ - `degraded`: the local task is retained; display the returned warning.
125
+ - `blocked`: retain the candidate and retry the same file after the transient problem is fixed.
126
+ - `failed`: report the stable error code. Never modify and retry a candidate under the same idempotency key.
130
127
 
131
- ### 4. Cascade Issue Creation and Metadata Sync
128
+ ### 4. Platform Failure Compatibility
132
129
 
133
- After task.md is written, call the declarative intents; the internal core owns templates, body rendering, identity validation, capability degradation, idempotency, and task binding:
130
+ The host service owns platform cascading. The compatibility recovery commands remain visible in the host warning and are not run from the sandbox:
134
131
 
135
132
  ```bash
136
- agent-infra-internal platform-issue create {task-id} --agent {standard-agent-token}
137
- agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status waiting-for-triage --assignees current --milestone initial --issue-type --fields
133
+ agent-infra-internal task-warning {task-id} add --step create-task --severity ACTION_REQUIRED --code ISSUE_CREATE_FAILED --target issue --message "{error_code}: {error_message}" --action "Fix auth/network/template issues and manually retry Issue creation, or create/find an Issue and write issue_number"
134
+ agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}
138
135
  ```
139
136
 
140
- Handle the result:
141
- - Intent created the Issue: `issue_number` was written through the task writer; run `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
142
- - Rule failed (auth / network / template parse / etc.): do not roll back task.md or append an extra Activity Log entry; run `agent-infra-internal task-warning {task-id} add --step create-task --severity ACTION_REQUIRED --code ISSUE_CREATE_FAILED --target issue --message "{error_code}: {error_message}" --action "Fix auth/network/template issues and manually retry Issue creation, or create/find an Issue and write issue_number"` to submit a structured warning intent (callers do not allocate ids or edit rows), then follow Scenario C
143
- - Intent returned no-op/degraded: continue applicable operations without blocking the workflow
144
- - task.md already has a valid `issue_number`: create validates the binding and returns no-op without creating a duplicate
137
+ The skill only consumes the Issue identity, operations, and warnings returned by the host; it must not repeat platform writes.
145
138
 
146
139
  ### 5. Verification Gate
147
140
 
148
- **Allocate short id first** (ensures the registry entry is allocated; the validation gate will read it):
149
-
150
- ```bash
151
- node .agents/scripts/task-short-id.js alloc "$task_id"
152
- ```
153
-
154
- If this fails (non-zero exit), follow the message — archive some active tasks or raise `task.shortIdLength` — and do NOT continue.
155
-
156
- Run the verification gate to confirm the task artifact and sync state are valid:
141
+ The host `task-create` service runs the same typed gate before returning. Consume the returned `task:verify` operation; a branch-only sandbox must not try to read the invisible new task. For direct host diagnostics, run:
157
142
 
158
143
  ```bash
159
144
  agent-infra-internal task-verify {task-id} create-task.completed --format text
@@ -244,12 +229,10 @@ For later platform sync: after fixing auth / network / template issues, manually
244
229
 
245
230
  ## Completion Checklist
246
231
 
247
- - [ ] Created the task file `.agents/workspace/active/{task-id}/task.md`
232
+ - [ ] Wrote one candidate and invoked `agent-infra-internal task-create`
233
+ - [ ] The host created `.agents/workspace/active/{task-id}/task.md`
248
234
  - [ ] Wrote and checked `## Task Input` source and state semantics according to `reference/context-capture.md`
249
- - [ ] Updated `current_step` to requirement-analysis in task.md
250
- - [ ] Updated `updated_at` to the current time in task.md
251
- - [ ] Updated `assigned_to` in task.md
252
- - [ ] Appended an Activity Log entry to task.md
235
+ - [ ] The returned task id and short id passed completion verification
253
236
  - [ ] Tried cascading Issue creation through `.agents/rules/create-issue.md`; if it failed, kept task.md and recorded the reason
254
237
  - [ ] Rendered the selected next-step commands through the shared helper
255
238
  - [ ] **Did not modify any business code or configuration files**
@@ -17,7 +17,7 @@ description: >
17
17
  - 不要执行需求分析;分析由 `analyze-task` 独立完成
18
18
  - 不要直接实现所描述的功能
19
19
  - 不要跳过工作流直接进入计划/实现阶段
20
- - 仅执行:解析描述 -> 创建任务文件 -> 更新任务状态 -> 按 `.agents/rules/create-issue.md` 级联尝试创建 Issue -> 告知用户下一步
20
+ - 仅执行:解析描述 -> 一次性生成结构化 candidate -> 调用宿主 `task-create` 入口 -> 校验结果 -> 告知用户下一步
21
21
  - Issue 创建由 `.agents/rules/create-issue.md` 规则决定;自定义或空平台(未提供平台变体规则文件)时,规则会自然降级为 no-op
22
22
 
23
23
  用户的描述是一个**待办事项**,而不是**立即执行的指令**。
@@ -71,7 +71,7 @@ description: >
71
71
  - `bugfix` -> `bug-fix`
72
72
  - `refactor` -> `refactoring`
73
73
 
74
- ### 2. 创建任务目录和文件
74
+ ### 2. 生成不可变 candidate
75
75
 
76
76
  获取当前时间戳:
77
77
 
@@ -79,14 +79,17 @@ description: >
79
79
  date +%Y%m%d-%H%M%S
80
80
  ```
81
81
 
82
- - 创建任务目录:`.agents/workspace/active/TASK-{yyyyMMdd-HHmmss}/`
83
- - 使用 `.agents/templates/task.md` 模板创建任务文件:`task.md`
84
- - 将步骤 1 捕获的结构化上下文写入 `## 任务输入`,确保任务文件脱离原会话后仍可理解
82
+ - 生成随机 UUID v4 作为 `idempotencyKey`,并把步骤 1 的结果写入单个 JSON 文件。
83
+ - candidate 必须符合宿主 `TaskCreateCandidateV1`:`version`、`idempotencyKey`、标准 `agent`、`title`、`type`、不带项目前缀的 `branchSlug`、`priority`、`effort`、`description` 和 `taskInput` 七类列表。
84
+ - 首次提交前只写一次 candidate;等待终态期间不得重新运行 AI 推导或改写文件。超时重试必须复用同一文件,由客户端生成新的 outer request ID。
85
85
 
86
- **重要**:
87
- - 目录命名:`TASK-{yyyyMMdd-HHmmss}`(**必须**包含 `TASK-` 前缀)
88
- - 示例:`TASK-20260306-143022`
89
- - 任务 ID = 目录名
86
+ 调用统一入口:
87
+
88
+ ```bash
89
+ agent-infra-internal task-create --input "$candidate_file"
90
+ ```
91
+
92
+ 宿主负责 TASK-id/时间戳/版本戳、workflow/branch 派生、模板渲染、原子持久化、短号、Issue 与 warning。技能不得自行 `mkdir`、复制任务模板、分配短号或直接调用平台子命令。
90
93
 
91
94
  任务元数据(task.md YAML front matter):
92
95
  ```yaml
@@ -108,7 +111,7 @@ assigned_to: {当前 AI 代理}
108
111
 
109
112
  priority / effort 必填:由 AI 从任务标题与描述推断后填入(候选值见 `.agents/rules/issue-fields.md`;中文输入按本地化映射规范化)。start_date / target_date 创建时保持留空:`start_date` 由 analyze 阶段写入、`target_date` 由 complete 阶段写入;不要臆测日期。
110
113
 
111
- ### 3. 更新任务状态
114
+ ### 3. 处理结构化结果
112
115
 
113
116
  获取当前时间:
114
117
 
@@ -116,43 +119,25 @@ priority / effort 必填:由 AI 从任务标题与描述推断后填入(候
116
119
  date "+%Y-%m-%d %H:%M:%S%z" | sed 's/\([+-][0-9][0-9]\)\([0-9][0-9]\)$/\1:\2/'
117
120
  ```
118
121
 
119
- 更新 `.agents/workspace/active/{task-id}/task.md`:
120
- - `current_step`:requirement-analysis
121
- - `assigned_to`:{当前 AI 代理}
122
- - `updated_at`:{当前时间}
123
- - `agent_infra_version`:按 `.agents/rules/version-stamp.md` 取值
124
- - `## 上下文` 中的 `- **分支**:`:更新为生成的分支名
125
- - **追加**到 `## Activity Log`(不要覆盖之前的记录):
126
- ```
127
- - {YYYY-MM-DD HH:mm:ss±HH:MM} — **Create Task** by {agent} — Task created from description
128
- ```
122
+ - `applied` / `no-op`:从响应读取 task ID、短号与可选 Issue 身份;不得从目录扫描推断。
123
+ - `degraded`:本地任务已经保留;展示响应中的 warning。
124
+ - `blocked`:保留 candidate 文件,修复暂态问题后用同一文件重试。
125
+ - `failed`:报告稳定错误码;幂等冲突时不得改写原 key 或原 candidate 后重试。
129
126
 
130
- ### 4. 级联创建并同步 Issue
127
+ ### 4. 平台失败兼容说明
131
128
 
132
- 在 task.md 落盘并记录 `Create Task` 后调用声明式 Issue intent;标题、正文、模板、身份校验、权限降级、幂等创建和 task.md 绑定均由 internal core 处理:
129
+ 平台级联由宿主服务完成。兼容的人工恢复命令仍由宿主 warning 指引,不在沙箱内执行:
133
130
 
134
131
  ```bash
135
- agent-infra-internal platform-issue create {task-id} --agent {standard-agent-token}
136
- agent-infra-internal platform-issue sync {task-id} --agent {standard-agent-token} --status waiting-for-triage --assignees current --milestone initial --issue-type --fields
132
+ agent-infra-internal task-warning {task-id} add --step create-task --severity ACTION_REQUIRED --code ISSUE_CREATE_FAILED --target issue --message "{error_code}: {error_message}" --action "修复认证/网络/模板问题后手动重试 Issue 创建,或手动创建/找到 Issue 后写入 issue_number"
133
+ agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}
137
134
  ```
138
135
 
139
- 处理结果:
140
- - intent 成功创建 Issue:`issue_number` 已由任务写入内核回写;调用 `agent-infra-internal platform-comment sync {task-id} --kind task --agent {standard-agent-token}`
141
- - 规则失败(认证 / 网络 / 模板解析等):不回滚 task.md;不追加额外 Activity Log;先调用 `agent-infra-internal task-warning {task-id} add --step create-task --severity ACTION_REQUIRED --code ISSUE_CREATE_FAILED --target issue --message "{error_code}: {error_message}" --action "修复认证/网络/模板问题后手动重试 Issue 创建,或手动创建/找到 Issue 后写入 issue_number"` 提交结构化 warning 意图(调用方不分配编号或写表格);再按"场景 C:Issue 创建失败"输出
142
- - intent 为 no-op/degraded:按结构化 operations 继续可执行部分;自定义或空平台不创建评论且不阻塞工作流
143
- - task.md 已存在有效 `issue_number`:create intent 校验绑定后返回 no-op,不重复创建
136
+ 技能只消费宿主返回的 Issue identity、operations 与 warnings;不得重复发起平台写入。
144
137
 
145
138
  ### 5. 完成校验
146
139
 
147
- **先调用短号分配**(保证注册表 entry 已分配;完成校验阶段会读取):
148
-
149
- ```bash
150
- node .agents/scripts/task-short-id.js alloc "$task_id"
151
- ```
152
-
153
- 如失败(退出码非 0),按提示「归档若干任务」或「调高 task.shortIdLength」处理;不要继续执行后续步骤。
154
-
155
- 运行完成校验,确认任务产物和同步状态符合规范:
140
+ 宿主 `task-create` 服务在返回前运行同一 typed 完成校验;技能从响应的 `task:verify` operation 取得当次结果。branch-only 不得尝试读取不可见的新任务。宿主直接诊断时可运行:
156
141
 
157
142
  ```bash
158
143
  agent-infra-internal task-verify {task-id} create-task.completed --format text
@@ -243,12 +228,10 @@ Issue 创建失败:
243
228
 
244
229
  ## 完成检查清单
245
230
 
246
- - [ ] 创建了任务文件 `.agents/workspace/active/{task-id}/task.md`
231
+ - [ ] 只生成一次结构化 candidate 并调用 `agent-infra-internal task-create`
232
+ - [ ] 宿主创建了任务文件 `.agents/workspace/active/{task-id}/task.md`
247
233
  - [ ] 已按 `reference/context-capture.md` 写入并复核 `## 任务输入` 的来源与状态语义
248
- - [ ] 更新了 task.md 中的 `current_step` 为 requirement-analysis
249
- - [ ] 更新了 task.md 中的 `updated_at` 为当前时间
250
- - [ ] 更新了 task.md 中的 `assigned_to`
251
- - [ ] 追加了 Activity Log 条目到 task.md
234
+ - [ ] 响应中的任务 ID 和短号已通过完成校验
252
235
  - [ ] 已按 `.agents/rules/create-issue.md` 尝试级联创建 Issue;失败时保留 task.md 并记录原因
253
236
  - [ ] 已通过统一 helper 渲染已选场景的下一步命令
254
237
  - [ ] **没有修改任何业务代码或配置文件**
@@ -11,6 +11,56 @@
11
11
  "statusMessage": "Checking template version before git commit"
12
12
  }
13
13
  ]
14
+ },
15
+ {
16
+ "matcher": "^collaborationspawn_agent$",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "node \"$(git rev-parse --show-toplevel)/.agents/hooks/lifecycle-delegation.js\" --client codex --event pre-tool",
21
+ "timeout": 5,
22
+ "statusMessage": "Recording Codex lifecycle spawn evidence"
23
+ }
24
+ ]
25
+ }
26
+ ],
27
+ "PostToolUse": [
28
+ {
29
+ "matcher": "^collaborationspawn_agent$",
30
+ "hooks": [
31
+ {
32
+ "type": "command",
33
+ "command": "node \"$(git rev-parse --show-toplevel)/.agents/hooks/lifecycle-delegation.js\" --client codex --event post-tool",
34
+ "timeout": 5,
35
+ "statusMessage": "Recording Codex lifecycle tool completion"
36
+ }
37
+ ]
38
+ }
39
+ ],
40
+ "SubagentStart": [
41
+ {
42
+ "matcher": "^agent-infra-lifecycle-(executor|reviewer)$",
43
+ "hooks": [
44
+ {
45
+ "type": "command",
46
+ "command": "node \"$(git rev-parse --show-toplevel)/.agents/hooks/lifecycle-delegation.js\" --client codex --event subagent-start",
47
+ "timeout": 5,
48
+ "statusMessage": "Recording Codex child identity"
49
+ }
50
+ ]
51
+ }
52
+ ],
53
+ "SubagentStop": [
54
+ {
55
+ "matcher": "^agent-infra-lifecycle-(executor|reviewer)$",
56
+ "hooks": [
57
+ {
58
+ "type": "command",
59
+ "command": "node \"$(git rev-parse --show-toplevel)/.agents/hooks/lifecycle-delegation.js\" --client codex --event subagent-stop",
60
+ "timeout": 5,
61
+ "statusMessage": "Recording Codex child stop evidence"
62
+ }
63
+ ]
14
64
  }
15
65
  ]
16
66
  }