@kindgi/cli 0.0.0-bootstrap.0 → 0.1.0

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 (496) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +690 -1
  3. package/dist/build/apt.d.ts +16 -0
  4. package/dist/build/apt.d.ts.map +1 -0
  5. package/dist/build/apt.js +50 -0
  6. package/dist/build/apt.js.map +1 -0
  7. package/dist/build/bundle.d.ts +45 -0
  8. package/dist/build/bundle.d.ts.map +1 -0
  9. package/dist/build/bundle.js +121 -0
  10. package/dist/build/bundle.js.map +1 -0
  11. package/dist/build/containerfile.d.ts +27 -0
  12. package/dist/build/containerfile.d.ts.map +1 -0
  13. package/dist/build/containerfile.js +196 -0
  14. package/dist/build/containerfile.js.map +1 -0
  15. package/dist/build/context-files.d.ts +24 -0
  16. package/dist/build/context-files.d.ts.map +1 -0
  17. package/dist/build/context-files.js +99 -0
  18. package/dist/build/context-files.js.map +1 -0
  19. package/dist/build/defaults.d.ts +66 -0
  20. package/dist/build/defaults.d.ts.map +1 -0
  21. package/dist/build/defaults.js +586 -0
  22. package/dist/build/defaults.js.map +1 -0
  23. package/dist/build/envelope.d.ts +72 -0
  24. package/dist/build/envelope.d.ts.map +1 -0
  25. package/dist/build/envelope.js +76 -0
  26. package/dist/build/envelope.js.map +1 -0
  27. package/dist/build/host-install.d.ts +48 -0
  28. package/dist/build/host-install.d.ts.map +1 -0
  29. package/dist/build/host-install.js +375 -0
  30. package/dist/build/host-install.js.map +1 -0
  31. package/dist/build/image-config.d.ts +32 -0
  32. package/dist/build/image-config.d.ts.map +1 -0
  33. package/dist/build/image-config.js +129 -0
  34. package/dist/build/image-config.js.map +1 -0
  35. package/dist/build/integrity.d.ts +51 -0
  36. package/dist/build/integrity.d.ts.map +1 -0
  37. package/dist/build/integrity.js +75 -0
  38. package/dist/build/integrity.js.map +1 -0
  39. package/dist/build/node-image.d.ts +18 -0
  40. package/dist/build/node-image.d.ts.map +1 -0
  41. package/dist/build/node-image.js +46 -0
  42. package/dist/build/node-image.js.map +1 -0
  43. package/dist/build/pack-root.d.ts +69 -0
  44. package/dist/build/pack-root.d.ts.map +1 -0
  45. package/dist/build/pack-root.js +102 -0
  46. package/dist/build/pack-root.js.map +1 -0
  47. package/dist/build/poetry-requirements.d.ts +5 -0
  48. package/dist/build/poetry-requirements.d.ts.map +1 -0
  49. package/dist/build/poetry-requirements.js +8 -0
  50. package/dist/build/poetry-requirements.js.map +1 -0
  51. package/dist/build/python-image.d.ts +40 -0
  52. package/dist/build/python-image.d.ts.map +1 -0
  53. package/dist/build/python-image.js +197 -0
  54. package/dist/build/python-image.js.map +1 -0
  55. package/dist/build/runners.d.ts +259 -0
  56. package/dist/build/runners.d.ts.map +1 -0
  57. package/dist/build/runners.js +4 -0
  58. package/dist/build/runners.js.map +1 -0
  59. package/dist/build/version-specifier.d.ts +2 -0
  60. package/dist/build/version-specifier.d.ts.map +1 -0
  61. package/dist/build/version-specifier.js +70 -0
  62. package/dist/build/version-specifier.js.map +1 -0
  63. package/dist/cli-package.d.ts +15 -0
  64. package/dist/cli-package.d.ts.map +1 -0
  65. package/dist/cli-package.js +37 -0
  66. package/dist/cli-package.js.map +1 -0
  67. package/dist/cli.d.ts +3 -0
  68. package/dist/cli.d.ts.map +1 -0
  69. package/dist/cli.js +26 -0
  70. package/dist/cli.js.map +1 -0
  71. package/dist/commands/adapters.d.ts +3 -0
  72. package/dist/commands/adapters.d.ts.map +1 -0
  73. package/dist/commands/adapters.js +148 -0
  74. package/dist/commands/adapters.js.map +1 -0
  75. package/dist/commands/agents.d.ts +3 -0
  76. package/dist/commands/agents.d.ts.map +1 -0
  77. package/dist/commands/agents.js +82 -0
  78. package/dist/commands/agents.js.map +1 -0
  79. package/dist/commands/approvals.d.ts +3 -0
  80. package/dist/commands/approvals.d.ts.map +1 -0
  81. package/dist/commands/approvals.js +92 -0
  82. package/dist/commands/approvals.js.map +1 -0
  83. package/dist/commands/artifacts.d.ts +3 -0
  84. package/dist/commands/artifacts.d.ts.map +1 -0
  85. package/dist/commands/artifacts.js +87 -0
  86. package/dist/commands/artifacts.js.map +1 -0
  87. package/dist/commands/auth.d.ts +3 -0
  88. package/dist/commands/auth.d.ts.map +1 -0
  89. package/dist/commands/auth.js +88 -0
  90. package/dist/commands/auth.js.map +1 -0
  91. package/dist/commands/build.d.ts +39 -0
  92. package/dist/commands/build.d.ts.map +1 -0
  93. package/dist/commands/build.js +872 -0
  94. package/dist/commands/build.js.map +1 -0
  95. package/dist/commands/capabilities.d.ts +3 -0
  96. package/dist/commands/capabilities.d.ts.map +1 -0
  97. package/dist/commands/capabilities.js +38 -0
  98. package/dist/commands/capabilities.js.map +1 -0
  99. package/dist/commands/conversations.d.ts +3 -0
  100. package/dist/commands/conversations.d.ts.map +1 -0
  101. package/dist/commands/conversations.js +75 -0
  102. package/dist/commands/conversations.js.map +1 -0
  103. package/dist/commands/deploy.d.ts +7 -0
  104. package/dist/commands/deploy.d.ts.map +1 -0
  105. package/dist/commands/deploy.js +697 -0
  106. package/dist/commands/deploy.js.map +1 -0
  107. package/dist/commands/dev.d.ts +44 -0
  108. package/dist/commands/dev.d.ts.map +1 -0
  109. package/dist/commands/dev.js +1032 -0
  110. package/dist/commands/dev.js.map +1 -0
  111. package/dist/commands/env.d.ts +27 -0
  112. package/dist/commands/env.d.ts.map +1 -0
  113. package/dist/commands/env.js +816 -0
  114. package/dist/commands/env.js.map +1 -0
  115. package/dist/commands/feedback.d.ts +33 -0
  116. package/dist/commands/feedback.d.ts.map +1 -0
  117. package/dist/commands/feedback.js +374 -0
  118. package/dist/commands/feedback.js.map +1 -0
  119. package/dist/commands/flows.d.ts +3 -0
  120. package/dist/commands/flows.d.ts.map +1 -0
  121. package/dist/commands/flows.js +60 -0
  122. package/dist/commands/flows.js.map +1 -0
  123. package/dist/commands/guardrails.d.ts +3 -0
  124. package/dist/commands/guardrails.d.ts.map +1 -0
  125. package/dist/commands/guardrails.js +89 -0
  126. package/dist/commands/guardrails.js.map +1 -0
  127. package/dist/commands/health.d.ts +8 -0
  128. package/dist/commands/health.d.ts.map +1 -0
  129. package/dist/commands/health.js +40 -0
  130. package/dist/commands/health.js.map +1 -0
  131. package/dist/commands/helpers.d.ts +37 -0
  132. package/dist/commands/helpers.d.ts.map +1 -0
  133. package/dist/commands/helpers.js +93 -0
  134. package/dist/commands/helpers.js.map +1 -0
  135. package/dist/commands/index.d.ts +7 -0
  136. package/dist/commands/index.d.ts.map +1 -0
  137. package/dist/commands/index.js +90 -0
  138. package/dist/commands/index.js.map +1 -0
  139. package/dist/commands/init.d.ts +46 -0
  140. package/dist/commands/init.d.ts.map +1 -0
  141. package/dist/commands/init.js +455 -0
  142. package/dist/commands/init.js.map +1 -0
  143. package/dist/commands/key.d.ts +3 -0
  144. package/dist/commands/key.d.ts.map +1 -0
  145. package/dist/commands/key.js +322 -0
  146. package/dist/commands/key.js.map +1 -0
  147. package/dist/commands/mcp.d.ts +43 -0
  148. package/dist/commands/mcp.d.ts.map +1 -0
  149. package/dist/commands/mcp.js +433 -0
  150. package/dist/commands/mcp.js.map +1 -0
  151. package/dist/commands/memory.d.ts +3 -0
  152. package/dist/commands/memory.d.ts.map +1 -0
  153. package/dist/commands/memory.js +82 -0
  154. package/dist/commands/memory.js.map +1 -0
  155. package/dist/commands/observations.d.ts +3 -0
  156. package/dist/commands/observations.d.ts.map +1 -0
  157. package/dist/commands/observations.js +27 -0
  158. package/dist/commands/observations.js.map +1 -0
  159. package/dist/commands/proposals.d.ts +3 -0
  160. package/dist/commands/proposals.d.ts.map +1 -0
  161. package/dist/commands/proposals.js +116 -0
  162. package/dist/commands/proposals.js.map +1 -0
  163. package/dist/commands/provenance.d.ts +3 -0
  164. package/dist/commands/provenance.d.ts.map +1 -0
  165. package/dist/commands/provenance.js +53 -0
  166. package/dist/commands/provenance.js.map +1 -0
  167. package/dist/commands/providers.d.ts +3 -0
  168. package/dist/commands/providers.d.ts.map +1 -0
  169. package/dist/commands/providers.js +202 -0
  170. package/dist/commands/providers.js.map +1 -0
  171. package/dist/commands/reviewers.d.ts +3 -0
  172. package/dist/commands/reviewers.d.ts.map +1 -0
  173. package/dist/commands/reviewers.js +78 -0
  174. package/dist/commands/reviewers.js.map +1 -0
  175. package/dist/commands/runs.d.ts +3 -0
  176. package/dist/commands/runs.d.ts.map +1 -0
  177. package/dist/commands/runs.js +221 -0
  178. package/dist/commands/runs.js.map +1 -0
  179. package/dist/commands/secrets.d.ts +21 -0
  180. package/dist/commands/secrets.d.ts.map +1 -0
  181. package/dist/commands/secrets.js +750 -0
  182. package/dist/commands/secrets.js.map +1 -0
  183. package/dist/commands/skills.d.ts +64 -0
  184. package/dist/commands/skills.d.ts.map +1 -0
  185. package/dist/commands/skills.js +430 -0
  186. package/dist/commands/skills.js.map +1 -0
  187. package/dist/commands/test.d.ts +5 -0
  188. package/dist/commands/test.d.ts.map +1 -0
  189. package/dist/commands/test.js +181 -0
  190. package/dist/commands/test.js.map +1 -0
  191. package/dist/commands/tokens.d.ts +3 -0
  192. package/dist/commands/tokens.d.ts.map +1 -0
  193. package/dist/commands/tokens.js +33 -0
  194. package/dist/commands/tokens.js.map +1 -0
  195. package/dist/commands/tools.d.ts +3 -0
  196. package/dist/commands/tools.d.ts.map +1 -0
  197. package/dist/commands/tools.js +153 -0
  198. package/dist/commands/tools.js.map +1 -0
  199. package/dist/commands/types.d.ts +54 -0
  200. package/dist/commands/types.d.ts.map +1 -0
  201. package/dist/commands/types.js +4 -0
  202. package/dist/commands/types.js.map +1 -0
  203. package/dist/commands/unwired.d.ts +17 -0
  204. package/dist/commands/unwired.d.ts.map +1 -0
  205. package/dist/commands/unwired.js +41 -0
  206. package/dist/commands/unwired.js.map +1 -0
  207. package/dist/commands/version.d.ts +8 -0
  208. package/dist/commands/version.d.ts.map +1 -0
  209. package/dist/commands/version.js +41 -0
  210. package/dist/commands/version.js.map +1 -0
  211. package/dist/config.d.ts +42 -0
  212. package/dist/config.d.ts.map +1 -0
  213. package/dist/config.js +83 -0
  214. package/dist/config.js.map +1 -0
  215. package/dist/context.d.ts +153 -0
  216. package/dist/context.d.ts.map +1 -0
  217. package/dist/context.js +44 -0
  218. package/dist/context.js.map +1 -0
  219. package/dist/deploy/defaults.d.ts +14 -0
  220. package/dist/deploy/defaults.d.ts.map +1 -0
  221. package/dist/deploy/defaults.js +37 -0
  222. package/dist/deploy/defaults.js.map +1 -0
  223. package/dist/deploy/envelope-loader.d.ts +24 -0
  224. package/dist/deploy/envelope-loader.d.ts.map +1 -0
  225. package/dist/deploy/envelope-loader.js +141 -0
  226. package/dist/deploy/envelope-loader.js.map +1 -0
  227. package/dist/deploy/post.d.ts +48 -0
  228. package/dist/deploy/post.d.ts.map +1 -0
  229. package/dist/deploy/post.js +210 -0
  230. package/dist/deploy/post.js.map +1 -0
  231. package/dist/deploy/response.d.ts +42 -0
  232. package/dist/deploy/response.d.ts.map +1 -0
  233. package/dist/deploy/response.js +128 -0
  234. package/dist/deploy/response.js.map +1 -0
  235. package/dist/deploy/runners.d.ts +218 -0
  236. package/dist/deploy/runners.d.ts.map +1 -0
  237. package/dist/deploy/runners.js +4 -0
  238. package/dist/deploy/runners.js.map +1 -0
  239. package/dist/dev/bundler.d.ts +8 -0
  240. package/dist/dev/bundler.d.ts.map +1 -0
  241. package/dist/dev/bundler.js +154 -0
  242. package/dist/dev/bundler.js.map +1 -0
  243. package/dist/dev/defaults.d.ts +138 -0
  244. package/dist/dev/defaults.d.ts.map +1 -0
  245. package/dist/dev/defaults.js +691 -0
  246. package/dist/dev/defaults.js.map +1 -0
  247. package/dist/dev/docker-compose.dev.yml +56 -0
  248. package/dist/dev/index-child.d.ts +2 -0
  249. package/dist/dev/index-child.d.ts.map +1 -0
  250. package/dist/dev/index-child.js +53 -0
  251. package/dist/dev/index-child.js.map +1 -0
  252. package/dist/dev/pack-code.d.ts +36 -0
  253. package/dist/dev/pack-code.d.ts.map +1 -0
  254. package/dist/dev/pack-code.js +129 -0
  255. package/dist/dev/pack-code.js.map +1 -0
  256. package/dist/dev/pack-env.d.ts +13 -0
  257. package/dist/dev/pack-env.d.ts.map +1 -0
  258. package/dist/dev/pack-env.js +36 -0
  259. package/dist/dev/pack-env.js.map +1 -0
  260. package/dist/dev/pack-service.d.ts +32 -0
  261. package/dist/dev/pack-service.d.ts.map +1 -0
  262. package/dist/dev/pack-service.js +188 -0
  263. package/dist/dev/pack-service.js.map +1 -0
  264. package/dist/dev/paths.d.ts +22 -0
  265. package/dist/dev/paths.d.ts.map +1 -0
  266. package/dist/dev/paths.js +35 -0
  267. package/dist/dev/paths.js.map +1 -0
  268. package/dist/dev/python-builder.d.ts +16 -0
  269. package/dist/dev/python-builder.d.ts.map +1 -0
  270. package/dist/dev/python-builder.js +122 -0
  271. package/dist/dev/python-builder.js.map +1 -0
  272. package/dist/dev/register.d.ts +71 -0
  273. package/dist/dev/register.d.ts.map +1 -0
  274. package/dist/dev/register.js +54 -0
  275. package/dist/dev/register.js.map +1 -0
  276. package/dist/dev/runners.d.ts +287 -0
  277. package/dist/dev/runners.d.ts.map +1 -0
  278. package/dist/dev/runners.js +4 -0
  279. package/dist/dev/runners.js.map +1 -0
  280. package/dist/dev/runtime-container.d.ts +62 -0
  281. package/dist/dev/runtime-container.d.ts.map +1 -0
  282. package/dist/dev/runtime-container.js +164 -0
  283. package/dist/dev/runtime-container.js.map +1 -0
  284. package/dist/dev/runtime-env.d.ts +62 -0
  285. package/dist/dev/runtime-env.d.ts.map +1 -0
  286. package/dist/dev/runtime-env.js +100 -0
  287. package/dist/dev/runtime-env.js.map +1 -0
  288. package/dist/dev/runtime-image.d.ts +13 -0
  289. package/dist/dev/runtime-image.d.ts.map +1 -0
  290. package/dist/dev/runtime-image.js +15 -0
  291. package/dist/dev/runtime-image.js.map +1 -0
  292. package/dist/env/defaults.d.ts +3 -0
  293. package/dist/env/defaults.d.ts.map +1 -0
  294. package/dist/env/defaults.js +22 -0
  295. package/dist/env/defaults.js.map +1 -0
  296. package/dist/env/pack-env-plan.d.ts +70 -0
  297. package/dist/env/pack-env-plan.d.ts.map +1 -0
  298. package/dist/env/pack-env-plan.js +236 -0
  299. package/dist/env/pack-env-plan.js.map +1 -0
  300. package/dist/env/parser.d.ts +9 -0
  301. package/dist/env/parser.d.ts.map +1 -0
  302. package/dist/env/parser.js +11 -0
  303. package/dist/env/parser.js.map +1 -0
  304. package/dist/env/project-env.d.ts +34 -0
  305. package/dist/env/project-env.d.ts.map +1 -0
  306. package/dist/env/project-env.js +45 -0
  307. package/dist/env/project-env.js.map +1 -0
  308. package/dist/env/runners.d.ts +22 -0
  309. package/dist/env/runners.d.ts.map +1 -0
  310. package/dist/env/runners.js +4 -0
  311. package/dist/env/runners.js.map +1 -0
  312. package/dist/env/writer.d.ts +7 -0
  313. package/dist/env/writer.d.ts.map +1 -0
  314. package/dist/env/writer.js +9 -0
  315. package/dist/env/writer.js.map +1 -0
  316. package/dist/errors.d.ts +31 -0
  317. package/dist/errors.d.ts.map +1 -0
  318. package/dist/errors.js +107 -0
  319. package/dist/errors.js.map +1 -0
  320. package/dist/help.d.ts +5 -0
  321. package/dist/help.d.ts.map +1 -0
  322. package/dist/help.js +61 -0
  323. package/dist/help.js.map +1 -0
  324. package/dist/index.d.ts +13 -0
  325. package/dist/index.d.ts.map +1 -0
  326. package/dist/index.js +13 -0
  327. package/dist/index.js.map +1 -0
  328. package/dist/init/augment-scaffolder.d.ts +74 -0
  329. package/dist/init/augment-scaffolder.d.ts.map +1 -0
  330. package/dist/init/augment-scaffolder.js +459 -0
  331. package/dist/init/augment-scaffolder.js.map +1 -0
  332. package/dist/init/dependency-specs.d.ts +58 -0
  333. package/dist/init/dependency-specs.d.ts.map +1 -0
  334. package/dist/init/dependency-specs.js +153 -0
  335. package/dist/init/dependency-specs.js.map +1 -0
  336. package/dist/init/gitignore-patcher.d.ts +23 -0
  337. package/dist/init/gitignore-patcher.d.ts.map +1 -0
  338. package/dist/init/gitignore-patcher.js +103 -0
  339. package/dist/init/gitignore-patcher.js.map +1 -0
  340. package/dist/init/mode-detect.d.ts +34 -0
  341. package/dist/init/mode-detect.d.ts.map +1 -0
  342. package/dist/init/mode-detect.js +115 -0
  343. package/dist/init/mode-detect.js.map +1 -0
  344. package/dist/init/package-json-patcher.d.ts +36 -0
  345. package/dist/init/package-json-patcher.d.ts.map +1 -0
  346. package/dist/init/package-json-patcher.js +128 -0
  347. package/dist/init/package-json-patcher.js.map +1 -0
  348. package/dist/init/pyproject-patcher.d.ts +56 -0
  349. package/dist/init/pyproject-patcher.d.ts.map +1 -0
  350. package/dist/init/pyproject-patcher.js +324 -0
  351. package/dist/init/pyproject-patcher.js.map +1 -0
  352. package/dist/init/python-augment.d.ts +22 -0
  353. package/dist/init/python-augment.d.ts.map +1 -0
  354. package/dist/init/python-augment.js +300 -0
  355. package/dist/init/python-augment.js.map +1 -0
  356. package/dist/init/template-files.d.ts +16 -0
  357. package/dist/init/template-files.d.ts.map +1 -0
  358. package/dist/init/template-files.js +38 -0
  359. package/dist/init/template-files.js.map +1 -0
  360. package/dist/key/defaults.d.ts +3 -0
  361. package/dist/key/defaults.d.ts.map +1 -0
  362. package/dist/key/defaults.js +60 -0
  363. package/dist/key/defaults.js.map +1 -0
  364. package/dist/key/fingerprint.d.ts +6 -0
  365. package/dist/key/fingerprint.d.ts.map +1 -0
  366. package/dist/key/fingerprint.js +25 -0
  367. package/dist/key/fingerprint.js.map +1 -0
  368. package/dist/key/paths.d.ts +30 -0
  369. package/dist/key/paths.d.ts.map +1 -0
  370. package/dist/key/paths.js +51 -0
  371. package/dist/key/paths.js.map +1 -0
  372. package/dist/key/runners.d.ts +60 -0
  373. package/dist/key/runners.d.ts.map +1 -0
  374. package/dist/key/runners.js +4 -0
  375. package/dist/key/runners.js.map +1 -0
  376. package/dist/main.d.ts +106 -0
  377. package/dist/main.d.ts.map +1 -0
  378. package/dist/main.js +198 -0
  379. package/dist/main.js.map +1 -0
  380. package/dist/mcp/launcher.d.ts +143 -0
  381. package/dist/mcp/launcher.d.ts.map +1 -0
  382. package/dist/mcp/launcher.js +393 -0
  383. package/dist/mcp/launcher.js.map +1 -0
  384. package/dist/mcp/preset-loader.d.ts +29 -0
  385. package/dist/mcp/preset-loader.d.ts.map +1 -0
  386. package/dist/mcp/preset-loader.js +217 -0
  387. package/dist/mcp/preset-loader.js.map +1 -0
  388. package/dist/mcp/preset-types.d.ts +71 -0
  389. package/dist/mcp/preset-types.d.ts.map +1 -0
  390. package/dist/mcp/preset-types.js +4 -0
  391. package/dist/mcp/preset-types.js.map +1 -0
  392. package/dist/mcp/presets/README.md +68 -0
  393. package/dist/mcp/presets/postgres.json +15 -0
  394. package/dist/output.d.ts +26 -0
  395. package/dist/output.d.ts.map +1 -0
  396. package/dist/output.js +46 -0
  397. package/dist/output.js.map +1 -0
  398. package/dist/pack-config.d.ts +37 -0
  399. package/dist/pack-config.d.ts.map +1 -0
  400. package/dist/pack-config.js +65 -0
  401. package/dist/pack-config.js.map +1 -0
  402. package/dist/package-manager.d.ts +33 -0
  403. package/dist/package-manager.d.ts.map +1 -0
  404. package/dist/package-manager.js +129 -0
  405. package/dist/package-manager.js.map +1 -0
  406. package/dist/parse.d.ts +82 -0
  407. package/dist/parse.d.ts.map +1 -0
  408. package/dist/parse.js +99 -0
  409. package/dist/parse.js.map +1 -0
  410. package/dist/providers/preset-loader.d.ts +47 -0
  411. package/dist/providers/preset-loader.d.ts.map +1 -0
  412. package/dist/providers/preset-loader.js +107 -0
  413. package/dist/providers/preset-loader.js.map +1 -0
  414. package/dist/providers/presets/anthropic.json +47 -0
  415. package/dist/providers/presets/gemini.json +40 -0
  416. package/dist/reference.d.ts +28 -0
  417. package/dist/reference.d.ts.map +1 -0
  418. package/dist/reference.js +52 -0
  419. package/dist/reference.js.map +1 -0
  420. package/dist/sdk-package.d.ts +9 -0
  421. package/dist/sdk-package.d.ts.map +1 -0
  422. package/dist/sdk-package.js +20 -0
  423. package/dist/sdk-package.js.map +1 -0
  424. package/dist/sdk-skills/kindgi-authoring-agents/SKILL.md +253 -0
  425. package/dist/sdk-skills/kindgi-authoring-flows/SKILL.md +299 -0
  426. package/dist/sdk-skills/kindgi-authoring-guardrails/SKILL.md +291 -0
  427. package/dist/sdk-skills/kindgi-authoring-mcp-servers/SKILL.md +289 -0
  428. package/dist/sdk-skills/kindgi-authoring-providers/SKILL.md +704 -0
  429. package/dist/sdk-skills/kindgi-authoring-tools/SKILL.md +288 -0
  430. package/dist/sdk-skills/kindgi-framework-feedback/SKILL.md +211 -0
  431. package/dist/sdk-skills/kindgi-getting-started/SKILL.md +181 -0
  432. package/dist/sdk-skills/kindgi-python-authoring-agents/SKILL.md +205 -0
  433. package/dist/sdk-skills/kindgi-python-authoring-flows/SKILL.md +322 -0
  434. package/dist/sdk-skills/kindgi-python-authoring-guardrails/SKILL.md +173 -0
  435. package/dist/sdk-skills/kindgi-python-authoring-tools/SKILL.md +299 -0
  436. package/dist/sdk-skills/kindgi-python-getting-started/SKILL.md +240 -0
  437. package/dist/stop-signal.d.ts +15 -0
  438. package/dist/stop-signal.d.ts.map +1 -0
  439. package/dist/stop-signal.js +16 -0
  440. package/dist/stop-signal.js.map +1 -0
  441. package/dist/templates/minimal/.gitignore +8 -0
  442. package/dist/templates/minimal/.nvmrc +1 -0
  443. package/dist/templates/minimal/AGENTS.md +23 -0
  444. package/dist/templates/minimal/README.md.tmpl +69 -0
  445. package/dist/templates/minimal/agents/.gitkeep +0 -0
  446. package/dist/templates/minimal/flows/.gitkeep +0 -0
  447. package/dist/templates/minimal/guardrails/.gitkeep +0 -0
  448. package/dist/templates/minimal/kindgi.config.ts.tmpl +44 -0
  449. package/dist/templates/minimal/package.json.tmpl +25 -0
  450. package/dist/templates/minimal/pnpm-workspace.yaml +6 -0
  451. package/dist/templates/minimal/tools/.gitkeep +0 -0
  452. package/dist/templates/minimal/tsconfig.json.tmpl +27 -0
  453. package/dist/templates/minimal/vitest.config.ts.tmpl +14 -0
  454. package/dist/templates/python/.gitignore +9 -0
  455. package/dist/templates/python/AGENTS.md +30 -0
  456. package/dist/templates/python/README.md.tmpl +56 -0
  457. package/dist/templates/python/agents/echo_agent.py.tmpl +23 -0
  458. package/dist/templates/python/flows/echo_flow.py.tmpl +17 -0
  459. package/dist/templates/python/guardrails/response_not_empty.py.tmpl +27 -0
  460. package/dist/templates/python/pyproject.toml.tmpl +42 -0
  461. package/dist/templates/python/tests/test_tools.py.tmpl +22 -0
  462. package/dist/templates/python/tools/echo.py.tmpl +27 -0
  463. package/dist/templates/python/tools/greet.py.tmpl +20 -0
  464. package/dist/templates/sample/.gitignore +8 -0
  465. package/dist/templates/sample/.nvmrc +1 -0
  466. package/dist/templates/sample/AGENTS.md +23 -0
  467. package/dist/templates/sample/README.md.tmpl +85 -0
  468. package/dist/templates/sample/agents/echo-agent/index.ts.tmpl +34 -0
  469. package/dist/templates/sample/flows/echo-flow/index.ts.tmpl +59 -0
  470. package/dist/templates/sample/guardrails/response-not-empty/index.ts.tmpl +50 -0
  471. package/dist/templates/sample/kindgi.config.ts.tmpl +41 -0
  472. package/dist/templates/sample/package.json.tmpl +25 -0
  473. package/dist/templates/sample/pnpm-workspace.yaml +6 -0
  474. package/dist/templates/sample/tools/echo/index.test.ts.tmpl +31 -0
  475. package/dist/templates/sample/tools/echo/index.ts.tmpl +37 -0
  476. package/dist/templates/sample/tools/fetch-httpbin/index.ts.tmpl +60 -0
  477. package/dist/templates/sample/tools/greet/index.ts.tmpl +35 -0
  478. package/dist/templates/sample/tsconfig.json.tmpl +27 -0
  479. package/dist/templates/sample/vitest.config.ts.tmpl +14 -0
  480. package/dist/test/defaults.d.ts +3 -0
  481. package/dist/test/defaults.d.ts.map +1 -0
  482. package/dist/test/defaults.js +104 -0
  483. package/dist/test/defaults.js.map +1 -0
  484. package/dist/test/runners.d.ts +60 -0
  485. package/dist/test/runners.d.ts.map +1 -0
  486. package/dist/test/runners.js +4 -0
  487. package/dist/test/runners.js.map +1 -0
  488. package/dist/version-info.d.ts +9 -0
  489. package/dist/version-info.d.ts.map +1 -0
  490. package/dist/version-info.js +27 -0
  491. package/dist/version-info.js.map +1 -0
  492. package/dist/write-fully.d.ts +13 -0
  493. package/dist/write-fully.d.ts.map +1 -0
  494. package/dist/write-fully.js +17 -0
  495. package/dist/write-fully.js.map +1 -0
  496. package/package.json +63 -4
