@agimon-ai/po 0.0.0-alpha.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 (560) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +755 -0
  3. package/assets/banner.png +0 -0
  4. package/assets/banner.svg +25 -0
  5. package/assets/favicon.svg +15 -0
  6. package/assets/logo-light.png +0 -0
  7. package/assets/logo-light.svg +25 -0
  8. package/assets/logo.png +0 -0
  9. package/assets/logo.svg +25 -0
  10. package/assets/mascot.png +0 -0
  11. package/assets/mascot.svg +25 -0
  12. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  13. package/dist/antigravity.cjs +5 -0
  14. package/dist/antigravity.d.mts +2 -0
  15. package/dist/antigravity.mjs +2 -0
  16. package/dist/apiContracts.cjs +11 -0
  17. package/dist/apiContracts.cjs.map +1 -0
  18. package/dist/apiContracts.d.mts +52 -0
  19. package/dist/apiContracts.d.mts.map +1 -0
  20. package/dist/apiContracts.mjs +7 -0
  21. package/dist/apiContracts.mjs.map +1 -0
  22. package/dist/baseCommand.cjs +3 -0
  23. package/dist/baseCommand.d.mts +2 -0
  24. package/dist/baseCommand.mjs +2 -0
  25. package/dist/bin/cli.cjs +24 -0
  26. package/dist/bin/cli.cjs.map +1 -0
  27. package/dist/bin/cli.d.mts +1 -0
  28. package/dist/bin/cli.mjs +25 -0
  29. package/dist/bin/cli.mjs.map +1 -0
  30. package/dist/bin/doomRunner.cjs +33 -0
  31. package/dist/bin/doomRunner.cjs.map +1 -0
  32. package/dist/bin/doomRunner.d.mts +4 -0
  33. package/dist/bin/doomRunner.d.mts.map +1 -0
  34. package/dist/bin/doomRunner.mjs +32 -0
  35. package/dist/bin/doomRunner.mjs.map +1 -0
  36. package/dist/bin/serve.cjs +30 -0
  37. package/dist/bin/serve.cjs.map +1 -0
  38. package/dist/bin/serve.d.mts +1 -0
  39. package/dist/bin/serve.mjs +31 -0
  40. package/dist/bin/serve.mjs.map +1 -0
  41. package/dist/builders/cli/extensionAssembler/index.cjs +342 -0
  42. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -0
  43. package/dist/builders/cli/extensionAssembler/index.d.mts +85 -0
  44. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -0
  45. package/dist/builders/cli/extensionAssembler/index.mjs +335 -0
  46. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -0
  47. package/dist/catalog/index.json +430 -0
  48. package/dist/cli.cjs +28 -0
  49. package/dist/cli.d.mts +11 -0
  50. package/dist/cli.mjs +11 -0
  51. package/dist/cliApp.cjs +6 -0
  52. package/dist/cliApp.d.mts +2 -0
  53. package/dist/cliApp.mjs +2 -0
  54. package/dist/codex.cjs +8 -0
  55. package/dist/codex.d.mts +2 -0
  56. package/dist/codex.mjs +2 -0
  57. package/dist/commands.cjs +18 -0
  58. package/dist/commands.d.mts +9 -0
  59. package/dist/commands.mjs +9 -0
  60. package/dist/compatibility.cjs +27 -0
  61. package/dist/compatibility.d.mts +6 -0
  62. package/dist/compatibility.mjs +6 -0
  63. package/dist/compatibilityCommand.cjs +4 -0
  64. package/dist/compatibilityCommand.d.mts +2 -0
  65. package/dist/compatibilityCommand.mjs +2 -0
  66. package/dist/compatibilityContext.cjs +3 -0
  67. package/dist/compatibilityContext.d.mts +2 -0
  68. package/dist/compatibilityContext.mjs +2 -0
  69. package/dist/compatibilityOptions.cjs +5 -0
  70. package/dist/compatibilityOptions.d.mts +2 -0
  71. package/dist/compatibilityOptions.mjs +2 -0
  72. package/dist/config.cjs +163 -0
  73. package/dist/config.d.mts +7 -0
  74. package/dist/config.mjs +7 -0
  75. package/dist/doctorCommand.cjs +5 -0
  76. package/dist/doctorCommand.d.mts +2 -0
  77. package/dist/doctorCommand.mjs +2 -0
  78. package/dist/emitMcpCommand.cjs +4 -0
  79. package/dist/emitMcpCommand.d.mts +2 -0
  80. package/dist/emitMcpCommand.mjs +2 -0
  81. package/dist/explainCommand.cjs +5 -0
  82. package/dist/explainCommand.d.mts +2 -0
  83. package/dist/explainCommand.mjs +2 -0
  84. package/dist/extensions/server.cjs +39 -0
  85. package/dist/extensions/server.cjs.map +1 -0
  86. package/dist/extensions/server.d.mts +5 -0
  87. package/dist/extensions/server.d.mts.map +1 -0
  88. package/dist/extensions/server.mjs +34 -0
  89. package/dist/extensions/server.mjs.map +1 -0
  90. package/dist/harnessContext.cjs +5 -0
  91. package/dist/harnessContext.d.mts +2 -0
  92. package/dist/harnessContext.mjs +2 -0
  93. package/dist/harnessState.cjs +19 -0
  94. package/dist/harnessState.d.mts +2 -0
  95. package/dist/harnessState.mjs +2 -0
  96. package/dist/help.cjs +12 -0
  97. package/dist/help.d.mts +6 -0
  98. package/dist/help.mjs +6 -0
  99. package/dist/index.cjs +306 -0
  100. package/dist/index.d.mts +40 -0
  101. package/dist/index.mjs +37 -0
  102. package/dist/initCommand.cjs +4 -0
  103. package/dist/initCommand.d.mts +2 -0
  104. package/dist/initCommand.mjs +2 -0
  105. package/dist/matrixOptions.cjs +28 -0
  106. package/dist/matrixOptions.d.mts +2 -0
  107. package/dist/matrixOptions.mjs +2 -0
  108. package/dist/matrixSwitcher.cjs +11 -0
  109. package/dist/matrixSwitcher.d.mts +3 -0
  110. package/dist/matrixSwitcher.mjs +3 -0
  111. package/dist/mcpFilter.cjs +9 -0
  112. package/dist/mcpFilter.d.mts +1 -0
  113. package/dist/mcpFilter.mjs +2 -0
  114. package/dist/options.cjs +3 -0
  115. package/dist/options.d.mts +2 -0
  116. package/dist/options.mjs +2 -0
  117. package/dist/process.cjs +12 -0
  118. package/dist/process.d.mts +2 -0
  119. package/dist/process.mjs +2 -0
  120. package/dist/projectTrust.cjs +6 -0
  121. package/dist/projectTrust.d.mts +2 -0
  122. package/dist/projectTrust.mjs +2 -0
  123. package/dist/repository.cjs +5 -0
  124. package/dist/repository.d.mts +2 -0
  125. package/dist/repository.mjs +2 -0
  126. package/dist/resourceCollector.cjs +9 -0
  127. package/dist/resourceCollector.d.mts +1 -0
  128. package/dist/resourceCollector.mjs +2 -0
  129. package/dist/router.cjs +6 -0
  130. package/dist/router.d.mts +2 -0
  131. package/dist/router.mjs +2 -0
  132. package/dist/services.cjs +97 -0
  133. package/dist/services.d.mts +12 -0
  134. package/dist/services.mjs +12 -0
  135. package/dist/shared.cjs +18 -0
  136. package/dist/shared.d.mts +2 -0
  137. package/dist/shared.mjs +2 -0
  138. package/dist/src/bin/agentDirectory.cjs +27 -0
  139. package/dist/src/bin/agentDirectory.cjs.map +1 -0
  140. package/dist/src/bin/agentDirectory.mjs +26 -0
  141. package/dist/src/bin/agentDirectory.mjs.map +1 -0
  142. package/dist/src/builders/apiContractExport/index.cjs +126 -0
  143. package/dist/src/builders/apiContractExport/index.cjs.map +1 -0
  144. package/dist/src/builders/apiContractExport/index.mjs +123 -0
  145. package/dist/src/builders/apiContractExport/index.mjs.map +1 -0
  146. package/dist/src/builders/cli/entryResolution.cjs +39 -0
  147. package/dist/src/builders/cli/entryResolution.cjs.map +1 -0
  148. package/dist/src/builders/cli/entryResolution.mjs +35 -0
  149. package/dist/src/builders/cli/entryResolution.mjs.map +1 -0
  150. package/dist/src/builders/cli/harnessContext.cjs +175 -0
  151. package/dist/src/builders/cli/harnessContext.cjs.map +1 -0
  152. package/dist/src/builders/cli/harnessContext.d.mts +48 -0
  153. package/dist/src/builders/cli/harnessContext.d.mts.map +1 -0
  154. package/dist/src/builders/cli/harnessContext.mjs +167 -0
  155. package/dist/src/builders/cli/harnessContext.mjs.map +1 -0
  156. package/dist/src/builders/cli/sessionComposition.cjs +27 -0
  157. package/dist/src/builders/cli/sessionComposition.cjs.map +1 -0
  158. package/dist/src/builders/cli/sessionComposition.mjs +26 -0
  159. package/dist/src/builders/cli/sessionComposition.mjs.map +1 -0
  160. package/dist/src/builders/hooks/index.cjs +238 -0
  161. package/dist/src/builders/hooks/index.cjs.map +1 -0
  162. package/dist/src/builders/hooks/index.mjs +231 -0
  163. package/dist/src/builders/hooks/index.mjs.map +1 -0
  164. package/dist/src/builders/native/index.cjs +176 -0
  165. package/dist/src/builders/native/index.cjs.map +1 -0
  166. package/dist/src/builders/native/index.d.mts +36 -0
  167. package/dist/src/builders/native/index.d.mts.map +1 -0
  168. package/dist/src/builders/native/index.mjs +170 -0
  169. package/dist/src/builders/native/index.mjs.map +1 -0
  170. package/dist/src/builders/server/backgroundSync.cjs +333 -0
  171. package/dist/src/builders/server/backgroundSync.cjs.map +1 -0
  172. package/dist/src/builders/server/backgroundSync.mjs +320 -0
  173. package/dist/src/builders/server/backgroundSync.mjs.map +1 -0
  174. package/dist/src/builders/server/computerUseBinding.cjs +273 -0
  175. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -0
  176. package/dist/src/builders/server/computerUseBinding.mjs +269 -0
  177. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -0
  178. package/dist/src/builders/server/computerUseRecordings.cjs +188 -0
  179. package/dist/src/builders/server/computerUseRecordings.cjs.map +1 -0
  180. package/dist/src/builders/server/computerUseRecordings.mjs +184 -0
  181. package/dist/src/builders/server/computerUseRecordings.mjs.map +1 -0
  182. package/dist/src/builders/server/defaultWorkspace.cjs +38 -0
  183. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -0
  184. package/dist/src/builders/server/defaultWorkspace.mjs +35 -0
  185. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -0
  186. package/dist/src/builders/server/idleRestart.cjs +149 -0
  187. package/dist/src/builders/server/idleRestart.cjs.map +1 -0
  188. package/dist/src/builders/server/idleRestart.mjs +136 -0
  189. package/dist/src/builders/server/idleRestart.mjs.map +1 -0
  190. package/dist/src/builders/server/index.cjs +63 -0
  191. package/dist/src/builders/server/index.cjs.map +1 -0
  192. package/dist/src/builders/server/index.mjs +60 -0
  193. package/dist/src/builders/server/index.mjs.map +1 -0
  194. package/dist/src/builders/server/logSink.cjs +57 -0
  195. package/dist/src/builders/server/logSink.cjs.map +1 -0
  196. package/dist/src/builders/server/logSink.mjs +57 -0
  197. package/dist/src/builders/server/logSink.mjs.map +1 -0
  198. package/dist/src/builders/server/mcpApp.cjs +152 -0
  199. package/dist/src/builders/server/mcpApp.cjs.map +1 -0
  200. package/dist/src/builders/server/mcpApp.d.mts +18 -0
  201. package/dist/src/builders/server/mcpApp.d.mts.map +1 -0
  202. package/dist/src/builders/server/mcpApp.mjs +147 -0
  203. package/dist/src/builders/server/mcpApp.mjs.map +1 -0
  204. package/dist/src/builders/server/mcpAppBuild.cjs +111 -0
  205. package/dist/src/builders/server/mcpAppBuild.cjs.map +1 -0
  206. package/dist/src/builders/server/mcpAppBuild.d.mts +24 -0
  207. package/dist/src/builders/server/mcpAppBuild.d.mts.map +1 -0
  208. package/dist/src/builders/server/mcpAppBuild.mjs +105 -0
  209. package/dist/src/builders/server/mcpAppBuild.mjs.map +1 -0
  210. package/dist/src/builders/server/mcpBundle.cjs +87 -0
  211. package/dist/src/builders/server/mcpBundle.cjs.map +1 -0
  212. package/dist/src/builders/server/mcpBundle.d.mts +23 -0
  213. package/dist/src/builders/server/mcpBundle.d.mts.map +1 -0
  214. package/dist/src/builders/server/mcpBundle.mjs +84 -0
  215. package/dist/src/builders/server/mcpBundle.mjs.map +1 -0
  216. package/dist/src/builders/server/packageReloadCheck.cjs +62 -0
  217. package/dist/src/builders/server/packageReloadCheck.cjs.map +1 -0
  218. package/dist/src/builders/server/packageReloadCheck.mjs +61 -0
  219. package/dist/src/builders/server/packageReloadCheck.mjs.map +1 -0
  220. package/dist/src/builders/server/packageUrl.cjs +210 -0
  221. package/dist/src/builders/server/packageUrl.cjs.map +1 -0
  222. package/dist/src/builders/server/packageUrl.mjs +203 -0
  223. package/dist/src/builders/server/packageUrl.mjs.map +1 -0
  224. package/dist/src/builders/server/runtime.cjs +1428 -0
  225. package/dist/src/builders/server/runtime.cjs.map +1 -0
  226. package/dist/src/builders/server/runtime.mjs +1420 -0
  227. package/dist/src/builders/server/runtime.mjs.map +1 -0
  228. package/dist/src/builders/server/runtimeResources.cjs +72 -0
  229. package/dist/src/builders/server/runtimeResources.cjs.map +1 -0
  230. package/dist/src/builders/server/runtimeResources.mjs +71 -0
  231. package/dist/src/builders/server/runtimeResources.mjs.map +1 -0
  232. package/dist/src/builders/server/selectionStatus.cjs +12 -0
  233. package/dist/src/builders/server/selectionStatus.cjs.map +1 -0
  234. package/dist/src/builders/server/selectionStatus.mjs +12 -0
  235. package/dist/src/builders/server/selectionStatus.mjs.map +1 -0
  236. package/dist/src/builders/server/sessionArguments.cjs +63 -0
  237. package/dist/src/builders/server/sessionArguments.cjs.map +1 -0
  238. package/dist/src/builders/server/sessionArguments.mjs +62 -0
  239. package/dist/src/builders/server/sessionArguments.mjs.map +1 -0
  240. package/dist/src/builders/server/shutdown.cjs +16 -0
  241. package/dist/src/builders/server/shutdown.cjs.map +1 -0
  242. package/dist/src/builders/server/shutdown.mjs +16 -0
  243. package/dist/src/builders/server/shutdown.mjs.map +1 -0
  244. package/dist/src/builders/server/webTemplateDecision.cjs +34 -0
  245. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -0
  246. package/dist/src/builders/server/webTemplateDecision.mjs +32 -0
  247. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -0
  248. package/dist/src/builders/server/workspaceCheckout.cjs +31 -0
  249. package/dist/src/builders/server/workspaceCheckout.cjs.map +1 -0
  250. package/dist/src/builders/server/workspaceCheckout.mjs +29 -0
  251. package/dist/src/builders/server/workspaceCheckout.mjs.map +1 -0
  252. package/dist/src/builders/web/bundle.cjs +225 -0
  253. package/dist/src/builders/web/bundle.cjs.map +1 -0
  254. package/dist/src/builders/web/bundle.d.mts +65 -0
  255. package/dist/src/builders/web/bundle.d.mts.map +1 -0
  256. package/dist/src/builders/web/bundle.mjs +221 -0
  257. package/dist/src/builders/web/bundle.mjs.map +1 -0
  258. package/dist/src/builders/web/bundleAssetPolicy.cjs +96 -0
  259. package/dist/src/builders/web/bundleAssetPolicy.cjs.map +1 -0
  260. package/dist/src/builders/web/bundleAssetPolicy.d.mts +22 -0
  261. package/dist/src/builders/web/bundleAssetPolicy.d.mts.map +1 -0
  262. package/dist/src/builders/web/bundleAssetPolicy.mjs +95 -0
  263. package/dist/src/builders/web/bundleAssetPolicy.mjs.map +1 -0
  264. package/dist/src/builders/web/index.cjs +361 -0
  265. package/dist/src/builders/web/index.cjs.map +1 -0
  266. package/dist/src/builders/web/index.d.mts +109 -0
  267. package/dist/src/builders/web/index.d.mts.map +1 -0
  268. package/dist/src/builders/web/index.mjs +342 -0
  269. package/dist/src/builders/web/index.mjs.map +1 -0
  270. package/dist/src/builders/web/webDevRoots.cjs +27 -0
  271. package/dist/src/builders/web/webDevRoots.cjs.map +1 -0
  272. package/dist/src/builders/web/webDevRoots.d.mts +22 -0
  273. package/dist/src/builders/web/webDevRoots.d.mts.map +1 -0
  274. package/dist/src/builders/web/webDevRoots.mjs +25 -0
  275. package/dist/src/builders/web/webDevRoots.mjs.map +1 -0
  276. package/dist/src/builders/web/webPluginGenerate.cjs +188 -0
  277. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -0
  278. package/dist/src/builders/web/webPluginGenerate.d.mts +56 -0
  279. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -0
  280. package/dist/src/builders/web/webPluginGenerate.mjs +178 -0
  281. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -0
  282. package/dist/src/builders/web/webPluginManifest.cjs +128 -0
  283. package/dist/src/builders/web/webPluginManifest.cjs.map +1 -0
  284. package/dist/src/builders/web/webPluginManifest.d.mts +64 -0
  285. package/dist/src/builders/web/webPluginManifest.d.mts.map +1 -0
  286. package/dist/src/builders/web/webPluginManifest.mjs +118 -0
  287. package/dist/src/builders/web/webPluginManifest.mjs.map +1 -0
  288. package/dist/src/builders/web/webPluginScan.cjs +57 -0
  289. package/dist/src/builders/web/webPluginScan.cjs.map +1 -0
  290. package/dist/src/builders/web/webPluginScan.d.mts +19 -0
  291. package/dist/src/builders/web/webPluginScan.d.mts.map +1 -0
  292. package/dist/src/builders/web/webPluginScan.mjs +54 -0
  293. package/dist/src/builders/web/webPluginScan.mjs.map +1 -0
  294. package/dist/src/builders/web/webPluginVite.cjs +255 -0
  295. package/dist/src/builders/web/webPluginVite.cjs.map +1 -0
  296. package/dist/src/builders/web/webPluginVite.d.mts +64 -0
  297. package/dist/src/builders/web/webPluginVite.d.mts.map +1 -0
  298. package/dist/src/builders/web/webPluginVite.mjs +242 -0
  299. package/dist/src/builders/web/webPluginVite.mjs.map +1 -0
  300. package/dist/src/cli/cliApp.cjs +187 -0
  301. package/dist/src/cli/cliApp.cjs.map +1 -0
  302. package/dist/src/cli/cliApp.d.mts +32 -0
  303. package/dist/src/cli/cliApp.d.mts.map +1 -0
  304. package/dist/src/cli/cliApp.mjs +184 -0
  305. package/dist/src/cli/cliApp.mjs.map +1 -0
  306. package/dist/src/cli/commands/api-export/index.cjs +66 -0
  307. package/dist/src/cli/commands/api-export/index.cjs.map +1 -0
  308. package/dist/src/cli/commands/api-export/index.mjs +62 -0
  309. package/dist/src/cli/commands/api-export/index.mjs.map +1 -0
  310. package/dist/src/cli/commands/baseCommand.cjs +16 -0
  311. package/dist/src/cli/commands/baseCommand.cjs.map +1 -0
  312. package/dist/src/cli/commands/baseCommand.d.mts +24 -0
  313. package/dist/src/cli/commands/baseCommand.d.mts.map +1 -0
  314. package/dist/src/cli/commands/baseCommand.mjs +16 -0
  315. package/dist/src/cli/commands/baseCommand.mjs.map +1 -0
  316. package/dist/src/cli/commands/compat/context.cjs +115 -0
  317. package/dist/src/cli/commands/compat/context.cjs.map +1 -0
  318. package/dist/src/cli/commands/compat/context.d.mts +22 -0
  319. package/dist/src/cli/commands/compat/context.d.mts.map +1 -0
  320. package/dist/src/cli/commands/compat/context.mjs +110 -0
  321. package/dist/src/cli/commands/compat/context.mjs.map +1 -0
  322. package/dist/src/cli/commands/compat/help.cjs +26 -0
  323. package/dist/src/cli/commands/compat/help.cjs.map +1 -0
  324. package/dist/src/cli/commands/compat/help.d.mts +4 -0
  325. package/dist/src/cli/commands/compat/help.d.mts.map +1 -0
  326. package/dist/src/cli/commands/compat/help.mjs +25 -0
  327. package/dist/src/cli/commands/compat/help.mjs.map +1 -0
  328. package/dist/src/cli/commands/compat/index.cjs +73 -0
  329. package/dist/src/cli/commands/compat/index.cjs.map +1 -0
  330. package/dist/src/cli/commands/compat/index.d.mts +14 -0
  331. package/dist/src/cli/commands/compat/index.d.mts.map +1 -0
  332. package/dist/src/cli/commands/compat/index.mjs +70 -0
  333. package/dist/src/cli/commands/compat/index.mjs.map +1 -0
  334. package/dist/src/cli/commands/compat/options.cjs +88 -0
  335. package/dist/src/cli/commands/compat/options.cjs.map +1 -0
  336. package/dist/src/cli/commands/compat/options.d.mts +15 -0
  337. package/dist/src/cli/commands/compat/options.d.mts.map +1 -0
  338. package/dist/src/cli/commands/compat/options.mjs +86 -0
  339. package/dist/src/cli/commands/compat/options.mjs.map +1 -0
  340. package/dist/src/cli/commands/compat/providers/antigravity.cjs +294 -0
  341. package/dist/src/cli/commands/compat/providers/antigravity.cjs.map +1 -0
  342. package/dist/src/cli/commands/compat/providers/antigravity.d.mts +9 -0
  343. package/dist/src/cli/commands/compat/providers/antigravity.d.mts.map +1 -0
  344. package/dist/src/cli/commands/compat/providers/antigravity.mjs +289 -0
  345. package/dist/src/cli/commands/compat/providers/antigravity.mjs.map +1 -0
  346. package/dist/src/cli/commands/compat/providers/codex.cjs +178 -0
  347. package/dist/src/cli/commands/compat/providers/codex.cjs.map +1 -0
  348. package/dist/src/cli/commands/compat/providers/codex.d.mts +17 -0
  349. package/dist/src/cli/commands/compat/providers/codex.d.mts.map +1 -0
  350. package/dist/src/cli/commands/compat/providers/codex.mjs +170 -0
  351. package/dist/src/cli/commands/compat/providers/codex.mjs.map +1 -0
  352. package/dist/src/cli/commands/compat/providers/index.cjs +65 -0
  353. package/dist/src/cli/commands/compat/providers/index.cjs.map +1 -0
  354. package/dist/src/cli/commands/compat/providers/index.d.mts +15 -0
  355. package/dist/src/cli/commands/compat/providers/index.d.mts.map +1 -0
  356. package/dist/src/cli/commands/compat/providers/index.mjs +45 -0
  357. package/dist/src/cli/commands/compat/providers/index.mjs.map +1 -0
  358. package/dist/src/cli/commands/compat/providers/process.cjs +172 -0
  359. package/dist/src/cli/commands/compat/providers/process.cjs.map +1 -0
  360. package/dist/src/cli/commands/compat/providers/process.d.mts +33 -0
  361. package/dist/src/cli/commands/compat/providers/process.d.mts.map +1 -0
  362. package/dist/src/cli/commands/compat/providers/process.mjs +159 -0
  363. package/dist/src/cli/commands/compat/providers/process.mjs.map +1 -0
  364. package/dist/src/cli/commands/compat/providers/shared.cjs +76 -0
  365. package/dist/src/cli/commands/compat/providers/shared.cjs.map +1 -0
  366. package/dist/src/cli/commands/compat/providers/shared.d.mts +40 -0
  367. package/dist/src/cli/commands/compat/providers/shared.d.mts.map +1 -0
  368. package/dist/src/cli/commands/compat/providers/shared.mjs +61 -0
  369. package/dist/src/cli/commands/compat/providers/shared.mjs.map +1 -0
  370. package/dist/src/cli/commands/compat/types.d.mts +31 -0
  371. package/dist/src/cli/commands/compat/types.d.mts.map +1 -0
  372. package/dist/src/cli/commands/doctor/help.cjs +19 -0
  373. package/dist/src/cli/commands/doctor/help.cjs.map +1 -0
  374. package/dist/src/cli/commands/doctor/help.d.mts +4 -0
  375. package/dist/src/cli/commands/doctor/help.d.mts.map +1 -0
  376. package/dist/src/cli/commands/doctor/help.mjs +19 -0
  377. package/dist/src/cli/commands/doctor/help.mjs.map +1 -0
  378. package/dist/src/cli/commands/doctor/index.cjs +118 -0
  379. package/dist/src/cli/commands/doctor/index.cjs.map +1 -0
  380. package/dist/src/cli/commands/doctor/index.d.mts +33 -0
  381. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -0
  382. package/dist/src/cli/commands/doctor/index.mjs +113 -0
  383. package/dist/src/cli/commands/doctor/index.mjs.map +1 -0
  384. package/dist/src/cli/commands/emit-mcp/index.cjs +32 -0
  385. package/dist/src/cli/commands/emit-mcp/index.cjs.map +1 -0
  386. package/dist/src/cli/commands/emit-mcp/index.d.mts +19 -0
  387. package/dist/src/cli/commands/emit-mcp/index.d.mts.map +1 -0
  388. package/dist/src/cli/commands/emit-mcp/index.mjs +31 -0
  389. package/dist/src/cli/commands/emit-mcp/index.mjs.map +1 -0
  390. package/dist/src/cli/commands/explain/index.cjs +155 -0
  391. package/dist/src/cli/commands/explain/index.cjs.map +1 -0
  392. package/dist/src/cli/commands/explain/index.d.mts +57 -0
  393. package/dist/src/cli/commands/explain/index.d.mts.map +1 -0
  394. package/dist/src/cli/commands/explain/index.mjs +150 -0
  395. package/dist/src/cli/commands/explain/index.mjs.map +1 -0
  396. package/dist/src/cli/commands/init/constants.cjs +11 -0
  397. package/dist/src/cli/commands/init/constants.cjs.map +1 -0
  398. package/dist/src/cli/commands/init/constants.mjs +11 -0
  399. package/dist/src/cli/commands/init/constants.mjs.map +1 -0
  400. package/dist/src/cli/commands/init/help.cjs +17 -0
  401. package/dist/src/cli/commands/init/help.cjs.map +1 -0
  402. package/dist/src/cli/commands/init/help.d.mts +4 -0
  403. package/dist/src/cli/commands/init/help.d.mts.map +1 -0
  404. package/dist/src/cli/commands/init/help.mjs +17 -0
  405. package/dist/src/cli/commands/init/help.mjs.map +1 -0
  406. package/dist/src/cli/commands/init/index.cjs +67 -0
  407. package/dist/src/cli/commands/init/index.cjs.map +1 -0
  408. package/dist/src/cli/commands/init/index.d.mts +12 -0
  409. package/dist/src/cli/commands/init/index.d.mts.map +1 -0
  410. package/dist/src/cli/commands/init/index.mjs +63 -0
  411. package/dist/src/cli/commands/init/index.mjs.map +1 -0
  412. package/dist/src/cli/commands/init/presenter.cjs +140 -0
  413. package/dist/src/cli/commands/init/presenter.cjs.map +1 -0
  414. package/dist/src/cli/commands/init/presenter.d.mts +8 -0
  415. package/dist/src/cli/commands/init/presenter.d.mts.map +1 -0
  416. package/dist/src/cli/commands/init/presenter.mjs +140 -0
  417. package/dist/src/cli/commands/init/presenter.mjs.map +1 -0
  418. package/dist/src/cli/commands/sync/help.cjs +34 -0
  419. package/dist/src/cli/commands/sync/help.cjs.map +1 -0
  420. package/dist/src/cli/commands/sync/help.d.mts +4 -0
  421. package/dist/src/cli/commands/sync/help.d.mts.map +1 -0
  422. package/dist/src/cli/commands/sync/help.mjs +34 -0
  423. package/dist/src/cli/commands/sync/help.mjs.map +1 -0
  424. package/dist/src/cli/commands/sync/index.cjs +215 -0
  425. package/dist/src/cli/commands/sync/index.cjs.map +1 -0
  426. package/dist/src/cli/commands/sync/index.d.mts +20 -0
  427. package/dist/src/cli/commands/sync/index.d.mts.map +1 -0
  428. package/dist/src/cli/commands/sync/index.mjs +206 -0
  429. package/dist/src/cli/commands/sync/index.mjs.map +1 -0
  430. package/dist/src/cli/commands/sync/presenter.cjs +58 -0
  431. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -0
  432. package/dist/src/cli/commands/sync/presenter.d.mts +16 -0
  433. package/dist/src/cli/commands/sync/presenter.d.mts.map +1 -0
  434. package/dist/src/cli/commands/sync/presenter.mjs +57 -0
  435. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -0
  436. package/dist/src/cli/commands/sync/workflow.cjs +16 -0
  437. package/dist/src/cli/commands/sync/workflow.cjs.map +1 -0
  438. package/dist/src/cli/commands/sync/workflow.mjs +16 -0
  439. package/dist/src/cli/commands/sync/workflow.mjs.map +1 -0
  440. package/dist/src/cli/commands/web/index.cjs +88 -0
  441. package/dist/src/cli/commands/web/index.cjs.map +1 -0
  442. package/dist/src/cli/commands/web/index.mjs +85 -0
  443. package/dist/src/cli/commands/web/index.mjs.map +1 -0
  444. package/dist/src/cli/harnessOptions.cjs +70 -0
  445. package/dist/src/cli/harnessOptions.cjs.map +1 -0
  446. package/dist/src/cli/harnessOptions.d.mts +26 -0
  447. package/dist/src/cli/harnessOptions.d.mts.map +1 -0
  448. package/dist/src/cli/harnessOptions.mjs +66 -0
  449. package/dist/src/cli/harnessOptions.mjs.map +1 -0
  450. package/dist/src/cli/help.cjs +82 -0
  451. package/dist/src/cli/help.cjs.map +1 -0
  452. package/dist/src/cli/help.d.mts +10 -0
  453. package/dist/src/cli/help.d.mts.map +1 -0
  454. package/dist/src/cli/help.mjs +78 -0
  455. package/dist/src/cli/help.mjs.map +1 -0
  456. package/dist/src/cli/matrixOptions.cjs +178 -0
  457. package/dist/src/cli/matrixOptions.cjs.map +1 -0
  458. package/dist/src/cli/matrixOptions.d.mts +90 -0
  459. package/dist/src/cli/matrixOptions.d.mts.map +1 -0
  460. package/dist/src/cli/matrixOptions.mjs +151 -0
  461. package/dist/src/cli/matrixOptions.mjs.map +1 -0
  462. package/dist/src/cli/options.cjs +281 -0
  463. package/dist/src/cli/options.cjs.map +1 -0
  464. package/dist/src/cli/options.d.mts +5 -0
  465. package/dist/src/cli/options.d.mts.map +1 -0
  466. package/dist/src/cli/options.mjs +279 -0
  467. package/dist/src/cli/options.mjs.map +1 -0
  468. package/dist/src/cli/router.cjs +57 -0
  469. package/dist/src/cli/router.cjs.map +1 -0
  470. package/dist/src/cli/router.d.mts +32 -0
  471. package/dist/src/cli/router.d.mts.map +1 -0
  472. package/dist/src/cli/router.mjs +54 -0
  473. package/dist/src/cli/router.mjs.map +1 -0
  474. package/dist/src/cli/server/options.cjs +71 -0
  475. package/dist/src/cli/server/options.cjs.map +1 -0
  476. package/dist/src/cli/server/options.mjs +70 -0
  477. package/dist/src/cli/server/options.mjs.map +1 -0
  478. package/dist/src/cli/server/processGuards.cjs +83 -0
  479. package/dist/src/cli/server/processGuards.cjs.map +1 -0
  480. package/dist/src/cli/server/processGuards.mjs +79 -0
  481. package/dist/src/cli/server/processGuards.mjs.map +1 -0
  482. package/dist/src/cli/server/run.cjs +69 -0
  483. package/dist/src/cli/server/run.cjs.map +1 -0
  484. package/dist/src/cli/server/run.mjs +66 -0
  485. package/dist/src/cli/server/run.mjs.map +1 -0
  486. package/dist/src/composition/harnessState/index.cjs +48 -0
  487. package/dist/src/composition/harnessState/index.cjs.map +1 -0
  488. package/dist/src/composition/harnessState/index.d.mts +19 -0
  489. package/dist/src/composition/harnessState/index.d.mts.map +1 -0
  490. package/dist/src/composition/harnessState/index.mjs +34 -0
  491. package/dist/src/composition/harnessState/index.mjs.map +1 -0
  492. package/dist/src/composition/layerPackageInstaller/index.cjs +651 -0
  493. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -0
  494. package/dist/src/composition/layerPackageInstaller/index.d.mts +74 -0
  495. package/dist/src/composition/layerPackageInstaller/index.d.mts.map +1 -0
  496. package/dist/src/composition/layerPackageInstaller/index.mjs +637 -0
  497. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -0
  498. package/dist/src/composition/poHomeMigration/index.cjs +234 -0
  499. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -0
  500. package/dist/src/composition/poHomeMigration/index.d.mts +12 -0
  501. package/dist/src/composition/poHomeMigration/index.d.mts.map +1 -0
  502. package/dist/src/composition/poHomeMigration/index.mjs +226 -0
  503. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -0
  504. package/dist/src/composition/projectTrust/index.cjs +51 -0
  505. package/dist/src/composition/projectTrust/index.cjs.map +1 -0
  506. package/dist/src/composition/projectTrust/index.d.mts +22 -0
  507. package/dist/src/composition/projectTrust/index.d.mts.map +1 -0
  508. package/dist/src/composition/projectTrust/index.mjs +48 -0
  509. package/dist/src/composition/projectTrust/index.mjs.map +1 -0
  510. package/dist/src/composition/repository/index.cjs +68 -0
  511. package/dist/src/composition/repository/index.cjs.map +1 -0
  512. package/dist/src/composition/repository/index.d.mts +22 -0
  513. package/dist/src/composition/repository/index.d.mts.map +1 -0
  514. package/dist/src/composition/repository/index.mjs +63 -0
  515. package/dist/src/composition/repository/index.mjs.map +1 -0
  516. package/dist/src/composition/syncPrune/index.cjs +85 -0
  517. package/dist/src/composition/syncPrune/index.cjs.map +1 -0
  518. package/dist/src/composition/syncPrune/index.d.mts +33 -0
  519. package/dist/src/composition/syncPrune/index.d.mts.map +1 -0
  520. package/dist/src/composition/syncPrune/index.mjs +82 -0
  521. package/dist/src/composition/syncPrune/index.mjs.map +1 -0
  522. package/dist/src/composition/syncService/index.cjs +808 -0
  523. package/dist/src/composition/syncService/index.cjs.map +1 -0
  524. package/dist/src/composition/syncService/index.d.mts +65 -0
  525. package/dist/src/composition/syncService/index.d.mts.map +1 -0
  526. package/dist/src/composition/syncService/index.mjs +792 -0
  527. package/dist/src/composition/syncService/index.mjs.map +1 -0
  528. package/dist/src/composition/syncService/localBuilds.cjs +367 -0
  529. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -0
  530. package/dist/src/composition/syncService/localBuilds.mjs +358 -0
  531. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -0
  532. package/dist/src/composition/transitionLayers.cjs +17 -0
  533. package/dist/src/composition/transitionLayers.cjs.map +1 -0
  534. package/dist/src/composition/transitionLayers.d.mts +6 -0
  535. package/dist/src/composition/transitionLayers.d.mts.map +1 -0
  536. package/dist/src/composition/transitionLayers.mjs +16 -0
  537. package/dist/src/composition/transitionLayers.mjs.map +1 -0
  538. package/dist/src/composition/types/harness.d.mts +52 -0
  539. package/dist/src/composition/types/harness.d.mts.map +1 -0
  540. package/dist/src/extensions/setupDiagnostics.cjs +65 -0
  541. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -0
  542. package/dist/src/extensions/setupDiagnostics.mjs +64 -0
  543. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -0
  544. package/dist/utils.cjs +4 -0
  545. package/dist/utils.d.mts +2 -0
  546. package/dist/utils.mjs +2 -0
  547. package/dist/webBuilder.cjs +59 -0
  548. package/dist/webBuilder.d.mts +9 -0
  549. package/dist/webBuilder.mjs +9 -0
  550. package/docs/server/api-export.md +86 -0
  551. package/docs/server/api.md +144 -0
  552. package/docs/server/getting-started.md +114 -0
  553. package/docs/server/index.md +67 -0
  554. package/docs/server/ipc.md +97 -0
  555. package/docs/server/lifecycle.md +108 -0
  556. package/docs/server/security.md +101 -0
  557. package/llms.txt +12 -0
  558. package/package.json +295 -0
  559. package/src/prompts/po-author-extension/SKILL.md +35 -0
  560. package/src/prompts/po-author-extension/references/extension-contract.md +134 -0
