@kya-os/cli 1.8.1 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/dist/commands/agent.d.ts +35 -0
  2. package/dist/commands/agent.d.ts.map +1 -0
  3. package/dist/commands/agent.js +321 -0
  4. package/dist/commands/agent.js.map +1 -0
  5. package/dist/commands/build.js +2 -2
  6. package/dist/commands/build.js.map +1 -1
  7. package/dist/commands/check.js +3 -3
  8. package/dist/commands/check.js.map +1 -1
  9. package/dist/commands/checkpoint-init.d.ts +1 -1
  10. package/dist/commands/checkpoint-init.d.ts.map +1 -1
  11. package/dist/commands/checkpoint-init.js +8 -41
  12. package/dist/commands/checkpoint-init.js.map +1 -1
  13. package/dist/commands/claim.js +2 -2
  14. package/dist/commands/claim.js.map +1 -1
  15. package/dist/commands/dco.d.ts +59 -0
  16. package/dist/commands/dco.d.ts.map +1 -1
  17. package/dist/commands/dco.js +280 -5
  18. package/dist/commands/dco.js.map +1 -1
  19. package/dist/commands/dev.js +1 -1
  20. package/dist/commands/dev.js.map +1 -1
  21. package/dist/commands/doctor.d.ts.map +1 -1
  22. package/dist/commands/doctor.js +18 -24
  23. package/dist/commands/doctor.js.map +1 -1
  24. package/dist/commands/env.js +6 -6
  25. package/dist/commands/env.js.map +1 -1
  26. package/dist/commands/identity.js +3 -3
  27. package/dist/commands/identity.js.map +1 -1
  28. package/dist/commands/init-stages.d.ts +141 -0
  29. package/dist/commands/init-stages.d.ts.map +1 -0
  30. package/dist/commands/init-stages.js +684 -0
  31. package/dist/commands/init-stages.js.map +1 -0
  32. package/dist/commands/init.d.ts +46 -16
  33. package/dist/commands/init.d.ts.map +1 -1
  34. package/dist/commands/init.js +229 -279
  35. package/dist/commands/init.js.map +1 -1
  36. package/dist/commands/orchestrator.d.ts +18 -0
  37. package/dist/commands/orchestrator.d.ts.map +1 -0
  38. package/dist/commands/orchestrator.js +251 -0
  39. package/dist/commands/orchestrator.js.map +1 -0
  40. package/dist/commands/register.d.ts +1 -1
  41. package/dist/commands/register.d.ts.map +1 -1
  42. package/dist/commands/register.js +35 -7
  43. package/dist/commands/register.js.map +1 -1
  44. package/dist/commands/review.d.ts +48 -0
  45. package/dist/commands/review.d.ts.map +1 -0
  46. package/dist/commands/review.js +220 -0
  47. package/dist/commands/review.js.map +1 -0
  48. package/dist/commands/rotate.js +4 -4
  49. package/dist/commands/rotate.js.map +1 -1
  50. package/dist/commands/score.d.ts +15 -0
  51. package/dist/commands/score.d.ts.map +1 -0
  52. package/dist/commands/score.js +471 -0
  53. package/dist/commands/score.js.map +1 -0
  54. package/dist/commands/start.js +3 -3
  55. package/dist/commands/start.js.map +1 -1
  56. package/dist/commands/status.js +1 -1
  57. package/dist/commands/status.js.map +1 -1
  58. package/dist/commands/verify.js +6 -6
  59. package/dist/commands/verify.js.map +1 -1
  60. package/dist/dco.d.ts +4 -0
  61. package/dist/dco.d.ts.map +1 -0
  62. package/dist/dco.js +23 -0
  63. package/dist/dco.js.map +1 -0
  64. package/dist/index.js +52 -9
  65. package/dist/orchestrator/daemon.d.ts +137 -0
  66. package/dist/orchestrator/daemon.d.ts.map +1 -0
  67. package/dist/orchestrator/daemon.js +242 -0
  68. package/dist/orchestrator/daemon.js.map +1 -0
  69. package/dist/orchestrator/db/dispatches.d.ts +108 -0
  70. package/dist/orchestrator/db/dispatches.d.ts.map +1 -0
  71. package/dist/orchestrator/db/dispatches.js +122 -0
  72. package/dist/orchestrator/db/dispatches.js.map +1 -0
  73. package/dist/orchestrator/db/index.d.ts +50 -0
  74. package/dist/orchestrator/db/index.d.ts.map +1 -0
  75. package/dist/orchestrator/db/index.js +116 -0
  76. package/dist/orchestrator/db/index.js.map +1 -0
  77. package/dist/orchestrator/db/journal.d.ts +93 -0
  78. package/dist/orchestrator/db/journal.d.ts.map +1 -0
  79. package/dist/orchestrator/db/journal.js +91 -0
  80. package/dist/orchestrator/db/journal.js.map +1 -0
  81. package/dist/orchestrator/db/liveness.d.ts +97 -0
  82. package/dist/orchestrator/db/liveness.d.ts.map +1 -0
  83. package/dist/orchestrator/db/liveness.js +105 -0
  84. package/dist/orchestrator/db/liveness.js.map +1 -0
  85. package/dist/orchestrator/db/mission.d.ts +78 -0
  86. package/dist/orchestrator/db/mission.d.ts.map +1 -0
  87. package/dist/orchestrator/db/mission.js +99 -0
  88. package/dist/orchestrator/db/mission.js.map +1 -0
  89. package/dist/orchestrator/db/schema.d.ts +14 -0
  90. package/dist/orchestrator/db/schema.d.ts.map +1 -0
  91. package/dist/orchestrator/db/schema.js +169 -0
  92. package/dist/orchestrator/db/schema.js.map +1 -0
  93. package/dist/orchestrator/db/tickets.d.ts +147 -0
  94. package/dist/orchestrator/db/tickets.d.ts.map +1 -0
  95. package/dist/orchestrator/db/tickets.js +238 -0
  96. package/dist/orchestrator/db/tickets.js.map +1 -0
  97. package/dist/orchestrator/db/verdicts.d.ts +187 -0
  98. package/dist/orchestrator/db/verdicts.d.ts.map +1 -0
  99. package/dist/orchestrator/db/verdicts.js +197 -0
  100. package/dist/orchestrator/db/verdicts.js.map +1 -0
  101. package/dist/orchestrator/events.d.ts +69 -0
  102. package/dist/orchestrator/events.d.ts.map +1 -0
  103. package/dist/orchestrator/events.js +20 -0
  104. package/dist/orchestrator/events.js.map +1 -0
  105. package/dist/orchestrator/github-credential-anchor-sender.d.ts +159 -0
  106. package/dist/orchestrator/github-credential-anchor-sender.d.ts.map +1 -0
  107. package/dist/orchestrator/github-credential-anchor-sender.js +313 -0
  108. package/dist/orchestrator/github-credential-anchor-sender.js.map +1 -0
  109. package/dist/orchestrator/hub-dispatch.d.ts +120 -0
  110. package/dist/orchestrator/hub-dispatch.d.ts.map +1 -0
  111. package/dist/orchestrator/hub-dispatch.js +257 -0
  112. package/dist/orchestrator/hub-dispatch.js.map +1 -0
  113. package/dist/orchestrator/hub-observer.d.ts +201 -0
  114. package/dist/orchestrator/hub-observer.d.ts.map +1 -0
  115. package/dist/orchestrator/hub-observer.js +474 -0
  116. package/dist/orchestrator/hub-observer.js.map +1 -0
  117. package/dist/orchestrator/journal-writer.d.ts +80 -0
  118. package/dist/orchestrator/journal-writer.d.ts.map +1 -0
  119. package/dist/orchestrator/journal-writer.js +113 -0
  120. package/dist/orchestrator/journal-writer.js.map +1 -0
  121. package/dist/orchestrator/mcp/server.d.ts +136 -0
  122. package/dist/orchestrator/mcp/server.d.ts.map +1 -0
  123. package/dist/orchestrator/mcp/server.js +582 -0
  124. package/dist/orchestrator/mcp/server.js.map +1 -0
  125. package/dist/orchestrator/mcp/stdio.d.ts +22 -0
  126. package/dist/orchestrator/mcp/stdio.d.ts.map +1 -0
  127. package/dist/orchestrator/mcp/stdio.js +51 -0
  128. package/dist/orchestrator/mcp/stdio.js.map +1 -0
  129. package/dist/orchestrator/review.d.ts +131 -0
  130. package/dist/orchestrator/review.d.ts.map +1 -0
  131. package/dist/orchestrator/review.js +322 -0
  132. package/dist/orchestrator/review.js.map +1 -0
  133. package/dist/tui/app.d.ts +33 -0
  134. package/dist/tui/app.d.ts.map +1 -0
  135. package/dist/tui/app.js +71 -0
  136. package/dist/tui/app.js.map +1 -0
  137. package/dist/tui/components.d.ts +110 -0
  138. package/dist/tui/components.d.ts.map +1 -0
  139. package/dist/tui/components.js +118 -0
  140. package/dist/tui/components.js.map +1 -0
  141. package/dist/tui/index.d.ts +30 -0
  142. package/dist/tui/index.d.ts.map +1 -0
  143. package/dist/tui/index.js +95 -0
  144. package/dist/tui/index.js.map +1 -0
  145. package/dist/tui/keymap.d.ts +33 -0
  146. package/dist/tui/keymap.d.ts.map +1 -0
  147. package/dist/tui/keymap.js +49 -0
  148. package/dist/tui/keymap.js.map +1 -0
  149. package/dist/tui/nav.d.ts +29 -0
  150. package/dist/tui/nav.d.ts.map +1 -0
  151. package/dist/tui/nav.js +39 -0
  152. package/dist/tui/nav.js.map +1 -0
  153. package/dist/tui/sanitize.d.ts +25 -0
  154. package/dist/tui/sanitize.d.ts.map +1 -0
  155. package/dist/tui/sanitize.js +36 -0
  156. package/dist/tui/sanitize.js.map +1 -0
  157. package/dist/tui/theme.d.ts +32 -0
  158. package/dist/tui/theme.d.ts.map +1 -0
  159. package/dist/tui/theme.js +63 -0
  160. package/dist/tui/theme.js.map +1 -0
  161. package/dist/tui/views/agents.d.ts +67 -0
  162. package/dist/tui/views/agents.d.ts.map +1 -0
  163. package/dist/tui/views/agents.js +231 -0
  164. package/dist/tui/views/agents.js.map +1 -0
  165. package/dist/tui/views/index.d.ts +93 -0
  166. package/dist/tui/views/index.d.ts.map +1 -0
  167. package/dist/tui/views/index.js +150 -0
  168. package/dist/tui/views/index.js.map +1 -0
  169. package/dist/tui/views/registry.d.ts +22 -0
  170. package/dist/tui/views/registry.d.ts.map +1 -0
  171. package/dist/tui/views/registry.js +110 -0
  172. package/dist/tui/views/registry.js.map +1 -0
  173. package/dist/utils/agent/backoff.d.ts +31 -0
  174. package/dist/utils/agent/backoff.d.ts.map +1 -0
  175. package/dist/utils/agent/backoff.js +51 -0
  176. package/dist/utils/agent/backoff.js.map +1 -0
  177. package/dist/utils/agent/markers.d.ts +87 -0
  178. package/dist/utils/agent/markers.d.ts.map +1 -0
  179. package/dist/utils/agent/markers.js +147 -0
  180. package/dist/utils/agent/markers.js.map +1 -0
  181. package/dist/utils/agent/review.d.ts +67 -0
  182. package/dist/utils/agent/review.d.ts.map +1 -0
  183. package/dist/utils/agent/review.js +305 -0
  184. package/dist/utils/agent/review.js.map +1 -0
  185. package/dist/utils/agent/spawn-agent.d.ts +117 -0
  186. package/dist/utils/agent/spawn-agent.d.ts.map +1 -0
  187. package/dist/utils/agent/spawn-agent.js +177 -0
  188. package/dist/utils/agent/spawn-agent.js.map +1 -0
  189. package/dist/utils/agent/task.d.ts +101 -0
  190. package/dist/utils/agent/task.d.ts.map +1 -0
  191. package/dist/utils/agent/task.js +357 -0
  192. package/dist/utils/agent/task.js.map +1 -0
  193. package/dist/utils/agent/verify.d.ts +47 -0
  194. package/dist/utils/agent/verify.d.ts.map +1 -0
  195. package/dist/utils/agent/verify.js +144 -0
  196. package/dist/utils/agent/verify.js.map +1 -0
  197. package/dist/utils/agent-detector.d.ts +48 -0
  198. package/dist/utils/agent-detector.d.ts.map +1 -0
  199. package/dist/utils/agent-detector.js +74 -0
  200. package/dist/utils/agent-detector.js.map +1 -0
  201. package/dist/utils/agent-profile-stage.d.ts +70 -0
  202. package/dist/utils/agent-profile-stage.d.ts.map +1 -0
  203. package/dist/utils/agent-profile-stage.js +153 -0
  204. package/dist/utils/agent-profile-stage.js.map +1 -0
  205. package/dist/utils/agent-profiles.d.ts +27 -0
  206. package/dist/utils/agent-profiles.d.ts.map +1 -0
  207. package/dist/utils/agent-profiles.js +61 -0
  208. package/dist/utils/agent-profiles.js.map +1 -0
  209. package/dist/utils/checkpoint-api.d.ts +1 -1
  210. package/dist/utils/checkpoint-api.js +1 -1
  211. package/dist/utils/checkpoint-env.d.ts +1 -1
  212. package/dist/utils/checkpoint-env.js +2 -2
  213. package/dist/utils/checkpoint-env.js.map +1 -1
  214. package/dist/utils/checkpoint-scaffold.d.ts +1 -1
  215. package/dist/utils/checkpoint-scaffold.js +1 -1
  216. package/dist/utils/cli-kit/browser.d.ts +24 -0
  217. package/dist/utils/cli-kit/browser.d.ts.map +1 -0
  218. package/dist/utils/cli-kit/browser.js +58 -0
  219. package/dist/utils/cli-kit/browser.js.map +1 -0
  220. package/dist/utils/cli-kit/claim-polling.d.ts +18 -0
  221. package/dist/utils/cli-kit/claim-polling.d.ts.map +1 -0
  222. package/dist/utils/{claim-polling.js → cli-kit/claim-polling.js} +19 -26
  223. package/dist/utils/cli-kit/claim-polling.js.map +1 -0
  224. package/dist/utils/cli-kit/diagnostics.d.ts +9 -0
  225. package/dist/utils/cli-kit/diagnostics.d.ts.map +1 -0
  226. package/dist/utils/cli-kit/diagnostics.js +11 -0
  227. package/dist/utils/cli-kit/diagnostics.js.map +1 -0
  228. package/dist/utils/cli-kit/fs-safe.d.ts +14 -0
  229. package/dist/utils/cli-kit/fs-safe.d.ts.map +1 -0
  230. package/dist/utils/cli-kit/fs-safe.js +20 -0
  231. package/dist/utils/cli-kit/fs-safe.js.map +1 -0
  232. package/dist/utils/cli-kit/index.d.ts +15 -0
  233. package/dist/utils/cli-kit/index.d.ts.map +1 -0
  234. package/dist/utils/cli-kit/index.js +10 -0
  235. package/dist/utils/cli-kit/index.js.map +1 -0
  236. package/dist/utils/cli-kit/json-file.d.ts +21 -0
  237. package/dist/utils/cli-kit/json-file.d.ts.map +1 -0
  238. package/dist/utils/cli-kit/json-file.js +51 -0
  239. package/dist/utils/cli-kit/json-file.js.map +1 -0
  240. package/dist/utils/cli-kit/marker-block.d.ts +26 -0
  241. package/dist/utils/cli-kit/marker-block.d.ts.map +1 -0
  242. package/dist/utils/cli-kit/marker-block.js +61 -0
  243. package/dist/utils/cli-kit/marker-block.js.map +1 -0
  244. package/dist/utils/cli-kit/paths.d.ts +15 -0
  245. package/dist/utils/cli-kit/paths.d.ts.map +1 -0
  246. package/dist/utils/cli-kit/paths.js +21 -0
  247. package/dist/utils/cli-kit/paths.js.map +1 -0
  248. package/dist/utils/cli-kit/secure-storage.d.ts +14 -0
  249. package/dist/utils/cli-kit/secure-storage.d.ts.map +1 -0
  250. package/dist/utils/cli-kit/secure-storage.js +20 -0
  251. package/dist/utils/cli-kit/secure-storage.js.map +1 -0
  252. package/dist/utils/cli-kit/step-report.d.ts +16 -0
  253. package/dist/utils/cli-kit/step-report.d.ts.map +1 -0
  254. package/dist/utils/cli-kit/step-report.js +36 -0
  255. package/dist/utils/cli-kit/step-report.js.map +1 -0
  256. package/dist/utils/dco/agent-metadata.d.ts +1 -1
  257. package/dist/utils/dco/agent-metadata.js +1 -1
  258. package/dist/utils/dco/agent-metadata.js.map +1 -1
  259. package/dist/utils/dco/claude-config.d.ts +18 -14
  260. package/dist/utils/dco/claude-config.d.ts.map +1 -1
  261. package/dist/utils/dco/claude-config.js +31 -97
  262. package/dist/utils/dco/claude-config.js.map +1 -1
  263. package/dist/utils/dco/dispatch.d.ts +134 -0
  264. package/dist/utils/dco/dispatch.d.ts.map +1 -0
  265. package/dist/utils/dco/dispatch.js +399 -0
  266. package/dist/utils/dco/dispatch.js.map +1 -0
  267. package/dist/utils/dco/fix.d.ts +122 -0
  268. package/dist/utils/dco/fix.d.ts.map +1 -0
  269. package/dist/utils/dco/fix.js +560 -0
  270. package/dist/utils/dco/fix.js.map +1 -0
  271. package/dist/utils/dco/git-config.d.ts.map +1 -1
  272. package/dist/utils/dco/git-config.js +5 -3
  273. package/dist/utils/dco/git-config.js.map +1 -1
  274. package/dist/utils/dco/github.d.ts +101 -0
  275. package/dist/utils/dco/github.d.ts.map +1 -1
  276. package/dist/utils/dco/github.js +133 -0
  277. package/dist/utils/dco/github.js.map +1 -1
  278. package/dist/utils/dco/paths.d.ts +1 -8
  279. package/dist/utils/dco/paths.d.ts.map +1 -1
  280. package/dist/utils/dco/paths.js +3 -12
  281. package/dist/utils/dco/paths.js.map +1 -1
  282. package/dist/utils/dco/render.d.ts +1 -1
  283. package/dist/utils/dco/render.d.ts.map +1 -1
  284. package/dist/utils/dco/render.js +4 -21
  285. package/dist/utils/dco/render.js.map +1 -1
  286. package/dist/utils/dco/resolve-agent.d.ts +54 -0
  287. package/dist/utils/dco/resolve-agent.d.ts.map +1 -0
  288. package/dist/utils/dco/resolve-agent.js +164 -0
  289. package/dist/utils/dco/resolve-agent.js.map +1 -0
  290. package/dist/utils/dco/setup.d.ts +10 -7
  291. package/dist/utils/dco/setup.d.ts.map +1 -1
  292. package/dist/utils/dco/setup.js +264 -200
  293. package/dist/utils/dco/setup.js.map +1 -1
  294. package/dist/utils/dco/signing-key-writer.d.ts +40 -0
  295. package/dist/utils/dco/signing-key-writer.d.ts.map +1 -0
  296. package/dist/utils/dco/signing-key-writer.js +76 -0
  297. package/dist/utils/dco/signing-key-writer.js.map +1 -0
  298. package/dist/utils/dco/ssh-key.d.ts +50 -0
  299. package/dist/utils/dco/ssh-key.d.ts.map +1 -1
  300. package/dist/utils/dco/ssh-key.js +129 -8
  301. package/dist/utils/dco/ssh-key.js.map +1 -1
  302. package/dist/utils/dco/status.d.ts +1 -1
  303. package/dist/utils/dco/status.d.ts.map +1 -1
  304. package/dist/utils/dco/status.js +3 -3
  305. package/dist/utils/dco/status.js.map +1 -1
  306. package/dist/utils/dco/verify.d.ts +170 -0
  307. package/dist/utils/dco/verify.d.ts.map +1 -0
  308. package/dist/utils/dco/verify.js +550 -0
  309. package/dist/utils/dco/verify.js.map +1 -0
  310. package/dist/utils/dependency-installer.d.ts +37 -0
  311. package/dist/utils/dependency-installer.d.ts.map +1 -0
  312. package/dist/utils/dependency-installer.js +32 -0
  313. package/dist/utils/dependency-installer.js.map +1 -0
  314. package/dist/utils/github-credential-stage.d.ts +87 -0
  315. package/dist/utils/github-credential-stage.d.ts.map +1 -0
  316. package/dist/utils/github-credential-stage.js +168 -0
  317. package/dist/utils/github-credential-stage.js.map +1 -0
  318. package/dist/utils/github-credential.d.ts +160 -0
  319. package/dist/utils/github-credential.d.ts.map +1 -0
  320. package/dist/utils/github-credential.js +308 -0
  321. package/dist/utils/github-credential.js.map +1 -0
  322. package/dist/utils/gitignore.d.ts +17 -0
  323. package/dist/utils/gitignore.d.ts.map +1 -0
  324. package/dist/utils/gitignore.js +40 -0
  325. package/dist/utils/gitignore.js.map +1 -0
  326. package/dist/utils/hub-config.d.ts +21 -0
  327. package/dist/utils/hub-config.d.ts.map +1 -0
  328. package/dist/utils/hub-config.js +28 -0
  329. package/dist/utils/hub-config.js.map +1 -0
  330. package/dist/utils/identity-heal.d.ts +16 -0
  331. package/dist/utils/identity-heal.d.ts.map +1 -0
  332. package/dist/utils/identity-heal.js +37 -0
  333. package/dist/utils/identity-heal.js.map +1 -0
  334. package/dist/utils/init/pipeline.d.ts +74 -0
  335. package/dist/utils/init/pipeline.d.ts.map +1 -0
  336. package/dist/utils/init/pipeline.js +96 -0
  337. package/dist/utils/init/pipeline.js.map +1 -0
  338. package/dist/utils/poll.d.ts +15 -1
  339. package/dist/utils/poll.d.ts.map +1 -1
  340. package/dist/utils/poll.js +6 -3
  341. package/dist/utils/poll.js.map +1 -1
  342. package/dist/utils/register-agent-identity.d.ts +67 -0
  343. package/dist/utils/register-agent-identity.d.ts.map +1 -0
  344. package/dist/utils/register-agent-identity.js +34 -0
  345. package/dist/utils/register-agent-identity.js.map +1 -0
  346. package/dist/utils/review/did-web-key.d.ts +34 -0
  347. package/dist/utils/review/did-web-key.d.ts.map +1 -0
  348. package/dist/utils/review/did-web-key.js +104 -0
  349. package/dist/utils/review/did-web-key.js.map +1 -0
  350. package/dist/utils/review/load-registry.d.ts +33 -0
  351. package/dist/utils/review/load-registry.d.ts.map +1 -0
  352. package/dist/utils/review/load-registry.js +62 -0
  353. package/dist/utils/review/load-registry.js.map +1 -0
  354. package/dist/utils/review/verdict-verify.d.ts +43 -0
  355. package/dist/utils/review/verdict-verify.d.ts.map +1 -0
  356. package/dist/utils/review/verdict-verify.js +53 -0
  357. package/dist/utils/review/verdict-verify.js.map +1 -0
  358. package/dist/utils/review-registry-writer.d.ts +52 -0
  359. package/dist/utils/review-registry-writer.d.ts.map +1 -0
  360. package/dist/utils/review-registry-writer.js +79 -0
  361. package/dist/utils/review-registry-writer.js.map +1 -0
  362. package/dist/utils/should-install-dependency.d.ts +17 -0
  363. package/dist/utils/should-install-dependency.d.ts.map +1 -0
  364. package/dist/utils/should-install-dependency.js +25 -0
  365. package/dist/utils/should-install-dependency.js.map +1 -0
  366. package/dist/utils/tool-readiness.d.ts +57 -0
  367. package/dist/utils/tool-readiness.d.ts.map +1 -0
  368. package/dist/utils/tool-readiness.js +114 -0
  369. package/dist/utils/tool-readiness.js.map +1 -0
  370. package/dist/utils/which.d.ts +2 -0
  371. package/dist/utils/which.d.ts.map +1 -0
  372. package/dist/utils/which.js +22 -0
  373. package/dist/utils/which.js.map +1 -0
  374. package/dist/version.d.ts +15 -0
  375. package/dist/version.d.ts.map +1 -0
  376. package/dist/version.js +29 -0
  377. package/dist/version.js.map +1 -0
  378. package/package.json +19 -6
  379. package/dist/utils/claim-polling.d.ts +0 -21
  380. package/dist/utils/claim-polling.d.ts.map +0 -1
  381. package/dist/utils/claim-polling.js.map +0 -1
  382. package/dist/utils/dco/fs-safe.d.ts +0 -14
  383. package/dist/utils/dco/fs-safe.d.ts.map +0 -1
  384. package/dist/utils/dco/fs-safe.js +0 -20
  385. package/dist/utils/dco/fs-safe.js.map +0 -1
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The stage pipeline `kya-os init` runs.
3
+ *
4
+ * `init.ts`'s flow is seven ordered stages (readiness/install, identity,
5
+ * claim, agent profiles, GitHub credentials, hub context, summary+TUI
6
+ * handoff). Each stage decides for itself whether it applies at all
7
+ * (`when`) and reports one summary line plus any warnings (`run`) instead
8
+ * of printing ad hoc -- the pipeline collects every stage's report so the
9
+ * caller can print one consolidated block before the TUI handoff question,
10
+ * which is what makes a re-run ("already set up" in one line each, per
11
+ * stage) possible without every stage re-implementing that summary itself.
12
+ *
13
+ * `when` is also the seam P16/P17 runtime-optionality depends on: a guard
14
+ * that checks whether the stage's own module exists (a dynamic import
15
+ * wrapped in try/catch) rather than a hardcoded flag means a stage
16
+ * activates itself the moment its dependency lands on `main`, with zero
17
+ * code change here.
18
+ *
19
+ * A stage's `run` is expected to catch its own recoverable failures and
20
+ * report them as `{ ok: false, warnings: [...] }` -- exactly how init.ts's
21
+ * existing non-fatal error handling already works. A `run` that needs to
22
+ * stop the whole pipeline (today: only a missing `git` or an identity
23
+ * failure) throws a {@link StageFatalError}; anything else it throws is
24
+ * treated as an unexpected bug, not a modeled failure, and propagates
25
+ * uncaught. This module never touches `process.exit` itself -- the caller
26
+ * owns the NODE_ENV=test guard and the exit code, which is what keeps this
27
+ * file trivially unit-testable on its own.
28
+ *
29
+ * @module cli/utils/init/pipeline
30
+ */
31
+ /** Raised by a stage's `run` to stop the pipeline with a specific exit code. */
32
+ export class StageFatalError extends Error {
33
+ constructor(exitCode, message) {
34
+ super(message);
35
+ this.name = "StageFatalError";
36
+ this.exitCode = exitCode;
37
+ }
38
+ }
39
+ /**
40
+ * Runs every applicable stage in order, stopping immediately (and
41
+ * rethrowing) if a stage throws. Callers that want a "skipped" line for an
42
+ * omitted stage build it from {@link RunStagesReport.omitted} themselves --
43
+ * this function does not synthesize one, since a stage's own `when` is the
44
+ * only place that knows WHY it does not apply (module absent vs. a --skip
45
+ * flag vs. platform mismatch).
46
+ */
47
+ export async function runStages(stages, ctx) {
48
+ const ran = [];
49
+ const omitted = [];
50
+ for (const stage of stages) {
51
+ if (!(await stage.when(ctx))) {
52
+ omitted.push(stage.name);
53
+ continue;
54
+ }
55
+ const result = await stage.run(ctx);
56
+ ran.push({ name: stage.name, result });
57
+ }
58
+ return { ran, omitted };
59
+ }
60
+ /**
61
+ * Attempts a dynamic import purely to test whether a module resolves,
62
+ * discarding the module itself. The standard `when` guard for a
63
+ * runtime-optional stage (P16/P17): resolves true once the real file lands
64
+ * on disk, false while it is absent, with no other code change required.
65
+ *
66
+ * `fromUrl` is REQUIRED, not optional, and exists specifically so a
67
+ * relative `specifier` resolves against the CALLER's own module location
68
+ * rather than this file's. A dynamic `import()` written inside this
69
+ * function always resolves a relative specifier against pipeline.ts's own
70
+ * URL, not wherever the string was written -- a bug this signature makes
71
+ * structurally impossible to reintroduce, caught once already by a
72
+ * relative specifier silently resolving one directory short of where its
73
+ * author meant (`../utils/x.js` written in `commands/init-stages.ts`, but
74
+ * evaluated from `utils/init/`, landing on a nonexistent
75
+ * `utils/utils/x.js`). Call as `moduleExists("../utils/x.js",
76
+ * import.meta.url)` from the module that owns the specifier.
77
+ *
78
+ * Memoized per RESOLVED specifier for the life of the process. Whether a
79
+ * module exists cannot change between two `init()` invocations in the
80
+ * same process (the CLI is not hot-reloaded mid-run), and re-attempting a
81
+ * failing dynamic import on every call is measurably expensive -- a test
82
+ * suite that calls `init()` hundreds of times was slow enough to make
83
+ * unrelated, timing-sensitive tests miss their own deadlines under
84
+ * parallel load before this cache existed.
85
+ */
86
+ const moduleExistsCache = new Map();
87
+ export async function moduleExists(specifier, fromUrl) {
88
+ const resolved = new URL(specifier, fromUrl).href;
89
+ let cached = moduleExistsCache.get(resolved);
90
+ if (!cached) {
91
+ cached = import(resolved).then(() => true, () => false);
92
+ moduleExistsCache.set(resolved, cached);
93
+ }
94
+ return cached;
95
+ }
96
+ //# sourceMappingURL=pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/utils/init/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAQH,gFAAgF;AAChF,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAExC,YAAY,QAAgB,EAAE,OAAe;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AA4BD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAiC,EACjC,GAAQ;IAER,MAAM,GAAG,GAAe,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzB,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA4B,CAAC;AAC9D,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,SAAiB,EAAE,OAAe;IACnE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;IAClD,IAAI,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAC5B,GAAG,EAAE,CAAC,IAAI,EACV,GAAG,EAAE,CAAC,KAAK,CACZ,CAAC;QACF,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -9,7 +9,7 @@
9
9
  * this is exactly the drift that let checkpoint-init.ts's own poll loop
