@fitlab-ai/agent-infra 0.12.0 → 0.12.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 (331) hide show
  1. package/README.md +0 -2
  2. package/README.zh-CN.md +0 -2
  3. package/dist/bin/internal-cli.js +2 -17
  4. package/dist/lib/agent-clients/adapter.js +0 -13
  5. package/dist/lib/agent-clients/adapters/antigravity-cli.js +0 -5
  6. package/dist/lib/agent-clients/adapters/claude-code-credentials.js +0 -17
  7. package/dist/lib/agent-clients/adapters/claude-code.js +0 -9
  8. package/dist/lib/agent-clients/adapters/codex.js +0 -52
  9. package/dist/lib/agent-clients/adapters/opencode.js +0 -5
  10. package/dist/lib/agent-clients/adapters/traecli.js +0 -5
  11. package/dist/lib/agent-clients/config.js +19 -54
  12. package/dist/lib/agent-clients/registry.js +1 -12
  13. package/dist/lib/agent-clients/schema.js +0 -18
  14. package/dist/lib/agent-clients/tokens.js +1 -2
  15. package/dist/lib/agent-clients/types.js +0 -1
  16. package/dist/lib/decide.js +2 -0
  17. package/dist/lib/git/worktree-identity.js +1 -9
  18. package/dist/lib/internal/agent-client.js +2 -62
  19. package/dist/lib/internal/cli-route-inventory.js +1 -5
  20. package/dist/lib/internal/manual-validation.js +29 -27
  21. package/dist/lib/internal/platform-comment.js +56 -7
  22. package/dist/lib/internal/task-create.js +1 -1
  23. package/dist/lib/internal/task-event.js +1 -8
  24. package/dist/lib/internal/task-finalization.js +0 -1
  25. package/dist/lib/internal/task-lifecycle.js +2 -2
  26. package/dist/lib/internal/task-operation-registry.js +4 -20
  27. package/dist/lib/internal/task-review.js +4 -4
  28. package/dist/lib/platform/comment-safety.js +1 -7
  29. package/dist/lib/platform/in-label-sync.js +1 -14
  30. package/dist/lib/platform/issue-comments.js +373 -282
  31. package/dist/lib/platform/issue-summary-content.js +112 -0
  32. package/dist/lib/platform/issues.js +1 -1
  33. package/dist/lib/platform/operation-coordinator.js +4 -2
  34. package/dist/lib/platform/pr-change-report.js +176 -30
  35. package/dist/lib/platform/pr-checks.js +2 -8
  36. package/dist/lib/platform/pr-summary-content.js +54 -0
  37. package/dist/lib/platform/pr-summary.js +318 -284
  38. package/dist/lib/platform/provider-validation.js +0 -20
  39. package/dist/lib/platform/pull-requests.js +73 -84
  40. package/dist/lib/platform/releases.js +1 -43
  41. package/dist/lib/platform/summary-content-pipeline.js +18 -0
  42. package/dist/lib/platform/verification-required.js +0 -2
  43. package/dist/lib/platform/verification-sync.js +1 -79
  44. package/dist/lib/process-data/normalize.js +1 -185
  45. package/dist/lib/process-data/privacy.js +1 -16
  46. package/dist/lib/process-data/sources.js +2 -279
  47. package/dist/lib/render.js +0 -12
  48. package/dist/lib/run/index.js +15 -10
  49. package/dist/lib/run/skills.js +0 -3
  50. package/dist/lib/sandbox/commands/create.js +40 -53
  51. package/dist/lib/sandbox/commands/list-running.js +0 -18
  52. package/dist/lib/sandbox/commands/start.js +7 -8
  53. package/dist/lib/sandbox/constants.js +0 -6
  54. package/dist/lib/sandbox/control/client.js +0 -1
  55. package/dist/lib/sandbox/control/container-identity.js +1 -16
  56. package/dist/lib/sandbox/control/executor.js +0 -4
  57. package/dist/lib/sandbox/control/identity-sentinel.js +0 -7
  58. package/dist/lib/sandbox/control/lifecycle.js +21 -37
  59. package/dist/lib/sandbox/control/native-file-lock.js +0 -3
  60. package/dist/lib/sandbox/control/server.js +18 -38
  61. package/dist/lib/sandbox/control/state.js +1 -9
  62. package/dist/lib/sandbox/dockerfile.js +0 -6
  63. package/dist/lib/sandbox/engine.js +0 -14
  64. package/dist/lib/sandbox/engines/docker-exact-discovery.js +1 -4
  65. package/dist/lib/sandbox/engines/wsl2-paths.js +0 -3
  66. package/dist/lib/sandbox/recovery.js +24 -26
  67. package/dist/lib/sandbox/removal.js +67 -518
  68. package/dist/lib/sandbox/task-resolver.js +0 -41
  69. package/dist/lib/sandbox/tools.js +1 -4
  70. package/dist/lib/sandbox/workspace-view.js +1 -2
  71. package/dist/lib/server/display.js +0 -6
  72. package/dist/lib/task/activity-intent.js +45 -40
  73. package/dist/lib/task/activity-log.js +9 -16
  74. package/dist/lib/task/artifact-command.js +1 -1
  75. package/dist/lib/task/artifact-lifecycle.js +61 -63
  76. package/dist/lib/task/artifact-name.js +0 -6
  77. package/dist/lib/task/artifact-operations.js +3 -3
  78. package/dist/lib/task/capabilities.js +4 -5
  79. package/dist/lib/task/commands/log.js +0 -6
  80. package/dist/lib/task/commands/status.js +17 -60
  81. package/dist/lib/task/commit-operation.js +28 -39
  82. package/dist/lib/task/completion-facts.js +56 -43
  83. package/dist/lib/task/control-authority.js +23 -256
  84. package/dist/lib/task/control-recovery.js +3 -5
  85. package/dist/lib/task/create.js +2 -4
  86. package/dist/lib/task/decision-intents.js +8 -9
  87. package/dist/lib/task/delivery-target.js +1 -40
  88. package/dist/lib/task/events.js +84 -107
  89. package/dist/lib/task/finalization.js +60 -15
  90. package/dist/lib/task/ledger-intents.js +1 -1
  91. package/dist/lib/task/lifecycle-execution.js +38 -33
  92. package/dist/lib/task/lifecycle.js +49 -41
  93. package/dist/lib/task/local-artifact-finalization.js +1 -4
  94. package/dist/lib/task/manual-validation-evidence.js +1 -37
  95. package/dist/lib/task/platform-operation-recovery.js +151 -108
  96. package/dist/lib/task/pr-delivery-fact.js +2 -5
  97. package/dist/lib/task/qualification-confirmation.js +5 -7
  98. package/dist/lib/task/resolve-ref.js +1 -25
  99. package/dist/lib/task/review-command.js +2 -2
  100. package/dist/lib/task/review-finalization.js +1 -21
  101. package/dist/lib/task/review-fingerprint.js +0 -4
  102. package/dist/lib/task/secure-fs.js +0 -56
  103. package/dist/lib/task/short-id.js +1 -39
  104. package/dist/lib/task/skill-scope.js +0 -1
  105. package/dist/lib/task/verification-engine.js +58 -282
  106. package/dist/lib/task/verification.js +6 -3
  107. package/dist/lib/task/write.js +11 -1
  108. package/lib/agent-clients/adapter.ts +0 -76
  109. package/lib/agent-clients/adapters/antigravity-cli.ts +0 -5
  110. package/lib/agent-clients/adapters/claude-code-credentials.ts +0 -19
  111. package/lib/agent-clients/adapters/claude-code.ts +0 -9
  112. package/lib/agent-clients/adapters/codex.ts +0 -56
  113. package/lib/agent-clients/adapters/opencode.ts +0 -5
  114. package/lib/agent-clients/adapters/traecli.ts +0 -5
  115. package/lib/agent-clients/config.ts +20 -61
  116. package/lib/agent-clients/registry.ts +1 -34
  117. package/lib/agent-clients/schema.ts +0 -18
  118. package/lib/agent-clients/tokens.ts +1 -2
  119. package/lib/agent-clients/types.ts +0 -15
  120. package/lib/decide.ts +1 -0
  121. package/lib/git/worktree-identity.ts +0 -10
  122. package/lib/internal/agent-client.ts +2 -70
  123. package/lib/internal/cli-route-inventory.ts +1 -4
  124. package/lib/internal/manual-validation.ts +28 -27
  125. package/lib/internal/platform-comment.ts +46 -4
  126. package/lib/internal/task-create.ts +0 -1
  127. package/lib/internal/task-event.ts +1 -5
  128. package/lib/internal/task-finalization.ts +0 -1
  129. package/lib/internal/task-lifecycle.ts +3 -5
  130. package/lib/internal/task-operation-registry.ts +3 -19
  131. package/lib/internal/task-review.ts +4 -4
  132. package/lib/platform/comment-safety.ts +0 -10
  133. package/lib/platform/github-provider.ts +0 -2
  134. package/lib/platform/in-label-sync.ts +0 -16
  135. package/lib/platform/issue-comments.ts +478 -301
  136. package/lib/platform/issue-summary-content.ts +132 -0
  137. package/lib/platform/issues.ts +0 -2
  138. package/lib/platform/operation-coordinator.ts +4 -2
  139. package/lib/platform/pr-change-report.ts +165 -25
  140. package/lib/platform/pr-checks.ts +1 -10
  141. package/lib/platform/pr-review.ts +1 -1
  142. package/lib/platform/pr-summary-content.ts +60 -0
  143. package/lib/platform/pr-summary.ts +364 -257
  144. package/lib/platform/provider-bridge.ts +0 -1
  145. package/lib/platform/provider-loader.ts +1 -5
  146. package/lib/platform/provider-validation.ts +1 -49
  147. package/lib/platform/pull-requests.ts +64 -99
  148. package/lib/platform/releases.ts +1 -40
  149. package/lib/platform/summary-content-pipeline.ts +23 -0
  150. package/lib/platform/verification-required.ts +0 -2
  151. package/lib/platform/verification-sync.ts +0 -94
  152. package/lib/process-data/normalize.ts +1 -186
  153. package/lib/process-data/privacy.ts +2 -19
  154. package/lib/process-data/sources.ts +3 -283
  155. package/lib/render.ts +0 -15
  156. package/lib/run/index.ts +13 -7
  157. package/lib/run/skills.ts +0 -4
  158. package/lib/sandbox/commands/create.ts +37 -74
  159. package/lib/sandbox/commands/list-running.ts +0 -19
  160. package/lib/sandbox/commands/start.ts +7 -10
  161. package/lib/sandbox/constants.ts +0 -8
  162. package/lib/sandbox/control/client.ts +0 -1
  163. package/lib/sandbox/control/container-identity.ts +1 -16
  164. package/lib/sandbox/control/executor.ts +1 -5
  165. package/lib/sandbox/control/identity-sentinel.ts +0 -8
  166. package/lib/sandbox/control/lifecycle.ts +18 -51
  167. package/lib/sandbox/control/native-file-lock.ts +0 -8
  168. package/lib/sandbox/control/protocol.ts +0 -2
  169. package/lib/sandbox/control/server.ts +13 -39
  170. package/lib/sandbox/control/state.ts +1 -10
  171. package/lib/sandbox/dockerfile.ts +0 -11
  172. package/lib/sandbox/engine.ts +0 -17
  173. package/lib/sandbox/engines/docker-exact-discovery.ts +1 -5
  174. package/lib/sandbox/engines/wsl2-paths.ts +0 -4
  175. package/lib/sandbox/recovery.ts +24 -26
  176. package/lib/sandbox/removal.ts +58 -687
  177. package/lib/sandbox/shell.ts +1 -1
  178. package/lib/sandbox/task-resolver.ts +0 -48
  179. package/lib/sandbox/tools.ts +1 -5
  180. package/lib/sandbox/workspace-view.ts +2 -4
  181. package/lib/server/display.ts +0 -14
  182. package/lib/server/process-control.ts +1 -1
  183. package/lib/task/activity-intent.ts +36 -44
  184. package/lib/task/activity-log.ts +9 -22
  185. package/lib/task/artifact-command.ts +1 -1
  186. package/lib/task/artifact-lifecycle.ts +58 -67
  187. package/lib/task/artifact-name.ts +0 -7
  188. package/lib/task/artifact-operations.ts +3 -3
  189. package/lib/task/capabilities.ts +5 -6
  190. package/lib/task/commands/log.ts +0 -7
  191. package/lib/task/commands/status.ts +14 -79
  192. package/lib/task/commit-operation.ts +29 -51
  193. package/lib/task/completion-facts.ts +45 -42
  194. package/lib/task/control-authority.ts +27 -317
  195. package/lib/task/control-recovery.ts +2 -5
  196. package/lib/task/create.ts +2 -5
  197. package/lib/task/decision-intents.ts +5 -5
  198. package/lib/task/delivery-target.ts +0 -40
  199. package/lib/task/events.ts +89 -123
  200. package/lib/task/finalization.ts +52 -15
  201. package/lib/task/ledger-intents.ts +1 -1
  202. package/lib/task/lifecycle-execution.ts +37 -89
  203. package/lib/task/lifecycle.ts +48 -44
  204. package/lib/task/local-artifact-finalization.ts +0 -7
  205. package/lib/task/manual-validation-evidence.ts +1 -47
  206. package/lib/task/platform-operation-recovery.ts +117 -104
  207. package/lib/task/pr-delivery-fact.ts +2 -11
  208. package/lib/task/qualification-confirmation.ts +6 -6
  209. package/lib/task/resolve-ref.ts +0 -23
  210. package/lib/task/review-command.ts +2 -2
  211. package/lib/task/review-finalization.ts +1 -27
  212. package/lib/task/review-fingerprint.ts +0 -8
  213. package/lib/task/secure-fs.ts +0 -42
  214. package/lib/task/short-id.ts +0 -43
  215. package/lib/task/skill-scope.ts +0 -1
  216. package/lib/task/verification-engine.ts +56 -287
  217. package/lib/task/verification.ts +5 -5
  218. package/lib/task/write.ts +12 -1
  219. package/package.json +2 -2
  220. package/templates/.agents/README.en.md +1 -3
  221. package/templates/.agents/README.zh-CN.md +0 -2
  222. package/templates/.agents/rules/README.en.md +0 -1
  223. package/templates/.agents/rules/README.zh-CN.md +0 -1
  224. package/templates/.agents/rules/commit-and-pr.en.md +1 -1
  225. package/templates/.agents/rules/commit-and-pr.zh-CN.md +1 -1
  226. package/templates/.agents/rules/no-mid-flow-questions.en.md +0 -10
  227. package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +0 -10
  228. package/templates/.agents/rules/pr-sync.en.md +4 -2
  229. package/templates/.agents/rules/pr-sync.zh-CN.md +6 -9
  230. package/templates/.agents/rules/task-management.en.md +3 -3
  231. package/templates/.agents/rules/task-management.zh-CN.md +3 -3
  232. package/templates/.agents/skills/analyze-task/SKILL.en.md +3 -3
  233. package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +3 -3
  234. package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
  235. package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
  236. package/templates/.agents/skills/code-task/SKILL.en.md +2 -2
  237. package/templates/.agents/skills/code-task/SKILL.zh-CN.md +4 -4
  238. package/templates/.agents/skills/commit/SKILL.en.md +2 -2
  239. package/templates/.agents/skills/commit/SKILL.zh-CN.md +2 -2
  240. package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +6 -6
  241. package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +6 -6
  242. package/templates/.agents/skills/commit/reference/pr-summary-sync.en.md +1 -1
  243. package/templates/.agents/skills/commit/reference/pr-summary-sync.zh-CN.md +1 -1
  244. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.en.md +2 -2
  245. package/templates/.agents/skills/complete-manual-validation/reference/summary-update.zh-CN.md +2 -2
  246. package/templates/.agents/skills/complete-task/SKILL.en.md +10 -25
  247. package/templates/.agents/skills/complete-task/SKILL.zh-CN.md +11 -26
  248. package/templates/.agents/skills/create-pr/SKILL.en.md +1 -1
  249. package/templates/.agents/skills/create-pr/SKILL.zh-CN.md +1 -1
  250. package/templates/.agents/skills/create-pr/reference/change-report.en.md +9 -2
  251. package/templates/.agents/skills/create-pr/reference/change-report.zh-CN.md +9 -2
  252. package/templates/.agents/skills/create-pr/reference/comment-publish.en.md +2 -2
  253. package/templates/.agents/skills/create-pr/reference/comment-publish.zh-CN.md +2 -2
  254. package/templates/.agents/skills/create-task/SKILL.en.md +0 -18
  255. package/templates/.agents/skills/create-task/SKILL.zh-CN.md +0 -18
  256. package/templates/.agents/skills/plan-task/SKILL.en.md +2 -2
  257. package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -2
  258. package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
  259. package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
  260. package/templates/.agents/skills/review-code/SKILL.en.md +5 -5
  261. package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -5
  262. package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
  263. package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
  264. package/templates/.agents/skills/review-pr/SKILL.en.md +4 -4
  265. package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +4 -4
  266. package/templates/.agents/skills/run-manual-validation/SKILL.en.md +1 -1
  267. package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +1 -1
  268. package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +3 -75
  269. package/templates/.agents/skills/watch-pr/SKILL.en.md +1 -1
  270. package/templates/.agents/skills/watch-pr/SKILL.zh-CN.md +1 -1
  271. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.en.md +3 -3
  272. package/templates/.agents/skills/watch-pr/reference/monitor-and-heal.zh-CN.md +3 -3
  273. package/templates/.agents/templates/task.en.md +1 -0
  274. package/templates/.agents/templates/task.zh-CN.md +1 -0
  275. package/templates/.claude/settings.json +0 -24
  276. package/templates/.codex/hooks.json +0 -50
  277. package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +0 -582
  278. package/dist/lib/agent-clients/adapters/codex-lifecycle/binding.js +0 -114
  279. package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +0 -237
  280. package/dist/lib/agent-clients/adapters/codex-lifecycle/cli.js +0 -443
  281. package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +0 -236
  282. package/dist/lib/agent-clients/adapters/codex-lifecycle/recovery.js +0 -292
  283. package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +0 -267
  284. package/dist/lib/agent-clients/adapters/codex-orchestration.js +0 -466
  285. package/dist/lib/internal/task-orchestration.js +0 -71
  286. package/dist/lib/platform/verification.js +0 -6
  287. package/dist/lib/run/prompt.js +0 -2
  288. package/dist/lib/sandbox/engines/authority.js +0 -289
  289. package/dist/lib/task/delegation-receipts.js +0 -410
  290. package/dist/lib/task/orchestration.js +0 -1233
  291. package/dist/lib/task/verification-checks.js +0 -9
  292. package/dist/lib/task/workspace-snapshot.js +0 -121
  293. package/dist/lifecycle-build-manifest.json +0 -6
  294. package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +0 -688
  295. package/lib/agent-clients/adapters/codex-lifecycle/binding.ts +0 -147
  296. package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +0 -349
  297. package/lib/agent-clients/adapters/codex-lifecycle/cli.ts +0 -506
  298. package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +0 -385
  299. package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +0 -41
  300. package/lib/agent-clients/adapters/codex-lifecycle/recovery.ts +0 -418
  301. package/lib/agent-clients/adapters/codex-lifecycle/store.ts +0 -354
  302. package/lib/agent-clients/adapters/codex-orchestration.ts +0 -630
  303. package/lib/internal/task-orchestration.ts +0 -74
  304. package/lib/platform/verification.ts +0 -11
  305. package/lib/run/prompt.ts +0 -1
  306. package/lib/sandbox/engines/authority.ts +0 -365
  307. package/lib/task/delegation-receipts.ts +0 -547
  308. package/lib/task/orchestration.ts +0 -1651
  309. package/lib/task/verification-checks.ts +0 -10
  310. package/lib/task/workspace-snapshot.ts +0 -144
  311. package/templates/.agents/hooks/lifecycle-delegation.js +0 -140
  312. package/templates/.agents/rules/lifecycle-orchestration.en.md +0 -44
  313. package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +0 -44
  314. package/templates/.agents/skills/run-task/SKILL.en.md +0 -29
  315. package/templates/.agents/skills/run-task/SKILL.zh-CN.md +0 -29
  316. package/templates/.agents/skills/run-task/config/verify.en.json +0 -10
  317. package/templates/.agents/skills/run-task/config/verify.zh-CN.json +0 -10
  318. package/templates/.agents/skills/run-task/reference/host-validation.en.md +0 -24
  319. package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +0 -24
  320. package/templates/.claude/agents/agent-infra-lifecycle-executor.en.md +0 -6
  321. package/templates/.claude/agents/agent-infra-lifecycle-executor.zh-CN.md +0 -6
  322. package/templates/.claude/agents/agent-infra-lifecycle-reviewer.en.md +0 -6
  323. package/templates/.claude/agents/agent-infra-lifecycle-reviewer.zh-CN.md +0 -6
  324. package/templates/.claude/commands/run-task.en.md +0 -8
  325. package/templates/.claude/commands/run-task.zh-CN.md +0 -8
  326. package/templates/.codex/agents/agent-infra-lifecycle-executor.en.toml +0 -3
  327. package/templates/.codex/agents/agent-infra-lifecycle-executor.zh-CN.toml +0 -3
  328. package/templates/.codex/agents/agent-infra-lifecycle-reviewer.en.toml +0 -3
  329. package/templates/.codex/agents/agent-infra-lifecycle-reviewer.zh-CN.toml +0 -3
  330. package/templates/.opencode/commands/run-task.en.md +0 -11
  331. package/templates/.opencode/commands/run-task.zh-CN.md +0 -11