@@ -0,0 +1,66 @@
1
+ import type { BuildRunners, DockerBuildOptions, DockerBuildResult, EsbuildBundleOptions, EsbuildBundleResult, LocalIndexResult, PostBuildOptions, PostBuildResult, PullImageIndexOptions, PullImageIndexResult, PythonBuildRunners, RunLocalIndexerOptions, SignOptions, SignResult, StreamBuildLogsOptions, TarPackOptions, TarPackResult, TerminalPayload, WriteContainerfileOptions, WriteContextOptions } from './runners.js';
2
+ /**
3
+ * Index the build the way the image's indexer stage does: the bundled
4
+ * `kindgi-index.mjs`, in its own process, over the same bundles and
5
+ * config, writing `expected-index.json`. Run from the bundles' folder,
6
+ * it loads what the image loads (zod, for one, from the pack's own
7
+ * dependencies), so the two indexes compare like with like.
8
+ */
9
+ export declare function runLocalIndexerReal(opts: RunLocalIndexerOptions): Promise<LocalIndexResult>;
10
+ /**
11
+ * Bundle a build, into `outputDir` (the image's `dist/`), every bundle
12
+ * `.mjs` with a linked sourcemap:
13
+ * - the pack's primitives and its `kindgi.config.*`: the pack's own
14
+ * code bundled, its installed dependencies left to the image's
15
+ * `node_modules` (imported by name);
16
+ * - the framework's process entries, `kindgi-index.mjs` and
17
+ * `kindgi-pack-service.mjs`: self-contained, from the CLI's own
18
+ * `@kindgi/handler-runtime` (the pack's install has none once
19
+ * pruned);
20
+ * - `bundle-map.json`: each primitive's source path → its bundle.
21
+ */
22
+ export declare function esbuildBundleReal(opts: EsbuildBundleOptions): Promise<EsbuildBundleResult>;
23
+ export declare function writeContainerfileReal(opts: WriteContainerfileOptions): Promise<void>;
24
+ /**
25
+ * Write the image's build context into `contextDir` (emptied first):
26
+ * host/ the files the install reads, at their paths under the install root
27
+ * ext/ the files the build extensions read, at their paths under the install root
28
+ * dist/ the bundles
29
+ * include/ `bundle.include` files, at their pack-relative paths
30
+ * Containerfile
31
+ * Nothing else of the app: never its source, never its `.env` or
32
+ * registry credentials.
33
+ */
34
+ export declare function writeContextReal(opts: WriteContextOptions): Promise<void>;
35
+ /** Tar a written context (`writeContext`) for the build service. */
36
+ export declare function tarPackReal(opts: TarPackOptions): Promise<TarPackResult>;
37
+ /** A Python pack's build context: the listed pack files plus the Containerfile. */
38
+ export declare function tarContextReal(opts: {
39
+ readonly packDir: string;
40
+ readonly files: readonly string[];
41
+ readonly containerfilePath: string;
42
+ readonly outputPath: string;
43
+ }): Promise<TarPackResult>;
44
+ /** The Python pack's steps of `kindgi build`. */
45
+ export declare const PYTHON_BUILD_RUNNERS: PythonBuildRunners;
46
+ export declare function postBuildReal(opts: PostBuildOptions): Promise<PostBuildResult>;
47
+ export declare function streamBuildLogsReal(opts: StreamBuildLogsOptions): Promise<TerminalPayload>;
48
+ /**
49
+ * Mirror of `packages/build-server/src/docker-wrapper.ts:
50
+ * extractFileFromImage`. Uses `docker create/cp/rm` — the same
51
+ * dependency footprint the build server declares, so a machine that
52
+ * can run the build server also has this path available.
53
+ */
54
+ export declare function pullImageIndexReal(opts: PullImageIndexOptions): Promise<PullImageIndexResult>;
55
+ /**
56
+ * Build the image from a written context into the local Docker image
57
+ * store: `docker buildx build --load`, registry config passed as
58
+ * BuildKit secrets (never in a layer). Every output line goes to
59
+ * `onLog`.
60
+ */
61
+ export declare function dockerBuildReal(opts: DockerBuildOptions): Promise<DockerBuildResult>;
62
+ export declare function signEnvelopeReal(opts: SignOptions): Promise<SignResult>;
63
+ export declare const REAL_BUILD_RUNNERS: BuildRunners;
64
+ export declare function defaultBuildWorkDir(): string;
65
+ export declare function sha256HexOf(bytes: Uint8Array): string;
66
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/build/defaults.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAMtB;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CA4D3B;AAMD;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CA6D9B;AAsBD,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAa3F;AAMD;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB/E;AAED,oEAAoE;AACpE,wBAAsB,WAAW,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAE9E;AAkBD,mFAAmF;AACnF,wBAAsB,cAAc,CAAC,IAAI,EAAE;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,aAAa,CAAC,CAYzB;AAED,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,EAAE,kBA2BlC,CAAC;AAMF,wBAAsB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CA8CpF;AAMD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,eAAe,CAAC,CA6C1B;AAMD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CAkC/B;AAMD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAqD1F;AA6ED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAuB7E;AAMD,eAAO,MAAM,kBAAkB,EAAE,YAYhC,CAAC;AAIF,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAID,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAErD"}
@@ -0,0 +1,586 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ /**
4
+ * Production wiring for `kindgi build`. Each `BuildRunners` slot is
5
+ * implemented against real infrastructure (esbuild, tar, fetch,
6
+ * @kindgi/handler-runtime.runIndexer, @kindgi/crypto.signEd25519,
7
+ * a docker CLI shell-out). Tests never touch this file — they inject
8
+ * fixtures via `runCli({ buildRunners })`.
9
+ */
10
+ import { spawn } from 'node:child_process';
11
+ import { createHash, createPrivateKey, createPublicKey } from 'node:crypto';
12
+ import { cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
13
+ import { tmpdir } from 'node:os';
14
+ import { dirname, join, resolve } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+ import { parsePrivateKeyPem, serializePublicKeyPem, signEd25519 } from '@kindgi/crypto';
17
+ import { readSse } from '@kindgi/sdk/client';
18
+ import { runPythonIndexer } from '../dev/defaults.js';
19
+ import { REQUIRE_BANNER, collectPackEntries, nodeModulesExternalPlugin } from './bundle.js';
20
+ import { renderContainerfile } from './containerfile.js';
21
+ import { installCommands } from './host-install.js';
22
+ import { renderPythonContainerfile } from './python-image.js';
23
+ // ---------------------------------------------------------------------
24
+ // Local indexer — the integrity-gate baseline
25
+ // ---------------------------------------------------------------------
26
+ /**
27
+ * Index the build the way the image's indexer stage does: the bundled
28
+ * `kindgi-index.mjs`, in its own process, over the same bundles and
29
+ * config, writing `expected-index.json`. Run from the bundles' folder,
30
+ * it loads what the image loads (zod, for one, from the pack's own
31
+ * dependencies), so the two indexes compare like with like.
32
+ */
33
+ export async function runLocalIndexerReal(opts) {
34
+ const dist = opts.bundleDir;
35
+ const args = [
36
+ '--enable-source-maps',
37
+ join(dist, 'kindgi-index.mjs'),
38
+ '--pack-dir',
39
+ opts.packDir,
40
+ '--config',
41
+ join(dist, 'kindgi.config.mjs'),
42
+ '--bundle-map',
43
+ join(dist, 'bundle-map.json'),
44
+ '--module-root',
45
+ dist,
46
+ '--artifact-version',
47
+ opts.artifactVersion,
48
+ '--published-at',
49
+ opts.publishedAt,
50
+ '--output',
51
+ opts.outputPath,
52
+ ];
53
+ const run = await spawnOutcome(process.execPath, args, opts.packDir);
54
+ if (run.code !== 0) {
55
+ // `kindgi-index: <code>: <message>`
56
+ const line = run.stderr.trim().split('\n').pop() ?? '';
57
+ const match = /^kindgi-index: ([a-z-]+): (.*)$/s.exec(line);
58
+ return {
59
+ kind: 'err',
60
+ code: match?.[1] ?? 'index-failed',
61
+ message: match?.[2] ?? (run.stderr.trim() || `kindgi-index exited ${run.code}`),
62
+ };
63
+ }
64
+ let report;
65
+ let index;
66
+ try {
67
+ report = JSON.parse(run.stdout);
68
+ index = JSON.parse(await readFile(opts.outputPath, 'utf8'));
69
+ }
70
+ catch (cause) {
71
+ return {
72
+ kind: 'err',
73
+ code: 'index-read-failed',
74
+ message: `The indexer finished, but its report or ${opts.outputPath} can't be read: ${cause.message}`,
75
+ };
76
+ }
77
+ return {
78
+ kind: 'ok',
79
+ packId: report.packId,
80
+ packVersion: report.packVersion,
81
+ counts: report.counts,
82
+ fileErrors: report.fileErrors.map((e) => ({
83
+ code: e.code,
84
+ message: e.message,
85
+ ...(e.filePath !== undefined && { filePath: e.filePath }),
86
+ })),
87
+ index,
88
+ };
89
+ }
90
+ // ---------------------------------------------------------------------
91
+ // esbuild bundle
92
+ // ---------------------------------------------------------------------
93
+ /**
94
+ * Bundle a build, into `outputDir` (the image's `dist/`), every bundle
95
+ * `.mjs` with a linked sourcemap:
96
+ * - the pack's primitives and its `kindgi.config.*`: the pack's own
97
+ * code bundled, its installed dependencies left to the image's
98
+ * `node_modules` (imported by name);
99
+ * - the framework's process entries, `kindgi-index.mjs` and
100
+ * `kindgi-pack-service.mjs`: self-contained, from the CLI's own
101
+ * `@kindgi/handler-runtime` (the pack's install has none once
102
+ * pruned);
103
+ * - `bundle-map.json`: each primitive's source path → its bundle.
104
+ */
105
+ export async function esbuildBundleReal(opts) {
106
+ const esbuild = await import('esbuild');
107
+ await rm(opts.outputDir, { recursive: true, force: true });
108
+ await mkdir(opts.outputDir, { recursive: true });
109
+ const common = {
110
+ absWorkingDir: opts.packDir,
111
+ outdir: opts.outputDir,
112
+ outExtension: { '.js': '.mjs' },
113
+ bundle: true,
114
+ format: 'esm',
115
+ platform: 'node',
116
+ target: `node${opts.nodeMajor}`,
117
+ sourcemap: 'linked',
118
+ banner: { js: REQUIRE_BANNER },
119
+ metafile: true,
120
+ logLevel: 'silent',
121
+ // Readable stack traces in the image; no minification.
122
+ minify: false,
123
+ };
124
+ const packEntries = await collectPackEntries(opts.packDir, opts.discoveryPatterns);
125
+ const externalPackages = new Set();
126
+ const externals = nodeModulesExternalPlugin({ importBy: 'bare', externalPackages });
127
+ const pack = await esbuild.build({
128
+ ...common,
129
+ entryPoints: [
130
+ ...packEntries.map((e) => ({ in: e.abs, out: e.outRel })),
131
+ { in: opts.configPath, out: 'kindgi.config' },
132
+ ],
133
+ plugins: [externals],
134
+ });
135
+ // Resolved from the CLI's own package, whose dependency it is.
136
+ const cliRoot = await cliPackageRoot();
137
+ const framework = await esbuild.build({
138
+ ...common,
139
+ absWorkingDir: cliRoot,
140
+ entryPoints: [
141
+ { in: '@kindgi/handler-runtime/kindgi-index-main', out: 'kindgi-index' },
142
+ { in: '@kindgi/handler-runtime/pack-service-main', out: 'kindgi-pack-service' },
143
+ ],
144
+ });
145
+ const bundleMap = {};
146
+ for (const entry of packEntries)
147
+ bundleMap[entry.sourceRel] = `${entry.outRel}.mjs`;
148
+ await writeFile(join(opts.outputDir, 'bundle-map.json'), `${JSON.stringify(bundleMap, null, 2)}\n`, 'utf8');
149
+ // Metafile output keys are relative to each build's `absWorkingDir`.
150
+ const outputs = [
151
+ ...Object.entries(pack.metafile?.outputs ?? {}).map(([p, o]) => [resolve(opts.packDir, p), o]),
152
+ ...Object.entries(framework.metafile?.outputs ?? {}).map(([p, o]) => [resolve(cliRoot, p), o]),
153
+ ];
154
+ return {
155
+ emitted: outputs.map(([p]) => p).sort(),
156
+ totalBytes: outputs.reduce((sum, [, o]) => sum + o.bytes, 0),
157
+ externals: [...externalPackages].sort(),
158
+ bundleMap,
159
+ };
160
+ }
161
+ /** The `@kindgi/cli` package folder (this file's nearest `package.json`). */
162
+ async function cliPackageRoot() {
163
+ let dir = dirname(fileURLToPath(import.meta.url));
164
+ for (;;) {
165
+ try {
166
+ const pkg = JSON.parse(await readFile(join(dir, 'package.json'), 'utf8'));
167
+ if (pkg.name === '@kindgi/cli')
168
+ return dir;
169
+ }
170
+ catch {
171
+ // not here
172
+ }
173
+ const parent = dirname(dir);
174
+ if (parent === dir)
175
+ throw new Error('kindgi build: cannot find the @kindgi/cli package folder');
176
+ dir = parent;
177
+ }
178
+ }
179
+ // ---------------------------------------------------------------------
180
+ // Containerfile
181
+ // ---------------------------------------------------------------------
182
+ export async function writeContainerfileReal(opts) {
183
+ const text = renderContainerfile({
184
+ baseImageRef: opts.baseImageRef,
185
+ artifactVersion: opts.artifactVersion,
186
+ publishedAt: opts.publishedAt,
187
+ buildTarget: opts.buildTarget,
188
+ install: opts.install,
189
+ commands: installCommands(opts.install),
190
+ image: opts.image,
191
+ hasIncludes: opts.hasIncludes,
192
+ });
193
+ await mkdir(join(opts.outputPath, '..'), { recursive: true });
194
+ await writeFile(opts.outputPath, text, 'utf8');
195
+ }
196
+ // ---------------------------------------------------------------------
197
+ // Build context + tarball
198
+ // ---------------------------------------------------------------------
199
+ /**
200
+ * Write the image's build context into `contextDir` (emptied first):
201
+ * host/ the files the install reads, at their paths under the install root
202
+ * ext/ the files the build extensions read, at their paths under the install root
203
+ * dist/ the bundles
204
+ * include/ `bundle.include` files, at their pack-relative paths
205
+ * Containerfile
206
+ * Nothing else of the app: never its source, never its `.env` or
207
+ * registry credentials.
208
+ */
209
+ export async function writeContextReal(opts) {
210
+ await rm(opts.contextDir, { recursive: true, force: true });
211
+ await mkdir(opts.contextDir, { recursive: true });
212
+ for (const rel of opts.install.files) {
213
+ const dest = join(opts.contextDir, 'host', rel);
214
+ await mkdir(dirname(dest), { recursive: true });
215
+ await cp(join(opts.install.root, rel), dest);
216
+ }
217
+ for (const rel of opts.extensionFiles) {
218
+ const dest = join(opts.contextDir, 'ext', opts.install.packRel, rel);
219
+ await mkdir(dirname(dest), { recursive: true });
220
+ await cp(join(opts.packDir, rel), dest);
221
+ }
222
+ await cp(opts.bundleDir, join(opts.contextDir, 'dist'), { recursive: true });
223
+ for (const rel of opts.includes) {
224
+ const dest = join(opts.contextDir, 'include', rel);
225
+ await mkdir(dirname(dest), { recursive: true });
226
+ await cp(join(opts.packDir, rel), dest);
227
+ }
228
+ await cp(opts.containerfilePath, join(opts.contextDir, 'Containerfile'));
229
+ }
230
+ /** Tar a written context (`writeContext`) for the build service. */
231
+ export async function tarPackReal(opts) {
232
+ return deterministicTar(opts.contextDir, opts.outputPath);
233
+ }
234
+ /**
235
+ * Gzip `contextDir` into `outputPath` with every mtime at the epoch, so the
236
+ * tarball's hash depends only on its content; the scratch context is
237
+ * removed afterwards.
238
+ */
239
+ async function deterministicTar(contextDir, outputPath) {
240
+ const tar = await import('tar');
241
+ await tar.create({ gzip: true, cwd: contextDir, portable: true, file: outputPath, mtime: new Date(0) }, ['.']);
242
+ const bytes = await readFile(outputPath);
243
+ await rm(contextDir, { recursive: true, force: true });
244
+ return { path: outputPath, bytes: new Uint8Array(bytes), size: bytes.length };
245
+ }
246
+ /** A Python pack's build context: the listed pack files plus the Containerfile. */
247
+ export async function tarContextReal(opts) {
248
+ const { cp } = await import('node:fs/promises');
249
+ const contextDir = join(join(opts.outputPath, '..'), '.tar-context');
250
+ await rm(contextDir, { recursive: true, force: true });
251
+ await mkdir(contextDir, { recursive: true });
252
+ for (const rel of opts.files) {
253
+ const dest = join(contextDir, rel);
254
+ await mkdir(dirname(dest), { recursive: true });
255
+ await cp(join(opts.packDir, rel), dest);
256
+ }
257
+ await cp(opts.containerfilePath, join(contextDir, 'Containerfile'));
258
+ return deterministicTar(contextDir, opts.outputPath);
259
+ }
260
+ /** The Python pack's steps of `kindgi build`. */
261
+ export const PYTHON_BUILD_RUNNERS = {
262
+ runLocalIndexer: (opts) => runPythonIndexer({
263
+ packDir: opts.packDir,
264
+ outputPath: opts.outputPath,
265
+ python: opts.python,
266
+ env: opts.env,
267
+ artifactVersion: opts.artifactVersion,
268
+ publishedAt: opts.publishedAt,
269
+ }),
270
+ async writeContainerfile(opts) {
271
+ await mkdir(join(opts.outputPath, '..'), { recursive: true });
272
+ await writeFile(opts.outputPath, renderPythonContainerfile({
273
+ baseImageRef: opts.baseImageRef,
274
+ uvImageRef: opts.uvImageRef,
275
+ artifactVersion: opts.artifactVersion,
276
+ publishedAt: opts.publishedAt,
277
+ buildTarget: opts.buildTarget,
278
+ installer: opts.installer,
279
+ systemPackages: opts.systemPackages,
280
+ }), 'utf8');
281
+ },
282
+ tarContext: tarContextReal,
283
+ };
284
+ // ---------------------------------------------------------------------
285
+ // POST /v1/build
286
+ // ---------------------------------------------------------------------
287
+ export async function postBuildReal(opts) {
288
+ const form = new FormData();
289
+ const blob = new Blob([opts.tarballBytes], { type: 'application/gzip' });
290
+ form.append('pack.tgz', blob, 'pack.tgz');
291
+ form.append('buildTarget', opts.buildTarget);
292
+ if (opts.registryPushCredsRef !== undefined) {
293
+ form.append('registryPushCredsRef', opts.registryPushCredsRef);
294
+ }
295
+ const url = `${opts.endpoint.replace(/\/+$/, '')}/v1/build`;
296
+ const res = await opts.fetchImpl(url, {
297
+ method: 'POST',
298
+ headers: { 'X-Content-SHA256': opts.tarballSha256 },
299
+ body: form,
300
+ });
301
+ if (res.status !== 200 && res.status !== 202) {
302
+ const errBody = await res.text().catch(() => '');
303
+ throw new Error(`POST /v1/build failed with HTTP ${res.status}: ${errBody}`);
304
+ }
305
+ const payload = (await res.json());
306
+ const terminal = payload.status === 'completed' || payload.status === 'failed'
307
+ ? {
308
+ status: payload.status,
309
+ ...(payload.imageRef !== undefined && { imageRef: payload.imageRef }),
310
+ ...(payload.imageDigest !== undefined && { imageDigest: payload.imageDigest }),
311
+ ...(payload.indexJson !== undefined && { indexJson: payload.indexJson }),
312
+ ...(payload.indexHash !== undefined && { indexHash: payload.indexHash }),
313
+ ...(payload.buildLogsUrl !== undefined && { buildLogsUrl: payload.buildLogsUrl }),
314
+ ...(payload.error !== undefined && { error: payload.error }),
315
+ }
316
+ : undefined;
317
+ return {
318
+ buildJobId: payload.buildJobId,
319
+ status: payload.status,
320
+ buildLogsUrl: payload.buildLogsUrl,
321
+ ...(terminal !== undefined && { terminal }),
322
+ };
323
+ }
324
+ // ---------------------------------------------------------------------
325
+ // SSE stream of build logs
326
+ // ---------------------------------------------------------------------
327
+ export async function streamBuildLogsReal(opts) {
328
+ const url = `${opts.endpoint.replace(/\/+$/, '')}/v1/build/${opts.buildJobId}/stream`;
329
+ let terminal;
330
+ const iter = readSse({
331
+ url,
332
+ fetchImpl: opts.fetchImpl,
333
+ ...(opts.signal !== undefined && { signal: opts.signal }),
334
+ // The build server's stream is single-shot; disable auto-retry.
335
+ shouldRetry: () => false,
336
+ });
337
+ for await (const event of iter) {
338
+ if (event.event === 'log') {
339
+ const data = event.data;
340
+ if (typeof data.line === 'string')
341
+ opts.onLog(data.line);
342
+ continue;
343
+ }
344
+ if (event.event === 'terminal') {
345
+ const data = event.data;
346
+ terminal = {
347
+ status: data.status,
348
+ ...(data.imageRef !== undefined && { imageRef: data.imageRef }),
349
+ ...(data.imageDigest !== undefined && { imageDigest: data.imageDigest }),
350
+ ...(data.indexJson !== undefined && { indexJson: data.indexJson }),
351
+ ...(data.indexHash !== undefined && { indexHash: data.indexHash }),
352
+ ...(data.buildLogsUrl !== undefined && { buildLogsUrl: data.buildLogsUrl }),
353
+ ...(data.error !== undefined && { error: data.error }),
354
+ };
355
+ }
356
+ }
357
+ if (terminal === undefined) {
358
+ throw new Error(`SSE stream closed without a terminal event for buildJobId ${opts.buildJobId}`);
359
+ }
360
+ return terminal;
361
+ }
362
+ // ---------------------------------------------------------------------
363
+ // docker pull + extract /app/index.json (for the byte-diff path)
364
+ // ---------------------------------------------------------------------
365
+ /**
366
+ * Mirror of `packages/build-server/src/docker-wrapper.ts:
367
+ * extractFileFromImage`. Uses `docker create/cp/rm` — the same
368
+ * dependency footprint the build server declares, so a machine that
369
+ * can run the build server also has this path available.
370
+ */
371
+ export async function pullImageIndexReal(opts) {
372
+ await mkdir(opts.workDir, { recursive: true });
373
+ const onLog = opts.onLog ?? (() => { });
374
+ const platform = opts.platform !== undefined ? ['--platform', opts.platform] : [];
375
+ if (opts.pull !== false) {
376
+ onLog(`docker pull ${opts.imageRef}`);
377
+ await spawnCapture('docker', ['pull', ...platform, opts.imageRef], opts.signal);
378
+ }
379
+ const containerId = (await spawnCapture('docker', ['create', ...platform, opts.imageRef], opts.signal)).trim();
380
+ const localCopy = join(opts.workDir, 'server-index.json');
381
+ try {
382
+ onLog(`docker cp ${containerId}:/app/index.json ${localCopy}`);
383
+ await spawnCapture('docker', ['cp', `${containerId}:/app/index.json`, localCopy], opts.signal);
384
+ const bytes = await readFile(localCopy);
385
+ return { bytes };
386
+ }
387
+ finally {
388
+ try {
389
+ await spawnCapture('docker', ['rm', containerId], undefined);
390
+ }
391
+ catch {
392
+ // ignore — leaked containers are an operator concern, not a build
393
+ // failure.
394
+ }
395
+ try {
396
+ await rm(localCopy);
397
+ }
398
+ catch {
399
+ // ignore
400
+ }
401
+ }
402
+ }
403
+ // ---------------------------------------------------------------------
404
+ // docker buildx build --load (`kindgi build --local`)
405
+ // ---------------------------------------------------------------------
406
+ /**
407
+ * Build the image from a written context into the local Docker image
408
+ * store: `docker buildx build --load`, registry config passed as
409
+ * BuildKit secrets (never in a layer). Every output line goes to
410
+ * `onLog`.
411
+ */
412
+ export async function dockerBuildReal(opts) {
413
+ const metadataFile = join(opts.contextDir, '..', 'buildx-metadata.json');
414
+ const args = [
415
+ 'buildx',
416
+ 'build',
417
+ opts.push === true ? '--push' : '--load',
418
+ ...(opts.platform !== undefined ? ['--platform', opts.platform] : []),
419
+ // A plain image manifest: its digest is the image's, nothing else's.
420
+ '--provenance=false',
421
+ '--metadata-file',
422
+ metadataFile,
423
+ '--progress',
424
+ 'plain',
425
+ '--file',
426
+ join(opts.contextDir, 'Containerfile'),
427
+ '--tag',
428
+ opts.tag,
429
+ '--build-arg',
430
+ 'SOURCE_DATE_EPOCH=0',
431
+ '--build-arg',
432
+ `KINDGI_BUILD_TARGET=${opts.buildTarget}`,
433
+ ...opts.secrets.flatMap((s) => ['--secret', `id=${s.id},src=${s.src}`]),
434
+ opts.contextDir,
435
+ ];
436
+ const tail = [];
437
+ const run = await spawnOutcome('docker', args, opts.contextDir, (line) => {
438
+ tail.push(line);
439
+ if (tail.length > 30)
440
+ tail.shift();
441
+ opts.onLog?.(line);
442
+ });
443
+ if (run.code !== 0) {
444
+ return { kind: 'err', message: `docker buildx build exited ${run.code}:\n${tail.join('\n')}` };
445
+ }
446
+ if (opts.push === true) {
447
+ // The registry's digest of what was pushed.
448
+ let digest;
449
+ try {
450
+ digest = JSON.parse(await readFile(metadataFile, 'utf8'))['containerimage.digest'];
451
+ }
452
+ catch {
453
+ digest = undefined;
454
+ }
455
+ if (typeof digest !== 'string' || !/^sha256:[0-9a-f]{64}$/.test(digest)) {
456
+ return { kind: 'err', message: `docker buildx pushed ${opts.tag} but reported no digest` };
457
+ }
458
+ return { kind: 'ok', imageId: digest, digest };
459
+ }
460
+ const inspected = await spawnOutcome('docker', ['image', 'inspect', '--format', '{{.Id}}', opts.tag], opts.contextDir);
461
+ if (inspected.code !== 0) {
462
+ return { kind: 'err', message: `docker image inspect ${opts.tag}: ${inspected.stderr.trim()}` };
463
+ }
464
+ return { kind: 'ok', imageId: inspected.stdout.trim() };
465
+ }
466
+ /** Run a command to the end: its exit code and output, each line also to `onLine`. */
467
+ function spawnOutcome(command, args, cwd, onLine) {
468
+ return new Promise((resolveRun) => {
469
+ const child = spawn(command, args, { cwd, stdio: ['ignore', 'pipe', 'pipe'] });
470
+ let stdout = '';
471
+ let stderr = '';
472
+ const lines = (chunk, pending) => {
473
+ if (onLine === undefined)
474
+ return;
475
+ pending.text += chunk.toString('utf8');
476
+ const parts = pending.text.split('\n');
477
+ pending.text = parts.pop() ?? '';
478
+ for (const line of parts)
479
+ onLine(line);
480
+ };
481
+ const out = { text: '' };
482
+ const err = { text: '' };
483
+ child.stdout?.on('data', (c) => {
484
+ stdout += c.toString('utf8');
485
+ lines(c, out);
486
+ });
487
+ child.stderr?.on('data', (c) => {
488
+ stderr += c.toString('utf8');
489
+ lines(c, err);
490
+ });
491
+ child.on('error', (cause) => resolveRun({ code: 127, stdout, stderr: `${stderr}${cause.message}` }));
492
+ child.on('close', (code) => {
493
+ for (const rest of [out.text, err.text])
494
+ if (rest !== '')
495
+ onLine?.(rest);
496
+ resolveRun({ code: code ?? 1, stdout, stderr });
497
+ });
498
+ });
499
+ }
500
+ function spawnCapture(command, args, signal) {
501
+ return new Promise((resolve, reject) => {
502
+ const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'] });
503
+ let stdout = '';
504
+ let stderr = '';
505
+ child.stdout?.on('data', (c) => {
506
+ stdout += c.toString('utf8');
507
+ });
508
+ child.stderr?.on('data', (c) => {
509
+ stderr += c.toString('utf8');
510
+ });
511
+ const onAbort = () => {
512
+ try {
513
+ child.kill('SIGTERM');
514
+ }
515
+ catch {
516
+ // ignore
517
+ }
518
+ };
519
+ if (signal !== undefined) {
520
+ if (signal.aborted)
521
+ onAbort();
522
+ else
523
+ signal.addEventListener('abort', onAbort, { once: true });
524
+ }
525
+ child.on('error', reject);
526
+ child.on('close', (code) => {
527
+ if (signal !== undefined)
528
+ signal.removeEventListener('abort', onAbort);
529
+ if (code === 0)
530
+ resolve(stdout);
531
+ else
532
+ reject(new Error(`${command} ${args.join(' ')} exited ${code}: ${stderr.trim()}`));
533
+ });
534
+ });
535
+ }
536
+ // ---------------------------------------------------------------------
537
+ // Ed25519 sign
538
+ // ---------------------------------------------------------------------
539
+ export async function signEnvelopeReal(opts) {
540
+ const parsed = parsePrivateKeyPem(opts.privateKeyPem);
541
+ if (parsed.kind === 'err') {
542
+ throw new Error(`Signing key rejected: ${parsed.error.code} — ${parsed.error.message}`);
543
+ }
544
+ const sig = signEd25519(parsed.value, opts.message);
545
+ if (sig.kind === 'err') {
546
+ throw new Error(`Ed25519 signing failed: ${sig.error.message}`);
547
+ }
548
+ // Derive the public key from the PEM with Node's crypto: @kindgi/crypto
549
+ // has no `derivePublicKey` helper.
550
+ const priv = createPrivateKey({ key: opts.privateKeyPem, format: 'pem' });
551
+ const pub = createPublicKey(priv);
552
+ const spki = pub.export({ format: 'der', type: 'spki' });
553
+ const raw = new Uint8Array(spki).subarray(-32); // Ed25519 SPKI trailer is the raw pub key.
554
+ const publicKeyPem = serializePublicKeyPem(raw);
555
+ return {
556
+ signatureBase64: Buffer.from(sig.value).toString('base64'),
557
+ publicKeyPem,
558
+ };
559
+ }
560
+ // ---------------------------------------------------------------------
561
+ // Wired seam
562
+ // ---------------------------------------------------------------------
563
+ export const REAL_BUILD_RUNNERS = {
564
+ runLocalIndexer: runLocalIndexerReal,
565
+ esbuildBundle: esbuildBundleReal,
566
+ writeContainerfile: writeContainerfileReal,
567
+ writeContext: writeContextReal,
568
+ tarPack: tarPackReal,
569
+ dockerBuild: dockerBuildReal,
570
+ postBuild: postBuildReal,
571
+ streamBuildLogs: streamBuildLogsReal,
572
+ pullImageIndex: pullImageIndexReal,
573
+ signEnvelope: signEnvelopeReal,
574
+ python: PYTHON_BUILD_RUNNERS,
575
+ };
576
+ // Re-export utility for callers that want a portable tmp workdir for
577
+ // the image-pull path.
578
+ export function defaultBuildWorkDir() {
579
+ return join(tmpdir(), 'kindgi-cli-build');
580
+ }
581
+ // Re-export the small primitive tests use to independently compute the
582
+ // tarball hash without the tar step.
583
+ export function sha256HexOf(bytes) {
584
+ return `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
585
+ }
586
+ //# sourceMappingURL=defaults.js.map