10
10
  * ship without the SIGINT guard claim-polling.ts already had (PR #658
11
11
  * deep review, finding B7). Left unmigrated here: this change's ground
12
- * rules explicitly scope out the existing top-level `mcpi init` (MCP-I
12
+ * rules explicitly scope out the existing top-level `kya-os init` (MCP-I
13
13
  * agent flow) beyond the parseAsync entrypoint change, so claim-polling.ts
14
14
  * keeps its own copy for now; folding it onto this shared helper is a
15
15
  * follow-up once that flow is in scope.
@@ -38,6 +38,20 @@ export interface PollOptions {
38
38
  intervalMs: number;
39
39
  timeoutMs: number;
40
40
  }
41
+ /**
42
+ * Equivalent to `AbortSignal.timeout(ms)`, built from a plain
43
+ * `setTimeout` instead so a test using `vi.useFakeTimers()` can control
44
+ * it: Node's native `AbortSignal.timeout` doesn't respect faked timers,
45
+ * since it isn't implemented in terms of the global `setTimeout` vitest
46
+ * patches. Exported so any command issuing its own single-shot `fetch`
47
+ * outside `pollWithDeadline` (e.g. score.ts's submit request) gets the
48
+ * same fake-timer-safe per-request timeout instead of a second, subtly
49
+ * different copy of this logic.
50
+ */
51
+ export declare function timeoutSignal(ms: number): {
52
+ signal: AbortSignal;
53
+ cancel: () => void;
54
+ };
41
55
  /**
42
56
  * Calls `step` roughly every `intervalMs` until it returns `done`/`fatal`
43
57
  * or `timeoutMs` elapses on the wall clock. Each attempt gets an
@@ -1 +1 @@
1
- {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../src/utils/poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAClB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtC,MAAM,MAAM,WAAW,CAAC,CAAC,IACrB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC7B;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,GACtB;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzC,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAqBD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAmCzB"}
1
+ {"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../src/utils/poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAClB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC1B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtC,MAAM,MAAM,WAAW,CAAC,CAAC,IACrB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC7B;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,GACtB;IAAE,OAAO,EAAE,aAAa,CAAA;CAAE,GAC1B;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEzC,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG;IACzC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAOA;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAmCzB"}
@@ -9,7 +9,7 @@
9
9
  * this is exactly the drift that let checkpoint-init.ts's own poll loop
10
10
  * ship without the SIGINT guard claim-polling.ts already had (PR #658
11
11
  * deep review, finding B7). Left unmigrated here: this change's ground
12
- * rules explicitly scope out the existing top-level `mcpi init` (MCP-I
12
+ * rules explicitly scope out the existing top-level `kya-os init` (MCP-I
13
13
  * agent flow) beyond the parseAsync entrypoint change, so claim-polling.ts
14
14
  * keeps its own copy for now; folding it onto this shared helper is a
15
15
  * follow-up once that flow is in scope.
@@ -19,9 +19,12 @@
19
19
  * `setTimeout` instead so a test using `vi.useFakeTimers()` can control
20
20
  * it: Node's native `AbortSignal.timeout` doesn't respect faked timers,
21
21
  * since it isn't implemented in terms of the global `setTimeout` vitest
22
- * patches.
22
+ * patches. Exported so any command issuing its own single-shot `fetch`
23
+ * outside `pollWithDeadline` (e.g. score.ts's submit request) gets the
24
+ * same fake-timer-safe per-request timeout instead of a second, subtly
25
+ * different copy of this logic.
23
26
  */
24
- function timeoutSignal(ms) {
27
+ export function timeoutSignal(ms) {
25
28
  const controller = new AbortController();
26
29
  const timer = setTimeout(() => controller.abort(new Error("Request timed out")), ms);
27
30
  return { signal: controller.signal, cancel: () => clearTimeout(timer) };
@@ -1 +1 @@
1
- {"version":3,"file":"poll.js","sourceRoot":"","sources":["../../src/utils/poll.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAkBH;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,EAAU;IAI/B,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CACtB,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC,EACtD,EAAE,CACH,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAmD,EACnD,OAAoB;IAEpB,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IACxC,IAA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M,EAAE,CAAC;YACX,CAAC;YAED,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM;gBACxB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;YAClD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;gBACzB,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;YAEnD,IAAI,WAAW;gBAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;YACnD,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ;gBAAE,MAAM,CAAC,0CAA0C;YAE7E,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { RegisterAgentIdentity } from "./agent-profile-stage.js";
2
+ /**
3
+ * Builds a `RegisterAgentIdentity` seam for `kya-os init`'s agent-profile
4
+ * stage that mints and registers a genuinely separate identity per profile,
5
+ * by running the SAME registration path init's own primary identity uses
6
+ * (`enableMCPIdentityCLI`) -- but inside a throwaway temp directory.
7
+ *
8
+ * Why the temp directory: `enableMCPIdentityCLI` hardcodes
9
+ * `.mcpi/identity.json` relative to `process.cwd()` (see
10
+ * `@kya-os/mcp-i`'s `IdentityManager`); it has no parameter to point at a
11
+ * different identity file. Running it a second time in the SAME cwd would
12
+ * just find the primary agent's identity.json already there and return
13
+ * that same identity again, not mint a new one. Isolating each call in its
14
+ * own temp dir is the only way to get a distinct identity out of the public
15
+ * API without modifying `@kya-os/mcp-i`.
16
+ *
17
+ * `process.chdir` is restored in a `finally` no matter what, and the whole
18
+ * call is awaited sequentially by the profile stage's loop (never run
19
+ * concurrently with other cwd-sensitive work in this process).
20
+ */
21
+ /**
22
+ * The real shape of @kya-os/mcp-i's `enableMCPIdentityCLI`, modeled locally
23
+ * rather than imported: the dynamic `import("@kya-os/mcp-i")` init.ts uses
24
+ * exists specifically to survive monorepo CI orderings where that package
25
+ * isn't built yet, and a static (even type-only) import from it here would
26
+ * reintroduce that exact dependency at typecheck time. Covers every field
27
+ * either call site (init.ts's own primary-identity call, and this file's
28
+ * profile-registration call) actually reads or passes.
29
+ */
30
+ export interface EnableMCPIdentityCLIResult {
31
+ identity: {
32
+ did: string;
33
+ privateKey: string;
34
+ publicKey: string;
35
+ kid: string;
36
+ };
37
+ metadata: {
38
+ isNewIdentity: boolean;
39
+ claimUrl?: string;
40
+ agentSlug?: string;
41
+ agentId?: string;
42
+ registryUrl: string;
43
+ };
44
+ }
45
+ export type EnableMCPIdentityCLIFn = (options: {
46
+ name?: string;
47
+ description?: string;
48
+ repository?: string;
49
+ endpoint?: string;
50
+ logLevel?: "silent" | "info" | "debug";
51
+ skipRegistration?: boolean;
52
+ onProgress?: (event: {
53
+ stage: string;
54
+ data?: unknown;
55
+ }) => void | Promise<void>;
56
+ }) => Promise<EnableMCPIdentityCLIResult>;
57
+ export interface CreateRegisterAgentIdentityOptions {
58
+ endpoint?: string;
59
+ /** Required: the real `enableMCPIdentityCLI` from `@kya-os/mcp-i`. */
60
+ enableMCPIdentityCLIImpl: EnableMCPIdentityCLIFn;
61
+ cwdImpl?: () => string;
62
+ chdirImpl?: (dir: string) => void;
63
+ mkdtempImpl?: (prefix: string) => string;
64
+ rmImpl?: (path: string) => void;
65
+ }
66
+ export declare function createRegisterAgentIdentity(options: CreateRegisterAgentIdentityOptions): RegisterAgentIdentity;
67
+ //# sourceMappingURL=register-agent-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-agent-identity.d.ts","sourceRoot":"","sources":["../../src/utils/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M,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kCAAkC,GAC1C,qBAAqB,CA8BvB"}
@@ -0,0 +1,34 @@
1
+ import { mkdtempSync, rmSync } from "fs";
2
+ import { tmpdir } from "os";
3
+ import { join } from "path";
4
+ export function createRegisterAgentIdentity(options) {
5
+ const cwdImpl = options.cwdImpl ?? (() => process.cwd());
6
+ const chdirImpl = options.chdirImpl ?? ((dir) => process.chdir(dir));
7
+ const mkdtempImpl = options.mkdtempImpl ?? ((prefix) => mkdtempSync(prefix));
8
+ const rmImpl = options.rmImpl ?? ((path) => rmSync(path, { recursive: true, force: true }));
9
+ return async ({ name }) => {
10
+ const originalCwd = cwdImpl();
11
+ const tempDir = mkdtempImpl(join(tmpdir(), "mcpi-profile-"));
12
+ try {
13
+ chdirImpl(tempDir);
14
+ const result = await options.enableMCPIdentityCLIImpl({
15
+ name,
16
+ endpoint: options.endpoint,
17
+ logLevel: "silent",
18
+ skipRegistration: false,
19
+ });
20
+ return {
21
+ did: result.identity.did,
22
+ claimUrl: result.metadata.claimUrl,
23
+ agentSlug: result.metadata.agentSlug,
24
+ privateKey: result.identity.privateKey,
25
+ publicKey: result.identity.publicKey,
26
+ };
27
+ }
28
+ finally {
29
+ chdirImpl(originalCwd);
30
+ rmImpl(tempDir);
31
+ }
32
+ };
33
+ }
34
+ //# sourceMappingURL=register-agent-identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register-agent-identity.js","sourceRoot":"","sources":["../../src/utils/register-agent-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,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MAAM,CAAC,QAAQ,CAAC,UAAU;gBACtC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS;aACrC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,WAAW,CAAC,CAAC;YACvB,MAAM,CAAC,OAAO,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * did:web -> raw Ed25519 public key resolution for `kya-os review verify`
3
+ * (review-loop P9 commit 3).
4
+ *
5
+ * Scope v1: `did:web` only — the epic's reviewer DIDs are all
6
+ * `did:web:knowthat.ai:agents:<slug>`. Reuses the SAME URL mapping and SSRF
7
+ * defense `dco verify`'s PR-attribution check already established
8
+ * (`didWebToHttpsUrl`, `checkDocumentHostIsSafe`) rather than re-deriving
9
+ * either: the host here is exactly as untrusted (wire-supplied, from a
10
+ * signed verdict's `proof.kid`) as the DID claimed in a PR body is there.
11
+ *
12
+ * @module cli/utils/review/did-web-key
13
+ */
14
+ import { type LookupLike } from "../dco/verify.js";
15
+ export type DidWebKeyFailure = "unsupported-method" | "unresolvable" | "blocked-host" | "no-key";
16
+ export interface DidWebKeyResult {
17
+ ok: boolean;
18
+ /** Raw 32-byte Ed25519 public key. Present only when `ok` is true. */
19
+ raw?: Buffer;
20
+ reason?: DidWebKeyFailure;
21
+ detail?: string;
22
+ }
23
+ export type FetchLike = (url: string, init?: {
24
+ signal?: AbortSignal;
25
+ redirect?: RequestInit["redirect"];
26
+ }) => Promise<Response>;
27
+ /**
28
+ * Resolve a `did:web` identity to its raw 32-byte Ed25519 public key by
29
+ * fetching its DID document. Fail-closed: any host-safety failure, network
30
+ * error, non-200, invalid JSON, or missing key returns `{ ok: false, ... }`
31
+ * rather than throwing.
32
+ */
33
+ export declare function resolveDidWebEd25519Key(did: string, fetchImpl?: FetchLike, lookupImpl?: LookupLike): Promise<DidWebKeyResult>;
34
+ //# sourceMappingURL=did-web-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-web-key.d.ts","sourceRoot":"","sources":["../../../src/utils/review/did-web-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,gBAAgB,GACxB,oBAAoB,GACpB,cAAc,GACd,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,sEAAsE;IACtE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,UAAU,CAAC,CAAA;CAAE,KAChE,OAAO,CAAC,QAAQ,CAAC,CAAC;AA+BvB;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,EACX,SAAS,GAAE,SAA2C,EACtD,UAAU,GAAE,UAA0B,GACrC,OAAO,CAAC,eAAe,CAAC,CA4D1B"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * did:web -> raw Ed25519 public key resolution for `kya-os review verify`
3
+ * (review-loop P9 commit 3).
4
+ *
5
+ * Scope v1: `did:web` only — the epic's reviewer DIDs are all
6
+ * `did:web:knowthat.ai:agents:<slug>`. Reuses the SAME URL mapping and SSRF
7
+ * defense `dco verify`'s PR-attribution check already established
8
+ * (`didWebToHttpsUrl`, `checkDocumentHostIsSafe`) rather than re-deriving
9
+ * either: the host here is exactly as untrusted (wire-supplied, from a
10
+ * signed verdict's `proof.kid`) as the DID claimed in a PR body is there.
11
+ *
12
+ * @module cli/utils/review/did-web-key
13
+ */
14
+ import { didWebToHttpsUrl, checkDocumentHostIsSafe, defaultLookup, } from "../dco/verify.js";
15
+ const RESOLVE_TIMEOUT_MS = 10000;
16
+ /**
17
+ * Pull the first Ed25519 (OKP) `publicKeyJwk` out of a DID document's
18
+ * `verificationMethod` array. Mirrors
19
+ * `packages/compute/src/didcomm/did-web.ts`'s `extractEd25519Jwk` exactly
20
+ * (same kty/crv/x checks) — compute can't be imported from the CLI (see
21
+ * this command's constraints), so the ~15-line check is duplicated rather
22
+ * than shared; keep the two in sync if the JWK shape check ever changes.
23
+ */
24
+ function extractEd25519Jwk(doc) {
25
+ if (!doc || typeof doc !== "object")
26
+ return null;
27
+ const methods = doc.verificationMethod;
28
+ if (!Array.isArray(methods))
29
+ return null;
30
+ for (const method of methods) {
31
+ const jwk = method?.publicKeyJwk;
32
+ if (jwk &&
33
+ typeof jwk.kty === "string" &&
34
+ jwk.kty.toUpperCase() === "OKP" &&
35
+ jwk.crv === "Ed25519" &&
36
+ typeof jwk.x === "string") {
37
+ return { x: jwk.x };
38
+ }
39
+ }
40
+ return null;
41
+ }
42
+ /**
43
+ * Resolve a `did:web` identity to its raw 32-byte Ed25519 public key by
44
+ * fetching its DID document. Fail-closed: any host-safety failure, network
45
+ * error, non-200, invalid JSON, or missing key returns `{ ok: false, ... }`
46
+ * rather than throwing.
47
+ */
48
+ export async function resolveDidWebEd25519Key(did, fetchImpl = (url, init) => fetch(url, init), lookupImpl = defaultLookup) {
49
+ const documentUrl = didWebToHttpsUrl(did);
50
+ if (!documentUrl) {
51
+ return {
52
+ ok: false,
53
+ reason: "unsupported-method",
54
+ detail: "Only did:web identities can be resolved (v1 scope).",
55
+ };
56
+ }
57
+ const hostCheck = await checkDocumentHostIsSafe(documentUrl, lookupImpl);
58
+ if (!hostCheck.safe) {
59
+ return { ok: false, reason: hostCheck.reason, detail: hostCheck.detail };
60
+ }
61
+ let response;
62
+ try {
63
+ response = await fetchImpl(documentUrl, {
64
+ signal: AbortSignal.timeout(RESOLVE_TIMEOUT_MS),
65
+ // A redirect target is unverified — refusing to follow it keeps the
66
+ // host check above from being bypassable by a 3xx response, same
67
+ // reasoning as verifyPrAttribution's identical guard.
68
+ redirect: "manual",
69
+ });
70
+ }
71
+ catch (error) {
72
+ return {
73
+ ok: false,
74
+ reason: "unresolvable",
75
+ detail: error instanceof Error ? error.message : String(error),
76
+ };
77
+ }
78
+ if (!response.ok) {
79
+ return {
80
+ ok: false,
81
+ reason: "unresolvable",
82
+ detail: response.type === "opaqueredirect"
83
+ ? "Server returned a redirect, which is not followed."
84
+ : `HTTP ${response.status}`,
85
+ };
86
+ }
87
+ let document;
88
+ try {
89
+ document = await response.json();
90
+ }
91
+ catch {
92
+ return { ok: false, reason: "unresolvable", detail: "Response was not valid JSON." };
93
+ }
94
+ const jwk = extractEd25519Jwk(document);
95
+ if (!jwk) {
96
+ return {
97
+ ok: false,
98
+ reason: "no-key",
99
+ detail: "No Ed25519 verification key in DID document.",
100
+ };
101
+ }
102
+ return { ok: true, raw: Buffer.from(jwk.x, "base64url") };
103
+ }
104
+ //# sourceMappingURL=did-web-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"did-web-key.js","sourceRoot":"","sources":["../../../src/utils/review/did-web-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,GAEd,MAAM,kBAAkB,CAAC;AAqB1B,MAAM,kBAAkB,GAAG,KAAM,CAAC;AAElC;;;;;;;GAOG;AACH,SAAS,iBAAiB,CAAC,GAAY;IACrC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACjD,MAAM,OAAO,GAAI,GAAwC,CAAC,kBAAkB,CAAC;IAC7E,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAI,MAA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AC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,cAAc;YACtB,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC/D,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,cAAc;YACtB,MAAM,EACJ,QAAQ,CAAC,IAAI,KAAK,gBAAgB;gBAChC,CAAC,CAAC,oDAAoD;gBACtD,CAAC,CAAC,QAAQ,QAAQ,CAAC,MAAM,EAAE;SAChC,CAAC;IACJ,CAAC;IAED,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,8BAA8B,EAAE,CAAC;IACvF,CAAC;IAED,MAAM,GAAG,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,8CAA8C;SACvD,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Reviewer registry loading for `kya-os review verify` (review-loop P9,
3
+ * sm2 finding: a signature verifying is NOT the same guarantee as "this
4
+ * signer is a recognized reviewer for this org" — see review.ts's own doc
5
+ * comment on why this exists and how its absence is surfaced).
6
+ *
7
+ * Mirrors `packages/compute/src/didcomm/reviewer-registry.ts`'s resolution
8
+ * order (`REVIEW_REGISTRY_PATH`, then `REVIEW_REGISTRY_JSON`) and its
9
+ * "never return a partially valid registry" contract, reimplemented here
10
+ * rather than imported: that loader lives in `@kya-os/compute`, which the
11
+ * CLI must never import (compute is PID 1 in Fly workers; the CLI is a
12
+ * published binary — same boundary `did-web-key.ts`'s doc comment notes).
13
+ * `ReviewerRegistrySchema` itself IS shared, from `@kya-os/contracts/review`,
14
+ * a pure Zod schema with no compute dependency.
15
+ *
16
+ * @module cli/utils/review/load-registry
17
+ */
18
+ import { type ReviewerRegistry } from "@kya-os/contracts/review";
19
+ export interface LoadRegistryResult {
20
+ /** Present when a registry was found and validated. */
21
+ registry?: ReviewerRegistry;
22
+ /** Present when a registry source WAS configured but failed to load or validate — distinct from "none configured" (undefined `registry` with no `error` either). */
23
+ error?: string;
24
+ }
25
+ /**
26
+ * Resolution order: an explicit path (the `--registry` flag), then
27
+ * `REVIEW_REGISTRY_PATH`, then `REVIEW_REGISTRY_JSON`. Returns `{}` (both
28
+ * fields undefined) when nothing is configured — the command treats that
29
+ * as "membership checking unavailable," not an error, since it wasn't part
30
+ * of this command's original required scope.
31
+ */
32
+ export declare function loadReviewerRegistryForVerify(explicitPath?: string): LoadRegistryResult;
33
+ //# sourceMappingURL=load-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-registry.d.ts","sourceRoot":"","sources":["../../../src/utils/review/load-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,oKAAoK;IACpK,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAkBvF"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Reviewer registry loading for `kya-os review verify` (review-loop P9,
3
+ * sm2 finding: a signature verifying is NOT the same guarantee as "this
4
+ * signer is a recognized reviewer for this org" — see review.ts's own doc
5
+ * comment on why this exists and how its absence is surfaced).
6
+ *
7
+ * Mirrors `packages/compute/src/didcomm/reviewer-registry.ts`'s resolution
8
+ * order (`REVIEW_REGISTRY_PATH`, then `REVIEW_REGISTRY_JSON`) and its
9
+ * "never return a partially valid registry" contract, reimplemented here
10
+ * rather than imported: that loader lives in `@kya-os/compute`, which the
11
+ * CLI must never import (compute is PID 1 in Fly workers; the CLI is a
12
+ * published binary — same boundary `did-web-key.ts`'s doc comment notes).
13
+ * `ReviewerRegistrySchema` itself IS shared, from `@kya-os/contracts/review`,
14
+ * a pure Zod schema with no compute dependency.
15
+ *
16
+ * @module cli/utils/review/load-registry
17
+ */
18
+ import { readFileSync } from "node:fs";
19
+ import { ReviewerRegistrySchema } from "@kya-os/contracts/review";
20
+ /**
21
+ * Resolution order: an explicit path (the `--registry` flag), then
22
+ * `REVIEW_REGISTRY_PATH`, then `REVIEW_REGISTRY_JSON`. Returns `{}` (both
23
+ * fields undefined) when nothing is configured — the command treats that
24
+ * as "membership checking unavailable," not an error, since it wasn't part
25
+ * of this command's original required scope.
26
+ */
27
+ export function loadReviewerRegistryForVerify(explicitPath) {
28
+ const path = explicitPath ?? process.env.REVIEW_REGISTRY_PATH;
29
+ if (path) {
30
+ let raw;
31
+ try {
32
+ raw = readFileSync(path, "utf-8");
33
+ }
34
+ catch (error) {
35
+ return { error: `failed to read reviewer registry at "${path}": ${describeError(error)}` };
36
+ }
37
+ return parseRegistry(raw, `file "${path}"`);
38
+ }
39
+ const inline = process.env.REVIEW_REGISTRY_JSON;
40
+ if (inline) {
41
+ return parseRegistry(inline, "REVIEW_REGISTRY_JSON");
42
+ }
43
+ return {};
44
+ }
45
+ function parseRegistry(raw, sourceLabel) {
46
+ let parsed;
47
+ try {
48
+ parsed = JSON.parse(raw);
49
+ }
50
+ catch (error) {
51
+ return { error: `failed to parse reviewer registry JSON from ${sourceLabel}: ${describeError(error)}` };
52
+ }
53
+ const result = ReviewerRegistrySchema.safeParse(parsed);
54
+ if (!result.success) {
55
+ return { error: `invalid reviewer registry from ${sourceLabel}: ${result.error.message}` };
56
+ }
57
+ return { registry: result.data };
58
+ }
59
+ function describeError(error) {
60
+ return error instanceof Error ? error.message : String(error);
61
+ }
62
+ //# sourceMappingURL=load-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-registry.js","sourceRoot":"","sources":["../../../src/utils/review/load-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAyB,MAAM,0BAA0B,CAAC;AASzF;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAAC,YAAqB;IACjE,MAAM,IAAI,GAAG,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAC9D,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,GAAW,CAAC;QAChB,IAAI,CAAC;YACH,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,KAAK,EAAE,wCAAwC,IAAI,MAAM,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;QAC7F,CAAC;QACD,OAAO,aAAa,CAAC,GAAG,EAAE,SAAS,IAAI,GAAG,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAChD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,aAAa,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,aAAa,CAAC,GAAW,EAAE,WAAmB;IACrD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,KAAK,EAAE,+CAA+C,WAAW,KAAK,aAAa,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;IAC1G,CAAC;IACD,MAAM,MAAM,GAAG,sBAAsB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,KAAK,EAAE,kCAAkC,WAAW,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IAC7F,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;AACnC,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Local review-verdict proof verification for `kya-os review verify`
3
+ * (review-loop P9 commit 3).
4
+ *
5
+ * Seam completed (was TEMPORARY pending review-loop P13's commit 0 / PR
6
+ * #701, now merged): delegates the signature check to
7
+ * `@kya-os/contracts/review/verify`'s `verifyReviewVerdictProof(body,
8
+ * publicKeyRaw)` (the same raw-bytes shape `resolveDidWebEd25519Key`,
9
+ * did-web-key.ts, already produces) rather than reimplementing the
10
+ * SPKI-wrap Ed25519 verify locally. `verifyLocalReviewVerdictProof` stays
11
+ * as a thin wrapper -- not deleted outright -- because contracts' function
12
+ * returns a plain boolean with no way to distinguish a digest mismatch
13
+ * from a signature failure, and `commands/review.ts` reports those as two
14
+ * different human-readable reasons; this wrapper does the digest
15
+ * pre-check itself (matching compute's `review.ts`'s identical seam) to
16
+ * keep that distinction, then delegates for the signature half.
17
+ *
18
+ * @module cli/utils/review/verdict-verify
19
+ */
20
+ import { type ReviewVerdictBody } from "@kya-os/contracts/review";
21
+ export type VerdictProofFailureReason = "digest" | "signature";
22
+ export interface VerdictProofResult {
23
+ valid: boolean;
24
+ reason?: VerdictProofFailureReason;
25
+ }
26
+ /**
27
+ * Verify a review verdict's proof against a RAW Ed25519 public key: that
28
+ * `findingsDigest` matches `findings`, and that `proof.signature` was
29
+ * produced by the private half of `publicKeyRaw`. Fail-closed — any
30
+ * malformed input or key-import failure returns `{ valid: false, reason:
31
+ * "signature" }` rather than throwing (contracts' `verifyReviewVerdictProof`
32
+ * is itself fail-closed, never throws).
33
+ */
34
+ export declare function verifyLocalReviewVerdictProof(body: ReviewVerdictBody, publicKeyRaw: Buffer): VerdictProofResult;
35
+ /**
36
+ * Extract every fenced ```kya-os-signed-verdict block's raw contents from a
37
+ * review or comment body. Returns the raw text (not yet parsed/validated) —
38
+ * callers JSON.parse and `ReviewVerdictBodySchema.safeParse` each block
39
+ * themselves, so a malformed block reports as one INVALID row rather than
40
+ * aborting extraction of the others.
41
+ */
42
+ export declare function extractSignedVerdictBlocks(markdown: string): string[];
43
+ //# sourceMappingURL=verdict-verify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict-verify.d.ts","sourceRoot":"","sources":["../../../src/utils/review/verdict-verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE/D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,yBAAyB,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,iBAAiB,EACvB,YAAY,EAAE,MAAM,GACnB,kBAAkB,CAOpB;AAID;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAMrE"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Local review-verdict proof verification for `kya-os review verify`
3
+ * (review-loop P9 commit 3).
4
+ *
5
+ * Seam completed (was TEMPORARY pending review-loop P13's commit 0 / PR
6
+ * #701, now merged): delegates the signature check to
7
+ * `@kya-os/contracts/review/verify`'s `verifyReviewVerdictProof(body,
8
+ * publicKeyRaw)` (the same raw-bytes shape `resolveDidWebEd25519Key`,
9
+ * did-web-key.ts, already produces) rather than reimplementing the
10
+ * SPKI-wrap Ed25519 verify locally. `verifyLocalReviewVerdictProof` stays
11
+ * as a thin wrapper -- not deleted outright -- because contracts' function
12
+ * returns a plain boolean with no way to distinguish a digest mismatch
13
+ * from a signature failure, and `commands/review.ts` reports those as two
14
+ * different human-readable reasons; this wrapper does the digest
15
+ * pre-check itself (matching compute's `review.ts`'s identical seam) to
16
+ * keep that distinction, then delegates for the signature half.
17
+ *
18
+ * @module cli/utils/review/verdict-verify
19
+ */
20
+ import { verifyReviewVerdictProof } from "@kya-os/contracts/review/verify";
21
+ import { computeFindingsDigest, } from "@kya-os/contracts/review";
22
+ /**
23
+ * Verify a review verdict's proof against a RAW Ed25519 public key: that
24
+ * `findingsDigest` matches `findings`, and that `proof.signature` was
25
+ * produced by the private half of `publicKeyRaw`. Fail-closed — any
26
+ * malformed input or key-import failure returns `{ valid: false, reason:
27
+ * "signature" }` rather than throwing (contracts' `verifyReviewVerdictProof`
28
+ * is itself fail-closed, never throws).
29
+ */
30
+ export function verifyLocalReviewVerdictProof(body, publicKeyRaw) {
31
+ if (computeFindingsDigest(body.findings) !== body.findingsDigest) {
32
+ return { valid: false, reason: "digest" };
33
+ }
34
+ return verifyReviewVerdictProof(body, publicKeyRaw)
35
+ ? { valid: true }
36
+ : { valid: false, reason: "signature" };
37
+ }
38
+ const SIGNED_VERDICT_FENCE = /```kya-os-signed-verdict\n([\s\S]*?)\n```/g;
39
+ /**
40
+ * Extract every fenced ```kya-os-signed-verdict block's raw contents from a
41
+ * review or comment body. Returns the raw text (not yet parsed/validated) —
42
+ * callers JSON.parse and `ReviewVerdictBodySchema.safeParse` each block
43
+ * themselves, so a malformed block reports as one INVALID row rather than
44
+ * aborting extraction of the others.
45
+ */
46
+ export function extractSignedVerdictBlocks(markdown) {
47
+ const blocks = [];
48
+ for (const match of markdown.matchAll(SIGNED_VERDICT_FENCE)) {
49
+ blocks.push(match[1]);
50
+ }
51
+ return blocks;
52
+ }
53
+ //# sourceMappingURL=verdict-verify.js.map