@@ -0,0 +1,358 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { writeFileAtomic } from "@agimon-ai/po-core/runtimeJson";
4
+ import { spawn, spawnSync } from "node:child_process";
5
+ import crypto from "node:crypto";
6
+ //#region src/composition/syncService/localBuilds.ts
7
+ /**
8
+ * Builds the packages sync roots name by local path, so the web, native and MCP builds read
9
+ * current output. Each package builds at most once per sync, in dependency order within the
10
+ * local set, with the package manager its nearest lockfile names. Install never runs.
11
+ */
12
+ const LOCAL_SOURCE_DIRECTORY = "src";
13
+ const PACKAGE_MANIFEST = "package.json";
14
+ const NODE_MODULES = "node_modules";
15
+ const LOCAL_BUILDS_FILE = path.join("build", "local-builds.json");
16
+ const BUILD_SCRIPT = "build";
17
+ /** Bytes of stderr kept per build while it runs; older output is dropped as it arrives. */
18
+ const STDERR_TAIL_BYTES = 65536;
19
+ /**
20
+ * A local build that runs longer than this is stopped and reported as failed. Sync holds its
21
+ * lock while a build runs, so a hung build must not hold it forever.
22
+ */
23
+ const LOCAL_BUILD_TIMEOUT_MS = 6e5;
24
+ /** How long a build's stderr may stay open after it exits, held by a process it left running. */
25
+ const STDERR_CLOSE_GRACE_MS = 1e3;
26
+ const MILLISECONDS_PER_SECOND = 1e3;
27
+ const LOGIN_SHELL_TIMEOUT_MS = 1e4;
28
+ const DEFAULT_PACKAGE_MANAGER = "npm";
29
+ const NO_SUCH_PROCESS = "ESRCH";
30
+ /** Checked nearest-first in each folder; the first lockfile found names the package manager. */
31
+ const LOCKFILES = [
32
+ ["pnpm-lock.yaml", "pnpm"],
33
+ ["bun.lock", "bun"],
34
+ ["bun.lockb", "bun"],
35
+ ["yarn.lock", "yarn"],
36
+ ["package-lock.json", "npm"]
37
+ ];
38
+ /** Variables a Po session or another harness exports; a package build must not see them. */
39
+ const HARNESS_PREFIXES = [
40
+ "PO_",
41
+ "PI_",
42
+ "CLAUDE_",
43
+ "CODEX_"
44
+ ];
45
+ const HARNESS_VARIABLES = /* @__PURE__ */ new Set([
46
+ "CLAUDECODE",
47
+ "MCP_UI_VIEWER",
48
+ "npm_config_user_agent"
49
+ ]);
50
+ const DEPENDENCY_FIELDS = [
51
+ "dependencies",
52
+ "devDependencies",
53
+ "peerDependencies",
54
+ "optionalDependencies"
55
+ ];
56
+ function sourceFiles(directory) {
57
+ let entries;
58
+ try {
59
+ entries = fs.readdirSync(directory, { withFileTypes: true });
60
+ } catch {
61
+ return [];
62
+ }
63
+ return entries.flatMap((entry) => {
64
+ const full = path.join(directory, entry.name);
65
+ if (entry.isDirectory()) return entry.name === NODE_MODULES ? [] : sourceFiles(full);
66
+ return entry.isFile() ? [full] : [];
67
+ });
68
+ }
69
+ /**
70
+ * The build stamp of a local package: an mtime and size signature over its `package.json`
71
+ * and every file under `src/`.
72
+ * ponytail: it misses edits to dependencies outside the package; a content hash is the upgrade.
73
+ */
74
+ function localBuildStamp(packageDirectory) {
75
+ const files = [path.join(packageDirectory, PACKAGE_MANIFEST), ...sourceFiles(path.join(packageDirectory, LOCAL_SOURCE_DIRECTORY))];
76
+ const hash = crypto.createHash("sha256");
77
+ for (const file of files.sort()) {
78
+ const relative = path.relative(packageDirectory, file);
79
+ try {
80
+ const stat = fs.statSync(file);
81
+ hash.update(`${relative}\0${String(stat.size)}\0${String(stat.mtimeMs)}\n`);
82
+ } catch {
83
+ hash.update(`${relative}\0missing\n`);
84
+ }
85
+ }
86
+ return hash.digest("hex");
87
+ }
88
+ function localBuildsPath(globalRoot) {
89
+ return path.join(globalRoot, LOCAL_BUILDS_FILE);
90
+ }
91
+ function readStamps(globalRoot) {
92
+ try {
93
+ const parsed = JSON.parse(fs.readFileSync(localBuildsPath(globalRoot), "utf8"));
94
+ return typeof parsed === "object" && parsed !== null ? parsed : {};
95
+ } catch {
96
+ return {};
97
+ }
98
+ }
99
+ function readManifest(directory) {
100
+ try {
101
+ return JSON.parse(fs.readFileSync(path.join(directory, PACKAGE_MANIFEST), "utf8"));
102
+ } catch {
103
+ return;
104
+ }
105
+ }
106
+ /** The package manager the nearest lockfile names, walking up from the package. */
107
+ function packageManagerFor(directory) {
108
+ let current = path.resolve(directory);
109
+ for (;;) {
110
+ for (const [lockfile, manager] of LOCKFILES) if (fs.existsSync(path.join(current, lockfile))) return manager;
111
+ const parent = path.dirname(current);
112
+ if (parent === current) return DEFAULT_PACKAGE_MANAGER;
113
+ current = parent;
114
+ }
115
+ }
116
+ function findOnPath(binary, searchPath) {
117
+ for (const directory of (searchPath ?? "").split(path.delimiter).filter(Boolean)) {
118
+ const candidate = path.join(directory, binary);
119
+ try {
120
+ fs.accessSync(candidate, fs.constants.X_OK);
121
+ if (fs.statSync(candidate).isFile()) return candidate;
122
+ } catch {}
123
+ }
124
+ }
125
+ /**
126
+ * The login shell's PATH. Desktop apps launched from Finder get a minimal PATH (inferred,
127
+ * not checked here), so a package manager installed through a shell profile is missing.
128
+ */
129
+ function loginShellPath(environment) {
130
+ const shell = environment.SHELL ?? "/bin/zsh";
131
+ const result = spawnSync(shell, ["-ilc", "printf %s \"$PATH\""], {
132
+ encoding: "utf8",
133
+ timeout: LOGIN_SHELL_TIMEOUT_MS
134
+ });
135
+ return result.status === 0 && result.stdout.trim() !== "" ? result.stdout.trim() : void 0;
136
+ }
137
+ /** The build environment: the caller's minus every `PO_*` and harness variable. */
138
+ function buildEnvironment(environment) {
139
+ return Object.fromEntries(Object.entries(environment).filter(([name]) => !HARNESS_VARIABLES.has(name) && !HARNESS_PREFIXES.some((prefix) => name.startsWith(prefix))));
140
+ }
141
+ function entryPaths(value) {
142
+ if (typeof value === "string") return [value];
143
+ if (Array.isArray(value)) return value.flatMap(entryPaths);
144
+ if (typeof value === "object" && value !== null) return Object.values(value).flatMap(entryPaths);
145
+ return [];
146
+ }
147
+ /** Whether every file `main`, `module` and `exports` name exists; false when they name none. */
148
+ function builtEntriesPresent(directory, manifest) {
149
+ const entries = [
150
+ manifest.main,
151
+ manifest.module,
152
+ manifest.exports
153
+ ].flatMap(entryPaths).filter((entry) => !entry.includes("*"));
154
+ return entries.length > 0 && entries.every((entry) => fs.existsSync(path.resolve(directory, entry)));
155
+ }
156
+ /** The directories ordered so each local package builds after the local packages it depends on. */
157
+ function dependencyOrder(directories, manifests) {
158
+ const byName = /* @__PURE__ */ new Map();
159
+ for (const directory of directories) {
160
+ const name = manifests.get(directory)?.name;
161
+ if (name !== void 0) byName.set(name, directory);
162
+ }
163
+ const ordered = [];
164
+ const visiting = /* @__PURE__ */ new Set();
165
+ const visit = (directory) => {
166
+ if (ordered.includes(directory) || visiting.has(directory)) return;
167
+ visiting.add(directory);
168
+ const manifest = manifests.get(directory);
169
+ for (const field of DEPENDENCY_FIELDS) {
170
+ const dependencies = manifest?.[field];
171
+ if (typeof dependencies !== "object" || dependencies === null) continue;
172
+ for (const name of Object.keys(dependencies)) {
173
+ const dependency = byName.get(name);
174
+ if (dependency !== void 0) visit(dependency);
175
+ }
176
+ }
177
+ visiting.delete(directory);
178
+ ordered.push(directory);
179
+ };
180
+ for (const directory of directories) visit(directory);
181
+ return ordered;
182
+ }
183
+ function stderrTail(stderr) {
184
+ return stderr.trimEnd().split("\n").filter(Boolean).slice(-20);
185
+ }
186
+ /** Signals that end this process; a build in its own process group would not receive them. */
187
+ const FORWARDED_SIGNALS = [
188
+ "SIGINT",
189
+ "SIGTERM",
190
+ "SIGHUP"
191
+ ];
192
+ const SEPARATE_PROCESS_GROUPS = process.platform !== "win32";
193
+ /**
194
+ * Kills the build and everything it started. The build leads its own process group, so the
195
+ * package manager's tsc or vite children die with it.
196
+ * ponytail: Windows has no process groups here, so only the package manager is killed there;
197
+ * `taskkill /T /F` is the upgrade if Windows builds must stop their children too.
198
+ */
199
+ function killBuild(child) {
200
+ if (!SEPARATE_PROCESS_GROUPS || child.pid === void 0) {
201
+ child.kill("SIGKILL");
202
+ return;
203
+ }
204
+ try {
205
+ process.kill(-child.pid, "SIGKILL");
206
+ } catch (error) {
207
+ if (error.code !== NO_SUCH_PROCESS) child.kill("SIGKILL");
208
+ }
209
+ }
210
+ /**
211
+ * Runs one build script without buffering its output: stdout is discarded and only the stderr
212
+ * tail is kept. A build still running after `timeoutMs` is killed with every process it started
213
+ * and reported as timed out. A build that exits while something it started still holds stderr
214
+ * open has that process group killed when the grace ends, so nothing writes after it returns.
215
+ */
216
+ function runBuildScript(binary, directory, environment, timeoutMs) {
217
+ return new Promise((resolve) => {
218
+ let tail = Buffer.alloc(0);
219
+ let timedOut = false;
220
+ let leftRunning = false;
221
+ let settled = false;
222
+ let grace;
223
+ const child = spawn(binary, ["run", BUILD_SCRIPT], {
224
+ cwd: directory,
225
+ env: environment,
226
+ stdio: [
227
+ "ignore",
228
+ "ignore",
229
+ "pipe"
230
+ ],
231
+ detached: SEPARATE_PROCESS_GROUPS
232
+ });
233
+ const forward = (signal) => {
234
+ killBuild(child);
235
+ if (process.listenerCount(signal) > 1) return;
236
+ process.removeListener(signal, forward);
237
+ process.kill(process.pid, signal);
238
+ };
239
+ if (SEPARATE_PROCESS_GROUPS) for (const signal of FORWARDED_SIGNALS) process.on(signal, forward);
240
+ const finish = (result) => {
241
+ if (settled) return;
242
+ settled = true;
243
+ clearTimeout(timer);
244
+ clearTimeout(grace);
245
+ for (const signal of FORWARDED_SIGNALS) process.removeListener(signal, forward);
246
+ child.stderr?.destroy();
247
+ resolve({
248
+ ...result,
249
+ timedOut,
250
+ leftRunning,
251
+ stderr: tail.toString("utf8")
252
+ });
253
+ };
254
+ const timer = setTimeout(() => {
255
+ timedOut = true;
256
+ killBuild(child);
257
+ }, timeoutMs);
258
+ child.stderr?.on("data", (chunk) => {
259
+ tail = Buffer.concat([tail, chunk]);
260
+ if (tail.length > STDERR_TAIL_BYTES) tail = tail.subarray(tail.length - STDERR_TAIL_BYTES);
261
+ });
262
+ child.on("error", (error) => finish({
263
+ status: null,
264
+ signal: null,
265
+ error
266
+ }));
267
+ child.on("close", (status, signal) => finish({
268
+ status,
269
+ signal
270
+ }));
271
+ child.on("exit", (status, signal) => {
272
+ grace = setTimeout(() => {
273
+ if (!timedOut) leftRunning = true;
274
+ killBuild(child);
275
+ finish({
276
+ status,
277
+ signal
278
+ });
279
+ }, timedOut ? 0 : STDERR_CLOSE_GRACE_MS);
280
+ });
281
+ });
282
+ }
283
+ /**
284
+ * Builds every local package that changed since its last successful build, and returns each
285
+ * directory's outcome. A failure never stops the others.
286
+ */
287
+ async function buildLocalPackages(input) {
288
+ const { globalRoot, environment, onCommand, onNotice } = input;
289
+ const timeoutMs = input.timeoutMs ?? 6e5;
290
+ const directories = [...new Set(input.directories)];
291
+ const manifests = new Map(directories.map((directory) => [directory, readManifest(directory)]));
292
+ const stamps = readStamps(globalRoot);
293
+ const outcomes = /* @__PURE__ */ new Map();
294
+ const childEnvironment = buildEnvironment(environment);
295
+ let searchPath = environment.PATH;
296
+ let loginPathTried = false;
297
+ const resolveBinary = (manager) => {
298
+ const found = findOnPath(manager, searchPath);
299
+ if (found !== void 0 || loginPathTried || process.platform !== "darwin") return found;
300
+ loginPathTried = true;
301
+ const loginPath = loginShellPath(environment);
302
+ if (loginPath === void 0) return void 0;
303
+ searchPath = loginPath;
304
+ childEnvironment.PATH = loginPath;
305
+ return findOnPath(manager, searchPath);
306
+ };
307
+ for (const directory of dependencyOrder(directories, manifests)) {
308
+ const manifest = manifests.get(directory);
309
+ if (manifest === void 0) {
310
+ outcomes.set(directory, {
311
+ status: "failed",
312
+ reason: `'${directory}' has no readable package.json`
313
+ });
314
+ continue;
315
+ }
316
+ const stamp = localBuildStamp(directory);
317
+ if (stamps[directory] === stamp) {
318
+ outcomes.set(directory, { status: "cached" });
319
+ continue;
320
+ }
321
+ if (typeof manifest.scripts?.[BUILD_SCRIPT] !== "string") {
322
+ outcomes.set(directory, builtEntriesPresent(directory, manifest) ? { status: "cached" } : {
323
+ status: "failed",
324
+ reason: "it has no build script and no built entries"
325
+ });
326
+ continue;
327
+ }
328
+ const manager = packageManagerFor(directory);
329
+ const binary = resolveBinary(manager);
330
+ if (binary === void 0) {
331
+ outcomes.set(directory, {
332
+ status: "failed",
333
+ reason: `${manager} is not on PATH`
334
+ });
335
+ continue;
336
+ }
337
+ onCommand(`${binary} run ${BUILD_SCRIPT} (in ${directory})`);
338
+ onNotice(`building ${manifest.name ?? directory}`);
339
+ const result = await runBuildScript(binary, directory, childEnvironment, timeoutMs);
340
+ if (result.status === 0 && !result.timedOut && !result.leftRunning) {
341
+ stamps[directory] = localBuildStamp(directory);
342
+ writeFileAtomic(localBuildsPath(globalRoot), `${JSON.stringify(stamps, null, 2)}\n`);
343
+ outcomes.set(directory, { status: "built" });
344
+ continue;
345
+ }
346
+ const exit = result.timedOut ? `timed out after ${String(timeoutMs / MILLISECONDS_PER_SECOND)} s` : result.status === 0 && result.leftRunning ? "it exited but left processes running, which were stopped" : result.error?.message ?? `exit ${String(result.status ?? result.signal)}`;
347
+ outcomes.set(directory, {
348
+ status: "failed",
349
+ reason: `${manager} run ${BUILD_SCRIPT} failed (${exit})`,
350
+ stderr: stderrTail(result.stderr)
351
+ });
352
+ }
353
+ return outcomes;
354
+ }
355
+ //#endregion
356
+ export { LOCAL_BUILD_TIMEOUT_MS, buildEnvironment, buildLocalPackages, localBuildStamp, localBuildsPath, packageManagerFor };
357
+
358
+ //# sourceMappingURL=localBuilds.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localBuilds.mjs","names":[],"sources":["../../../../src/composition/syncService/localBuilds.ts"],"sourcesContent":["import { type ChildProcess, spawn, spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { writeFileAtomic } from '@agimon-ai/po-core/runtimeJson';\n\n/**\n * Builds the packages sync roots name by local path, so the web, native and MCP builds read\n * current output. Each package builds at most once per sync, in dependency order within the\n * local set, with the package manager its nearest lockfile names. Install never runs.\n */\n\nconst LOCAL_SOURCE_DIRECTORY = 'src';\nconst PACKAGE_MANIFEST = 'package.json';\nconst NODE_MODULES = 'node_modules';\nconst LOCAL_BUILDS_FILE = path.join('build', 'local-builds.json');\nconst BUILD_SCRIPT = 'build';\nconst STDERR_TAIL_LINES = 20;\n/** Bytes of stderr kept per build while it runs; older output is dropped as it arrives. */\nconst STDERR_TAIL_BYTES = 64 * 1024;\n/**\n * A local build that runs longer than this is stopped and reported as failed. Sync holds its\n * lock while a build runs, so a hung build must not hold it forever.\n */\nexport const LOCAL_BUILD_TIMEOUT_MS = 10 * 60 * 1000;\n/** How long a build's stderr may stay open after it exits, held by a process it left running. */\nconst STDERR_CLOSE_GRACE_MS = 1000;\nconst MILLISECONDS_PER_SECOND = 1000;\nconst LOGIN_SHELL_TIMEOUT_MS = 10_000;\nconst DEFAULT_PACKAGE_MANAGER = 'npm';\nconst NO_SUCH_PROCESS = 'ESRCH';\n/** Checked nearest-first in each folder; the first lockfile found names the package manager. */\nconst LOCKFILES: readonly (readonly [string, string])[] = [\n ['pnpm-lock.yaml', 'pnpm'],\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['yarn.lock', 'yarn'],\n ['package-lock.json', 'npm'],\n];\n/** Variables a Po session or another harness exports; a package build must not see them. */\nconst HARNESS_PREFIXES = ['PO_', 'PI_', 'CLAUDE_', 'CODEX_'];\nconst HARNESS_VARIABLES = new Set(['CLAUDECODE', 'MCP_UI_VIEWER', 'npm_config_user_agent']);\nconst DEPENDENCY_FIELDS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];\n\nexport interface LocalPackage {\n /** The selector as a root's configuration names it. */\n selector: string;\n directory: string;\n}\n\nexport type LocalBuildOutcome =\n | { status: 'built' | 'cached' }\n | { status: 'failed'; reason: string; stderr?: string[] };\n\nexport interface LocalBuildInput {\n globalRoot: string;\n environment: NodeJS.ProcessEnv;\n directories: readonly string[];\n /** Receives each command line as it starts. */\n onCommand: (command: string) => void;\n onNotice: (message: string) => void;\n /** Overrides `LOCAL_BUILD_TIMEOUT_MS`. */\n timeoutMs?: number;\n}\n\ninterface Manifest {\n name?: string;\n main?: unknown;\n module?: unknown;\n exports?: unknown;\n scripts?: Record<string, unknown>;\n [field: string]: unknown;\n}\n\nfunction sourceFiles(directory: string): string[] {\n let entries: fs.Dirent[];\n try {\n entries = fs.readdirSync(directory, { withFileTypes: true });\n } catch {\n // A package without a source folder has only its manifest to stamp.\n return [];\n }\n return entries.flatMap((entry) => {\n const full = path.join(directory, entry.name);\n if (entry.isDirectory()) return entry.name === NODE_MODULES ? [] : sourceFiles(full);\n return entry.isFile() ? [full] : [];\n });\n}\n\n/**\n * The build stamp of a local package: an mtime and size signature over its `package.json`\n * and every file under `src/`.\n * ponytail: it misses edits to dependencies outside the package; a content hash is the upgrade.\n */\nexport function localBuildStamp(packageDirectory: string): string {\n const files = [\n path.join(packageDirectory, PACKAGE_MANIFEST),\n ...sourceFiles(path.join(packageDirectory, LOCAL_SOURCE_DIRECTORY)),\n ];\n const hash = crypto.createHash('sha256');\n for (const file of files.sort()) {\n const relative = path.relative(packageDirectory, file);\n try {\n const stat = fs.statSync(file);\n hash.update(`${relative}\\0${String(stat.size)}\\0${String(stat.mtimeMs)}\\n`);\n } catch {\n // Recorded as missing, so the stamp moves when the file appears.\n hash.update(`${relative}\\0missing\\n`);\n }\n }\n return hash.digest('hex');\n}\n\nexport function localBuildsPath(globalRoot: string): string {\n return path.join(globalRoot, LOCAL_BUILDS_FILE);\n}\n\nfunction readStamps(globalRoot: string): Record<string, string> {\n try {\n const parsed = JSON.parse(fs.readFileSync(localBuildsPath(globalRoot), 'utf8')) as unknown;\n return typeof parsed === 'object' && parsed !== null ? (parsed as Record<string, string>) : {};\n } catch {\n // Missing or unreadable: every package builds once.\n return {};\n }\n}\n\nfunction readManifest(directory: string): Manifest | undefined {\n try {\n return JSON.parse(fs.readFileSync(path.join(directory, PACKAGE_MANIFEST), 'utf8')) as Manifest;\n } catch {\n return undefined;\n }\n}\n\n/** The package manager the nearest lockfile names, walking up from the package. */\nexport function packageManagerFor(directory: string): string {\n let current = path.resolve(directory);\n for (;;) {\n for (const [lockfile, manager] of LOCKFILES) if (fs.existsSync(path.join(current, lockfile))) return manager;\n const parent = path.dirname(current);\n if (parent === current) return DEFAULT_PACKAGE_MANAGER;\n current = parent;\n }\n}\n\nfunction findOnPath(binary: string, searchPath: string | undefined): string | undefined {\n for (const directory of (searchPath ?? '').split(path.delimiter).filter(Boolean)) {\n const candidate = path.join(directory, binary);\n try {\n fs.accessSync(candidate, fs.constants.X_OK);\n if (fs.statSync(candidate).isFile()) return candidate;\n } catch {\n // Not in this folder.\n }\n }\n return undefined;\n}\n\n/**\n * The login shell's PATH. Desktop apps launched from Finder get a minimal PATH (inferred,\n * not checked here), so a package manager installed through a shell profile is missing.\n */\nfunction loginShellPath(environment: NodeJS.ProcessEnv): string | undefined {\n const shell = environment.SHELL ?? '/bin/zsh';\n const result = spawnSync(shell, ['-ilc', 'printf %s \"$PATH\"'], {\n encoding: 'utf8',\n timeout: LOGIN_SHELL_TIMEOUT_MS,\n });\n return result.status === 0 && result.stdout.trim() !== '' ? result.stdout.trim() : undefined;\n}\n\n/** The build environment: the caller's minus every `PO_*` and harness variable. */\nexport function buildEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv {\n return Object.fromEntries(\n Object.entries(environment).filter(\n ([name]) => !HARNESS_VARIABLES.has(name) && !HARNESS_PREFIXES.some((prefix) => name.startsWith(prefix)),\n ),\n );\n}\n\nfunction entryPaths(value: unknown): string[] {\n if (typeof value === 'string') return [value];\n if (Array.isArray(value)) return value.flatMap(entryPaths);\n if (typeof value === 'object' && value !== null) return Object.values(value).flatMap(entryPaths);\n return [];\n}\n\n/** Whether every file `main`, `module` and `exports` name exists; false when they name none. */\nfunction builtEntriesPresent(directory: string, manifest: Manifest): boolean {\n const entries = [manifest.main, manifest.module, manifest.exports]\n .flatMap(entryPaths)\n .filter((entry) => !entry.includes('*'));\n return entries.length > 0 && entries.every((entry) => fs.existsSync(path.resolve(directory, entry)));\n}\n\n/** The directories ordered so each local package builds after the local packages it depends on. */\nfunction dependencyOrder(directories: readonly string[], manifests: Map<string, Manifest | undefined>): string[] {\n const byName = new Map<string, string>();\n for (const directory of directories) {\n const name = manifests.get(directory)?.name;\n if (name !== undefined) byName.set(name, directory);\n }\n const ordered: string[] = [];\n const visiting = new Set<string>();\n const visit = (directory: string): void => {\n if (ordered.includes(directory) || visiting.has(directory)) return;\n visiting.add(directory);\n const manifest = manifests.get(directory);\n for (const field of DEPENDENCY_FIELDS) {\n const dependencies = manifest?.[field];\n if (typeof dependencies !== 'object' || dependencies === null) continue;\n for (const name of Object.keys(dependencies)) {\n const dependency = byName.get(name);\n if (dependency !== undefined) visit(dependency);\n }\n }\n visiting.delete(directory);\n ordered.push(directory);\n };\n for (const directory of directories) visit(directory);\n return ordered;\n}\n\nfunction stderrTail(stderr: string): string[] {\n return stderr.trimEnd().split('\\n').filter(Boolean).slice(-STDERR_TAIL_LINES);\n}\n\ninterface BuildRun {\n status: number | null;\n signal: NodeJS.Signals | null;\n error?: Error;\n timedOut: boolean;\n /** It exited while a process it started still held stderr open; that process was stopped. */\n leftRunning: boolean;\n /** The last `STDERR_TAIL_BYTES` of stderr. */\n stderr: string;\n}\n\n/** Signals that end this process; a build in its own process group would not receive them. */\nconst FORWARDED_SIGNALS: readonly NodeJS.Signals[] = ['SIGINT', 'SIGTERM', 'SIGHUP'];\nconst SEPARATE_PROCESS_GROUPS = process.platform !== 'win32';\n\n/**\n * Kills the build and everything it started. The build leads its own process group, so the\n * package manager's tsc or vite children die with it.\n * ponytail: Windows has no process groups here, so only the package manager is killed there;\n * `taskkill /T /F` is the upgrade if Windows builds must stop their children too.\n */\nfunction killBuild(child: ChildProcess): void {\n if (!SEPARATE_PROCESS_GROUPS || child.pid === undefined) {\n child.kill('SIGKILL');\n return;\n }\n try {\n process.kill(-child.pid, 'SIGKILL');\n } catch (error) {\n // ESRCH: every process of the group has exited already, which is the goal. Anything else\n // (EPERM) falls back to the package manager alone rather than crash inside a timer.\n if ((error as NodeJS.ErrnoException).code !== NO_SUCH_PROCESS) child.kill('SIGKILL');\n }\n}\n\n/**\n * Runs one build script without buffering its output: stdout is discarded and only the stderr\n * tail is kept. A build still running after `timeoutMs` is killed with every process it started\n * and reported as timed out. A build that exits while something it started still holds stderr\n * open has that process group killed when the grace ends, so nothing writes after it returns.\n */\nfunction runBuildScript(\n binary: string,\n directory: string,\n environment: NodeJS.ProcessEnv,\n timeoutMs: number,\n): Promise<BuildRun> {\n return new Promise((resolve) => {\n let tail = Buffer.alloc(0);\n let timedOut = false;\n let leftRunning = false;\n let settled = false;\n let grace: NodeJS.Timeout | undefined;\n // Its own process group, so a kill reaches its children. Still awaited: never unref'd.\n const child = spawn(binary, ['run', BUILD_SCRIPT], {\n cwd: directory,\n env: environment,\n stdio: ['ignore', 'ignore', 'pipe'],\n detached: SEPARATE_PROCESS_GROUPS,\n });\n // A detached build no longer gets the terminal's Ctrl+C, so this process passes it on.\n const forward = (signal: NodeJS.Signals): void => {\n killBuild(child);\n if (process.listenerCount(signal) > 1) return;\n // Only this handler was listening: end as the signal would have without it.\n process.removeListener(signal, forward);\n process.kill(process.pid, signal);\n };\n if (SEPARATE_PROCESS_GROUPS) for (const signal of FORWARDED_SIGNALS) process.on(signal, forward);\n const finish = (result: Pick<BuildRun, 'status' | 'signal' | 'error'>): void => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n clearTimeout(grace);\n for (const signal of FORWARDED_SIGNALS) process.removeListener(signal, forward);\n child.stderr?.destroy();\n resolve({ ...result, timedOut, leftRunning, stderr: tail.toString('utf8') });\n };\n const timer = setTimeout(() => {\n timedOut = true;\n killBuild(child);\n }, timeoutMs);\n child.stderr?.on('data', (chunk: Buffer) => {\n tail = Buffer.concat([tail, chunk]);\n if (tail.length > STDERR_TAIL_BYTES) tail = tail.subarray(tail.length - STDERR_TAIL_BYTES);\n });\n child.on('error', (error) => finish({ status: null, signal: null, error }));\n child.on('close', (status, signal) => finish({ status, signal }));\n // A process the build left running can hold stderr open, so 'close' may never come.\n child.on('exit', (status, signal) => {\n grace = setTimeout(\n () => {\n if (!timedOut) leftRunning = true;\n killBuild(child);\n finish({ status, signal });\n },\n timedOut ? 0 : STDERR_CLOSE_GRACE_MS,\n );\n });\n });\n}\n\n/**\n * Builds every local package that changed since its last successful build, and returns each\n * directory's outcome. A failure never stops the others.\n */\nexport async function buildLocalPackages(input: LocalBuildInput): Promise<Map<string, LocalBuildOutcome>> {\n const { globalRoot, environment, onCommand, onNotice } = input;\n const timeoutMs = input.timeoutMs ?? LOCAL_BUILD_TIMEOUT_MS;\n const directories = [...new Set(input.directories)];\n const manifests = new Map(directories.map((directory) => [directory, readManifest(directory)]));\n const stamps = readStamps(globalRoot);\n const outcomes = new Map<string, LocalBuildOutcome>();\n const childEnvironment = buildEnvironment(environment);\n let searchPath = environment.PATH;\n let loginPathTried = false;\n const resolveBinary = (manager: string): string | undefined => {\n const found = findOnPath(manager, searchPath);\n if (found !== undefined || loginPathTried || process.platform !== 'darwin') return found;\n loginPathTried = true;\n const loginPath = loginShellPath(environment);\n if (loginPath === undefined) return undefined;\n searchPath = loginPath;\n childEnvironment.PATH = loginPath;\n return findOnPath(manager, searchPath);\n };\n\n for (const directory of dependencyOrder(directories, manifests)) {\n const manifest = manifests.get(directory);\n if (manifest === undefined) {\n outcomes.set(directory, { status: 'failed', reason: `'${directory}' has no readable package.json` });\n continue;\n }\n const stamp = localBuildStamp(directory);\n // ponytail: an unchanged stamp skips the build even when a dependency outside the\n // package changed; a content hash over the dependency closure is the upgrade.\n if (stamps[directory] === stamp) {\n outcomes.set(directory, { status: 'cached' });\n continue;\n }\n if (typeof manifest.scripts?.[BUILD_SCRIPT] !== 'string') {\n outcomes.set(\n directory,\n builtEntriesPresent(directory, manifest)\n ? { status: 'cached' }\n : { status: 'failed', reason: 'it has no build script and no built entries' },\n );\n continue;\n }\n const manager = packageManagerFor(directory);\n const binary = resolveBinary(manager);\n if (binary === undefined) {\n outcomes.set(directory, { status: 'failed', reason: `${manager} is not on PATH` });\n continue;\n }\n const command = `${binary} run ${BUILD_SCRIPT} (in ${directory})`;\n onCommand(command);\n onNotice(`building ${manifest.name ?? directory}`);\n const result = await runBuildScript(binary, directory, childEnvironment, timeoutMs);\n if (result.status === 0 && !result.timedOut && !result.leftRunning) {\n // The stamp after the build, as the sync pointer records it: a build that writes into\n // src/ or package.json must not look changed to the next sync.\n stamps[directory] = localBuildStamp(directory);\n writeFileAtomic(localBuildsPath(globalRoot), `${JSON.stringify(stamps, null, 2)}\\n`);\n outcomes.set(directory, { status: 'built' });\n continue;\n }\n const exit = result.timedOut\n ? `timed out after ${String(timeoutMs / MILLISECONDS_PER_SECOND)} s`\n : result.status === 0 && result.leftRunning\n ? 'it exited but left processes running, which were stopped'\n : (result.error?.message ?? `exit ${String(result.status ?? result.signal)}`);\n outcomes.set(directory, {\n status: 'failed',\n reason: `${manager} run ${BUILD_SCRIPT} failed (${exit})`,\n stderr: stderrTail(result.stderr),\n });\n }\n return outcomes;\n}\n"],"mappings":";;;;;;;;;;;AAaA,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;AACzB,MAAM,eAAe;AACrB,MAAM,oBAAoB,KAAK,KAAK,SAAS,mBAAmB;AAChE,MAAM,eAAe;;AAGrB,MAAM,oBAAoB;;;;;AAK1B,MAAa,yBAAyB;;AAEtC,MAAM,wBAAwB;AAC9B,MAAM,0BAA0B;AAChC,MAAM,yBAAyB;AAC/B,MAAM,0BAA0B;AAChC,MAAM,kBAAkB;;AAExB,MAAM,YAAoD;CACxD,CAAC,kBAAkB,MAAM;CACzB,CAAC,YAAY,KAAK;CAClB,CAAC,aAAa,KAAK;CACnB,CAAC,aAAa,MAAM;CACpB,CAAC,qBAAqB,KAAK;AAC7B;;AAEA,MAAM,mBAAmB;CAAC;CAAO;CAAO;CAAW;AAAQ;AAC3D,MAAM,oCAAoB,IAAI,IAAI;CAAC;CAAc;CAAiB;AAAuB,CAAC;AAC1F,MAAM,oBAAoB;CAAC;CAAgB;CAAmB;CAA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EAAE,MAC/D,OAAO,WAAW,KAAK,OAAO,cAC5B,6DACC,OAAO,OAAO,WAAW,QAAQ,OAAO,OAAO,UAAU,OAAO,MAAM;EAC7E,SAAS,IAAI,WAAW;GACtB,QAAQ;GACR,QAAQ,GAAG,QAAQ,OAAO,aAAa,WAAW,KAAK;GACvD,QAAQ,WAAW,OAAO,MAAM;EAClC,CAAC;CACH;CACA,OAAO;AACT"}
@@ -0,0 +1,17 @@
1
+ //#region src/composition/transitionLayers.ts
2
+ function extensionLayers(config, names) {
3
+ return names.filter((name) => {
4
+ const layer = config.layers[name];
5
+ return Boolean(layer && ((layer.extensions?.length ?? 0) > 0 || (layer.packages?.length ?? 0) > 0));
6
+ });
7
+ }
8
+ function needsRelaunch(config, before, after) {
9
+ const previous = extensionLayers(config, before);
10
+ const candidate = extensionLayers(config, after);
11
+ return previous.length !== candidate.length || previous.some((name, index) => name !== candidate[index]);
12
+ }
13
+ //#endregion
14
+ exports.extensionLayers = extensionLayers;
15
+ exports.needsRelaunch = needsRelaunch;
16
+
17
+ //# sourceMappingURL=transitionLayers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitionLayers.cjs","names":[],"sources":["../../../src/composition/transitionLayers.ts"],"sourcesContent":["import type { MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nexport function extensionLayers(config: MajorModesConfig, names: readonly string[]): string[] {\n return names.filter((name) => {\n const layer = config.layers[name];\n return Boolean(layer && ((layer.extensions?.length ?? 0) > 0 || (layer.packages?.length ?? 0) > 0));\n });\n}\n\nexport function needsRelaunch(config: MajorModesConfig, before: readonly string[], after: readonly string[]): boolean {\n const previous = extensionLayers(config, before);\n const candidate = extensionLayers(config, after);\n return previous.length !== candidate.length || previous.some((name, index) => name !== candidate[index]);\n}\n"],"mappings":";AACA,SAAgB,gBAAgB,QAA0B,OAAoC;CAC5F,OAAO,MAAM,QAAQ,SAAS;EAC5B,MAAM,QAAQ,OAAO,OAAO;EAC5B,OAAO,QAAQ,WAAW,MAAM,YAAY,UAAU,KAAK,MAAM,MAAM,UAAU,UAAU,KAAK,EAAE;CACpG,CAAC;AACH;AAEA,SAAgB,cAAc,QAA0B,QAA2B,OAAmC;CACpH,MAAM,WAAW,gBAAgB,QAAQ,MAAM;CAC/C,MAAM,YAAY,gBAAgB,QAAQ,KAAK;CAC/C,OAAO,SAAS,WAAW,UAAU,UAAU,SAAS,MAAM,MAAM,UAAU,SAAS,UAAU,MAAM;AACzG"}
@@ -0,0 +1,6 @@
1
+ import { MajorModesConfig } from "@agimon-ai/po-config/majorModes";
2
+ //#region src/composition/transitionLayers.d.ts
3
+ export declare function extensionLayers(config: MajorModesConfig, names: readonly string[]): string[];
4
+ export declare function needsRelaunch(config: MajorModesConfig, before: readonly string[], after: readonly string[]): boolean;
5
+ //#endregion
6
+ //# sourceMappingURL=transitionLayers.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitionLayers.d.mts","names":[],"sources":["../../../src/composition/transitionLayers.ts"],"mappings":";;wBACgB,gBAAgB,QAAQ,kBAAkB;wBAO1C,cAAc,QAAQ,kBAAkB,2BAA2B"}
@@ -0,0 +1,16 @@
1
+ //#region src/composition/transitionLayers.ts
2
+ function extensionLayers(config, names) {
3
+ return names.filter((name) => {
4
+ const layer = config.layers[name];
5
+ return Boolean(layer && ((layer.extensions?.length ?? 0) > 0 || (layer.packages?.length ?? 0) > 0));
6
+ });
7
+ }
8
+ function needsRelaunch(config, before, after) {
9
+ const previous = extensionLayers(config, before);
10
+ const candidate = extensionLayers(config, after);
11
+ return previous.length !== candidate.length || previous.some((name, index) => name !== candidate[index]);
12
+ }
13
+ //#endregion
14
+ export { extensionLayers, needsRelaunch };
15
+
16
+ //# sourceMappingURL=transitionLayers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitionLayers.mjs","names":[],"sources":["../../../src/composition/transitionLayers.ts"],"sourcesContent":["import type { MajorModesConfig } from '@agimon-ai/po-config/majorModes';\nexport function extensionLayers(config: MajorModesConfig, names: readonly string[]): string[] {\n return names.filter((name) => {\n const layer = config.layers[name];\n return Boolean(layer && ((layer.extensions?.length ?? 0) > 0 || (layer.packages?.length ?? 0) > 0));\n });\n}\n\nexport function needsRelaunch(config: MajorModesConfig, before: readonly string[], after: readonly string[]): boolean {\n const previous = extensionLayers(config, before);\n const candidate = extensionLayers(config, after);\n return previous.length !== candidate.length || previous.some((name, index) => name !== candidate[index]);\n}\n"],"mappings":";AACA,SAAgB,gBAAgB,QAA0B,OAAoC;CAC5F,OAAO,MAAM,QAAQ,SAAS;EAC5B,MAAM,QAAQ,OAAO,OAAO;EAC5B,OAAO,QAAQ,WAAW,MAAM,YAAY,UAAU,KAAK,MAAM,MAAM,UAAU,UAAU,KAAK,EAAE;CACpG,CAAC;AACH;AAEA,SAAgB,cAAc,QAA0B,QAA2B,OAAmC;CACpH,MAAM,WAAW,gBAAgB,QAAQ,MAAM;CAC/C,MAAM,YAAY,gBAAgB,QAAQ,KAAK;CAC/C,OAAO,SAAS,WAAW,UAAU,UAAU,SAAS,MAAM,MAAM,UAAU,SAAS,UAAU,MAAM;AACzG"}
@@ -0,0 +1,52 @@
1
+ //#region src/composition/types/harness.d.ts
2
+ export type HarnessPreset = 'default' | 'kimi';
3
+ export type HarnessOutputFormat = 'native' | 'vibe-lint';
4
+ export interface HarnessOptions {
5
+ /** The checkout the run executes in. */
6
+ repoRoot: string;
7
+ /**
8
+ * Where modes, domains, profiles, plugins and MCP config are read from. Set when the checkout
9
+ * belongs to a workspace rooted elsewhere, such as a worktree; defaults to repoRoot.
10
+ */
11
+ configRoot?: string;
12
+ /** Injected home root for home-scoped generated artifacts. */
13
+ homeDirectory?: string;
14
+ cwd: string;
15
+ /** Execution environment supplied by the caller; defaults to process.env. */
16
+ environment?: NodeJS.ProcessEnv;
17
+ /** One persona and its environment defaults from `.po/profiles.yaml`. */
18
+ profile?: string;
19
+ /** Domain names that select plugins, skills, agents, and MCP scope. */
20
+ domains: string[];
21
+ /** One named major mode from `.po/modes.yaml`. */
22
+ majorMode: string;
23
+ /** Print the resolved matrix and exit instead of launching Pi. */
24
+ explain: boolean;
25
+ /** Write the resolved MCP config into this directory and exit. */
26
+ emitMcp?: string;
27
+ /**
28
+ * Stage resources here instead of in a temporary directory.
29
+ *
30
+ * Set by `po sync`, whose output has to survive the process so plain Pi
31
+ * can load it. The caller then owns the directory and its removal.
32
+ */
33
+ resourceDirectory?: string;
34
+ pluginDirectories: string[];
35
+ additionalDirectories: string[];
36
+ preset: HarnessPreset;
37
+ /** Native Pi output or one vibe-lint script-provider response object. */
38
+ outputFormat: HarnessOutputFormat;
39
+ automation: boolean;
40
+ allowProtectedWrites: boolean;
41
+ hooks: boolean;
42
+ mcp: boolean;
43
+ agents: boolean;
44
+ piArgs: string[];
45
+ }
46
+ export interface ParsedHarnessArgs {
47
+ options: Omit<HarnessOptions, 'repoRoot'>;
48
+ help: boolean;
49
+ version: boolean;
50
+ }
51
+ //#endregion
52
+ //# sourceMappingURL=harness.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"harness.d.mts","names":[],"sources":["../../../../src/composition/types/harness.ts"],"mappings":";YAAY;YACA;iBAEK;;EAEf;;;;;EAKA;;EAEA;EACA;;EAEA,cAAc,OAAO;;EAErB;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;EAOA;EACA;EACA;EACA,QAAQ;;EAER,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,SAAS,KAAK;EACd;EACA"}
@@ -0,0 +1,65 @@
1
+ const require_index = require("../cli/commands/doctor/index.cjs");
2
+ let _agimon_ai_po_config_harnessState = require("@agimon-ai/po-config/harnessState");
3
+ let _agimon_ai_po_core_serverFacet = require("@agimon-ai/po-core/serverFacet");
4
+ let _agimon_ai_po_core_help = require("@agimon-ai/po-core/help");
5
+ let typebox = require("typebox");
6
+ //#region src/extensions/setupDiagnostics.ts
7
+ const DIAGNOSE_SETUP_NAME = "diagnose_setup";
8
+ const guidance = {
9
+ "config.yaml": "po-author-config",
10
+ "modes.yaml": "po-author-major-mode",
11
+ "domains.yaml": "po-author-domain",
12
+ "profiles.yaml": "po-author-profile"
13
+ };
14
+ function createSetupDiagnosticsTool(readScope, authorize) {
15
+ return (0, _agimon_ai_po_core_serverFacet.defineTool)({
16
+ name: DIAGNOSE_SETUP_NAME,
17
+ description: "Check this session's saved configuration, installed packages, and the global web build without changing anything. Returns scoped check results and the relevant setup guidance, never configuration values or credentials.",
18
+ parameters: typebox.Type.Object({}, { additionalProperties: false }),
19
+ when: _agimon_ai_po_core_help.DOOM_HELP_WHEN,
20
+ executionMode: "serial",
21
+ async execute(_input, execution) {
22
+ const signal = authorize(execution.signal);
23
+ const scope = readScope();
24
+ const environment = (0, _agimon_ai_po_config_harnessState.projectHarnessEnvironment)({
25
+ root: scope.repoRoot,
26
+ majorMode: scope.selection.majorMode,
27
+ domains: [...scope.selection.domains],
28
+ profile: scope.selection.profile
29
+ }, { ...scope.environment });
30
+ const report = require_index.collectDoctorReport(environment, scope.cwd);
31
+ signal.throwIfAborted();
32
+ authorize(execution.signal);
33
+ const result = {
34
+ scope: "current-session",
35
+ configurationRoot: report.repoRoot,
36
+ appliedSelection: {
37
+ majorMode: scope.selection.majorMode,
38
+ domains: [...scope.selection.domains],
39
+ profile: scope.selection.profile
40
+ },
41
+ status: report.problems === 0 && report.skipped.length === 0 ? "checks-passed" : "issues-found",
42
+ checks: report.sections.map((section) => ({
43
+ area: section.label,
44
+ status: section.problems.length ? "failed" : "passed",
45
+ problemCount: section.problems.length,
46
+ guidance: guidance[section.label] ?? "po-use-help"
47
+ })),
48
+ skipped: report.skipped,
49
+ limitations: "These are saved configuration and installation checks, not a network authentication or agent health test. Error text and configuration values are omitted to protect credentials. Inspect a failed area with its package guidance before proposing a repair."
50
+ };
51
+ return {
52
+ content: [{
53
+ type: "text",
54
+ text: JSON.stringify(result, null, 2)
55
+ }],
56
+ details: result
57
+ };
58
+ }
59
+ });
60
+ }
61
+ //#endregion
62
+ exports.DIAGNOSE_SETUP_NAME = DIAGNOSE_SETUP_NAME;
63
+ exports.createSetupDiagnosticsTool = createSetupDiagnosticsTool;
64
+
65
+ //# sourceMappingURL=setupDiagnostics.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupDiagnostics.cjs","names":["defineTool","Type","HELP_WHEN","projectHarnessEnvironment","collectDoctorReport"],"sources":["../../../src/extensions/setupDiagnostics.ts"],"sourcesContent":["import { projectHarnessEnvironment } from '@agimon-ai/po-config/harnessState';\nimport type { DoomHeadlessSelection } from '@agimon-ai/po-core/headless';\nimport { DOOM_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverFacet';\nimport { Type } from 'typebox';\n\nimport { collectDoctorReport } from '../cli/commands/doctor';\n\nexport const DIAGNOSE_SETUP_NAME = 'diagnose_setup';\nexport interface SetupDiagnosticScope {\n repoRoot: string;\n cwd: string;\n environment: Readonly<Record<string, string | undefined>>;\n selection: Pick<DoomHeadlessSelection, 'majorMode' | 'domains' | 'profile'>;\n}\n\nconst guidance: Readonly<Record<string, string>> = {\n 'config.yaml': 'po-author-config',\n 'modes.yaml': 'po-author-major-mode',\n 'domains.yaml': 'po-author-domain',\n 'profiles.yaml': 'po-author-profile',\n};\n\nexport function createSetupDiagnosticsTool(\n readScope: () => SetupDiagnosticScope,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: DIAGNOSE_SETUP_NAME,\n description:\n \"Check this session's saved configuration, installed packages, and the global web build without changing anything. Returns scoped check results and the relevant setup guidance, never configuration values or credentials.\",\n parameters: Type.Object({}, { additionalProperties: false }),\n when: HELP_WHEN,\n executionMode: 'serial',\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const scope = readScope();\n const environment = projectHarnessEnvironment(\n {\n root: scope.repoRoot,\n majorMode: scope.selection.majorMode,\n domains: [...scope.selection.domains],\n profile: scope.selection.profile,\n },\n { ...scope.environment },\n );\n const report = collectDoctorReport(environment, scope.cwd);\n signal.throwIfAborted();\n authorize(execution.signal);\n const result = {\n scope: 'current-session',\n configurationRoot: report.repoRoot,\n appliedSelection: {\n majorMode: scope.selection.majorMode,\n domains: [...scope.selection.domains],\n profile: scope.selection.profile,\n },\n status: report.problems === 0 && report.skipped.length === 0 ? 'checks-passed' : 'issues-found',\n checks: report.sections.map((section) => ({\n area: section.label,\n status: section.problems.length ? 'failed' : 'passed',\n problemCount: section.problems.length,\n guidance: guidance[section.label] ?? 'po-use-help',\n })),\n skipped: report.skipped,\n limitations:\n 'These are saved configuration and installation checks, not a network authentication or agent health test. Error text and configuration values are omitted to protect credentials. Inspect a failed area with its package guidance before proposing a repair.',\n };\n return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], details: result };\n },\n });\n}\n"],"mappings":";;;;;;AAQA,MAAa,sBAAsB;AAQnC,MAAM,WAA6C;CACjD,eAAe;CACf,cAAc;CACd,gBAAgB;CAChB,iBAAiB;AACnB;AAEA,SAAgB,2BACd,WACA,WACA;CACA,QAAA,GAAOA,+BAAAA,WAAAA,CAAW;EAChB,MAAM;EACN,aACE;EACF,YAAYC,QAAAA,KAAK,OAAO,CAAC,GAAG,EAAE,sBAAsB,MAAM,CAAC;EAC3D,MAAMC,wBAAAA;EACN,eAAe;EACf,MAAM,QAAQ,QAAQ,WAAW;GAC/B,MAAM,SAAS,UAAU,UAAU,MAAM;GACzC,MAAM,QAAQ,UAAU;GACxB,MAAM,eAAA,GAAcC,kCAAAA,0BAAAA,CAClB;IACE,MAAM,MAAM;IACZ,WAAW,MAAM,UAAU;IAC3B,SAAS,CAAC,GAAG,MAAM,UAAU,OAAO;IACpC,SAAS,MAAM,UAAU;GAC3B,GACA,EAAE,GAAG,MAAM,YAAY,CACzB;GACA,MAAM,SAASC,cAAAA,oBAAoB,aAAa,MAAM,GAAG;GACzD,OAAO,eAAe;GACtB,UAAU,UAAU,MAAM;GAC1B,MAAM,SAAS;IACb,OAAO;IACP,mBAAmB,OAAO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