@@ -290,15 +290,6 @@ function validateSecurityAlert(value) {
290
290
  data: jsonValue(item.data, 'security alert.data')
291
291
  };
292
292
  }
293
- function validateLabelDefinition(value, label) {
294
- const item = record(value, label);
295
- exactKeys(item, ['name', 'color', 'description'], label);
296
- return {
297
- name: stringValue(item.name, `${label}.name`),
298
- color: stringValue(item.color, `${label}.color`),
299
- description: stringValue(item.description, `${label}.description`, true)
300
- };
301
- }
302
293
  function validateLabelReconciliation(value) {
303
294
  const item = record(value, 'label reconciliation');
304
295
  exactKeys(item, ['changed', 'created', 'updated', 'removed', 'skipped'], 'label reconciliation');
@@ -311,17 +302,6 @@ function validateLabelReconciliation(value) {
311
302
  skipped: names('skipped')
312
303
  };
313
304
  }
314
- function validateMilestoneDefinition(value, label) {
315
- const item = record(value, label);
316
- exactKeys(item, ['title', 'description', 'state'], label);
317
- if (item.state !== 'open' && item.state !== 'closed')
318
- throw new Error(`${label}.state is invalid`);
319
- return {
320
- title: stringValue(item.title, `${label}.title`),
321
- description: stringValue(item.description, `${label}.description`, true),
322
- state: item.state
323
- };
324
- }
325
305
  function validateMilestoneInitialization(value) {
326
306
  const item = record(value, 'milestone initialization');
327
307
  exactKeys(item, ['changed', 'created', 'skipped'], 'milestone initialization');
@@ -1,11 +1,10 @@
1
- import { normalizePullRequest } from './github-data.js';
2
1
  import fs from 'node:fs';
3
2
  import path from 'node:path';
4
3
  import { createHash } from 'node:crypto';
5
4
  import { execFileSync } from 'node:child_process';
6
5
  import { parseTypedTaskFrontmatter } from '../task/frontmatter.js';
7
6
  import { resolveTaskRef } from '../task/resolve-ref.js';
8
- import { extractSection } from '../task/sections.js';
7
+ import { activityWarnings, locateActivityLog } from '../task/activity-log.js';
9
8
  import { captureTaskWriteMetadata, writeTask } from '../task/write.js';
10
9
  import { resolvePlatformProviderContext } from './context.js';
11
10
  import { inspectPlatformIssue } from './issues.js';
@@ -162,39 +161,6 @@ function expectedHead(repository, head) {
162
161
  const repoName = repository.split('/')[1] || '';
163
162
  return { repository: `${head.slice(0, colon)}/${repoName}`, ref: head.slice(colon + 1) };
164
163
  }
165
- function selectPullRequest(remotes, repository, head, base, expectedSha) {
166
- const wanted = expectedHead(repository, head);
167
- const matches = remotes.flatMap((remote) => {
168
- const normalized = normalizePullRequest(remote, repository);
169
- return normalized && normalized.state === 'open' && normalized.head.repository === wanted.repository &&
170
- normalized.head.ref === wanted.ref && normalized.base.repository === repository && normalized.base.ref === base
171
- ? [normalized] : [];
172
- });
173
- if (expectedSha && matches.some((match) => match.head.sha !== expectedSha)) {
174
- return { status: 'head-mismatch', pullRequest: null };
175
- }
176
- if (matches.length === 1)
177
- return { status: 'resolved', pullRequest: matches[0] };
178
- return { status: matches.length === 0 ? 'missing' : 'ambiguous', pullRequest: null };
179
- }
180
- function validateBoundPullRequest(base, pullRequest, head, baseRef, expectedSha) {
181
- if (!pullRequest)
182
- return {
183
- ok: false,
184
- error: { code: 'PR_BIND_RECHECK_FAILED', message: 'Bound pull request identity is unavailable', retryable: false }
185
- };
186
- const wanted = expectedHead(base.context.platform.repository, head);
187
- if (pullRequest.head.repository !== wanted.repository
188
- || pullRequest.head.ref !== wanted.ref
189
- || pullRequest.head.sha !== expectedSha
190
- || pullRequest.base.repository !== base.context.platform.repository
191
- || pullRequest.base.ref !== baseRef)
192
- return {
193
- ok: false,
194
- error: { code: 'PR_BIND_IDENTITY_MISMATCH', message: 'Bound pull request identity does not match the current expected head/base', retryable: false }
195
- };
196
- return { ok: true };
197
- }
198
164
  function resolveTaskDeliveryTarget(repoRoot, frontmatter) {
199
165
  const existing = {
200
166
  ...(typeof frontmatter.delivery_remote === 'string' && frontmatter.delivery_remote
@@ -682,9 +648,12 @@ async function syncPlatformPullRequestInLabels(prToken, options = {}) {
682
648
  resources: resourcesState, evidence: { kind: 'pull-request-files', pullRequestFiles: files.value, closingIssues: closingIssueIdentities }, error: null
683
649
  });
684
650
  }
685
- function appendActivity(content, line) {
686
- const body = extractSection(content, ['活动日志', 'Activity Log']);
687
- return `${body.replace(/\s+$/, '')}${body.trim() ? '\n' : ''}${line}`;
651
+ function activityMutation(content, line) {
652
+ const section = locateActivityLog(content);
653
+ if (!section)
654
+ return [];
655
+ return [{ kind: 'section', aliases: ['活动日志', 'Activity Log'], heading: section.heading,
656
+ body: `${section.body}${section.body ? '\n' : ''}${line}` }];
688
657
  }
689
658
  function deliveryIdentity(pullRequest) {
690
659
  return {
@@ -710,15 +679,11 @@ function boundFactFor(pullRequest, source, issue, verifiedAt) {
710
679
  });
711
680
  }
712
681
  function writeCreateStarted(base, agent) {
713
- const starts = (base.content.match(/\*\*Create PR \[started\]\*\*/g) || []).length;
714
- const dones = (base.content.match(/\*\*Create PR\*\*/g) || []).length;
715
- if (starts > dones)
716
- return { status: 'no-op' };
717
682
  const metadata = captureTaskWriteMetadata();
718
683
  return writeTask({
719
684
  taskRef: base.resolved.taskId,
720
685
  expectedState: 'active',
721
- mutations: [{ kind: 'section', aliases: ['活动日志', 'Activity Log'], heading: '活动日志', body: appendActivity(base.content, `- ${metadata.timestamp} — **Create PR [started]** by ${agent} — started`) }]
686
+ mutations: activityMutation(base.content, `- ${metadata.timestamp} — **Create PR [started]** by ${agent} — started`)
722
687
  }, { repoRoot: base.resolved.repoRoot, metadataProvider: () => metadata });
723
688
  }
724
689
  function bindIdentity(base, pullRequest, agent, source, dryRun = false, expectedHead, expectedHeadSha) {
@@ -750,7 +715,7 @@ function bindIdentity(base, pullRequest, agent, source, dryRun = false, expected
750
715
  dryRun,
751
716
  mutations: [
752
717
  { kind: 'frontmatter', set: { ...factMutation.set, assigned_to: agent } },
753
- { kind: 'section', aliases: ['活动日志', 'Activity Log'], heading: '活动日志', body: appendActivity(current, `- ${metadata.timestamp} — **Create PR** by ${agent} — PR #${pullRequest.number} created → ${pullRequest.url}`) }
718
+ ...activityMutation(current, `- ${metadata.timestamp} — **Create PR** by ${agent} — PR #${pullRequest.number} created → ${pullRequest.url}`)
754
719
  ]
755
720
  }, { repoRoot: base.resolved.repoRoot, metadataProvider: () => metadata });
756
721
  }
@@ -779,13 +744,14 @@ async function bindPlatformPullRequestImpl(taskRef, options) {
779
744
  return inspected;
780
745
  const initialIdentity = validateWriterIdentity(base, inspected.pullRequest, {
781
746
  expectedHead: String(base.frontmatter.branch || ''),
747
+ expectedHeadSha: options.expectedHeadSha,
782
748
  errorCode: 'PR_BIND_IDENTITY_MISMATCH'
783
749
  });
784
750
  if (!initialIdentity.ok)
785
751
  return result('failed', base.resolved.taskId, base.issueNumber, requestedNumber, {
786
752
  pullRequest: inspected.pullRequest, error: initialIdentity.error
787
753
  });
788
- const written = bindIdentity(base, inspected.pullRequest, options.agent, 'explicit-bind', options.dryRun);
754
+ const written = bindIdentity(base, inspected.pullRequest, options.agent, 'explicit-bind', options.dryRun, undefined, options.expectedHeadSha);
789
755
  if (written.status === 'failed')
790
756
  return result('failed', base.resolved.taskId, base.issueNumber, requestedNumber, {
791
757
  pullRequest: inspected.pullRequest, error: { code: written.error.code, message: written.error.message, retryable: false }
@@ -796,7 +762,7 @@ async function bindPlatformPullRequestImpl(taskRef, options) {
796
762
  operations: [{ name: 'task:bind-pr', status: options.dryRun ? 'planned' : written.status === 'no-op' ? 'no-op' : 'applied', reasonCode: null }], error: null
797
763
  });
798
764
  }
799
- async function bindPlatformPullRequest(taskRef, options) {
765
+ async function bindPlatformPullRequestWithProjection(taskRef, options) {
800
766
  const intent = { action: 'bind', prToken: String(options.pr) };
801
767
  return journalPullRequestOperation(taskRef, options, intent, `pr:${options.pr}`, { pr: String(options.pr) }, () => bindPlatformPullRequestImpl(taskRef, options));
802
768
  }
@@ -940,32 +906,16 @@ async function resolveExternalPullRequest(taskRef, options) {
940
906
  }), { candidates: selected.candidates, eligible: selected.eligible, selected: rechecked.value });
941
907
  const selectedPullRequest = rechecked.value;
942
908
  const note = externalEvidenceNote(base.issueIdentity, selected.source, selectedPullRequest);
943
- const identityNote = externalIdentityEvidenceNote(base.issueIdentity, selectedPullRequest);
944
909
  const activityEntry = `**Bind External PR** by ${options.agent} — ${note}`;
945
- const auditLines = base.content.split(/\r?\n/).filter((line) => line.includes('**Bind External PR**'));
946
- const alreadyAudited = auditLines.some((line) => line.endsWith(identityNote));
947
- if (auditLines.length > 0 && !alreadyAudited)
910
+ if (base.prIdentity && !resourceIdentityEquals(base.prIdentity, pullRequestIdentity(selectedPullRequest)))
948
911
  return externalResult(result('failed', base.resolved.taskId, base.issueNumber, base.prNumber, {
949
- platform: base.context.platform,
950
- capabilities: base.context.capabilities,
951
- pullRequest: selectedPullRequest,
952
- error: { code: 'PR_BIND_CONFLICT', message: 'Existing external PR audit evidence conflicts with the selected identity', retryable: false }
912
+ platform: base.context.platform, capabilities: base.context.capabilities, pullRequest: selectedPullRequest,
913
+ error: { code: 'PR_BIND_CONFLICT', message: 'Selected identity does not match the task binding', retryable: false }
953
914
  }), { candidates: selected.candidates, eligible: selected.eligible, selected: selectedPullRequest });
954
- if (alreadyAudited && base.prIdentity && !resourceIdentityEquals(base.prIdentity, pullRequestIdentity(selectedPullRequest)))
955
- return externalResult(result('failed', base.resolved.taskId, base.issueNumber, base.prNumber, {
956
- platform: base.context.platform,
957
- capabilities: base.context.capabilities,
958
- pullRequest: selectedPullRequest,
959
- error: { code: 'PR_BIND_CONFLICT', message: 'External PR audit evidence does not match the task binding', retryable: false }
960
- }), { candidates: selected.candidates, eligible: selected.eligible, selected: selectedPullRequest });
961
- if (base.prIdentity && resourceIdentityEquals(base.prIdentity, pullRequestIdentity(selectedPullRequest)) && alreadyAudited) {
915
+ if (base.prIdentity && resourceIdentityEquals(base.prIdentity, pullRequestIdentity(selectedPullRequest)) && base.fact?.state === 'bound') {
962
916
  return externalResult(result('no-op', base.resolved.taskId, base.issueNumber, base.prNumber, {
963
- platform: base.context.platform,
964
- capabilities: base.context.capabilities,
965
- resource: { kind: 'pull-request', number: selectedPullRequest.number },
966
- pullRequest: selectedPullRequest,
967
- operations: [{ name: 'task:bind-external-pr', status: 'no-op', reasonCode: 'EVIDENCE_ALREADY_RECORDED' }],
968
- error: null
917
+ platform: base.context.platform, capabilities: base.context.capabilities, pullRequest: selectedPullRequest,
918
+ operations: [{ name: 'task:bind-external-pr', status: 'no-op', reasonCode: 'EVIDENCE_ALREADY_RECORDED' }], error: null
969
919
  }), { mode: 'external', authorization: selected.source, candidates: selected.candidates, eligible: selected.eligible, selected: selectedPullRequest });
970
920
  }
971
921
  const metadata = captureTaskWriteMetadata();
@@ -975,7 +925,7 @@ async function resolveExternalPullRequest(taskRef, options) {
975
925
  dryRun: options.dryRun,
976
926
  mutations: [
977
927
  { kind: 'frontmatter', set: { ...factFrontmatterMutation(boundFactFor(selectedPullRequest, selected.source === 'unique' ? 'external-unique' : 'external-explicit', base.issueNumber, metadata.timestamp)).set, assigned_to: options.agent } },
978
- { kind: 'section', aliases: ['活动日志', 'Activity Log'], heading: '活动日志', body: appendActivity(base.content, `- ${metadata.timestamp} — ${activityEntry}`) }
928
+ ...activityMutation(base.content, `- ${metadata.timestamp} — ${activityEntry}`)
979
929
  ]
980
930
  }, { repoRoot: base.resolved.repoRoot, metadataProvider: () => metadata });
981
931
  if (write.status === 'failed')
@@ -1006,7 +956,7 @@ async function createPlatformPullRequestImpl(taskRef, options) {
1006
956
  }), PRECONDITION_NOT_CREATED);
