neondeck 1.0.0-beta.4

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 (760) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/DEVELOPMENT.md +310 -0
  3. package/LICENSE +21 -0
  4. package/README.md +128 -0
  5. package/SOUL.md +8 -0
  6. package/bin/neondeck.mjs +27 -0
  7. package/config/dashboard.json +208 -0
  8. package/config/dashboard.schema.json +207 -0
  9. package/dist/SOUL.md +8 -0
  10. package/dist/assets/app-BuuvLo98.js +3620 -0
  11. package/dist/assets/app-BuuvLo98.js.map +1 -0
  12. package/dist/assets/autopilot-CKgEx8yQ.js +68025 -0
  13. package/dist/assets/autopilot-CKgEx8yQ.js.map +1 -0
  14. package/dist/assets/briefing-DYVbJaqk.js +2 -0
  15. package/dist/assets/briefing-DoO-fJr1.js +22 -0
  16. package/dist/assets/briefing-DoO-fJr1.js.map +1 -0
  17. package/dist/assets/command-run-B2TWLpLL.js +20 -0
  18. package/dist/assets/command-run-B2TWLpLL.js.map +1 -0
  19. package/dist/assets/command-run-CzQra_Y7.js +2 -0
  20. package/dist/assets/display-assistant-CbCRBSYM.js +389 -0
  21. package/dist/assets/display-assistant-CbCRBSYM.js.map +1 -0
  22. package/dist/assets/fix-pr-ci-BlUl-2ht.js +46 -0
  23. package/dist/assets/fix-pr-ci-BlUl-2ht.js.map +1 -0
  24. package/dist/assets/fix-pr-ci-Dl1wpKXp.js +2 -0
  25. package/dist/assets/migrations/20260710061339_neondeck_pre_1_0_baseline/migration.sql +748 -0
  26. package/dist/assets/migrations/20260710061339_neondeck_pre_1_0_baseline/snapshot.json +7240 -0
  27. package/dist/assets/prepare-pr-worktree-CLzccRYh.js +2 -0
  28. package/dist/assets/prepare-pr-worktree-DxyTygiU.js +17 -0
  29. package/dist/assets/prepare-pr-worktree-DxyTygiU.js.map +1 -0
  30. package/dist/assets/push-pr-autofix-BFNSEASU.js +2 -0
  31. package/dist/assets/push-pr-autofix-DlVjw1IN.js +17 -0
  32. package/dist/assets/push-pr-autofix-DlVjw1IN.js.map +1 -0
  33. package/dist/assets/review-pr-for-human-B2j8wz2L.js +2 -0
  34. package/dist/assets/review-pr-for-human-DcGE-7wb.js +708 -0
  35. package/dist/assets/review-pr-for-human-DcGE-7wb.js.map +1 -0
  36. package/dist/assets/safety-CawD9GxD.js +2499 -0
  37. package/dist/assets/safety-CawD9GxD.js.map +1 -0
  38. package/dist/assets/scheduled-agent-instruction-CQgogBv3.js +22 -0
  39. package/dist/assets/scheduled-agent-instruction-CQgogBv3.js.map +1 -0
  40. package/dist/assets/scheduled-agent-instruction-Dr2ebZRD.js +2 -0
  41. package/dist/assets/scheduler-tick-Cy26qBld.js +105 -0
  42. package/dist/assets/scheduler-tick-Cy26qBld.js.map +1 -0
  43. package/dist/assets/skills/github-gh/SKILL.md +56 -0
  44. package/dist/assets/skills/neon-ci-fix/SKILL.md +15 -0
  45. package/dist/assets/skills/neon-docs-fix/SKILL.md +15 -0
  46. package/dist/assets/skills/neon-issue-triage/SKILL.md +13 -0
  47. package/dist/assets/skills/neon-pr-review/SKILL.md +19 -0
  48. package/dist/assets/skills/neondeck/SKILL.md +123 -0
  49. package/dist/assets/skills/neondeck-handoff/SKILL.md +31 -0
  50. package/dist/assets/triage-pr-event-BlE3GKNR.js +17 -0
  51. package/dist/assets/triage-pr-event-BlE3GKNR.js.map +1 -0
  52. package/dist/assets/triage-pr-event-hxUP587F.js +2 -0
  53. package/dist/assets/verify-then-push-pr-autofix-CIl5ZwZm.js +2 -0
  54. package/dist/assets/verify-then-push-pr-autofix-Djy0UFUv.js +75 -0
  55. package/dist/assets/verify-then-push-pr-autofix-Djy0UFUv.js.map +1 -0
  56. package/dist/config/dashboard.json +208 -0
  57. package/dist/config/dashboard.schema.json +207 -0
  58. package/dist/server.mjs +582 -0
  59. package/dist/server.mjs.map +1 -0
  60. package/dist/skills/github-gh/SKILL.md +56 -0
  61. package/dist/skills/neon-ci-fix/SKILL.md +15 -0
  62. package/dist/skills/neon-docs-fix/SKILL.md +15 -0
  63. package/dist/skills/neon-issue-triage/SKILL.md +13 -0
  64. package/dist/skills/neon-pr-review/SKILL.md +19 -0
  65. package/dist/skills/neondeck/SKILL.md +123 -0
  66. package/dist/skills/neondeck-handoff/SKILL.md +31 -0
  67. package/drizzle.config.ts +7 -0
  68. package/package.json +155 -0
  69. package/shared/patch-anchors.ts +78 -0
  70. package/src/agents/busywork-workflow.ts +24 -0
  71. package/src/agents/display-assistant.ts +134 -0
  72. package/src/agents/pr-review-assistant.ts +25 -0
  73. package/src/agents/scheduler-workflow.ts +20 -0
  74. package/src/agents/support/tools.ts +346 -0
  75. package/src/app.ts +1 -0
  76. package/src/cli/index.ts +560 -0
  77. package/src/cli/learning.ts +44 -0
  78. package/src/cli/mcp.ts +496 -0
  79. package/src/cli/modules.ts +107 -0
  80. package/src/cli/onboarding.ts +667 -0
  81. package/src/cli/options.ts +103 -0
  82. package/src/cli/output.ts +399 -0
  83. package/src/cli/preapprovals.ts +204 -0
  84. package/src/cli/prompts.ts +108 -0
  85. package/src/cli/types.ts +59 -0
  86. package/src/db.ts +41 -0
  87. package/src/desktop/open.ts +698 -0
  88. package/src/desktop/service.ts +863 -0
  89. package/src/domains/mcp/actions.ts +420 -0
  90. package/src/domains/mcp/config.ts +501 -0
  91. package/src/domains/mcp/format.ts +35 -0
  92. package/src/domains/mcp/gate.ts +188 -0
  93. package/src/domains/mcp/index.ts +9 -0
  94. package/src/domains/mcp/instructions.ts +18 -0
  95. package/src/domains/mcp/oauth.ts +1063 -0
  96. package/src/domains/mcp/policy.ts +15 -0
  97. package/src/domains/mcp/registry.ts +461 -0
  98. package/src/domains/mcp/schemas.ts +171 -0
  99. package/src/domains/mcp/stdio.ts +451 -0
  100. package/src/domains/mcp/store.ts +905 -0
  101. package/src/domains/mcp/tools.ts +119 -0
  102. package/src/lib/action-result.ts +51 -0
  103. package/src/lib/exec.ts +118 -0
  104. package/src/lib/git.ts +20 -0
  105. package/src/lib/report-html.ts +193 -0
  106. package/src/lib/sqlite.ts +51 -0
  107. package/src/lib/valibot.ts +33 -0
  108. package/src/modules/app-state/index.ts +5 -0
  109. package/src/modules/app-state/native-notifications.ts +76 -0
  110. package/src/modules/app-state/notification-events.ts +45 -0
  111. package/src/modules/app-state/notifications.ts +276 -0
  112. package/src/modules/app-state/types.ts +42 -0
  113. package/src/modules/app-state/workflow-summaries.ts +201 -0
  114. package/src/modules/autonomous-audit/index.ts +225 -0
  115. package/src/modules/autopilot/actions.ts +165 -0
  116. package/src/modules/autopilot/admissions.ts +865 -0
  117. package/src/modules/autopilot/approvals.ts +59 -0
  118. package/src/modules/autopilot/ci-fix-run.ts +1332 -0
  119. package/src/modules/autopilot/ci-fix.ts +692 -0
  120. package/src/modules/autopilot/comments.ts +426 -0
  121. package/src/modules/autopilot/fixtures.ts +344 -0
  122. package/src/modules/autopilot/github-facts.ts +303 -0
  123. package/src/modules/autopilot/index.ts +64 -0
  124. package/src/modules/autopilot/notifications.ts +271 -0
  125. package/src/modules/autopilot/push-support.ts +288 -0
  126. package/src/modules/autopilot/push.ts +661 -0
  127. package/src/modules/autopilot/recovery.ts +656 -0
  128. package/src/modules/autopilot/review-feedback.ts +651 -0
  129. package/src/modules/autopilot/review-support.ts +524 -0
  130. package/src/modules/autopilot/revision-run.ts +445 -0
  131. package/src/modules/autopilot/schemas.ts +485 -0
  132. package/src/modules/autopilot/state-mappers.ts +512 -0
  133. package/src/modules/autopilot/state-schemas.ts +451 -0
  134. package/src/modules/autopilot/state-store.ts +183 -0
  135. package/src/modules/autopilot/state.ts +255 -0
  136. package/src/modules/autopilot/triage-support.ts +234 -0
  137. package/src/modules/autopilot/triage.ts +156 -0
  138. package/src/modules/autopilot/utils.ts +145 -0
  139. package/src/modules/autopilot/worktree.ts +622 -0
  140. package/src/modules/autopilot-policy/config.ts +110 -0
  141. package/src/modules/autopilot-policy/index.ts +4 -0
  142. package/src/modules/autopilot-policy/risk.ts +359 -0
  143. package/src/modules/autopilot-policy/schemas.ts +284 -0
  144. package/src/modules/autopilot-policy/service.ts +304 -0
  145. package/src/modules/commands/actions.ts +112 -0
  146. package/src/modules/commands/handlers/index.ts +3 -0
  147. package/src/modules/commands/handlers/misc.ts +441 -0
  148. package/src/modules/commands/handlers/queue.ts +694 -0
  149. package/src/modules/commands/handlers/repo.ts +339 -0
  150. package/src/modules/commands/index.ts +5 -0
  151. package/src/modules/commands/registry.ts +157 -0
  152. package/src/modules/commands/runner.ts +152 -0
  153. package/src/modules/commands/schemas.ts +107 -0
  154. package/src/modules/commands/summaries.ts +92 -0
  155. package/src/modules/commands/utils.ts +113 -0
  156. package/src/modules/config/actions.ts +253 -0
  157. package/src/modules/config/events.ts +80 -0
  158. package/src/modules/config/files.ts +9 -0
  159. package/src/modules/config/history.ts +74 -0
  160. package/src/modules/config/index.ts +9 -0
  161. package/src/modules/config/mutations/dashboard.ts +319 -0
  162. package/src/modules/config/mutations/execution.ts +89 -0
  163. package/src/modules/config/mutations/models.ts +467 -0
  164. package/src/modules/config/mutations/providers.ts +163 -0
  165. package/src/modules/config/mutations/repos.ts +620 -0
  166. package/src/modules/config/read.ts +135 -0
  167. package/src/modules/config/result.ts +66 -0
  168. package/src/modules/config/schemas.ts +181 -0
  169. package/src/modules/docs-drift/index.ts +1 -0
  170. package/src/modules/docs-drift/service.ts +863 -0
  171. package/src/modules/execution/actions.ts +35 -0
  172. package/src/modules/execution/approvals.ts +322 -0
  173. package/src/modules/execution/exedev/checkouts.ts +356 -0
  174. package/src/modules/execution/exedev/context.ts +286 -0
  175. package/src/modules/execution/index.ts +7 -0
  176. package/src/modules/execution/policy.ts +102 -0
  177. package/src/modules/execution/run.ts +589 -0
  178. package/src/modules/execution/schemas.ts +116 -0
  179. package/src/modules/execution/scope.ts +137 -0
  180. package/src/modules/execution/store.ts +320 -0
  181. package/src/modules/execution/utils.ts +105 -0
  182. package/src/modules/execution-policy/index.ts +424 -0
  183. package/src/modules/flue/execution-context.ts +41 -0
  184. package/src/modules/github/actions.ts +334 -0
  185. package/src/modules/github/checks.ts +484 -0
  186. package/src/modules/github/client.ts +110 -0
  187. package/src/modules/github/comments.ts +204 -0
  188. package/src/modules/github/errors.ts +50 -0
  189. package/src/modules/github/index.ts +92 -0
  190. package/src/modules/github/issues.ts +116 -0
  191. package/src/modules/github/pr-file-cache.ts +264 -0
  192. package/src/modules/github/pull-requests.ts +384 -0
  193. package/src/modules/github/queue.ts +342 -0
  194. package/src/modules/github/reviews.ts +1421 -0
  195. package/src/modules/github/schemas.ts +794 -0
  196. package/src/modules/github/state-truncation.ts +31 -0
  197. package/src/modules/handoff/index.ts +2 -0
  198. package/src/modules/handoff/schemas.ts +61 -0
  199. package/src/modules/handoff/service.ts +587 -0
  200. package/src/modules/hygiene/index.ts +1 -0
  201. package/src/modules/hygiene/service.ts +513 -0
  202. package/src/modules/kilo/actions.ts +229 -0
  203. package/src/modules/kilo/ci-fix-run-reconcile.ts +299 -0
  204. package/src/modules/kilo/docs-drift-boundary.ts +178 -0
  205. package/src/modules/kilo/index.ts +8 -0
  206. package/src/modules/kilo/notifications.ts +295 -0
  207. package/src/modules/kilo/process.ts +637 -0
  208. package/src/modules/kilo/results/actions.ts +66 -0
  209. package/src/modules/kilo/results/gates.ts +227 -0
  210. package/src/modules/kilo/results/index.ts +23 -0
  211. package/src/modules/kilo/results/schemas.ts +112 -0
  212. package/src/modules/kilo/results/service.ts +512 -0
  213. package/src/modules/kilo/results/state.ts +508 -0
  214. package/src/modules/kilo/results/verify.ts +328 -0
  215. package/src/modules/kilo/revision-reconcile.ts +187 -0
  216. package/src/modules/kilo/runtime-facts.ts +128 -0
  217. package/src/modules/kilo/schemas.ts +265 -0
  218. package/src/modules/kilo/service.ts +714 -0
  219. package/src/modules/kilo/sessions-adapters.ts +343 -0
  220. package/src/modules/kilo/sessions.ts +446 -0
  221. package/src/modules/kilo/store.ts +689 -0
  222. package/src/modules/kilo/utils.ts +166 -0
  223. package/src/modules/learning/automation-health.ts +441 -0
  224. package/src/modules/learning/automation-memory.ts +179 -0
  225. package/src/modules/learning/index.ts +6 -0
  226. package/src/modules/learning/observability.ts +616 -0
  227. package/src/modules/learning/operator.ts +404 -0
  228. package/src/modules/learning/reviews/agents.ts +33 -0
  229. package/src/modules/learning/reviews/complete.ts +321 -0
  230. package/src/modules/learning/reviews/context.ts +145 -0
  231. package/src/modules/learning/reviews/events.ts +306 -0
  232. package/src/modules/learning/reviews/index.ts +6 -0
  233. package/src/modules/learning/reviews/pr-cadence.ts +157 -0
  234. package/src/modules/learning/reviews/pr-context.ts +749 -0
  235. package/src/modules/learning/reviews/prepare.ts +387 -0
  236. package/src/modules/learning/reviews/schemas.ts +184 -0
  237. package/src/modules/learning/reviews/store.ts +405 -0
  238. package/src/modules/learning/skill-patches/actions.ts +86 -0
  239. package/src/modules/learning/skill-patches/index.ts +3 -0
  240. package/src/modules/learning/skill-patches/schemas.ts +60 -0
  241. package/src/modules/learning/skill-patches/service.ts +571 -0
  242. package/src/modules/learning/skill-patches/support.ts +417 -0
  243. package/src/modules/memory/actions.ts +183 -0
  244. package/src/modules/memory/candidates.ts +525 -0
  245. package/src/modules/memory/events.ts +2 -0
  246. package/src/modules/memory/index.ts +6 -0
  247. package/src/modules/memory/prompt.ts +214 -0
  248. package/src/modules/memory/schemas.ts +170 -0
  249. package/src/modules/memory/service.ts +578 -0
  250. package/src/modules/memory/store.ts +489 -0
  251. package/src/modules/pr-events/actions.ts +191 -0
  252. package/src/modules/pr-events/index.ts +45 -0
  253. package/src/modules/pr-events/schemas.ts +186 -0
  254. package/src/modules/pr-events/service.ts +1414 -0
  255. package/src/modules/pr-events/target.ts +222 -0
  256. package/src/modules/pr-events/utils.ts +85 -0
  257. package/src/modules/pr-events/watermarks.ts +308 -0
  258. package/src/modules/pr-local-diffs/index.ts +334 -0
  259. package/src/modules/pr-review-assist/actions.ts +199 -0
  260. package/src/modules/pr-review-assist/index.ts +3 -0
  261. package/src/modules/pr-review-assist/schemas.ts +74 -0
  262. package/src/modules/pr-review-assist/service.ts +656 -0
  263. package/src/modules/prepared-diffs/actions.ts +132 -0
  264. package/src/modules/prepared-diffs/index.ts +53 -0
  265. package/src/modules/prepared-diffs/schemas.ts +255 -0
  266. package/src/modules/prepared-diffs/service.ts +777 -0
  267. package/src/modules/prepared-diffs/store.ts +606 -0
  268. package/src/modules/reports/index.ts +1 -0
  269. package/src/modules/reports/service.ts +322 -0
  270. package/src/modules/repos/index.ts +3 -0
  271. package/src/modules/repos/model-discovery.ts +233 -0
  272. package/src/modules/repos/providers.ts +194 -0
  273. package/src/modules/repos/registry.ts +232 -0
  274. package/src/modules/runtime/agent-config.ts +167 -0
  275. package/src/modules/runtime/doctor.ts +528 -0
  276. package/src/modules/runtime/env.ts +123 -0
  277. package/src/modules/runtime/index.ts +12 -0
  278. package/src/modules/runtime/local-api-auth.ts +43 -0
  279. package/src/modules/runtime/metrics.ts +211 -0
  280. package/src/modules/runtime/skills-actions.ts +141 -0
  281. package/src/modules/runtime/skills.ts +689 -0
  282. package/src/modules/runtime/soul.ts +68 -0
  283. package/src/modules/runtime/status-database.ts +252 -0
  284. package/src/modules/runtime/status-schema.ts +149 -0
  285. package/src/modules/runtime/status.ts +482 -0
  286. package/src/modules/runtime/subagents.ts +37 -0
  287. package/src/modules/runtime/utility-model.ts +47 -0
  288. package/src/modules/safety/index.ts +3 -0
  289. package/src/modules/safety/policy-entries.ts +2432 -0
  290. package/src/modules/safety/schemas.ts +63 -0
  291. package/src/modules/safety/service.ts +58 -0
  292. package/src/modules/safety/tools.ts +15 -0
  293. package/src/modules/scheduled-tasks/actions.ts +113 -0
  294. package/src/modules/scheduled-tasks/dispatch.ts +105 -0
  295. package/src/modules/scheduled-tasks/index.ts +6 -0
  296. package/src/modules/scheduled-tasks/schemas.ts +91 -0
  297. package/src/modules/scheduled-tasks/service.ts +296 -0
  298. package/src/modules/scheduled-tasks/store.ts +814 -0
  299. package/src/modules/scheduled-tasks/triggers.ts +87 -0
  300. package/src/modules/scheduler/actions.ts +37 -0
  301. package/src/modules/scheduler/dispatch.ts +126 -0
  302. package/src/modules/scheduler/index.ts +4 -0
  303. package/src/modules/scheduler/lease.ts +247 -0
  304. package/src/modules/scheduler/pr-watch-event-deltas.ts +367 -0
  305. package/src/modules/scheduler/pr-watch-events.ts +834 -0
  306. package/src/modules/scheduler/schemas.ts +79 -0
  307. package/src/modules/scheduler/service.ts +228 -0
  308. package/src/modules/scheduler/utils.ts +106 -0
  309. package/src/modules/scheduler/workflow-invocation.ts +40 -0
  310. package/src/modules/sessions/actions.ts +213 -0
  311. package/src/modules/sessions/active-session.ts +46 -0
  312. package/src/modules/sessions/agent-context.ts +146 -0
  313. package/src/modules/sessions/approval-nudges.ts +156 -0
  314. package/src/modules/sessions/events.ts +58 -0
  315. package/src/modules/sessions/index.ts +10 -0
  316. package/src/modules/sessions/queries.ts +252 -0
  317. package/src/modules/sessions/references.ts +113 -0
  318. package/src/modules/sessions/schemas.ts +263 -0
  319. package/src/modules/sessions/service.ts +845 -0
  320. package/src/modules/sessions/store.ts +559 -0
  321. package/src/modules/sessions/summaries.ts +129 -0
  322. package/src/modules/sessions/utils.ts +18 -0
  323. package/src/modules/watches/actions.ts +115 -0
  324. package/src/modules/watches/index.ts +6 -0
  325. package/src/modules/watches/polling.ts +245 -0
  326. package/src/modules/watches/references.ts +293 -0
  327. package/src/modules/watches/schemas.ts +156 -0
  328. package/src/modules/watches/service.ts +558 -0
  329. package/src/modules/watches/store.ts +398 -0
  330. package/src/modules/watches/utils.ts +51 -0
  331. package/src/modules/worktree-verification/index.ts +256 -0
  332. package/src/modules/worktrees/access.ts +129 -0
  333. package/src/modules/worktrees/actions.ts +108 -0
  334. package/src/modules/worktrees/cleanup.ts +98 -0
  335. package/src/modules/worktrees/errors.ts +38 -0
  336. package/src/modules/worktrees/git.ts +48 -0
  337. package/src/modules/worktrees/index.ts +5 -0
  338. package/src/modules/worktrees/locks.ts +192 -0
  339. package/src/modules/worktrees/paths.ts +209 -0
  340. package/src/modules/worktrees/queries.ts +31 -0
  341. package/src/modules/worktrees/schemas.ts +234 -0
  342. package/src/modules/worktrees/service.ts +657 -0
  343. package/src/modules/worktrees/store.ts +414 -0
  344. package/src/repo-edit/actions.ts +129 -0
  345. package/src/repo-edit/audit.ts +180 -0
  346. package/src/repo-edit/fuzzy-replace.ts +256 -0
  347. package/src/repo-edit/git.ts +784 -0
  348. package/src/repo-edit/index.ts +4 -0
  349. package/src/repo-edit/locks.ts +27 -0
  350. package/src/repo-edit/patch-parser.ts +212 -0
  351. package/src/repo-edit/patch-service.ts +572 -0
  352. package/src/repo-edit/path-safety.ts +294 -0
  353. package/src/repo-edit/schemas.ts +220 -0
  354. package/src/repo-edit/service.ts +488 -0
  355. package/src/repo-edit/support.ts +459 -0
  356. package/src/runtime-home/app-db/index.ts +73 -0
  357. package/src/runtime-home/app-db/migrate.ts +491 -0
  358. package/src/runtime-home/app-db/migrations/20260710061339_neondeck_pre_1_0_baseline/migration.sql +748 -0
  359. package/src/runtime-home/app-db/migrations/20260710061339_neondeck_pre_1_0_baseline/snapshot.json +7240 -0
  360. package/src/runtime-home/app-db/reconcile.ts +155 -0
  361. package/src/runtime-home/app-db/schema.ts +1118 -0
  362. package/src/runtime-home/bootstrap.ts +171 -0
  363. package/src/runtime-home/defaults.ts +42 -0
  364. package/src/runtime-home/files.ts +193 -0
  365. package/src/runtime-home/index.ts +68 -0
  366. package/src/runtime-home/paths.ts +75 -0
  367. package/src/runtime-home/schemas.ts +485 -0
  368. package/src/sandboxes/exedev.ts +676 -0
  369. package/src/server/app.ts +5 -0
  370. package/src/server/autopilot-push-dispatch.ts +326 -0
  371. package/src/server/create-app.ts +160 -0
  372. package/src/server/events/config-stream.ts +67 -0
  373. package/src/server/events/notification-stream.ts +49 -0
  374. package/src/server/events/session-stream.ts +49 -0
  375. package/src/server/http.ts +56 -0
  376. package/src/server/learning-hooks.ts +430 -0
  377. package/src/server/middleware.ts +81 -0
  378. package/src/server/routes/autopilot.ts +318 -0
  379. package/src/server/routes/commands.ts +12 -0
  380. package/src/server/routes/config.ts +124 -0
  381. package/src/server/routes/execution.ts +71 -0
  382. package/src/server/routes/github.ts +372 -0
  383. package/src/server/routes/handoff.ts +69 -0
  384. package/src/server/routes/kilo.ts +179 -0
  385. package/src/server/routes/learning.ts +384 -0
  386. package/src/server/routes/mcp.ts +301 -0
  387. package/src/server/routes/memory.ts +99 -0
  388. package/src/server/routes/metrics.ts +12 -0
  389. package/src/server/routes/notifications.ts +48 -0
  390. package/src/server/routes/repo-edit.ts +115 -0
  391. package/src/server/routes/reports.ts +127 -0
  392. package/src/server/routes/repos.ts +50 -0
  393. package/src/server/routes/runtime.ts +48 -0
  394. package/src/server/routes/safety.ts +13 -0
  395. package/src/server/routes/scheduled-tasks.ts +58 -0
  396. package/src/server/routes/scheduler.ts +13 -0
  397. package/src/server/routes/sessions.ts +216 -0
  398. package/src/server/routes/skills.ts +103 -0
  399. package/src/server/routes/watches.ts +81 -0
  400. package/src/server/routes/workflows.ts +21 -0
  401. package/src/server/routes/worktrees.ts +64 -0
  402. package/src/server/scheduler-workflow.ts +541 -0
  403. package/src/server/serve.ts +100 -0
  404. package/src/setup.ts +162 -0
  405. package/src/skills/github-gh/SKILL.md +56 -0
  406. package/src/skills/neon-ci-fix/SKILL.md +15 -0
  407. package/src/skills/neon-docs-fix/SKILL.md +15 -0
  408. package/src/skills/neon-issue-triage/SKILL.md +13 -0
  409. package/src/skills/neon-pr-review/SKILL.md +19 -0
  410. package/src/skills/neondeck/SKILL.md +123 -0
  411. package/src/skills/neondeck-handoff/SKILL.md +31 -0
  412. package/src/workflows/briefing.ts +14 -0
  413. package/src/workflows/command-run.ts +15 -0
  414. package/src/workflows/comment-pr-autofix-result.ts +10 -0
  415. package/src/workflows/curate_learning_store.ts +37 -0
  416. package/src/workflows/dev-doctor.ts +10 -0
  417. package/src/workflows/fix-pr-ci-failure.ts +10 -0
  418. package/src/workflows/fix-pr-ci.ts +15 -0
  419. package/src/workflows/fix-pr-review-feedback.ts +10 -0
  420. package/src/workflows/handoff_to_kilo.ts +10 -0
  421. package/src/workflows/prepare-pr-worktree.ts +10 -0
  422. package/src/workflows/promote_kilo_result.ts +10 -0
  423. package/src/workflows/push-pr-autofix.ts +10 -0
  424. package/src/workflows/reconcile_kilo_task.ts +10 -0
  425. package/src/workflows/review-pr-for-human.ts +15 -0
  426. package/src/workflows/review_conversation_for_learning.ts +37 -0
  427. package/src/workflows/review_kilo_result.ts +10 -0
  428. package/src/workflows/review_pr_batch_for_learning.ts +37 -0
  429. package/src/workflows/scheduled-agent-instruction.ts +16 -0
  430. package/src/workflows/scheduler-tick.ts +10 -0
  431. package/src/workflows/summarize_kilo_session.ts +25 -0
  432. package/src/workflows/triage-pr-event.ts +10 -0
  433. package/src/workflows/verify-pr-worktree.ts +10 -0
  434. package/src/workflows/verify-then-push-pr-autofix.ts +82 -0
  435. package/src/workflows/verify_kilo_result.ts +10 -0
  436. package/src/workflows/watch-pr.ts +10 -0
  437. package/web/dist/assets/GitHubPrReview-QK9oqeDs.js +2 -0
  438. package/web/dist/assets/MultiFileView-CMm6tA9f.js +2970 -0
  439. package/web/dist/assets/abap-CLvhMVsD.js +1 -0
  440. package/web/dist/assets/actionscript-3--17pq3dv.js +1 -0
  441. package/web/dist/assets/ada-C5qYipkI.js +1 -0
  442. package/web/dist/assets/andromeeda-vGVdxbeo.js +1 -0
  443. package/web/dist/assets/angular-html-BVBpGdXr.js +1 -0
  444. package/web/dist/assets/angular-ts-BfdufMKP.js +1 -0
  445. package/web/dist/assets/apache-U0d_L8uA.js +1 -0
  446. package/web/dist/assets/apex-VAyPSnFM.js +1 -0
  447. package/web/dist/assets/apl-DWBSSoBH.js +1 -0
  448. package/web/dist/assets/applescript-CCn79oCD.js +1 -0
  449. package/web/dist/assets/ara-4CJ0cIlV.js +1 -0
  450. package/web/dist/assets/asciidoc-DE70LPWp.js +1 -0
  451. package/web/dist/assets/asm-Cmm7eHzH.js +1 -0
  452. package/web/dist/assets/astro-3LtMP0Sq.js +1 -0
  453. package/web/dist/assets/aurora-x-CDeNXAV0.js +1 -0
  454. package/web/dist/assets/awk-BWXHIvNe.js +1 -0
  455. package/web/dist/assets/ayu-dark-DluEY0Gj.js +1 -0
  456. package/web/dist/assets/ayu-light-C3h-C4tm.js +1 -0
  457. package/web/dist/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  458. package/web/dist/assets/ballerina-B7ZEbQpA.js +1 -0
  459. package/web/dist/assets/bat-Bo4NYOV-.js +1 -0
  460. package/web/dist/assets/beancount-D-usSTwE.js +1 -0
  461. package/web/dist/assets/berry-DKpUyyne.js +1 -0
  462. package/web/dist/assets/bibtex-Ci_nEsc7.js +1 -0
  463. package/web/dist/assets/bicep-CUHmPFLl.js +1 -0
  464. package/web/dist/assets/bird2-C6vDhewU.js +1 -0
  465. package/web/dist/assets/blade-llJRbbtR.js +1 -0
  466. package/web/dist/assets/bsl-BkkzgIyY.js +1 -0
  467. package/web/dist/assets/c-Wt1voDr2.js +1 -0
  468. package/web/dist/assets/c3-BFHwR3_K.js +1 -0
  469. package/web/dist/assets/cadence-CQ2zXKGN.js +1 -0
  470. package/web/dist/assets/cairo-DLTphjLi.js +1 -0
  471. package/web/dist/assets/catppuccin-frappe-3VR1Za6u.js +1 -0
  472. package/web/dist/assets/catppuccin-latte-DwIHMF0Q.js +1 -0
  473. package/web/dist/assets/catppuccin-macchiato-DYnBP6_5.js +1 -0
  474. package/web/dist/assets/catppuccin-mocha-DYhrFGRu.js +1 -0
  475. package/web/dist/assets/clarity-SemFz856.js +1 -0
  476. package/web/dist/assets/clojure-DqKBuwfJ.js +1 -0
  477. package/web/dist/assets/cmake-Bj61d0ZC.js +1 -0
  478. package/web/dist/assets/cobol-x_HIyl2P.js +1 -0
  479. package/web/dist/assets/codeowners-C8r90Shi.js +1 -0
  480. package/web/dist/assets/codeql-oeQT6MSM.js +1 -0
  481. package/web/dist/assets/coffee-CThvmt4R.js +1 -0
  482. package/web/dist/assets/common-lisp-Cv5bFMCO.js +1 -0
  483. package/web/dist/assets/coq-BrsZFFmf.js +1 -0
  484. package/web/dist/assets/cpp-NtAeskI3.js +1 -0
  485. package/web/dist/assets/crystal-DNu_sX0G.js +1 -0
  486. package/web/dist/assets/csharp-oqKa8noW.js +1 -0
  487. package/web/dist/assets/css-DJp_X0uY.js +1 -0
  488. package/web/dist/assets/csv-Dx-8-gkx.js +1 -0
  489. package/web/dist/assets/cue-CE9AQfxI.js +1 -0
  490. package/web/dist/assets/cypher-ClKdZ_lG.js +1 -0
  491. package/web/dist/assets/d-qD-0Kul2.js +1 -0
  492. package/web/dist/assets/dark-plus-Cs2F2srj.js +1 -0
  493. package/web/dist/assets/dart-CnvKMtbv.js +1 -0
  494. package/web/dist/assets/dax-BkyTk9wS.js +1 -0
  495. package/web/dist/assets/desktop-Dlh5hvp9.js +1 -0
  496. package/web/dist/assets/diff-woXpYk--.js +1 -0
  497. package/web/dist/assets/docker-IyjqRm3v.js +1 -0
  498. package/web/dist/assets/dotenv-_5a1GRtc.js +1 -0
  499. package/web/dist/assets/dracula-BHWKrbxM.js +1 -0
  500. package/web/dist/assets/dracula-soft-5eyTD99u.js +1 -0
  501. package/web/dist/assets/dream-maker-DW3nJb8Q.js +1 -0
  502. package/web/dist/assets/edge-ozw5tpLl.js +1 -0
  503. package/web/dist/assets/elixir-VhA6FeZt.js +1 -0
  504. package/web/dist/assets/elm-dREJmIFz.js +1 -0
  505. package/web/dist/assets/emacs-lisp-B4R74twV.js +1 -0
  506. package/web/dist/assets/erb-CIg6G69l.js +1 -0
  507. package/web/dist/assets/erlang-Cphh6RMH.js +1 -0
  508. package/web/dist/assets/everforest-dark-sB-x3p7T.js +1 -0
  509. package/web/dist/assets/everforest-light-Df2xbC6M.js +1 -0
  510. package/web/dist/assets/fennel-DQxkIbk2.js +1 -0
  511. package/web/dist/assets/fish-BJitypiv.js +1 -0
  512. package/web/dist/assets/fluent-C03EYrpw.js +1 -0
  513. package/web/dist/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
  514. package/web/dist/assets/fortran-free-form-CYNrtFtB.js +1 -0
  515. package/web/dist/assets/fsharp-D13ZGOAj.js +1 -0
  516. package/web/dist/assets/gdresource-C0sCabJj.js +1 -0
  517. package/web/dist/assets/gdscript-Cp2uCuqX.js +1 -0
  518. package/web/dist/assets/gdshader-CBce3t8t.js +1 -0
  519. package/web/dist/assets/genie-CV2tkWYe.js +1 -0
  520. package/web/dist/assets/gherkin-DExj1W_8.js +1 -0
  521. package/web/dist/assets/git-commit-BSykSTBG.js +1 -0
  522. package/web/dist/assets/git-rebase-B44mJPta.js +1 -0
  523. package/web/dist/assets/github-dark-C-LZuMrd.js +1 -0
  524. package/web/dist/assets/github-dark-default-DXG-b-1a.js +1 -0
  525. package/web/dist/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  526. package/web/dist/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  527. package/web/dist/assets/github-light-EUqPIrTm.js +1 -0
  528. package/web/dist/assets/github-light-default-BXViO-2h.js +1 -0
  529. package/web/dist/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  530. package/web/dist/assets/gleam-CSRkHgEL.js +1 -0
  531. package/web/dist/assets/glimmer-js-vH_gHG0-.js +1 -0
  532. package/web/dist/assets/glimmer-ts--abOzSAQ.js +1 -0
  533. package/web/dist/assets/glsl-Dv5r7kPw.js +1 -0
  534. package/web/dist/assets/gn-ilITqXS6.js +1 -0
  535. package/web/dist/assets/gnuplot-7GGW24-e.js +1 -0
  536. package/web/dist/assets/go-rLFTqkRN.js +1 -0
  537. package/web/dist/assets/graphql-CB4jsw2E.js +1 -0
  538. package/web/dist/assets/groovy-CacY0gHj.js +1 -0
  539. package/web/dist/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  540. package/web/dist/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  541. package/web/dist/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  542. package/web/dist/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  543. package/web/dist/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  544. package/web/dist/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  545. package/web/dist/assets/hack-DvEYX148.js +1 -0
  546. package/web/dist/assets/haml-zE6W3STP.js +1 -0
  547. package/web/dist/assets/handlebars-CzBR2SDs.js +1 -0
  548. package/web/dist/assets/haskell-D8IpX4py.js +1 -0
  549. package/web/dist/assets/haxe-OTjmBuCE.js +1 -0
  550. package/web/dist/assets/hcl-Dh228itO.js +1 -0
  551. package/web/dist/assets/hjson-CxZEssPk.js +1 -0
  552. package/web/dist/assets/hlsl-Cvrh5tZx.js +1 -0
  553. package/web/dist/assets/horizon-CE9ld1lL.js +1 -0
  554. package/web/dist/assets/horizon-bright-DSNQnXHK.js +1 -0
  555. package/web/dist/assets/houston-CsvMBhTu.js +1 -0
  556. package/web/dist/assets/html-C8UlPnhE.js +1 -0
  557. package/web/dist/assets/html-derivative-CY6NRz-J.js +1 -0
  558. package/web/dist/assets/http-Cyd7bS_S.js +1 -0
  559. package/web/dist/assets/hurl-CWPsiEpf.js +1 -0
  560. package/web/dist/assets/hxml-B0Qn7Nwc.js +1 -0
  561. package/web/dist/assets/hy-CZbG8q4J.js +1 -0
  562. package/web/dist/assets/imba-DsUTQ-LC.js +1 -0
  563. package/web/dist/assets/index-DqZpo0Jd.js +44 -0
  564. package/web/dist/assets/index-_jKCE4ks.css +2 -0
  565. package/web/dist/assets/ini-B5eOa1yu.js +1 -0
  566. package/web/dist/assets/java-CGc3VwQr.js +1 -0
  567. package/web/dist/assets/javascript-CUt1pgmJ.js +1 -0
  568. package/web/dist/assets/jinja-CD-Z-FLd.js +1 -0
  569. package/web/dist/assets/jison-imPNup1l.js +1 -0
  570. package/web/dist/assets/json-Bg9ijW3F.js +1 -0
  571. package/web/dist/assets/json5-BR5RXkoi.js +1 -0
  572. package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
  573. package/web/dist/assets/jsonl-CmCQp5Yx.js +1 -0
  574. package/web/dist/assets/jsonnet-CJTPZ8u_.js +1 -0
  575. package/web/dist/assets/jssm-DXw9l8Rf.js +1 -0
  576. package/web/dist/assets/jsx-CY6oMTks.js +1 -0
  577. package/web/dist/assets/julia-Dc3O-irA.js +1 -0
  578. package/web/dist/assets/just-BhOq_Kbv.js +1 -0
  579. package/web/dist/assets/kanagawa-dragon-CXtmUGW6.js +1 -0
  580. package/web/dist/assets/kanagawa-lotus-BN08jTvb.js +1 -0
  581. package/web/dist/assets/kanagawa-wave-CTweb8Dz.js +1 -0
  582. package/web/dist/assets/kdl-CsD5j6eV.js +1 -0
  583. package/web/dist/assets/kotlin-DhhofPvG.js +1 -0
  584. package/web/dist/assets/kusto-C7mF5XQf.js +1 -0
  585. package/web/dist/assets/laserwave-C_8bwKvT.js +1 -0
  586. package/web/dist/assets/latex-Cu4Y1d5w.js +1 -0
  587. package/web/dist/assets/lean-CewbzKMR.js +1 -0
  588. package/web/dist/assets/less-DVTAwKKz.js +1 -0
  589. package/web/dist/assets/light-plus-DVQuIRkW.js +1 -0
  590. package/web/dist/assets/liquid-CvXMrjlQ.js +1 -0
  591. package/web/dist/assets/llvm-Cm23YOpf.js +1 -0
  592. package/web/dist/assets/log-BNLmms1o.js +1 -0
  593. package/web/dist/assets/logo-Cluzi2Zq.js +1 -0
  594. package/web/dist/assets/lua-BjLEUjKY.js +1 -0
  595. package/web/dist/assets/luau-FMPmPwt6.js +1 -0
  596. package/web/dist/assets/make-Dixweg8N.js +1 -0
  597. package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
  598. package/web/dist/assets/marko-DvhNOisQ.js +1 -0
  599. package/web/dist/assets/material-theme-Bm3Qr25_.js +1 -0
  600. package/web/dist/assets/material-theme-darker-2IIEA8gg.js +1 -0
  601. package/web/dist/assets/material-theme-lighter-uhdI0v04.js +1 -0
  602. package/web/dist/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  603. package/web/dist/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  604. package/web/dist/assets/matlab-D7qyCx1q.js +1 -0
  605. package/web/dist/assets/mdc-Bm9TpL1X.js +1 -0
  606. package/web/dist/assets/mdx-DQZ5AkYe.js +1 -0
  607. package/web/dist/assets/mermaid-Bk4SNUv9.js +1 -0
  608. package/web/dist/assets/min-dark-BSWPekZh.js +1 -0
  609. package/web/dist/assets/min-light-DDpmG2fV.js +1 -0
  610. package/web/dist/assets/mipsasm-BMqwQI7S.js +1 -0
  611. package/web/dist/assets/mojo-BgCJLMeH.js +1 -0
  612. package/web/dist/assets/monokai-CdkpiU2Y.js +1 -0
  613. package/web/dist/assets/moonbit-CaWjb8XO.js +1 -0
  614. package/web/dist/assets/move-B1IS1UjX.js +1 -0
  615. package/web/dist/assets/narrat-_X_XdTYD.js +1 -0
  616. package/web/dist/assets/nextflow-BJtWHP5T.js +1 -0
  617. package/web/dist/assets/nextflow-groovy-DJMQeKeT.js +1 -0
  618. package/web/dist/assets/nginx-Bhc82uuv.js +1 -0
  619. package/web/dist/assets/night-owl-DhmEMT88.js +1 -0
  620. package/web/dist/assets/night-owl-light-eJ-hLW7d.js +1 -0
  621. package/web/dist/assets/nim-DXTVBFnF.js +1 -0
  622. package/web/dist/assets/nix-IvuFDN5E.js +1 -0
  623. package/web/dist/assets/nord-Cb4Vim4T.js +1 -0
  624. package/web/dist/assets/nushell-DcLAeLz5.js +1 -0
  625. package/web/dist/assets/objective-c-D1A_Heim.js +1 -0
  626. package/web/dist/assets/objective-cpp-BsSzOQcm.js +1 -0
  627. package/web/dist/assets/ocaml-O90oeIOV.js +1 -0
  628. package/web/dist/assets/odin-B1RWQWA5.js +1 -0
  629. package/web/dist/assets/one-dark-pro-CLwyXe_n.js +1 -0
  630. package/web/dist/assets/one-light-D7Lr4KcI.js +1 -0
  631. package/web/dist/assets/openscad-BUDT5pXO.js +1 -0
  632. package/web/dist/assets/pascal-4ZHwLPI5.js +1 -0
  633. package/web/dist/assets/perl-C7veXV9z.js +1 -0
  634. package/web/dist/assets/php-BRiuMnnr.js +1 -0
  635. package/web/dist/assets/pierre-dark-CpLgRqie.js +1 -0
  636. package/web/dist/assets/pierre-dark-protanopia-deuteranopia-B35FxJx-.js +1 -0
  637. package/web/dist/assets/pierre-dark-soft-kZQmAZld.js +1 -0
  638. package/web/dist/assets/pierre-dark-tritanopia-CpjhbsIL.js +1 -0
  639. package/web/dist/assets/pierre-dark-vibrant-CpQYzh95.js +1 -0
  640. package/web/dist/assets/pierre-light-CoaEpmwp.js +1 -0
  641. package/web/dist/assets/pierre-light-protanopia-deuteranopia-0fSaH845.js +1 -0
  642. package/web/dist/assets/pierre-light-soft-lWLdNTOI.js +1 -0
  643. package/web/dist/assets/pierre-light-tritanopia-CEbqgOJL.js +1 -0
  644. package/web/dist/assets/pierre-light-vibrant-D80Fkn33.js +1 -0
  645. package/web/dist/assets/pkl-ot-7Btpt.js +1 -0
  646. package/web/dist/assets/plastic-DQwYfKfQ.js +1 -0
  647. package/web/dist/assets/plsql-DGHpHOYJ.js +1 -0
  648. package/web/dist/assets/po-BiJDBrnU.js +1 -0
  649. package/web/dist/assets/poimandres-DRFjx7u4.js +1 -0
  650. package/web/dist/assets/polar-C7UOKdEL.js +1 -0
  651. package/web/dist/assets/postcss-BXeXVLqQ.js +1 -0
  652. package/web/dist/assets/powerquery-DNMTfnFr.js +1 -0
  653. package/web/dist/assets/powershell-DshXNtvi.js +1 -0
  654. package/web/dist/assets/prisma-BsRQq5mF.js +1 -0
  655. package/web/dist/assets/prolog-iXnhIJG7.js +1 -0
  656. package/web/dist/assets/proto-DB4EqR-F.js +1 -0
  657. package/web/dist/assets/pug-C5hz5LQ7.js +1 -0
  658. package/web/dist/assets/puppet-CDv2pdJW.js +1 -0
  659. package/web/dist/assets/purescript-9MfHhQsQ.js +1 -0
  660. package/web/dist/assets/python-gzcpVVnB.js +1 -0
  661. package/web/dist/assets/qml-BdUV3aTS.js +1 -0
  662. package/web/dist/assets/qmldir-DCQb3MpD.js +1 -0
  663. package/web/dist/assets/qss-Fe1Jh2GI.js +1 -0
  664. package/web/dist/assets/r-8R7vtdQc.js +1 -0
  665. package/web/dist/assets/racket-DcIDlBhZ.js +1 -0
  666. package/web/dist/assets/raku-B3gFvitq.js +1 -0
  667. package/web/dist/assets/razor-DRL52XO2.js +1 -0
  668. package/web/dist/assets/red-CJ3rzSJv.js +1 -0
  669. package/web/dist/assets/reg-CRGYupPL.js +1 -0
  670. package/web/dist/assets/regexp-Omp9DhTb.js +1 -0
  671. package/web/dist/assets/rel-BtDbiS_P.js +1 -0
  672. package/web/dist/assets/riscv-Ckw8ddFX.js +1 -0
  673. package/web/dist/assets/rolldown-runtime-QTnfLwEv.js +1 -0
  674. package/web/dist/assets/ron-VUp2lXgN.js +1 -0
  675. package/web/dist/assets/rose-pine-BthvhNj6.js +1 -0
  676. package/web/dist/assets/rose-pine-dawn-Dg85fqjY.js +1 -0
  677. package/web/dist/assets/rose-pine-moon-hon4tzzS.js +1 -0
  678. package/web/dist/assets/rosmsg-CAekHB0j.js +1 -0
  679. package/web/dist/assets/rst-BHX71KW9.js +1 -0
  680. package/web/dist/assets/ruby-B--HzjGU.js +1 -0
  681. package/web/dist/assets/rust-Cfkwpbl8.js +1 -0
  682. package/web/dist/assets/sas-DrLaYOK_.js +1 -0
  683. package/web/dist/assets/sass-DXrisJhu.js +1 -0
  684. package/web/dist/assets/scala-DKOlJaKm.js +1 -0
  685. package/web/dist/assets/scheme-DQCgrYNe.js +1 -0
  686. package/web/dist/assets/scss-DdSxiZKl.js +1 -0
  687. package/web/dist/assets/sdbl-bTVj8UrX.js +1 -0
  688. package/web/dist/assets/shaderlab-TOUzSsQk.js +1 -0
  689. package/web/dist/assets/shellscript-DwcUjJBL.js +1 -0
  690. package/web/dist/assets/shellsession-CPZkydE6.js +1 -0
  691. package/web/dist/assets/slack-dark-DnToyrRv.js +1 -0
  692. package/web/dist/assets/slack-ochin-B2OO5cIa.js +1 -0
  693. package/web/dist/assets/smalltalk-B16xEiuN.js +1 -0
  694. package/web/dist/assets/snazzy-light-4G7pJPwS.js +1 -0
  695. package/web/dist/assets/solarized-dark-DV17i1UV.js +1 -0
  696. package/web/dist/assets/solarized-light-DSh2HLQt.js +1 -0
  697. package/web/dist/assets/solidity-CKzVLygQ.js +1 -0
  698. package/web/dist/assets/soy-Br5FhD7c.js +1 -0
  699. package/web/dist/assets/sparql-D_iOobhT.js +1 -0
  700. package/web/dist/assets/splunk-BC2Px7Mm.js +1 -0
  701. package/web/dist/assets/sql-DNssxck8.js +1 -0
  702. package/web/dist/assets/ssh-config-BgfXC-Er.js +1 -0
  703. package/web/dist/assets/stata-DXn1tqOr.js +1 -0
  704. package/web/dist/assets/stylus-B6D30XZt.js +1 -0
  705. package/web/dist/assets/surfaces-B8Ko8AJ3.js +1 -0
  706. package/web/dist/assets/surrealql-IeLNQw0f.js +1 -0
  707. package/web/dist/assets/svelte-DOdLCIlh.js +1 -0
  708. package/web/dist/assets/swift-DonLKvLd.js +1 -0
  709. package/web/dist/assets/synthwave-84-nFMaYfgc.js +1 -0
  710. package/web/dist/assets/system-verilog-DJ5XKQeo.js +1 -0
  711. package/web/dist/assets/systemd-BxMlprV5.js +1 -0
  712. package/web/dist/assets/talonscript-CohzipZa.js +1 -0
  713. package/web/dist/assets/tasl-DMoTqEGO.js +1 -0
  714. package/web/dist/assets/tcl-CZd0xW_V.js +1 -0
  715. package/web/dist/assets/templ-CIwIngms.js +1 -0
  716. package/web/dist/assets/terraform-DswuEJGm.js +1 -0
  717. package/web/dist/assets/tex-D8QMumu5.js +1 -0
  718. package/web/dist/assets/tokyo-night-oM2G3aXe.js +1 -0
  719. package/web/dist/assets/toml-CcmNWLt0.js +1 -0
  720. package/web/dist/assets/ts-tags-BMVY4q-l.js +1 -0
  721. package/web/dist/assets/tsv-sltzmVWM.js +1 -0
  722. package/web/dist/assets/tsx-5Eka4NBX.js +1 -0
  723. package/web/dist/assets/turtle-ByJddavk.js +1 -0
  724. package/web/dist/assets/twig-C8o_5mgw.js +1 -0
  725. package/web/dist/assets/typescript-DOu2WMV5.js +1 -0
  726. package/web/dist/assets/typespec-BRdr0IET.js +1 -0
  727. package/web/dist/assets/typst-DI99ib-x.js +1 -0
  728. package/web/dist/assets/v-DETTlOr0.js +1 -0
  729. package/web/dist/assets/vala-zf12oZj6.js +1 -0
  730. package/web/dist/assets/vb-Djn5o6TS.js +1 -0
  731. package/web/dist/assets/verilog-CiiDBU1e.js +1 -0
  732. package/web/dist/assets/vesper-DdrHHSXu.js +1 -0
  733. package/web/dist/assets/vhdl-BroJfC0k.js +1 -0
  734. package/web/dist/assets/viml-DvXPmvsu.js +1 -0
  735. package/web/dist/assets/vitesse-black-fwtXNY1n.js +1 -0
  736. package/web/dist/assets/vitesse-dark-BZCL-v6S.js +1 -0
  737. package/web/dist/assets/vitesse-light-VbXTXTou.js +1 -0
  738. package/web/dist/assets/vue-BU18DNDL.js +1 -0
  739. package/web/dist/assets/vue-html-BeluIYX0.js +1 -0
  740. package/web/dist/assets/vue-vine-DGUAbOCX.js +1 -0
  741. package/web/dist/assets/vyper-CgoNMtux.js +1 -0
  742. package/web/dist/assets/wasm-BnjxR4X6.js +1 -0
  743. package/web/dist/assets/wasm-ByWQv1Qj.js +1 -0
  744. package/web/dist/assets/wenyan-C8pVoKbM.js +1 -0
  745. package/web/dist/assets/wgsl-BsKzXJz4.js +1 -0
  746. package/web/dist/assets/wikitext-ClFFjSW2.js +1 -0
  747. package/web/dist/assets/wit-DdvCle-K.js +1 -0
  748. package/web/dist/assets/wolfram-DLL8P-h_.js +1 -0
  749. package/web/dist/assets/worker-CBKQOXEl.js +160 -0
  750. package/web/dist/assets/xml-DIqSwXR3.js +1 -0
  751. package/web/dist/assets/xsl-Ct_-YIAy.js +1 -0
  752. package/web/dist/assets/yaml-DTtCYNlS.js +1 -0
  753. package/web/dist/assets/zenscript-BnlCZFoB.js +1 -0
  754. package/web/dist/assets/zig-CMLA9XwU.js +1 -0
  755. package/web/dist/icons/neondeck-icon-192.png +0 -0
  756. package/web/dist/icons/neondeck-icon-512.png +0 -0
  757. package/web/dist/icons/neondeck-icon.svg +41 -0
  758. package/web/dist/icons/neondeck-maskable-512.png +0 -0
  759. package/web/dist/index.html +24 -0
  760. package/web/dist/manifest.webmanifest +28 -0