1007
957
  }
1008
958
  try {
1009
- return await createExternalPullRequest(taskRef, options, base);
959
+ return await createExternalPullRequest(options, base);
1010
960
  }
1011
961
  catch (error) {
1012
962
  return withCreation(result('failed', base.resolved.taskId, base.issueNumber, null, {
@@ -1028,17 +978,26 @@ async function recoverCreatedPullRequest(taskRef, options) {
1028
978
  return result('failed', base.resolved.taskId, base.issueNumber, base.prNumber, {
1029
979
  error: { code: 'PLATFORM_OPERATION_ISSUE_REQUIRED', message: 'Pull-request recovery requires a bound Issue identity', retryable: false }
1030
980
  });
1031
- const head = base.provider.changeRequests?.verifyHead
1032
- ? await base.provider.changeRequests.verifyHead({ context: providerOperationContext(base.loadedContext), head: options.head })
1033
- : unsupportedProviderOperation(base.provider, 'changeRequests.verifyHead');
1034
- if (!head.ok)
1035
- return providerPullRequestError(base, head.error, base.prNumber);
981
+ let headSha;
982
+ if (base.provider.changeRequests?.verifyHead) {
983
+ const head = await base.provider.changeRequests.verifyHead({ context: providerOperationContext(base.loadedContext), head: options.head });
984
+ if (!head.ok)
985
+ return providerPullRequestError(base, head.error, base.prNumber);
986
+ headSha = head.value.sha;
987
+ }
988
+ else {
989
+ headSha = typeof base.frontmatter.delivery_remote_head === 'string' ? base.frontmatter.delivery_remote_head.trim() : '';
990
+ if (!headSha)
991
+ return result('blocked', base.resolved.taskId, base.issueNumber, base.prNumber, {
992
+ error: { code: 'PR_HEAD_UNVERIFIED', message: 'Verify and record the delivered remote head before retrying pull-request recovery', retryable: true }
993
+ });
994
+ }
1036
995
  if (base.prIdentity) {
1037
996
  const inspected = await inspectExternalPullRequest(base, base.prIdentity);
1038
997
  if (!inspected.pullRequest || inspected.status === 'failed' || inspected.status === 'blocked'
1039
998
  || inspected.pullRequest.base.repository !== base.context.platform.repository
1040
999
  || inspected.pullRequest.base.ref !== options.base || inspected.pullRequest.head.ref !== options.head
1041
- || inspected.pullRequest.head.sha !== head.value.sha) {
1000
+ || inspected.pullRequest.head.sha !== headSha) {
1042
1001
  return result('blocked', base.resolved.taskId, base.issueNumber, base.prNumber, {
1043
1002
  error: inspected.error ?? { code: 'PLATFORM_OPERATION_PR_NOT_CONFIRMED', message: 'Bound pull request does not match the pending create intent', retryable: true }
1044
1003
  });
@@ -1055,24 +1014,24 @@ async function recoverCreatedPullRequest(taskRef, options) {
1055
1014
  && candidate.base.ref === options.base
1056
1015
  && candidate.head.repository === base.context.platform.repository
1057
1016
  && candidate.head.ref === options.head
1058
- && candidate.head.sha === head.value.sha);
1017
+ && candidate.head.sha === headSha);
1059
1018
  if (matches.length !== 1 || !matches[0]?.number)
1060
1019
  return result('blocked', base.resolved.taskId, base.issueNumber, null, {
1061
1020
  error: { code: matches.length > 1 ? 'PLATFORM_OPERATION_PR_AMBIGUOUS' : 'PLATFORM_OPERATION_PR_NOT_CONFIRMED',
1062
1021
  message: 'Pending pull-request creation does not resolve to one exact repository/base/head identity', retryable: true }
1063
1022
  });
1064
- const bound = await bindPlatformPullRequest(base.resolved.taskId, { agent: options.agent, cwd: base.resolved.repoRoot, pr: matches[0].number });
1023
+ const bound = await bindPlatformPullRequest(base.resolved.taskId, { agent: options.agent, cwd: base.resolved.repoRoot, client: options.client, pr: matches[0].number, skipQueue: true, expectedHeadSha: headSha });
1065
1024
  if (!bound.pullRequest || (bound.status !== 'applied' && bound.status !== 'no-op') || bound.error)
1066
1025
  return bound;
1067
1026
  if (bound.pullRequest.base.repository !== base.context.platform.repository || bound.pullRequest.base.ref !== options.base
1068
1027
  || bound.pullRequest.head.repository !== base.context.platform.repository || bound.pullRequest.head.ref !== options.head
1069
- || bound.pullRequest.head.sha !== head.value.sha)
1028
+ || bound.pullRequest.head.sha !== headSha)
1070
1029
  return result('blocked', base.resolved.taskId, base.issueNumber, bound.task.prNumber, {
1071
1030
  error: { code: 'PLATFORM_OPERATION_PR_NOT_CONFIRMED', message: 'Bound pull request changed while recovering the create intent', retryable: true }
1072
1031
  });
1073
1032
  return bound;
1074
1033
  }
1075
- async function createPlatformPullRequest(taskRef, options) {
1034
+ async function createPlatformPullRequestWithProjection(taskRef, options) {
1076
1035
  const intent = { action: 'create', baseRef: options.base, headRef: options.head };
1077
1036
  const identityInput = {
1078
1037
  title: createHash('sha256').update(options.title).digest('hex'),
@@ -1081,7 +1040,7 @@ async function createPlatformPullRequest(taskRef, options) {
1081
1040
  };
1082
1041
  return journalPullRequestOperation(taskRef, options, intent, `head:${options.head}:base:${options.base}`, identityInput, () => createPlatformPullRequestImpl(taskRef, options));
1083
1042
  }
1084
- async function createExternalPullRequest(taskRef, options, base) {
1043
+ async function createExternalPullRequest(options, base) {
1085
1044
  if (!base.fact)
1086
1045
  return withCreation(result('failed', base.resolved.taskId, base.issueNumber, null, {
1087
1046
  error: { code: 'PR_DELIVERY_FACT_MISSING', message: 'Task has no pr_delivery_fact; repair the task metadata or create a new task', retryable: false }
@@ -1500,7 +1459,7 @@ function applySkippedPullRequestFact(resolved, options) {
1500
1459
  dryRun: options.dryRun,
1501
1460
  mutations: [
1502
1461
  { kind: 'frontmatter', set: { ...factFrontmatterMutation(fact).set, assigned_to: options.agent } },
1503
- { kind: 'section', aliases: ['活动日志', 'Activity Log'], heading: '活动日志', body: appendActivity(content, `- ${metadata.timestamp} — **Skip PR** by ${options.agent} — PR delivery explicitly skipped`) }
1462
+ ...activityMutation(content, `- ${metadata.timestamp} — **Skip PR** by ${options.agent} — PR delivery explicitly skipped`)
1504
1463
  ]
1505
1464
  }, { repoRoot: resolved.repoRoot, metadataProvider: () => metadata });
1506
1465
  if (write.status === 'failed')
@@ -1514,7 +1473,7 @@ function applySkippedPullRequestFact(resolved, options) {
1514
1473
  error: null
1515
1474
  });
1516
1475
  }
1517
- async function skipPlatformPullRequestFact(taskRef, options) {
1476
+ async function skipPlatformPullRequestFactWithProjection(taskRef, options) {
1518
1477
  const resolved = resolveTaskRef(taskRef, options.cwd ? { repoRoot: options.cwd } : {});
1519
1478
  if (!resolved.ok)
1520
1479
  return result('failed', resolved.taskId, null, null, {
@@ -1533,6 +1492,36 @@ async function skipPlatformPullRequestFact(taskRef, options) {
1533
1492
  });
1534
1493
  }
1535
1494
  }
1536
- export { bindPlatformPullRequest, createPlatformPullRequest, inspectPlatformPullRequest, inspectPlatformPullRequestByNumber, recoverCreatedPullRequest, resolveExternalPullRequest, skipPlatformPullRequestFact, selectExternalPullRequest, selectPullRequest, syncPlatformPullRequest, syncPlatformPullRequestInLabels };
1495
+ function withActivityWarnings(taskRef, cwd, output) {
1496
+ if (output.status === 'failed' || output.status === 'blocked')
1497
+ return output;
1498
+ const resolved = resolveTaskRef(taskRef, cwd ? { repoRoot: cwd } : {});
1499
+ if (!resolved.ok)
1500
+ return output;
1501
+ let logWarnings;
1502
+ try {
1503
+ logWarnings = activityWarnings(fs.readFileSync(resolved.taskMdPath, 'utf8'));
1504
+ }
1505
+ catch {
1506
+ return output;
1507
+ }
1508
+ if (!logWarnings.length)
1509
+ return output;
1510
+ const warnings = logWarnings.map((item) => ({ ...item, retryable: true, step: 'pr', target: resolved.taskId, severity: 'IMPORTANT' }));
1511
+ return { ...output, warnings: mergeOperationWarnings(output.warnings, warnings) };
1512
+ }
1513
+ async function bindPlatformPullRequest(taskRef, options) {
1514
+ return withActivityWarnings(taskRef, options.cwd, await bindPlatformPullRequestWithProjection(taskRef, options));
1515
+ }
1516
+ async function createPlatformPullRequest(taskRef, options) {
1517
+ return withActivityWarnings(taskRef, options.cwd, await createPlatformPullRequestWithProjection(taskRef, options));
1518
+ }
1519
+ async function resolveExternalPullRequestWithWarnings(taskRef, options) {
1520
+ return withActivityWarnings(taskRef, options.cwd, await resolveExternalPullRequest(taskRef, options));
1521
+ }
1522
+ async function skipPlatformPullRequestFact(taskRef, options) {
1523
+ return withActivityWarnings(taskRef, options.cwd, await skipPlatformPullRequestFactWithProjection(taskRef, options));
1524
+ }
1525
+ export { bindPlatformPullRequest, createPlatformPullRequest, inspectPlatformPullRequest, inspectPlatformPullRequestByNumber, recoverCreatedPullRequest, resolveExternalPullRequestWithWarnings as resolveExternalPullRequest, skipPlatformPullRequestFact, selectExternalPullRequest, syncPlatformPullRequest, syncPlatformPullRequestInLabels };
1537
1526
  export { warningResultForPrimary };
1538
1527
  //# sourceMappingURL=pull-requests.js.map
@@ -1,13 +1,6 @@
1
- import fs from 'node:fs';
2
- import crypto from 'node:crypto';
3
1
  import { resolvePlatformProviderContext } from './context.js';
4
2
  import { platformResult } from './types.js';
5
3
  import { providerError, providerOperationContext, providerStatus, unsupportedProviderOperation } from './provider-bridge.js';
6
- function flattenPages(value) {
7
- if (!Array.isArray(value))
8
- return [];
9
- return value.flatMap((entry) => Array.isArray(entry) ? entry : [entry]).filter((entry) => Boolean(entry) && typeof entry === 'object');
10
- }
11
4
  async function inspectPlatformRelease(tag, options = {}) {
12
5
  const loaded = await resolvePlatformProviderContext({ cwd: options.cwd, client: options.client });
13
6
  const context = loaded.ok ? loaded.value.context : loaded.context;
@@ -32,41 +25,6 @@ async function inspectPlatformRelease(tag, options = {}) {
32
25
  }
33
26
  return { ...platformResult('failed'), platform: context.platform, release: null, workflows: [], error: context.error };
34
27
  }
35
- async function upsertPlatformRelease(input, options = {}) {
36
- const inspected = await inspectPlatformRelease(input.tag, options);
37
- if (inspected.release?.published)
38
- return { ...inspected, status: 'no-op', changed: false, operations: [] };
39
- if (inspected.status === 'blocked' || inspected.status === 'failed')
40
- return { ...inspected, changed: false, operations: [] };
41
- if (!inspected.platform.repository)
42
- return { ...inspected, status: 'no-op', changed: false, operations: [] };
43
- const loaded = await resolvePlatformProviderContext({ cwd: options.cwd, client: options.client });
44
- if (loaded.ok) {
45
- let notes;
46
- if (input.notesFile) {
47
- try {
48
- const bytes = fs.readFileSync(input.notesFile);
49
- notes = { text: bytes.toString('utf8'), sha256: `sha256:${crypto.createHash('sha256').update(bytes).digest('hex')}`, byteLength: bytes.byteLength };
50
- }
51
- catch {
52
- return { ...inspected, status: 'failed', changed: false, operations: [{ name: 'create-release', status: 'failed' }], error: { code: 'RELEASE_NOTES_FILE_UNREADABLE', message: 'notes-file could not be read', retryable: false } };
53
- }
54
- }
55
- const created = loaded.value.provider.releases?.create
56
- ? await loaded.value.provider.releases.create({
57
- context: providerOperationContext(loaded.value),
58
- tag: input.tag,
59
- title: input.title ?? input.tag,
60
- ...(notes ? { notes } : {}),
61
- mutation: { idempotencyKey: `release:create:${input.tag}` }
62
- })
63
- : unsupportedProviderOperation(loaded.value.provider, 'releases.create');
64
- if (!created.ok)
65
- return { ...inspected, status: providerStatus(created.error), changed: false, operations: [{ name: 'create-release', status: 'failed' }], error: providerError(created.error, 'PLATFORM_PROVIDER_OPERATION_FAILED') };
66
- return { ...inspected, status: 'applied', changed: created.value.changed, operations: [{ name: 'create-release', status: 'applied' }], error: null };
67
- }
68
- return { ...inspected, status: 'failed', changed: false, operations: [{ name: 'create-release', status: 'failed' }], error: { code: 'PLATFORM_PROVIDER_LOAD_FAILED', message: 'Selected provider failed to load', retryable: false } };
69
- }
70
28
  async function reconcileReleaseMilestones(version, options = {}) {
71
29
  const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(version);
72
30
  if (!match)
@@ -115,5 +73,5 @@ async function reconcileReleaseMilestones(version, options = {}) {
115
73
  }
116
74
  return { status: 'failed', changed: false, operations: [], error: { code: 'PLATFORM_CAPABILITY_UNSUPPORTED', message: 'Release milestone reconciliation is unavailable', retryable: false } };
117
75
  }
118
- export { inspectPlatformRelease, reconcileReleaseMilestones, upsertPlatformRelease };
76
+ export { inspectPlatformRelease, reconcileReleaseMilestones };
119
77
  //# sourceMappingURL=releases.js.map
@@ -0,0 +1,18 @@
1
+ function parse(value, parser) {
2
+ try {
3
+ return parser(value);
4
+ }
5
+ catch (error) {
6
+ throw error instanceof Error ? error : new Error(String(error));
7
+ }
8
+ }
9
+ export function runSummaryContentPipeline(value, operations) {
10
+ try {
11
+ parse(value, operations.validate);
12
+ }
13
+ catch { /* Source correction gets a chance to repair invalid structure. */ }
14
+ const corrected = operations.correct(value);
15
+ const content = parse(corrected, operations.validate);
16
+ return { content, rendered: operations.render(content) };
17
+ }
18
+ //# sourceMappingURL=summary-content-pipeline.js.map
@@ -5,7 +5,6 @@ import { inspectRequiredChecks } from "./pr-checks.js";
5
5
  import { resolvePlatformProviderContext } from "./context.js";
6
6
  import { resolveReviewedHeadRelation } from "./merged-pr-equivalence.js";
7
7
  import { readPrDeliveryFact } from "../task/pr-delivery-fact.js";
8
- import { resourceIdentityNumber } from "./resource-identity.js";
9
8
  const CHECK_TYPE = "required-checks";
10
9
  const SHA_PATTERN = /^[0-9a-f]{7,40}$/i;
11
10
  function readPrFlow(repoRoot) {
@@ -33,7 +32,6 @@ export function evaluateRequiredChecks(context, shared) {
33
32
  }
34
33
  const fact = factRead.status === "valid" ? factRead.fact : null;
35
34
  const prIdentity = fact?.state === "bound" ? fact.identity.resource : null;
36
- const prNumber = resourceIdentityNumber(prIdentity);
37
35
  if (prFlow === "disabled" || fact?.state === "skipped" || !prIdentity) {
38
36
  return shared.passResult(CHECK_TYPE, "Skipped: required checks are not applicable to this task");
39
37
  }
@@ -13,7 +13,7 @@ import { readPrDeliveryFact } from "../task/pr-delivery-fact.js";
13
13
  import { providerError, providerOperationContext, resourceIdentityNumber, unsupportedProviderOperation } from "./provider-bridge.js";
14
14
  import { taskIssueIdentity } from "./task-identities.js";
15
15
  import { MARKERS, renderTaskCommentResult } from "./issue-comments.js";
16
- import { CONTROL_MARKER_PATTERN, canonicalizeCommentBody, renderSafeCodeFence, sanitizeMarkdownDocument } from "./comment-safety.js";
16
+ import { canonicalizeCommentBody, } from "./comment-safety.js";
17
17
  const CHECK_TYPE = "platform-sync";
18
18
  const VERSION_LINE_REGEX = /^[0-9]+\.[0-9]+\.x$/;
19
19
  const FRONTMATTER_FIELD_MAP = {
@@ -47,10 +47,6 @@ export function getDefaults() {
47
47
  }
48
48
  };
49
49
  }
50
- function sanitizeCommentContent(content) {
51
- const result = sanitizeMarkdownDocument(content, { reservedMarkers: [CONTROL_MARKER_PATTERN] });
52
- return result.ok ? result.value : null;
53
- }
54
50
  function infoResult(message) {
55
51
  return {
56
52
  type: CHECK_TYPE,
@@ -655,32 +651,6 @@ function extractCommentBody(commentBody) {
655
651
  }
656
652
  return lines.slice(start, end).join("\n");
657
653
  }
658
- function buildExpectedTaskBody(taskContent, shared) {
659
- const frontmatterMatch = taskContent.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/);
660
- if (!frontmatterMatch) {
661
- return sanitizeCommentContent(taskContent.trim());
662
- }
663
- const body = sanitizeCommentContent(taskContent.slice(frontmatterMatch[0].length).trim());
664
- if (body === null) {
665
- return null;
666
- }
667
- return [
668
- buildTaskFrontmatterSummary(shared),
669
- "",
670
- renderSafeCodeFence(frontmatterMatch[0].trim(), "yaml"),
671
- "",
672
- "</details>",
673
- "",
674
- body
675
- ].join("\n").trim();
676
- }
677
- function buildTaskFrontmatterSummary(shared) {
678
- const language = loadProjectLanguage(shared);
679
- if (language === "en" || language === "en-US") {
680
- return "<details><summary>Metadata (frontmatter)</summary>";
681
- }
682
- return "<details><summary>元数据 (frontmatter)</summary>";
683
- }
684
654
  function loadProjectLanguage(shared) {
685
655
  const override = process.env.VALIDATE_ARTIFACT_LANGUAGE;
686
656
  if (!shared.isBlank(override)) {
@@ -741,38 +711,6 @@ function mapTaskTypeToIssueType(taskType) {
741
711
  };
742
712
  return mapping[taskType] || "Task";
743
713
  }
744
- function normalizeIssueFields(payload) {
745
- const issue = payload?.data?.repository?.issue;
746
- const pinnedFields = Array.isArray(issue?.issueType?.pinnedFields)
747
- ? issue.issueType.pinnedFields
748
- : [];
749
- const values = Array.isArray(issue?.issueFieldValues?.nodes)
750
- ? issue.issueFieldValues.nodes
751
- : [];
752
- const pinnedNames = new Set(pinnedFields
753
- .map((field) => typeof field?.name === "string" ? field.name : "")
754
- .filter(Boolean));
755
- const normalizedValues = new Map();
756
- for (const value of values) {
757
- const fieldName = value?.field?.name;
758
- if (!fieldName) {
759
- continue;
760
- }
761
- if (value.__typename === "IssueFieldSingleSelectValue") {
762
- normalizedValues.set(fieldName, {
763
- kind: "single-select",
764
- value: normalizeOptionName(value.name)
765
- });
766
- }
767
- else if (value.__typename === "IssueFieldDateValue") {
768
- normalizedValues.set(fieldName, {
769
- kind: "date",
770
- value: normalizeDateValue(value.value)
771
- });
772
- }
773
- }
774
- return { pinnedNames, values: normalizedValues };
775
- }
776
714
  function normalizeExpectedIssueField(metadataKey, rawValue) {
777
715
  const value = String(rawValue || "").trim();
778
716
  if (!value) {
@@ -869,22 +807,6 @@ function gitText(args, cwd) {
869
807
  };
870
808
  }
871
809
  }
872
- function resolvePrHeadSha(context) {
873
- const fallback = () => gitText(["rev-parse", "HEAD"], context.taskDir);
874
- const branch = String(context.task?.metadata?.branch || "").trim();
875
- if (!branch) {
876
- return fallback();
877
- }
878
- const matchedWorktree = resolveBranchWorktree(context.taskDir, branch);
879
- if (!matchedWorktree) {
880
- return {
881
- ok: false,
882
- type: "check_failed",
883
- message: `Task branch '${branch}' is not checked out in a usable worktree`
884
- };
885
- }
886
- return gitText(["rev-parse", "HEAD"], matchedWorktree);
887
- }
888
810
  function interpolate(template, taskDir, artifactFile) {
889
811
  const artifactStem = artifactFile ? path.basename(artifactFile, path.extname(artifactFile)) : "";
890
812
  return template