@@ -0,0 +1,1332 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { fileURLToPath } from 'node:url';
4
+ import * as v from 'valibot';
5
+ import { asJsonValue } from '../../lib/action-result';
6
+ import { renderReportHtml } from '../../lib/report-html';
7
+ import {
8
+ ensureRuntimeHome,
9
+ runtimePaths,
10
+ type RepoConfig,
11
+ type RuntimePaths,
12
+ } from '../../runtime-home';
13
+ import {
14
+ addNotification,
15
+ addWorkflowSummary,
16
+ findWorkflowSummaryByKiloTaskId,
17
+ updateWorkflowSummary,
18
+ } from '../app-state';
19
+ import {
20
+ fetchFailingCheckFacts,
21
+ pullRequestEventStateTruncation,
22
+ type GitHubFailingCheckFact,
23
+ type GitHubPullRequestEventState,
24
+ } from '../github';
25
+ import { startKiloTask } from '../kilo';
26
+ import { loadAutomationLearningMemoryContext } from '../learning';
27
+ import { writeReport, type ReportRecord } from '../reports';
28
+ import { getGitHubPrEventState, type PullRequestTarget } from '../pr-events';
29
+ import type { PrEventStateDependencies } from '../pr-events';
30
+ import { readRepoRegistrySnapshot, repoFullName } from '../repos';
31
+ import { loadRuntimeSkill } from '../runtime';
32
+ import { lockWorktree, releaseWorktreeLock } from '../worktrees';
33
+ import { preparePrWorktree } from './worktree';
34
+ import { identifyLikelyCommands } from './github-facts';
35
+ import { errorMessage } from './utils';
36
+
37
+ const nonEmptyStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
38
+ const positiveIntegerSchema = v.pipe(v.number(), v.integer(), v.minValue(1));
39
+ const neonCiFixSkillPath = fileURLToPath(
40
+ new URL('../../skills/neon-ci-fix/SKILL.md', import.meta.url),
41
+ );
42
+
43
+ export const ciFixRunInputSchema = v.object({
44
+ ref: v.optional(nonEmptyStringSchema),
45
+ repo: v.optional(nonEmptyStringSchema),
46
+ prNumber: v.optional(positiveIntegerSchema),
47
+ reportOnly: v.optional(v.boolean()),
48
+ maxLogBytes: v.optional(
49
+ v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(256 * 1024)),
50
+ ),
51
+ });
52
+
53
+ export const ciFixRunOutputSchema = v.looseObject({
54
+ ok: v.boolean(),
55
+ action: v.string(),
56
+ changed: v.boolean(),
57
+ message: v.string(),
58
+ });
59
+
60
+ export type CiFixRunInput = v.InferInput<typeof ciFixRunInputSchema>;
61
+ export type CiFixRunOutput = Awaited<ReturnType<typeof runCiFix>>;
62
+
63
+ export type CiFixDossier = {
64
+ target: PullRequestTarget;
65
+ state: GitHubPullRequestEventState;
66
+ repo: RepoConfig | null;
67
+ failingChecks: GitHubFailingCheckFact[];
68
+ failingCheckFactsError: string | null;
69
+ likelyCommands: string[];
70
+ fetchedAt: string;
71
+ };
72
+
73
+ export type CiFixRunDependencies = {
74
+ readDossier?: (
75
+ input: v.InferOutput<typeof ciFixRunInputSchema>,
76
+ paths: RuntimePaths,
77
+ ) => Promise<CiFixDossier>;
78
+ fetchFailingCheckFacts?: typeof fetchFailingCheckFacts;
79
+ prEventDependencies?: PrEventStateDependencies;
80
+ preparePrWorktree?: typeof preparePrWorktree;
81
+ startKiloTask?: typeof startKiloTask;
82
+ lockWorktree?: typeof lockWorktree;
83
+ releaseWorktreeLock?: typeof releaseWorktreeLock;
84
+ };
85
+
86
+ export async function createCiFixReport(
87
+ rawInput: CiFixRunInput,
88
+ paths = runtimePaths(),
89
+ dependencies: CiFixRunDependencies = {},
90
+ ) {
91
+ const parsed = parseCiFixInput(rawInput);
92
+ if (!parsed.ok) return parsed.result;
93
+ const dossier = await readCiFixDossier(parsed.input, paths, dependencies);
94
+ if (!dossier.ok) return dossier.result;
95
+ const report = await writeCiFixDossierReport(
96
+ dossier.dossier,
97
+ {
98
+ createdBy: 'explain-ci',
99
+ mode: 'report-only',
100
+ },
101
+ paths,
102
+ );
103
+ return {
104
+ ok: true,
105
+ action: 'ci_fix_report' as const,
106
+ changed: true,
107
+ message: `Wrote CI failure dossier report for ${sourceRef(dossier.dossier)}.`,
108
+ report,
109
+ data: asJsonValue({
110
+ report: reportLink(report),
111
+ dossier: dossierSummary(dossier.dossier),
112
+ workflow: 'fix-pr-ci',
113
+ mode: 'report-only',
114
+ }),
115
+ };
116
+ }
117
+
118
+ export async function runCiFix(
119
+ rawInput: CiFixRunInput,
120
+ paths = runtimePaths(),
121
+ dependencies: CiFixRunDependencies = {},
122
+ ) {
123
+ const parsed = parseCiFixInput(rawInput);
124
+ if (!parsed.ok) return parsed.result;
125
+ await ensureRuntimeHome(paths);
126
+
127
+ const dossierResult = await readCiFixDossier(
128
+ parsed.input,
129
+ paths,
130
+ dependencies,
131
+ );
132
+ if (!dossierResult.ok) {
133
+ return preDossierFailure(parsed.input, dossierResult.result, paths);
134
+ }
135
+ const dossier = dossierResult.dossier;
136
+ const report = await writeCiFixDossierReport(
137
+ dossier,
138
+ {
139
+ createdBy: 'fix-pr-ci',
140
+ mode: parsed.input.reportOnly ? 'report-only' : 'fix',
141
+ },
142
+ paths,
143
+ );
144
+
145
+ if (parsed.input.reportOnly) {
146
+ return {
147
+ ok: true,
148
+ action: 'ci_fix_run' as const,
149
+ changed: true,
150
+ message: `Wrote CI failure dossier report for ${sourceRef(dossier)}.`,
151
+ data: asJsonValue({
152
+ workflow: 'fix-pr-ci',
153
+ mode: 'report-only',
154
+ report: reportLink(report),
155
+ dossier: dossierSummary(dossier),
156
+ }),
157
+ };
158
+ }
159
+
160
+ const stateTruncation = pullRequestEventStateTruncation(dossier.state);
161
+ if (stateTruncation.any) {
162
+ const message =
163
+ 'CI fix handoff requires complete PR event facts; wrote the dossier report but did not start Kilo because GitHub data was truncated.';
164
+ await notifyCiFixAttention(dossier, report, message, paths);
165
+ const workflowSummary = await addTerminalCiFixSummary(
166
+ dossier,
167
+ report,
168
+ {
169
+ status: 'failed',
170
+ outcome: 'pr-event-facts-truncated',
171
+ message,
172
+ requires: ['completePrEventFacts'],
173
+ truncation: stateTruncation.categories,
174
+ },
175
+ paths,
176
+ );
177
+ return failure(message, {
178
+ requires: ['completePrEventFacts'],
179
+ errors: [
180
+ `Truncated PR event fact categories: ${stateTruncation.categories.join(', ')}.`,
181
+ ],
182
+ data: {
183
+ report: reportLink(report),
184
+ dossier: dossierSummary(dossier),
185
+ truncation: stateTruncation,
186
+ },
187
+ workflowSummary,
188
+ });
189
+ }
190
+
191
+ if (dossier.failingCheckFactsError) {
192
+ const message =
193
+ 'CI fix handoff requires failing check facts; wrote the dossier report but did not start Kilo because check facts were unavailable.';
194
+ await notifyCiFixAttention(dossier, report, message, paths);
195
+ const workflowSummary = await addTerminalCiFixSummary(
196
+ dossier,
197
+ report,
198
+ {
199
+ status: 'failed',
200
+ outcome: 'failing-check-facts-unavailable',
201
+ message,
202
+ requires: ['github-check-facts'],
203
+ errors: [dossier.failingCheckFactsError],
204
+ },
205
+ paths,
206
+ );
207
+ return failure(message, {
208
+ requires: ['github-check-facts'],
209
+ errors: [dossier.failingCheckFactsError],
210
+ data: {
211
+ report: reportLink(report),
212
+ dossier: dossierSummary(dossier),
213
+ },
214
+ workflowSummary,
215
+ });
216
+ }
217
+
218
+ const failingCheckLogFactsError =
219
+ incompleteFailingCheckLogFactsError(dossier);
220
+ if (failingCheckLogFactsError) {
221
+ const message =
222
+ 'CI fix handoff requires complete failing check logs; wrote the dossier report but did not start Kilo because GitHub log facts were incomplete.';
223
+ await notifyCiFixAttention(dossier, report, message, paths);
224
+ const workflowSummary = await addTerminalCiFixSummary(
225
+ dossier,
226
+ report,
227
+ {
228
+ status: 'failed',
229
+ outcome: 'failing-check-logs-incomplete',
230
+ message,
231
+ requires: ['github-check-facts'],
232
+ errors: [failingCheckLogFactsError],
233
+ },
234
+ paths,
235
+ );
236
+ return failure(message, {
237
+ requires: ['github-check-facts'],
238
+ errors: [failingCheckLogFactsError],
239
+ data: {
240
+ report: reportLink(report),
241
+ dossier: dossierSummary(dossier),
242
+ },
243
+ workflowSummary,
244
+ });
245
+ }
246
+
247
+ if (dossier.failingChecks.length === 0) {
248
+ const message =
249
+ 'No failing GitHub check runs were present in the current CI dossier.';
250
+ await notifyCiFixAttention(dossier, report, message, paths);
251
+ const workflowSummary = await addTerminalCiFixSummary(
252
+ dossier,
253
+ report,
254
+ {
255
+ status: 'failed',
256
+ outcome: 'no-failing-checks',
257
+ message,
258
+ requires: ['failingChecks'],
259
+ },
260
+ paths,
261
+ );
262
+ return failure(message, {
263
+ requires: ['failingChecks'],
264
+ data: {
265
+ report: reportLink(report),
266
+ dossier: dossierSummary(dossier),
267
+ },
268
+ workflowSummary,
269
+ });
270
+ }
271
+
272
+ if (!dossier.repo) {
273
+ const message = `Repository ${dossier.target.repoFullName} is not configured for managed worktrees.`;
274
+ await notifyCiFixAttention(
275
+ dossier,
276
+ report,
277
+ 'Repository is not configured.',
278
+ paths,
279
+ );
280
+ const workflowSummary = await addTerminalCiFixSummary(
281
+ dossier,
282
+ report,
283
+ {
284
+ status: 'failed',
285
+ outcome: 'repo-missing',
286
+ message,
287
+ requires: ['repo'],
288
+ },
289
+ paths,
290
+ );
291
+ return failure(message, {
292
+ requires: ['repo'],
293
+ data: {
294
+ report: reportLink(report),
295
+ dossier: dossierSummary(dossier),
296
+ },
297
+ workflowSummary,
298
+ });
299
+ }
300
+
301
+ let releaseStatus: 'ready' | 'failed' | null = 'ready';
302
+ let lock: Awaited<ReturnType<typeof lockWorktree>> | null = null;
303
+ try {
304
+ lock = await (dependencies.lockWorktree ?? lockWorktree)(
305
+ {
306
+ repoId: dossier.repo.id,
307
+ prNumber: dossier.target.number,
308
+ scope: 'pr',
309
+ owner: 'ci-fix-run',
310
+ ttlSeconds: 86_400,
311
+ },
312
+ paths,
313
+ );
314
+ if (!lock.ok || !('lock' in lock)) {
315
+ releaseStatus = null;
316
+ await notifyCiFixAttention(dossier, report, lock.message, paths);
317
+ const workflowSummary = await addTerminalCiFixSummary(
318
+ dossier,
319
+ report,
320
+ {
321
+ status: 'failed',
322
+ outcome: 'lock-failed',
323
+ message: lock.message,
324
+ requires: ['worktreeLock'],
325
+ },
326
+ paths,
327
+ );
328
+ return failure(lock.message, {
329
+ requires: ['worktreeLock'],
330
+ data: {
331
+ report: reportLink(report),
332
+ dossier: dossierSummary(dossier),
333
+ lock,
334
+ },
335
+ workflowSummary,
336
+ });
337
+ }
338
+
339
+ const prepared = await (
340
+ dependencies.preparePrWorktree ?? preparePrWorktree
341
+ )(
342
+ {
343
+ repoId: dossier.repo.id,
344
+ prNumber: dossier.target.number,
345
+ createWorktree: true,
346
+ sync: true,
347
+ fetch: true,
348
+ lock: false,
349
+ lockId: lock.lock.id,
350
+ },
351
+ paths,
352
+ );
353
+ if (!prepared.ok) {
354
+ releaseStatus = 'failed';
355
+ await notifyCiFixAttention(dossier, report, prepared.message, paths);
356
+ const workflowSummary = await addTerminalCiFixSummary(
357
+ dossier,
358
+ report,
359
+ {
360
+ status: 'failed',
361
+ outcome: 'prepare-failed',
362
+ message: prepared.message,
363
+ requires: prepared.requires,
364
+ ciFixLockId: lock.lock.id,
365
+ },
366
+ paths,
367
+ );
368
+ return lowerLevelFailure('autopilot_prepare_pr_worktree', prepared, {
369
+ report,
370
+ dossier,
371
+ workflowSummary,
372
+ });
373
+ }
374
+
375
+ const preparedWorktree = objectField(objectField(prepared.data).worktree);
376
+ const worktreeId = stringField(preparedWorktree.id);
377
+ if (!worktreeId) {
378
+ releaseStatus = 'failed';
379
+ const message = 'PR worktree preparation did not return a worktree id.';
380
+ await notifyCiFixAttention(dossier, report, message, paths);
381
+ const workflowSummary = await addTerminalCiFixSummary(
382
+ dossier,
383
+ report,
384
+ {
385
+ status: 'failed',
386
+ outcome: 'worktree-id-missing',
387
+ message,
388
+ requires: ['worktreeId'],
389
+ ciFixLockId: lock.lock.id,
390
+ },
391
+ paths,
392
+ );
393
+ return failure(message, {
394
+ requires: ['worktreeId'],
395
+ data: {
396
+ report: reportLink(report),
397
+ dossier: dossierSummary(dossier),
398
+ },
399
+ workflowSummary,
400
+ });
401
+ }
402
+ const startedHeadSha =
403
+ stringField(preparedWorktree.headSha) ?? dossier.state.headSha;
404
+ if (startedHeadSha !== dossier.state.headSha) {
405
+ releaseStatus = 'failed';
406
+ const message =
407
+ 'CI fix handoff requires fresh PR facts; wrote the dossier report but did not start Kilo because the PR head changed after facts were collected.';
408
+ await notifyCiFixAttention(dossier, report, message, paths);
409
+ const workflowSummary = await addTerminalCiFixSummary(
410
+ dossier,
411
+ report,
412
+ {
413
+ status: 'failed',
414
+ outcome: 'pr-head-changed',
415
+ message,
416
+ requires: ['freshPrFacts'],
417
+ headSha: startedHeadSha,
418
+ dossierHeadSha: dossier.state.headSha,
419
+ ciFixLockId: lock.lock.id,
420
+ worktreeId,
421
+ },
422
+ paths,
423
+ );
424
+ return failure(message, {
425
+ requires: ['freshPrFacts'],
426
+ errors: [
427
+ `Prepared worktree head ${startedHeadSha} does not match dossier head ${dossier.state.headSha}.`,
428
+ ],
429
+ data: {
430
+ report: reportLink(report),
431
+ dossier: dossierSummary(dossier),
432
+ worktreeId,
433
+ headSha: startedHeadSha,
434
+ dossierHeadSha: dossier.state.headSha,
435
+ },
436
+ workflowSummary,
437
+ });
438
+ }
439
+
440
+ const learningMemoryContext = await loadAutomationLearningMemoryContext(
441
+ paths,
442
+ {
443
+ repoId: dossier.repo.id,
444
+ includeGlobal: true,
445
+ },
446
+ );
447
+ const prompt = await ciFixPrompt(
448
+ dossier,
449
+ report,
450
+ paths,
451
+ learningMemoryContext,
452
+ );
453
+ const kiloTaskId = `ci-fix-${randomUUID()}`;
454
+ const workflowSummary = await addWorkflowSummary(
455
+ {
456
+ workflow: 'ci_fix_run',
457
+ status: 'running',
458
+ summary: {
459
+ type: 'ci_fix_run',
460
+ outcome: 'kilo-starting',
461
+ pr: sourceRef(dossier),
462
+ repoId: dossier.repo.id,
463
+ repoFullName: dossier.target.repoFullName,
464
+ prNumber: dossier.target.number,
465
+ headSha: startedHeadSha,
466
+ dossierHeadSha: dossier.state.headSha,
467
+ failedCheckCount: dossier.failingChecks.length,
468
+ checks: dossier.failingChecks.map((check) => ({
469
+ id: check.id,
470
+ name: check.name,
471
+ conclusion: check.conclusion,
472
+ })),
473
+ reportId: report.id,
474
+ ciFixLockId: lock.lock.id,
475
+ kiloTaskId,
476
+ worktreeId,
477
+ memoryIds: learningMemoryContext.memoryIds,
478
+ },
479
+ },
480
+ paths,
481
+ );
482
+ const kilo = await (dependencies.startKiloTask ?? startKiloTask)(
483
+ {
484
+ taskId: kiloTaskId,
485
+ worktreeId,
486
+ title: `Fix CI: ${sourceRef(dossier)}`,
487
+ prompt,
488
+ mode: 'draft-fix',
489
+ allowAuto: true,
490
+ confirmAuto: true,
491
+ explicitUserRequest: true,
492
+ },
493
+ paths,
494
+ );
495
+ if (!kilo.ok) {
496
+ releaseStatus = 'failed';
497
+ await notifyCiFixAttention(dossier, report, kilo.message, paths);
498
+ await updateWorkflowSummary(
499
+ workflowSummary.id,
500
+ {
501
+ status: 'failed',
502
+ summary: {
503
+ ...objectField(workflowSummary.summary),
504
+ outcome: 'kilo-start-failed',
505
+ error: kilo.message,
506
+ },
507
+ },
508
+ paths,
509
+ );
510
+ return lowerLevelFailure('kilo_task_start', kilo, { report, dossier });
511
+ }
512
+
513
+ const startedKiloTaskId =
514
+ stringField(objectField(kilo).taskId) ?? kiloTaskId;
515
+ const currentWorkflowSummary =
516
+ (await findWorkflowSummaryByKiloTaskId(
517
+ 'ci_fix_run',
518
+ startedKiloTaskId,
519
+ paths,
520
+ )) ??
521
+ (await findWorkflowSummaryByKiloTaskId(
522
+ 'ci_fix_run',
523
+ kiloTaskId,
524
+ paths,
525
+ )) ??
526
+ workflowSummary;
527
+ const currentWorkflowSummaryBody = objectField(
528
+ currentWorkflowSummary.summary,
529
+ );
530
+ const updatedWorkflowSummary =
531
+ currentWorkflowSummary.status === 'running' &&
532
+ currentWorkflowSummaryBody.outcome === 'kilo-starting'
533
+ ? await updateWorkflowSummary(
534
+ currentWorkflowSummary.id,
535
+ {
536
+ status: 'running',
537
+ summary: {
538
+ ...currentWorkflowSummaryBody,
539
+ outcome: 'kilo-started',
540
+ kiloTaskId: startedKiloTaskId,
541
+ },
542
+ },
543
+ paths,
544
+ )
545
+ : currentWorkflowSummary;
546
+ releaseStatus = null;
547
+ await addNotification(
548
+ {
549
+ level: 'info',
550
+ title: 'CI fix queued',
551
+ message: `Queued Kilo CI fix for ${sourceRef(dossier)}.`,
552
+ source: 'fix-pr-ci',
553
+ sourceId: `${sourceRef(dossier)}:${dossier.state.headSha}:queued`,
554
+ data: {
555
+ workflow: 'fix-pr-ci',
556
+ reportId: report.id,
557
+ reportUrl: `/reports/${report.id}`,
558
+ ciFixLockId: lock.lock.id,
559
+ kiloTaskId: startedKiloTaskId,
560
+ worktreeId,
561
+ },
562
+ },
563
+ paths,
564
+ );
565
+
566
+ return {
567
+ ok: true,
568
+ action: 'ci_fix_run' as const,
569
+ changed: true,
570
+ message: `Queued CI fix for ${sourceRef(dossier)}.`,
571
+ data: asJsonValue({
572
+ workflow: 'fix-pr-ci',
573
+ outcome: 'kilo-started',
574
+ report: reportLink(report),
575
+ dossier: dossierSummary(dossier),
576
+ ciFixLockId: lock.lock.id,
577
+ kiloTaskId: startedKiloTaskId,
578
+ worktreeId,
579
+ }),
580
+ workflowSummary: updatedWorkflowSummary ?? currentWorkflowSummary,
581
+ };
582
+ } finally {
583
+ if (releaseStatus && lock?.ok && 'lock' in lock) {
584
+ await (dependencies.releaseWorktreeLock ?? releaseWorktreeLock)(
585
+ {
586
+ lockId: lock.lock.id,
587
+ owner: 'ci-fix-run',
588
+ finalStatus: releaseStatus,
589
+ },
590
+ paths,
591
+ );
592
+ }
593
+ }
594
+ }
595
+
596
+ export const fixPrCiRun = runCiFix;
597
+ export const createCiFailureDossierReport = createCiFixReport;
598
+
599
+ export async function readCiFixDossier(
600
+ input: v.InferOutput<typeof ciFixRunInputSchema>,
601
+ paths: RuntimePaths,
602
+ dependencies: CiFixRunDependencies = {},
603
+ ): Promise<
604
+ | { ok: true; dossier: CiFixDossier }
605
+ | { ok: false; result: ReturnType<typeof failure> }
606
+ > {
607
+ if (dependencies.readDossier) {
608
+ try {
609
+ return {
610
+ ok: true,
611
+ dossier: await dependencies.readDossier(input, paths),
612
+ };
613
+ } catch (error) {
614
+ return {
615
+ ok: false,
616
+ result: failure(
617
+ `Could not prepare CI fix dossier: ${errorMessage(error)}.`,
618
+ {
619
+ errors: [errorMessage(error)],
620
+ requires: ['ciFixDossier'],
621
+ },
622
+ ),
623
+ };
624
+ }
625
+ }
626
+
627
+ const stateResult = await getGitHubPrEventState(
628
+ {
629
+ ref: input.ref,
630
+ repo: input.repo,
631
+ prNumber: input.prNumber,
632
+ },
633
+ paths,
634
+ dependencies.prEventDependencies,
635
+ );
636
+ if (!stateResult.ok) {
637
+ return {
638
+ ok: false,
639
+ result: failure(stateResult.message, {
640
+ errors: stateResult.errors,
641
+ requires: stateResult.requires,
642
+ }),
643
+ };
644
+ }
645
+ const stateData = objectField(stateResult.data);
646
+ const target = targetField(stateData.target);
647
+ const state = stateData.state as GitHubPullRequestEventState | undefined;
648
+ if (!target || !state) {
649
+ return {
650
+ ok: false,
651
+ result: failure('GitHub PR event state response was incomplete.'),
652
+ };
653
+ }
654
+
655
+ const token = process.env.GITHUB_TOKEN;
656
+ if (!token) {
657
+ return {
658
+ ok: false,
659
+ result: failure('GITHUB_TOKEN is not configured.', {
660
+ requires: ['GITHUB_TOKEN'],
661
+ }),
662
+ };
663
+ }
664
+ let failingChecks: GitHubFailingCheckFact[] = [];
665
+ let failingCheckFactsError: string | null = null;
666
+ try {
667
+ failingChecks = await (
668
+ dependencies.fetchFailingCheckFacts ?? fetchFailingCheckFacts
669
+ )({
670
+ token,
671
+ owner: target.owner,
672
+ repo: target.repo,
673
+ ref: state.headSha,
674
+ maxLogBytes: input.maxLogBytes ?? 64 * 1024,
675
+ });
676
+ } catch (error) {
677
+ failingCheckFactsError = errorMessage(error);
678
+ }
679
+ const registry = await readRepoRegistrySnapshot(paths);
680
+ const repo =
681
+ registry.repos.find(
682
+ (candidate) =>
683
+ repoFullName(candidate).toLowerCase() ===
684
+ target.repoFullName.toLowerCase(),
685
+ ) ?? null;
686
+ const likelyCommands = repo
687
+ ? identifyLikelyCommands(failingChecks, repo, [], undefined, undefined)
688
+ : [];
689
+
690
+ return {
691
+ ok: true,
692
+ dossier: {
693
+ target,
694
+ state,
695
+ repo,
696
+ failingChecks,
697
+ failingCheckFactsError,
698
+ likelyCommands,
699
+ fetchedAt: new Date().toISOString(),
700
+ },
701
+ };
702
+ }
703
+
704
+ export async function writeCiFixDossierReport(
705
+ dossier: CiFixDossier,
706
+ input: {
707
+ createdBy: string;
708
+ mode: 'fix' | 'report-only';
709
+ },
710
+ paths = runtimePaths(),
711
+ ) {
712
+ const ref = sourceRef(dossier);
713
+ const generatedAt = new Date();
714
+ const stateTruncation = pullRequestEventStateTruncation(dossier.state);
715
+ const failingCheckLogFactsError =
716
+ incompleteFailingCheckLogFactsError(dossier);
717
+ return writeReport(
718
+ {
719
+ kind: 'ci-fix',
720
+ title: `CI Failure Dossier: ${ref}`,
721
+ repoId: dossier.repo?.id ?? null,
722
+ sourceRef: ref,
723
+ createdBy: input.createdBy,
724
+ summary: {
725
+ workflow: 'fix-pr-ci',
726
+ mode: input.mode,
727
+ repo: dossier.target.repoFullName,
728
+ prNumber: dossier.target.number,
729
+ headSha: dossier.state.headSha,
730
+ failedCheckCount: dossier.failingChecks.length,
731
+ failingCheckFactsError: dossier.failingCheckFactsError,
732
+ failingCheckLogFactsError,
733
+ likelyCommands: dossier.likelyCommands.slice(0, 5),
734
+ truncation: stateTruncation,
735
+ },
736
+ html: renderReportHtml({
737
+ eyebrow: 'CI FIX',
738
+ title: `CI Failure Dossier: ${ref}`,
739
+ summary:
740
+ dossier.failingCheckFactsError || failingCheckLogFactsError
741
+ ? 'Failing GitHub check facts could not be completely collected; this CI dossier is partial.'
742
+ : dossier.failingChecks.length === 0
743
+ ? 'No failing GitHub check runs were present in the fetched facts.'
744
+ : `${dossier.failingChecks.length} failing check run${dossier.failingChecks.length === 1 ? '' : 's'} found for ${dossier.state.headSha.slice(0, 12)}.`,
745
+ generatedAt,
746
+ sections: [
747
+ {
748
+ title: 'Pull Request',
749
+ items: [
750
+ { label: 'title', value: dossier.state.title },
751
+ { label: 'state', value: dossier.state.state },
752
+ { label: 'base', value: dossier.state.baseRef },
753
+ { label: 'head', value: dossier.state.headSha },
754
+ { label: 'url', value: dossier.state.url },
755
+ {
756
+ label: 'registered repo',
757
+ value: dossier.repo
758
+ ? `${dossier.repo.id} (${dossier.repo.path})`
759
+ : 'not configured',
760
+ },
761
+ {
762
+ label: 'truncated facts',
763
+ value: stateTruncation.any
764
+ ? stateTruncation.categories.join(', ')
765
+ : 'none',
766
+ },
767
+ ],
768
+ },
769
+ {
770
+ title: 'Fact Collection',
771
+ items: [
772
+ {
773
+ label: 'failing check facts',
774
+ value: dossier.failingCheckFactsError
775
+ ? `unavailable: ${dossier.failingCheckFactsError}`
776
+ : 'complete',
777
+ },
778
+ {
779
+ label: 'failing check logs',
780
+ value: failingCheckLogFactsError ?? 'complete',
781
+ },
782
+ ],
783
+ },
784
+ {
785
+ title: 'Failing Checks',
786
+ items:
787
+ dossier.failingChecks.length > 0
788
+ ? dossier.failingChecks.map((check) => ({
789
+ label: check.name,
790
+ value: checkReportValue(check),
791
+ }))
792
+ : [
793
+ {
794
+ label: 'checks',
795
+ value: dossier.failingCheckFactsError
796
+ ? `Unavailable: ${dossier.failingCheckFactsError}`
797
+ : 'No failing checks found.',
798
+ },
799
+ ],
800
+ },
801
+ {
802
+ title: 'Extracted Error Lines',
803
+ items:
804
+ extractedErrorLines(dossier).length > 0
805
+ ? extractedErrorLines(dossier).map((line, index) => ({
806
+ label: `${index + 1}. ${line.check}`,
807
+ value: line.text,
808
+ }))
809
+ : [
810
+ {
811
+ label: 'errors',
812
+ value:
813
+ 'No high-signal error lines were extracted from annotations or logs.',
814
+ },
815
+ ],
816
+ },
817
+ {
818
+ title: 'Suspect Files',
819
+ items:
820
+ suspectFiles(dossier).length > 0
821
+ ? suspectFiles(dossier).map((path, index) => ({
822
+ label: `file ${index + 1}`,
823
+ value: path,
824
+ }))
825
+ : [
826
+ {
827
+ label: 'files',
828
+ value:
829
+ 'No suspect files were extracted from annotations or logs.',
830
+ },
831
+ ],
832
+ },
833
+ {
834
+ title: 'Likely Local Commands',
835
+ items:
836
+ dossier.likelyCommands.length > 0
837
+ ? dossier.likelyCommands.map((command, index) => ({
838
+ label: `command ${index + 1}`,
839
+ value: command,
840
+ }))
841
+ : [
842
+ {
843
+ label: 'commands',
844
+ value:
845
+ 'No likely local validation command was inferred from configured scripts and failing checks.',
846
+ },
847
+ ],
848
+ },
849
+ {
850
+ title: 'Recent Commits',
851
+ items: recentCommits(dossier).map((commit) => ({
852
+ label: commit.sha.slice(0, 12),
853
+ value: [
854
+ commit.authorLogin ? `author: ${commit.authorLogin}` : null,
855
+ commit.committedAt ? `committed: ${commit.committedAt}` : null,
856
+ commit.url,
857
+ ]
858
+ .filter(Boolean)
859
+ .join('\n'),
860
+ })),
861
+ },
862
+ {
863
+ title: 'Run History',
864
+ items:
865
+ checkRunHistory(dossier).length > 0
866
+ ? checkRunHistory(dossier)
867
+ : [
868
+ {
869
+ label: 'check runs',
870
+ value:
871
+ 'No check-run history was present in the fetched PR or failing-check facts.',
872
+ },
873
+ ],
874
+ },
875
+ ],
876
+ }),
877
+ },
878
+ paths,
879
+ );
880
+ }
881
+
882
+ function parseCiFixInput(
883
+ rawInput: CiFixRunInput,
884
+ ):
885
+ | { ok: true; input: v.InferOutput<typeof ciFixRunInputSchema> }
886
+ | { ok: false; result: ReturnType<typeof failure> } {
887
+ const parsed = v.safeParse(ciFixRunInputSchema, rawInput);
888
+ if (!parsed.success) {
889
+ return {
890
+ ok: false,
891
+ result: failure('Invalid CI fix input.', {
892
+ errors: [v.summarize(parsed.issues)],
893
+ requires: ['pr'],
894
+ }),
895
+ };
896
+ }
897
+ if (!parsed.output.ref && (!parsed.output.repo || !parsed.output.prNumber)) {
898
+ return {
899
+ ok: false,
900
+ result: failure('A PR reference or repo/prNumber is required.', {
901
+ requires: ['pr'],
902
+ }),
903
+ };
904
+ }
905
+ return { ok: true, input: parsed.output };
906
+ }
907
+
908
+ async function ciFixPrompt(
909
+ dossier: CiFixDossier,
910
+ report: ReportRecord,
911
+ paths: RuntimePaths,
912
+ learningMemoryContext: Awaited<
913
+ ReturnType<typeof loadAutomationLearningMemoryContext>
914
+ >,
915
+ ) {
916
+ const skill = await runtimeSkillContent(
917
+ 'neon-ci-fix',
918
+ neonCiFixSkillPath,
919
+ paths,
920
+ );
921
+ return [
922
+ skill.trim()
923
+ ? `Runtime skill neon-ci-fix:\n${skill.trim()}`
924
+ : 'Runtime skill neon-ci-fix was unavailable; follow the task bounds below.',
925
+ '',
926
+ `Task: fix the failing CI checks for ${sourceRef(dossier)}.`,
927
+ `Report: /reports/${report.id}`,
928
+ `Head SHA: ${dossier.state.headSha}`,
929
+ '',
930
+ 'Bounds:',
931
+ '- Fix only the failing checks described in the dossier.',
932
+ '- Keep the change minimal and localized.',
933
+ '- Run likely local commands only when they are allowed by the environment.',
934
+ '- Commit local changes in this managed worktree when you make a fix.',
935
+ '- Never push, open a pull request, submit a review, or post a GitHub comment.',
936
+ '',
937
+ learningMemoryContext.text,
938
+ '',
939
+ 'Dossier facts:',
940
+ JSON.stringify(
941
+ {
942
+ pullRequest: {
943
+ repo: dossier.target.repoFullName,
944
+ number: dossier.target.number,
945
+ title: dossier.state.title,
946
+ url: dossier.state.url,
947
+ headSha: dossier.state.headSha,
948
+ baseRef: dossier.state.baseRef,
949
+ },
950
+ failingChecks: dossier.failingChecks.map((check) => ({
951
+ id: check.id,
952
+ name: check.name,
953
+ status: check.status,
954
+ conclusion: check.conclusion,
955
+ outputTitle: check.outputTitle,
956
+ outputSummary: truncate(check.outputSummary ?? '', 4_000),
957
+ outputText: truncate(check.outputText ?? '', 8_000),
958
+ annotations: check.annotations.slice(0, 20),
959
+ log: {
960
+ available: check.log.available,
961
+ truncated: check.log.truncated,
962
+ unavailableReason: check.log.unavailableReason,
963
+ text: truncate(check.log.text ?? '', 24_000),
964
+ },
965
+ })),
966
+ likelyCommands: dossier.likelyCommands,
967
+ recentCommits: recentCommits(dossier),
968
+ },
969
+ null,
970
+ 2,
971
+ ),
972
+ ].join('\n');
973
+ }
974
+
975
+ async function runtimeSkillContent(
976
+ id: string,
977
+ fallbackPath: string,
978
+ paths: RuntimePaths,
979
+ ) {
980
+ const loaded = await loadRuntimeSkill({ id }, paths);
981
+ if (loaded.ok) return loaded.skill.content;
982
+ return readFile(fallbackPath, 'utf8').catch(() => '');
983
+ }
984
+
985
+ function checkReportValue(check: GitHubFailingCheckFact) {
986
+ return [
987
+ `status: ${check.status}`,
988
+ `conclusion: ${check.conclusion ?? 'unknown'}`,
989
+ check.outputTitle ? `title: ${check.outputTitle}` : null,
990
+ check.outputSummary
991
+ ? `summary: ${truncate(check.outputSummary, 2_000)}`
992
+ : null,
993
+ check.outputText ? `output: ${truncate(check.outputText, 4_000)}` : null,
994
+ check.annotations.length
995
+ ? `annotations:\n${check.annotations
996
+ .slice(0, 10)
997
+ .map(
998
+ (annotation) =>
999
+ `${annotation.path}${annotation.startLine ? `:${annotation.startLine}` : ''} ${annotation.annotationLevel}: ${annotation.message}`,
1000
+ )
1001
+ .join('\n')}`
1002
+ : null,
1003
+ check.log.available && check.log.text
1004
+ ? `log excerpt${check.log.truncated ? ' (truncated)' : ''}:\n${truncate(check.log.text, 6_000)}`
1005
+ : `log unavailable: ${check.log.unavailableReason ?? 'not available'}`,
1006
+ check.htmlUrl ? `url: ${check.htmlUrl}` : null,
1007
+ ]
1008
+ .filter(Boolean)
1009
+ .join('\n');
1010
+ }
1011
+
1012
+ function extractedErrorLines(dossier: CiFixDossier) {
1013
+ const pattern =
1014
+ /\b(error|failed|failure|exception|traceback|assertion|panic|fatal|npm err|ts\d{4})\b/i;
1015
+ const lines: Array<{ check: string; text: string }> = [];
1016
+ for (const check of dossier.failingChecks) {
1017
+ for (const annotation of check.annotations) {
1018
+ lines.push({
1019
+ check: check.name,
1020
+ text: `${annotation.path}${annotation.startLine ? `:${annotation.startLine}` : ''} ${annotation.annotationLevel}: ${annotation.message}`,
1021
+ });
1022
+ if (lines.length >= 25) return lines;
1023
+ }
1024
+ for (const line of (check.log.text ?? '').split(/\r?\n/)) {
1025
+ const trimmed = line.trim();
1026
+ if (!trimmed || !pattern.test(trimmed)) continue;
1027
+ lines.push({ check: check.name, text: truncate(trimmed, 1_000) });
1028
+ if (lines.length >= 25) return lines;
1029
+ }
1030
+ }
1031
+ return lines;
1032
+ }
1033
+
1034
+ function suspectFiles(dossier: CiFixDossier) {
1035
+ const files = new Set<string>();
1036
+ const filePattern =
1037
+ /(?:^|\s)([A-Za-z0-9_.@/-]+\.(?:ts|tsx|js|jsx|json|md|css|scss|astro|yml|yaml|sql|py|go|rs|java|kt|swift|rb|php|sh))(?:[:\s]|$)/g;
1038
+ for (const check of dossier.failingChecks) {
1039
+ for (const annotation of check.annotations) {
1040
+ if (annotation.path) files.add(annotation.path);
1041
+ }
1042
+ for (const line of (check.log.text ?? '').split(/\r?\n/)) {
1043
+ for (const match of line.matchAll(filePattern)) {
1044
+ const path = match[1];
1045
+ if (path && !path.startsWith('/')) files.add(path);
1046
+ }
1047
+ }
1048
+ }
1049
+ return [...files].slice(0, 40);
1050
+ }
1051
+
1052
+ function recentCommits(dossier: CiFixDossier) {
1053
+ return dossier.state.commits.slice(-8);
1054
+ }
1055
+
1056
+ function checkRunHistory(dossier: CiFixDossier) {
1057
+ const seen = new Set<number>();
1058
+ const runs = [...dossier.failingChecks, ...dossier.state.checkRuns].filter(
1059
+ (run) => {
1060
+ if (seen.has(run.id)) return false;
1061
+ seen.add(run.id);
1062
+ return true;
1063
+ },
1064
+ );
1065
+ return runs.slice(0, 20).map((run) => ({
1066
+ label: `${run.name} #${run.id}`,
1067
+ value: [
1068
+ `head: ${run.headSha}`,
1069
+ `status: ${run.status}`,
1070
+ `conclusion: ${run.conclusion ?? 'unknown'}`,
1071
+ run.startedAt ? `started: ${run.startedAt}` : null,
1072
+ run.completedAt ? `completed: ${run.completedAt}` : null,
1073
+ run.htmlUrl ? `url: ${run.htmlUrl}` : run.detailsUrl,
1074
+ ]
1075
+ .filter(Boolean)
1076
+ .join('\n'),
1077
+ }));
1078
+ }
1079
+
1080
+ function sourceRef(dossier: CiFixDossier) {
1081
+ return `${dossier.target.repoFullName}#${dossier.target.number}`;
1082
+ }
1083
+
1084
+ function dossierSummary(dossier: CiFixDossier) {
1085
+ return {
1086
+ repo: dossier.target.repoFullName,
1087
+ prNumber: dossier.target.number,
1088
+ headSha: dossier.state.headSha,
1089
+ failedCheckCount: dossier.failingChecks.length,
1090
+ failingCheckFactsError: dossier.failingCheckFactsError,
1091
+ failingCheckLogFactsError: incompleteFailingCheckLogFactsError(dossier),
1092
+ failingChecks: dossier.failingChecks.map((check) => ({
1093
+ id: check.id,
1094
+ name: check.name,
1095
+ conclusion: check.conclusion,
1096
+ })),
1097
+ errorLines: extractedErrorLines(dossier).slice(0, 10),
1098
+ suspectFiles: suspectFiles(dossier),
1099
+ likelyCommands: dossier.likelyCommands.slice(0, 5),
1100
+ truncation: pullRequestEventStateTruncation(dossier.state),
1101
+ };
1102
+ }
1103
+
1104
+ function incompleteFailingCheckLogFactsError(dossier: CiFixDossier) {
1105
+ const incomplete = dossier.failingChecks.filter(
1106
+ (check) => !check.log.available || check.log.truncated,
1107
+ );
1108
+ if (incomplete.length === 0) return null;
1109
+
1110
+ const checks = incomplete
1111
+ .map((check) => {
1112
+ const reason = check.log.truncated
1113
+ ? 'truncated'
1114
+ : (check.log.unavailableReason ?? 'unavailable');
1115
+ return `${check.name} (${reason})`;
1116
+ })
1117
+ .join(', ');
1118
+ return `Incomplete failing check logs: ${checks}.`;
1119
+ }
1120
+
1121
+ function reportLink(report: ReportRecord) {
1122
+ return {
1123
+ id: report.id,
1124
+ title: report.title,
1125
+ url: `/reports/${report.id}`,
1126
+ };
1127
+ }
1128
+
1129
+ async function notifyCiFixAttention(
1130
+ dossier: CiFixDossier,
1131
+ report: ReportRecord,
1132
+ message: string,
1133
+ paths: RuntimePaths,
1134
+ ) {
1135
+ await addNotification(
1136
+ {
1137
+ level: 'attention',
1138
+ title: 'CI fix needs attention',
1139
+ message,
1140
+ source: 'fix-pr-ci',
1141
+ sourceId: `${sourceRef(dossier)}:${dossier.state.headSha}:attention`,
1142
+ data: {
1143
+ workflow: 'fix-pr-ci',
1144
+ repo: dossier.target.repoFullName,
1145
+ prNumber: dossier.target.number,
1146
+ reportId: report.id,
1147
+ reportUrl: `/reports/${report.id}`,
1148
+ },
1149
+ },
1150
+ paths,
1151
+ );
1152
+ }
1153
+
1154
+ async function addTerminalCiFixSummary(
1155
+ dossier: CiFixDossier,
1156
+ report: ReportRecord,
1157
+ input: {
1158
+ status: 'completed' | 'failed';
1159
+ outcome: string;
1160
+ message: string;
1161
+ requires?: string[];
1162
+ errors?: string[];
1163
+ ciFixLockId?: string | null;
1164
+ worktreeId?: string | null;
1165
+ truncation?: string[];
1166
+ headSha?: string;
1167
+ dossierHeadSha?: string;
1168
+ },
1169
+ paths: RuntimePaths,
1170
+ ) {
1171
+ return addWorkflowSummary(
1172
+ {
1173
+ workflow: 'ci_fix_run',
1174
+ status: input.status,
1175
+ summary: {
1176
+ type: 'ci_fix_run',
1177
+ outcome: input.outcome,
1178
+ pr: sourceRef(dossier),
1179
+ repoId: dossier.repo?.id ?? null,
1180
+ repoFullName: dossier.target.repoFullName,
1181
+ prNumber: dossier.target.number,
1182
+ headSha: input.headSha ?? dossier.state.headSha,
1183
+ dossierHeadSha: input.dossierHeadSha ?? dossier.state.headSha,
1184
+ failedCheckCount: dossier.failingChecks.length,
1185
+ checks: dossier.failingChecks.map((check) => ({
1186
+ id: check.id,
1187
+ name: check.name,
1188
+ conclusion: check.conclusion,
1189
+ })),
1190
+ reportId: report.id,
1191
+ ciFixLockId: input.ciFixLockId ?? null,
1192
+ message: input.message,
1193
+ requires: input.requires ?? [],
1194
+ errors: input.errors ?? [],
1195
+ truncation: input.truncation ?? [],
1196
+ worktreeId: input.worktreeId ?? null,
1197
+ completedAt: new Date().toISOString(),
1198
+ },
1199
+ },
1200
+ paths,
1201
+ );
1202
+ }
1203
+
1204
+ async function preDossierFailure(
1205
+ input: v.InferOutput<typeof ciFixRunInputSchema>,
1206
+ result: ReturnType<typeof failure>,
1207
+ paths: RuntimePaths,
1208
+ ) {
1209
+ const sourceId = input.ref ?? input.repo ?? 'unknown';
1210
+ await addNotification(
1211
+ {
1212
+ level: 'attention',
1213
+ title: 'CI fix failed',
1214
+ message: result.message,
1215
+ source: 'fix-pr-ci',
1216
+ sourceId,
1217
+ data: {
1218
+ workflow: 'fix-pr-ci',
1219
+ input: ciFixInputSummary(input),
1220
+ requires: 'requires' in result ? result.requires : undefined,
1221
+ errors: 'errors' in result ? result.errors : undefined,
1222
+ },
1223
+ },
1224
+ paths,
1225
+ );
1226
+ const workflowSummary = await addWorkflowSummary(
1227
+ {
1228
+ workflow: 'ci_fix_run',
1229
+ status: 'failed',
1230
+ summary: {
1231
+ type: 'ci_fix_run',
1232
+ outcome: 'dossier-failed',
1233
+ input: ciFixInputSummary(input),
1234
+ message: result.message,
1235
+ requires: 'requires' in result ? (result.requires ?? []) : [],
1236
+ errors: 'errors' in result ? (result.errors ?? []) : [],
1237
+ completedAt: new Date().toISOString(),
1238
+ },
1239
+ },
1240
+ paths,
1241
+ );
1242
+
1243
+ return failure(result.message, {
1244
+ requires: 'requires' in result ? result.requires : undefined,
1245
+ errors: 'errors' in result ? result.errors : undefined,
1246
+ data: {
1247
+ workflow: 'fix-pr-ci',
1248
+ outcome: 'dossier-failed',
1249
+ input: ciFixInputSummary(input),
1250
+ },
1251
+ workflowSummary,
1252
+ });
1253
+ }
1254
+
1255
+ function ciFixInputSummary(input: v.InferOutput<typeof ciFixRunInputSchema>) {
1256
+ return {
1257
+ ref: input.ref ?? null,
1258
+ repo: input.repo ?? null,
1259
+ prNumber: input.prNumber ?? null,
1260
+ reportOnly: input.reportOnly ?? false,
1261
+ };
1262
+ }
1263
+
1264
+ function lowerLevelFailure(
1265
+ action: string,
1266
+ result: { message: string; requires?: string[]; errors?: string[] },
1267
+ input: {
1268
+ report: ReportRecord;
1269
+ dossier: CiFixDossier;
1270
+ workflowSummary?: unknown;
1271
+ },
1272
+ ) {
1273
+ return failure(result.message, {
1274
+ requires: result.requires,
1275
+ errors: result.errors,
1276
+ data: {
1277
+ action,
1278
+ report: reportLink(input.report),
1279
+ dossier: dossierSummary(input.dossier),
1280
+ result,
1281
+ },
1282
+ workflowSummary: input.workflowSummary,
1283
+ });
1284
+ }
1285
+
1286
+ function failure(
1287
+ message: string,
1288
+ options: {
1289
+ errors?: string[];
1290
+ requires?: string[];
1291
+ data?: unknown;
1292
+ workflowSummary?: unknown;
1293
+ } = {},
1294
+ ) {
1295
+ return {
1296
+ ok: false,
1297
+ action: 'ci_fix_run' as const,
1298
+ changed: false,
1299
+ message,
1300
+ ...(options.errors ? { errors: options.errors } : {}),
1301
+ ...(options.requires ? { requires: options.requires } : {}),
1302
+ ...(options.data ? { data: asJsonValue(options.data) } : {}),
1303
+ ...(options.workflowSummary
1304
+ ? { workflowSummary: options.workflowSummary }
1305
+ : {}),
1306
+ };
1307
+ }
1308
+
1309
+ function objectField(value: unknown): Record<string, unknown> {
1310
+ return value && typeof value === 'object' && !Array.isArray(value)
1311
+ ? (value as Record<string, unknown>)
1312
+ : {};
1313
+ }
1314
+
1315
+ function stringField(value: unknown) {
1316
+ return typeof value === 'string' && value.trim() ? value : undefined;
1317
+ }
1318
+
1319
+ function targetField(value: unknown): PullRequestTarget | null {
1320
+ const target = objectField(value);
1321
+ const repoFullName = stringField(target.repoFullName);
1322
+ const owner = stringField(target.owner);
1323
+ const repo = stringField(target.repo);
1324
+ const number = typeof target.number === 'number' ? target.number : null;
1325
+ if (!repoFullName || !owner || !repo || !number) return null;
1326
+ return { repoFullName, owner, repo, number };
1327
+ }
1328
+
1329
+ function truncate(value: string, maxLength: number) {
1330
+ if (value.length <= maxLength) return value;
1331
+ return `${value.slice(0, maxLength)}\n[truncated]`;
1332
+ }