@agimon-ai/po 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (255) hide show
  1. package/README.md +14 -11
  2. package/dist/antigravity.mjs +1 -2
  3. package/dist/baseCommand.mjs +1 -2
  4. package/dist/bin/cli.cjs +37 -14
  5. package/dist/bin/cli.cjs.map +1 -1
  6. package/dist/bin/cli.mjs +34 -14
  7. package/dist/bin/cli.mjs.map +1 -1
  8. package/dist/bin/{doomRunner.cjs → poRunner.cjs} +5 -5
  9. package/dist/bin/poRunner.cjs.map +1 -0
  10. package/dist/bin/{doomRunner.d.mts → poRunner.d.mts} +2 -2
  11. package/dist/bin/poRunner.d.mts.map +1 -0
  12. package/dist/bin/{doomRunner.mjs → poRunner.mjs} +5 -5
  13. package/dist/bin/poRunner.mjs.map +1 -0
  14. package/dist/builders/cli/extensionAssembler/index.cjs +14 -12
  15. package/dist/builders/cli/extensionAssembler/index.cjs.map +1 -1
  16. package/dist/builders/cli/extensionAssembler/index.d.mts +2 -1
  17. package/dist/builders/cli/extensionAssembler/index.d.mts.map +1 -1
  18. package/dist/builders/cli/extensionAssembler/index.mjs +14 -12
  19. package/dist/builders/cli/extensionAssembler/index.mjs.map +1 -1
  20. package/dist/catalog/index.json +68 -51
  21. package/dist/cliApp.mjs +1 -2
  22. package/dist/codex.mjs +1 -2
  23. package/dist/compatibilityCommand.mjs +1 -2
  24. package/dist/compatibilityContext.mjs +1 -2
  25. package/dist/compatibilityOptions.mjs +1 -2
  26. package/dist/config.cjs +57 -12
  27. package/dist/config.d.mts +3 -3
  28. package/dist/config.mjs +3 -3
  29. package/dist/doctorCommand.mjs +1 -2
  30. package/dist/emitMcpCommand.mjs +1 -2
  31. package/dist/explainCommand.mjs +1 -2
  32. package/dist/extensions/server.cjs +11 -7
  33. package/dist/extensions/server.cjs.map +1 -1
  34. package/dist/extensions/server.d.mts +2 -2
  35. package/dist/extensions/server.d.mts.map +1 -1
  36. package/dist/extensions/server.mjs +12 -8
  37. package/dist/extensions/server.mjs.map +1 -1
  38. package/dist/harnessContext.mjs +1 -2
  39. package/dist/harnessState.cjs +66 -11
  40. package/dist/harnessState.d.mts +2 -2
  41. package/dist/harnessState.mjs +1 -2
  42. package/dist/index.cjs +60 -15
  43. package/dist/index.d.mts +3 -3
  44. package/dist/index.mjs +3 -3
  45. package/dist/initCommand.mjs +1 -2
  46. package/dist/matrixOptions.mjs +1 -2
  47. package/dist/options.mjs +1 -2
  48. package/dist/process.mjs +1 -2
  49. package/dist/projectTrust.cjs +2 -2
  50. package/dist/projectTrust.d.mts +2 -2
  51. package/dist/projectTrust.mjs +1 -2
  52. package/dist/repository.cjs +1 -1
  53. package/dist/repository.d.mts +2 -2
  54. package/dist/repository.mjs +1 -2
  55. package/dist/router.mjs +1 -2
  56. package/dist/shared.mjs +1 -2
  57. package/dist/src/bin/agentDirectory.cjs +18 -12
  58. package/dist/src/bin/agentDirectory.cjs.map +1 -1
  59. package/dist/src/bin/agentDirectory.mjs +15 -12
  60. package/dist/src/bin/agentDirectory.mjs.map +1 -1
  61. package/dist/src/builders/apiContractExport/index.cjs +6 -6
  62. package/dist/src/builders/apiContractExport/index.cjs.map +1 -1
  63. package/dist/src/builders/apiContractExport/index.mjs +9 -9
  64. package/dist/src/builders/apiContractExport/index.mjs.map +1 -1
  65. package/dist/src/builders/cli/entryResolution.cjs +3 -3
  66. package/dist/src/builders/cli/entryResolution.cjs.map +1 -1
  67. package/dist/src/builders/cli/entryResolution.mjs +3 -3
  68. package/dist/src/builders/cli/entryResolution.mjs.map +1 -1
  69. package/dist/src/builders/cli/harnessContext.cjs +5 -5
  70. package/dist/src/builders/cli/harnessContext.cjs.map +1 -1
  71. package/dist/src/builders/cli/harnessContext.mjs +7 -7
  72. package/dist/src/builders/cli/harnessContext.mjs.map +1 -1
  73. package/dist/src/builders/hooks/index.cjs +1 -1
  74. package/dist/src/builders/hooks/index.cjs.map +1 -1
  75. package/dist/src/builders/hooks/index.mjs +2 -2
  76. package/dist/src/builders/hooks/index.mjs.map +1 -1
  77. package/dist/src/builders/server/backgroundSync.cjs +13 -1
  78. package/dist/src/builders/server/backgroundSync.cjs.map +1 -1
  79. package/dist/src/builders/server/backgroundSync.mjs +13 -1
  80. package/dist/src/builders/server/backgroundSync.mjs.map +1 -1
  81. package/dist/src/builders/server/bundlerService.cjs +151 -0
  82. package/dist/src/builders/server/bundlerService.cjs.map +1 -0
  83. package/dist/src/builders/server/bundlerService.mjs +151 -0
  84. package/dist/src/builders/server/bundlerService.mjs.map +1 -0
  85. package/dist/src/builders/server/computerUseBinding.cjs +2 -2
  86. package/dist/src/builders/server/computerUseBinding.cjs.map +1 -1
  87. package/dist/src/builders/server/computerUseBinding.mjs +3 -3
  88. package/dist/src/builders/server/computerUseBinding.mjs.map +1 -1
  89. package/dist/src/builders/server/defaultWorkspace.cjs +1 -1
  90. package/dist/src/builders/server/defaultWorkspace.cjs.map +1 -1
  91. package/dist/src/builders/server/defaultWorkspace.mjs +2 -2
  92. package/dist/src/builders/server/defaultWorkspace.mjs.map +1 -1
  93. package/dist/src/builders/server/idleRestart.cjs +3 -3
  94. package/dist/src/builders/server/idleRestart.cjs.map +1 -1
  95. package/dist/src/builders/server/idleRestart.mjs +3 -3
  96. package/dist/src/builders/server/idleRestart.mjs.map +1 -1
  97. package/dist/src/builders/server/index.cjs +6 -6
  98. package/dist/src/builders/server/index.cjs.map +1 -1
  99. package/dist/src/builders/server/index.mjs +6 -6
  100. package/dist/src/builders/server/index.mjs.map +1 -1
  101. package/dist/src/builders/server/logSink.cjs +3 -3
  102. package/dist/src/builders/server/logSink.cjs.map +1 -1
  103. package/dist/src/builders/server/logSink.mjs +2 -2
  104. package/dist/src/builders/server/logSink.mjs.map +1 -1
  105. package/dist/src/builders/server/mcpBundle.cjs.map +1 -1
  106. package/dist/src/builders/server/mcpBundle.d.mts +2 -2
  107. package/dist/src/builders/server/mcpBundle.mjs.map +1 -1
  108. package/dist/src/builders/server/packageUrl.cjs +25 -18
  109. package/dist/src/builders/server/packageUrl.cjs.map +1 -1
  110. package/dist/src/builders/server/packageUrl.mjs +25 -18
  111. package/dist/src/builders/server/packageUrl.mjs.map +1 -1
  112. package/dist/src/builders/server/runtime.cjs +157 -168
  113. package/dist/src/builders/server/runtime.cjs.map +1 -1
  114. package/dist/src/builders/server/runtime.mjs +161 -171
  115. package/dist/src/builders/server/runtime.mjs.map +1 -1
  116. package/dist/src/builders/server/selectionStatus.cjs +3 -3
  117. package/dist/src/builders/server/selectionStatus.cjs.map +1 -1
  118. package/dist/src/builders/server/selectionStatus.mjs +3 -3
  119. package/dist/src/builders/server/selectionStatus.mjs.map +1 -1
  120. package/dist/src/builders/server/sessionArguments.cjs.map +1 -1
  121. package/dist/src/builders/server/sessionArguments.mjs.map +1 -1
  122. package/dist/src/builders/server/watcherService.cjs +65 -0
  123. package/dist/src/builders/server/watcherService.cjs.map +1 -0
  124. package/dist/src/builders/server/watcherService.mjs +61 -0
  125. package/dist/src/builders/server/watcherService.mjs.map +1 -0
  126. package/dist/src/builders/server/webTemplateDecision.cjs +1 -1
  127. package/dist/src/builders/server/webTemplateDecision.cjs.map +1 -1
  128. package/dist/src/builders/server/webTemplateDecision.mjs +2 -2
  129. package/dist/src/builders/server/webTemplateDecision.mjs.map +1 -1
  130. package/dist/src/builders/web/bundle.cjs.map +1 -1
  131. package/dist/src/builders/web/bundle.d.mts +4 -3
  132. package/dist/src/builders/web/bundle.mjs.map +1 -1
  133. package/dist/src/builders/web/bundleAssetPolicy.d.mts +1 -0
  134. package/dist/src/builders/web/index.cjs +1 -1
  135. package/dist/src/builders/web/index.cjs.map +1 -1
  136. package/dist/src/builders/web/index.d.mts +1 -0
  137. package/dist/src/builders/web/index.mjs +1 -1
  138. package/dist/src/builders/web/index.mjs.map +1 -1
  139. package/dist/src/builders/web/webPluginGenerate.cjs +4 -15
  140. package/dist/src/builders/web/webPluginGenerate.cjs.map +1 -1
  141. package/dist/src/builders/web/webPluginGenerate.d.mts +5 -9
  142. package/dist/src/builders/web/webPluginGenerate.d.mts.map +1 -1
  143. package/dist/src/builders/web/webPluginGenerate.mjs +4 -15
  144. package/dist/src/builders/web/webPluginGenerate.mjs.map +1 -1
  145. package/dist/src/builders/web/webPluginVite.d.mts +1 -0
  146. package/dist/src/cli/cliApp.cjs +1 -1
  147. package/dist/src/cli/cliApp.cjs.map +1 -1
  148. package/dist/src/cli/cliApp.mjs +1 -1
  149. package/dist/src/cli/cliApp.mjs.map +1 -1
  150. package/dist/src/cli/commands/compat/index.cjs +1 -1
  151. package/dist/src/cli/commands/compat/index.cjs.map +1 -1
  152. package/dist/src/cli/commands/compat/index.mjs +1 -1
  153. package/dist/src/cli/commands/compat/index.mjs.map +1 -1
  154. package/dist/src/cli/commands/doctor/index.cjs +2 -2
  155. package/dist/src/cli/commands/doctor/index.cjs.map +1 -1
  156. package/dist/src/cli/commands/doctor/index.d.mts +1 -0
  157. package/dist/src/cli/commands/doctor/index.d.mts.map +1 -1
  158. package/dist/src/cli/commands/doctor/index.mjs +4 -4
  159. package/dist/src/cli/commands/doctor/index.mjs.map +1 -1
  160. package/dist/src/cli/commands/explain/index.cjs +3 -1
  161. package/dist/src/cli/commands/explain/index.cjs.map +1 -1
  162. package/dist/src/cli/commands/explain/index.d.mts.map +1 -1
  163. package/dist/src/cli/commands/explain/index.mjs +4 -2
  164. package/dist/src/cli/commands/explain/index.mjs.map +1 -1
  165. package/dist/src/cli/commands/init/index.cjs +2 -2
  166. package/dist/src/cli/commands/init/index.cjs.map +1 -1
  167. package/dist/src/cli/commands/init/index.mjs +3 -3
  168. package/dist/src/cli/commands/init/index.mjs.map +1 -1
  169. package/dist/src/cli/commands/init/presenter.cjs +1 -1
  170. package/dist/src/cli/commands/init/presenter.cjs.map +1 -1
  171. package/dist/src/cli/commands/init/presenter.mjs +2 -2
  172. package/dist/src/cli/commands/init/presenter.mjs.map +1 -1
  173. package/dist/src/cli/commands/sync/index.cjs +4 -4
  174. package/dist/src/cli/commands/sync/index.cjs.map +1 -1
  175. package/dist/src/cli/commands/sync/index.d.mts +1 -0
  176. package/dist/src/cli/commands/sync/index.mjs +7 -7
  177. package/dist/src/cli/commands/sync/index.mjs.map +1 -1
  178. package/dist/src/cli/commands/sync/presenter.cjs +1 -1
  179. package/dist/src/cli/commands/sync/presenter.cjs.map +1 -1
  180. package/dist/src/cli/commands/sync/presenter.d.mts +1 -1
  181. package/dist/src/cli/commands/sync/presenter.mjs +1 -1
  182. package/dist/src/cli/commands/sync/presenter.mjs.map +1 -1
  183. package/dist/src/cli/commands/web/index.cjs +2 -1
  184. package/dist/src/cli/commands/web/index.cjs.map +1 -1
  185. package/dist/src/cli/commands/web/index.mjs +2 -1
  186. package/dist/src/cli/commands/web/index.mjs.map +1 -1
  187. package/dist/src/cli/harnessOptions.cjs +1 -1
  188. package/dist/src/cli/harnessOptions.cjs.map +1 -1
  189. package/dist/src/cli/harnessOptions.mjs +2 -2
  190. package/dist/src/cli/harnessOptions.mjs.map +1 -1
  191. package/dist/src/cli/help.cjs +2 -0
  192. package/dist/src/cli/help.cjs.map +1 -1
  193. package/dist/src/cli/help.mjs +2 -0
  194. package/dist/src/cli/help.mjs.map +1 -1
  195. package/dist/src/cli/matrixOptions.cjs +1 -1
  196. package/dist/src/cli/matrixOptions.cjs.map +1 -1
  197. package/dist/src/cli/matrixOptions.d.mts +1 -1
  198. package/dist/src/cli/matrixOptions.mjs +1 -1
  199. package/dist/src/cli/matrixOptions.mjs.map +1 -1
  200. package/dist/src/cli/server/run.cjs +1 -1
  201. package/dist/src/cli/server/run.cjs.map +1 -1
  202. package/dist/src/cli/server/run.mjs +2 -2
  203. package/dist/src/cli/server/run.mjs.map +1 -1
  204. package/dist/src/composition/harnessState/index.cjs +66 -11
  205. package/dist/src/composition/harnessState/index.cjs.map +1 -1
  206. package/dist/src/composition/harnessState/index.d.mts +3 -3
  207. package/dist/src/composition/harnessState/index.mjs +2 -2
  208. package/dist/src/composition/harnessState/index.mjs.map +1 -1
  209. package/dist/src/composition/layerPackageInstaller/index.cjs +5 -4
  210. package/dist/src/composition/layerPackageInstaller/index.cjs.map +1 -1
  211. package/dist/src/composition/layerPackageInstaller/index.mjs +6 -5
  212. package/dist/src/composition/layerPackageInstaller/index.mjs.map +1 -1
  213. package/dist/src/composition/poHomeMigration/index.cjs +1 -1
  214. package/dist/src/composition/poHomeMigration/index.cjs.map +1 -1
  215. package/dist/src/composition/poHomeMigration/index.mjs +1 -1
  216. package/dist/src/composition/poHomeMigration/index.mjs.map +1 -1
  217. package/dist/src/composition/projectTrust/index.cjs +6 -6
  218. package/dist/src/composition/projectTrust/index.cjs.map +1 -1
  219. package/dist/src/composition/projectTrust/index.d.mts +7 -7
  220. package/dist/src/composition/projectTrust/index.d.mts.map +1 -1
  221. package/dist/src/composition/projectTrust/index.mjs +6 -6
  222. package/dist/src/composition/projectTrust/index.mjs.map +1 -1
  223. package/dist/src/composition/repository/index.cjs +8 -8
  224. package/dist/src/composition/repository/index.cjs.map +1 -1
  225. package/dist/src/composition/repository/index.d.mts +5 -5
  226. package/dist/src/composition/repository/index.d.mts.map +1 -1
  227. package/dist/src/composition/repository/index.mjs +10 -10
  228. package/dist/src/composition/repository/index.mjs.map +1 -1
  229. package/dist/src/composition/syncService/index.cjs +29 -9
  230. package/dist/src/composition/syncService/index.cjs.map +1 -1
  231. package/dist/src/composition/syncService/index.d.mts.map +1 -1
  232. package/dist/src/composition/syncService/index.mjs +31 -11
  233. package/dist/src/composition/syncService/index.mjs.map +1 -1
  234. package/dist/src/composition/syncService/localBuilds.cjs +7 -2
  235. package/dist/src/composition/syncService/localBuilds.cjs.map +1 -1
  236. package/dist/src/composition/syncService/localBuilds.mjs +7 -2
  237. package/dist/src/composition/syncService/localBuilds.mjs.map +1 -1
  238. package/dist/src/extensions/setupDiagnostics.cjs +3 -3
  239. package/dist/src/extensions/setupDiagnostics.cjs.map +1 -1
  240. package/dist/src/extensions/setupDiagnostics.mjs +3 -3
  241. package/dist/src/extensions/setupDiagnostics.mjs.map +1 -1
  242. package/dist/utils.mjs +1 -2
  243. package/docs/server/api-export.md +3 -3
  244. package/docs/server/api.md +23 -22
  245. package/docs/server/getting-started.md +7 -7
  246. package/docs/server/index.md +4 -4
  247. package/docs/server/ipc.md +7 -11
  248. package/docs/server/lifecycle.md +17 -17
  249. package/docs/server/security.md +8 -8
  250. package/package.json +42 -45
  251. package/src/prompts/po-author-extension/SKILL.md +1 -1
  252. package/src/prompts/po-author-extension/references/extension-contract.md +4 -4
  253. package/dist/bin/doomRunner.cjs.map +0 -1
  254. package/dist/bin/doomRunner.d.mts.map +0 -1
  255. package/dist/bin/doomRunner.mjs.map +0 -1
@@ -25,22 +25,22 @@ function isFile(target) {
25
25
  }
26
26
  }
27
27
  /**
28
- * True when a directory carries a marker Doom Pi is willing to treat as a root.
28
+ * True when a directory carries a marker Po Pi is willing to treat as a root.
29
29
  *
30
- * Doom and Pi markers identify configured projects. A Git marker also counts so
30
+ * Po and Pi markers identify configured projects. A Git marker also counts so
31
31
  * personal configuration can be synchronized into a new checkout before it has
32
32
  * repository-local configuration. Build-tooling markers remain deliberately
33
33
  * excluded because they do not establish a repository boundary.
34
34
  */
35
35
  function isRepositoryRoot(directory) {
36
36
  const gitMarker = node_path.default.join(directory, GIT_DIRECTORY);
37
- return (0, _agimon_ai_po_core_piSettings.hasRepositoryDoomDirectory)(directory) || isFile(node_path.default.join(directory, PI_SETTINGS)) || isDirectory(gitMarker) || isFile(gitMarker);
37
+ return (0, _agimon_ai_po_core_piSettings.hasRepositoryPoDirectory)(directory) || isFile(node_path.default.join(directory, PI_SETTINGS)) || isDirectory(gitMarker) || isFile(gitMarker);
38
38
  }
39
39
  /**
40
40
  * Walks up from `start` looking for the repository root.
41
41
  *
42
42
  * The nearest marked ancestor wins, so a session started in a subdirectory
43
- * resolves to the repository that configured Doom rather than to a parent
43
+ * resolves to the repository that configured Po rather than to a parent
44
44
  * checkout that happens to sit above it.
45
45
  */
46
46
  function findRepositoryRoot(start) {
@@ -52,17 +52,17 @@ function findRepositoryRoot(start) {
52
52
  directory = parent;
53
53
  }
54
54
  }
55
- /** Uses the nearest repository when one exists, otherwise the user's global Doom composition. */
56
- function resolveDoomConfigurationRoot(start, homeDirectory) {
55
+ /** Uses the nearest repository when one exists, otherwise the user's global Po composition. */
56
+ function resolvePoConfigurationRoot(start, homeDirectory) {
57
57
  try {
58
58
  return findRepositoryRoot(start);
59
59
  } catch {
60
- return (0, _agimon_ai_po_config_config.globalDoomConfigDirectory)(homeDirectory);
60
+ return (0, _agimon_ai_po_config_config.globalPoConfigDirectory)(homeDirectory);
61
61
  }
62
62
  }
63
63
  //#endregion
64
64
  exports.findRepositoryRoot = findRepositoryRoot;
65
65
  exports.isRepositoryRoot = isRepositoryRoot;
66
- exports.resolveDoomConfigurationRoot = resolveDoomConfigurationRoot;
66
+ exports.resolvePoConfigurationRoot = resolvePoConfigurationRoot;
67
67
 
68
68
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","fs","hasRepositoryDoomDirectory","globalDoomConfigDirectory"],"sources":["../../../../src/composition/repository/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/po-config/config';\nimport { hasRepositoryDoomDirectory } from '@agimon-ai/po-core/piSettings';\n\n/** Git's root marker, which may be a directory or a worktree pointer file. */\nconst GIT_DIRECTORY = '.git';\n/** A Pi project that has been configured, rather than any stray `.pi` folder. */\nconst PI_SETTINGS = path.join('.pi', 'settings.json');\n\nfunction isDirectory(target: string): boolean {\n try {\n return fs.statSync(target).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction isFile(target: string): boolean {\n try {\n return fs.statSync(target).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * True when a directory carries a marker Doom Pi is willing to treat as a root.\n *\n * Doom and Pi markers identify configured projects. A Git marker also counts so\n * personal configuration can be synchronized into a new checkout before it has\n * repository-local configuration. Build-tooling markers remain deliberately\n * excluded because they do not establish a repository boundary.\n */\nexport function isRepositoryRoot(directory: string): boolean {\n const gitMarker = path.join(directory, GIT_DIRECTORY);\n return (\n hasRepositoryDoomDirectory(directory) ||\n isFile(path.join(directory, PI_SETTINGS)) ||\n isDirectory(gitMarker) ||\n isFile(gitMarker)\n );\n}\n\n/**\n * Walks up from `start` looking for the repository root.\n *\n * The nearest marked ancestor wins, so a session started in a subdirectory\n * resolves to the repository that configured Doom rather than to a parent\n * checkout that happens to sit above it.\n */\nexport function findRepositoryRoot(start: string): string {\n let directory = path.resolve(start);\n while (true) {\n if (isRepositoryRoot(directory)) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`Could not find repository root from ${start}`);\n directory = parent;\n }\n}\n\n/** Uses the nearest repository when one exists, otherwise the user's global Doom composition. */\nexport function resolveDoomConfigurationRoot(start: string, homeDirectory: string): string {\n try {\n return findRepositoryRoot(start);\n } catch {\n return globalDoomConfigDirectory(homeDirectory);\n }\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,gBAAgB;;AAEtB,MAAM,cAAcA,UAAAA,QAAK,KAAK,OAAO,eAAe;AAEpD,SAAS,YAAY,QAAyB;CAC5C,IAAI;EACF,OAAOC,QAAAA,QAAG,SAAS,MAAM,CAAC,CAAC,YAAY;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,OAAO,QAAyB;CACvC,IAAI;EACF,OAAOA,QAAAA,QAAG,SAAS,MAAM,CAAC,CAAC,OAAO;CACpC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,WAA4B;CAC3D,MAAM,YAAYD,UAAAA,QAAK,KAAK,WAAW,aAAa;CACpD,QAAA,GACEE,8BAAAA,2BAAAA,CAA2B,SAAS,KACpC,OAAOF,UAAAA,QAAK,KAAK,WAAW,WAAW,CAAC,KACxC,YAAY,SAAS,KACrB,OAAO,SAAS;AAEpB;;;;;;;;AASA,SAAgB,mBAAmB,OAAuB;CACxD,IAAI,YAAYA,UAAAA,QAAK,QAAQ,KAAK;CAClC,OAAO,MAAM;EACX,IAAI,iBAAiB,SAAS,GAAG,OAAO;EACxC,MAAM,SAASA,UAAAA,QAAK,QAAQ,SAAS;EACrC,IAAI,WAAW,WAAW,MAAM,IAAI,MAAM,uCAAuC,OAAO;EACxF,YAAY;CACd;AACF;;AAGA,SAAgB,6BAA6B,OAAe,eAA+B;CACzF,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,QAAQ;EACN,QAAA,GAAOG,4BAAAA,0BAAAA,CAA0B,aAAa;CAChD;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["path","fs","hasRepositoryPoDirectory","globalPoConfigDirectory"],"sources":["../../../../src/composition/repository/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { hasRepositoryPoDirectory } from '@agimon-ai/po-core/piSettings';\n\n/** Git's root marker, which may be a directory or a worktree pointer file. */\nconst GIT_DIRECTORY = '.git';\n/** A Pi project that has been configured, rather than any stray `.pi` folder. */\nconst PI_SETTINGS = path.join('.pi', 'settings.json');\n\nfunction isDirectory(target: string): boolean {\n try {\n return fs.statSync(target).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction isFile(target: string): boolean {\n try {\n return fs.statSync(target).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * True when a directory carries a marker Po Pi is willing to treat as a root.\n *\n * Po and Pi markers identify configured projects. A Git marker also counts so\n * personal configuration can be synchronized into a new checkout before it has\n * repository-local configuration. Build-tooling markers remain deliberately\n * excluded because they do not establish a repository boundary.\n */\nexport function isRepositoryRoot(directory: string): boolean {\n const gitMarker = path.join(directory, GIT_DIRECTORY);\n return (\n hasRepositoryPoDirectory(directory) ||\n isFile(path.join(directory, PI_SETTINGS)) ||\n isDirectory(gitMarker) ||\n isFile(gitMarker)\n );\n}\n\n/**\n * Walks up from `start` looking for the repository root.\n *\n * The nearest marked ancestor wins, so a session started in a subdirectory\n * resolves to the repository that configured Po rather than to a parent\n * checkout that happens to sit above it.\n */\nexport function findRepositoryRoot(start: string): string {\n let directory = path.resolve(start);\n while (true) {\n if (isRepositoryRoot(directory)) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`Could not find repository root from ${start}`);\n directory = parent;\n }\n}\n\n/** Uses the nearest repository when one exists, otherwise the user's global Po composition. */\nexport function resolvePoConfigurationRoot(start: string, homeDirectory: string): string {\n try {\n return findRepositoryRoot(start);\n } catch {\n return globalPoConfigDirectory(homeDirectory);\n }\n}\n"],"mappings":";;;;;;;;;AAOA,MAAM,gBAAgB;;AAEtB,MAAM,cAAcA,UAAAA,QAAK,KAAK,OAAO,eAAe;AAEpD,SAAS,YAAY,QAAyB;CAC5C,IAAI;EACF,OAAOC,QAAAA,QAAG,SAAS,MAAM,CAAC,CAAC,YAAY;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,OAAO,QAAyB;CACvC,IAAI;EACF,OAAOA,QAAAA,QAAG,SAAS,MAAM,CAAC,CAAC,OAAO;CACpC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,WAA4B;CAC3D,MAAM,YAAYD,UAAAA,QAAK,KAAK,WAAW,aAAa;CACpD,QAAA,GACEE,8BAAAA,yBAAAA,CAAyB,SAAS,KAClC,OAAOF,UAAAA,QAAK,KAAK,WAAW,WAAW,CAAC,KACxC,YAAY,SAAS,KACrB,OAAO,SAAS;AAEpB;;;;;;;;AASA,SAAgB,mBAAmB,OAAuB;CACxD,IAAI,YAAYA,UAAAA,QAAK,QAAQ,KAAK;CAClC,OAAO,MAAM;EACX,IAAI,iBAAiB,SAAS,GAAG,OAAO;EACxC,MAAM,SAASA,UAAAA,QAAK,QAAQ,SAAS;EACrC,IAAI,WAAW,WAAW,MAAM,IAAI,MAAM,uCAAuC,OAAO;EACxF,YAAY;CACd;AACF;;AAGA,SAAgB,2BAA2B,OAAe,eAA+B;CACvF,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,QAAQ;EACN,QAAA,GAAOG,4BAAAA,wBAAAA,CAAwB,aAAa;CAC9C;AACF"}
@@ -1,8 +1,8 @@
1
1
  //#region src/composition/repository/index.d.ts
2
2
  /**
3
- * True when a directory carries a marker Doom Pi is willing to treat as a root.
3
+ * True when a directory carries a marker Po Pi is willing to treat as a root.
4
4
  *
5
- * Doom and Pi markers identify configured projects. A Git marker also counts so
5
+ * Po and Pi markers identify configured projects. A Git marker also counts so
6
6
  * personal configuration can be synchronized into a new checkout before it has
7
7
  * repository-local configuration. Build-tooling markers remain deliberately
8
8
  * excluded because they do not establish a repository boundary.
@@ -12,11 +12,11 @@ export declare function isRepositoryRoot(directory: string): boolean;
12
12
  * Walks up from `start` looking for the repository root.
13
13
  *
14
14
  * The nearest marked ancestor wins, so a session started in a subdirectory
15
- * resolves to the repository that configured Doom rather than to a parent
15
+ * resolves to the repository that configured Po rather than to a parent
16
16
  * checkout that happens to sit above it.
17
17
  */
18
18
  export declare function findRepositoryRoot(start: string): string;
19
- /** Uses the nearest repository when one exists, otherwise the user's global Doom composition. */
20
- export declare function resolveDoomConfigurationRoot(start: string, homeDirectory: string): string;
19
+ /** Uses the nearest repository when one exists, otherwise the user's global Po composition. */
20
+ export declare function resolvePoConfigurationRoot(start: string, homeDirectory: string): string;
21
21
  //#endregion
22
22
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/repository/index.ts"],"mappings":";;;;;;;;;wBAmCgB,iBAAiB;;;;;;;;wBAiBjB,mBAAmB;;wBAWnB,6BAA6B,eAAe"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/repository/index.ts"],"mappings":";;;;;;;;;wBAmCgB,iBAAiB;;;;;;;;wBAiBjB,mBAAmB;;wBAWnB,2BAA2B,eAAe"}
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { globalDoomConfigDirectory } from "@agimon-ai/po-config/config";
4
- import { hasRepositoryDoomDirectory } from "@agimon-ai/po-core/piSettings";
3
+ import { globalPoConfigDirectory } from "@agimon-ai/po-config/config";
4
+ import { hasRepositoryPoDirectory } from "@agimon-ai/po-core/piSettings";
5
5
  //#region src/composition/repository/index.ts
6
6
  /** Git's root marker, which may be a directory or a worktree pointer file. */
7
7
  const GIT_DIRECTORY = ".git";
@@ -22,22 +22,22 @@ function isFile(target) {
22
22
  }
23
23
  }
24
24
  /**
25
- * True when a directory carries a marker Doom Pi is willing to treat as a root.
25
+ * True when a directory carries a marker Po Pi is willing to treat as a root.
26
26
  *
27
- * Doom and Pi markers identify configured projects. A Git marker also counts so
27
+ * Po and Pi markers identify configured projects. A Git marker also counts so
28
28
  * personal configuration can be synchronized into a new checkout before it has
29
29
  * repository-local configuration. Build-tooling markers remain deliberately
30
30
  * excluded because they do not establish a repository boundary.
31
31
  */
32
32
  function isRepositoryRoot(directory) {
33
33
  const gitMarker = path.join(directory, GIT_DIRECTORY);
34
- return hasRepositoryDoomDirectory(directory) || isFile(path.join(directory, PI_SETTINGS)) || isDirectory(gitMarker) || isFile(gitMarker);
34
+ return hasRepositoryPoDirectory(directory) || isFile(path.join(directory, PI_SETTINGS)) || isDirectory(gitMarker) || isFile(gitMarker);
35
35
  }
36
36
  /**
37
37
  * Walks up from `start` looking for the repository root.
38
38
  *
39
39
  * The nearest marked ancestor wins, so a session started in a subdirectory
40
- * resolves to the repository that configured Doom rather than to a parent
40
+ * resolves to the repository that configured Po rather than to a parent
41
41
  * checkout that happens to sit above it.
42
42
  */
43
43
  function findRepositoryRoot(start) {
@@ -49,15 +49,15 @@ function findRepositoryRoot(start) {
49
49
  directory = parent;
50
50
  }
51
51
  }
52
- /** Uses the nearest repository when one exists, otherwise the user's global Doom composition. */
53
- function resolveDoomConfigurationRoot(start, homeDirectory) {
52
+ /** Uses the nearest repository when one exists, otherwise the user's global Po composition. */
53
+ function resolvePoConfigurationRoot(start, homeDirectory) {
54
54
  try {
55
55
  return findRepositoryRoot(start);
56
56
  } catch {
57
- return globalDoomConfigDirectory(homeDirectory);
57
+ return globalPoConfigDirectory(homeDirectory);
58
58
  }
59
59
  }
60
60
  //#endregion
61
- export { findRepositoryRoot, isRepositoryRoot, resolveDoomConfigurationRoot };
61
+ export { findRepositoryRoot, isRepositoryRoot, resolvePoConfigurationRoot };
62
62
 
63
63
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/repository/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/po-config/config';\nimport { hasRepositoryDoomDirectory } from '@agimon-ai/po-core/piSettings';\n\n/** Git's root marker, which may be a directory or a worktree pointer file. */\nconst GIT_DIRECTORY = '.git';\n/** A Pi project that has been configured, rather than any stray `.pi` folder. */\nconst PI_SETTINGS = path.join('.pi', 'settings.json');\n\nfunction isDirectory(target: string): boolean {\n try {\n return fs.statSync(target).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction isFile(target: string): boolean {\n try {\n return fs.statSync(target).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * True when a directory carries a marker Doom Pi is willing to treat as a root.\n *\n * Doom and Pi markers identify configured projects. A Git marker also counts so\n * personal configuration can be synchronized into a new checkout before it has\n * repository-local configuration. Build-tooling markers remain deliberately\n * excluded because they do not establish a repository boundary.\n */\nexport function isRepositoryRoot(directory: string): boolean {\n const gitMarker = path.join(directory, GIT_DIRECTORY);\n return (\n hasRepositoryDoomDirectory(directory) ||\n isFile(path.join(directory, PI_SETTINGS)) ||\n isDirectory(gitMarker) ||\n isFile(gitMarker)\n );\n}\n\n/**\n * Walks up from `start` looking for the repository root.\n *\n * The nearest marked ancestor wins, so a session started in a subdirectory\n * resolves to the repository that configured Doom rather than to a parent\n * checkout that happens to sit above it.\n */\nexport function findRepositoryRoot(start: string): string {\n let directory = path.resolve(start);\n while (true) {\n if (isRepositoryRoot(directory)) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`Could not find repository root from ${start}`);\n directory = parent;\n }\n}\n\n/** Uses the nearest repository when one exists, otherwise the user's global Doom composition. */\nexport function resolveDoomConfigurationRoot(start: string, homeDirectory: string): string {\n try {\n return findRepositoryRoot(start);\n } catch {\n return globalDoomConfigDirectory(homeDirectory);\n }\n}\n"],"mappings":";;;;;;AAOA,MAAM,gBAAgB;;AAEtB,MAAM,cAAc,KAAK,KAAK,OAAO,eAAe;AAEpD,SAAS,YAAY,QAAyB;CAC5C,IAAI;EACF,OAAO,GAAG,SAAS,MAAM,CAAC,CAAC,YAAY;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,OAAO,QAAyB;CACvC,IAAI;EACF,OAAO,GAAG,SAAS,MAAM,CAAC,CAAC,OAAO;CACpC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,WAA4B;CAC3D,MAAM,YAAY,KAAK,KAAK,WAAW,aAAa;CACpD,OACE,2BAA2B,SAAS,KACpC,OAAO,KAAK,KAAK,WAAW,WAAW,CAAC,KACxC,YAAY,SAAS,KACrB,OAAO,SAAS;AAEpB;;;;;;;;AASA,SAAgB,mBAAmB,OAAuB;CACxD,IAAI,YAAY,KAAK,QAAQ,KAAK;CAClC,OAAO,MAAM;EACX,IAAI,iBAAiB,SAAS,GAAG,OAAO;EACxC,MAAM,SAAS,KAAK,QAAQ,SAAS;EACrC,IAAI,WAAW,WAAW,MAAM,IAAI,MAAM,uCAAuC,OAAO;EACxF,YAAY;CACd;AACF;;AAGA,SAAgB,6BAA6B,OAAe,eAA+B;CACzF,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,QAAQ;EACN,OAAO,0BAA0B,aAAa;CAChD;AACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/composition/repository/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { hasRepositoryPoDirectory } from '@agimon-ai/po-core/piSettings';\n\n/** Git's root marker, which may be a directory or a worktree pointer file. */\nconst GIT_DIRECTORY = '.git';\n/** A Pi project that has been configured, rather than any stray `.pi` folder. */\nconst PI_SETTINGS = path.join('.pi', 'settings.json');\n\nfunction isDirectory(target: string): boolean {\n try {\n return fs.statSync(target).isDirectory();\n } catch {\n return false;\n }\n}\n\nfunction isFile(target: string): boolean {\n try {\n return fs.statSync(target).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * True when a directory carries a marker Po Pi is willing to treat as a root.\n *\n * Po and Pi markers identify configured projects. A Git marker also counts so\n * personal configuration can be synchronized into a new checkout before it has\n * repository-local configuration. Build-tooling markers remain deliberately\n * excluded because they do not establish a repository boundary.\n */\nexport function isRepositoryRoot(directory: string): boolean {\n const gitMarker = path.join(directory, GIT_DIRECTORY);\n return (\n hasRepositoryPoDirectory(directory) ||\n isFile(path.join(directory, PI_SETTINGS)) ||\n isDirectory(gitMarker) ||\n isFile(gitMarker)\n );\n}\n\n/**\n * Walks up from `start` looking for the repository root.\n *\n * The nearest marked ancestor wins, so a session started in a subdirectory\n * resolves to the repository that configured Po rather than to a parent\n * checkout that happens to sit above it.\n */\nexport function findRepositoryRoot(start: string): string {\n let directory = path.resolve(start);\n while (true) {\n if (isRepositoryRoot(directory)) return directory;\n const parent = path.dirname(directory);\n if (parent === directory) throw new Error(`Could not find repository root from ${start}`);\n directory = parent;\n }\n}\n\n/** Uses the nearest repository when one exists, otherwise the user's global Po composition. */\nexport function resolvePoConfigurationRoot(start: string, homeDirectory: string): string {\n try {\n return findRepositoryRoot(start);\n } catch {\n return globalPoConfigDirectory(homeDirectory);\n }\n}\n"],"mappings":";;;;;;AAOA,MAAM,gBAAgB;;AAEtB,MAAM,cAAc,KAAK,KAAK,OAAO,eAAe;AAEpD,SAAS,YAAY,QAAyB;CAC5C,IAAI;EACF,OAAO,GAAG,SAAS,MAAM,CAAC,CAAC,YAAY;CACzC,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,OAAO,QAAyB;CACvC,IAAI;EACF,OAAO,GAAG,SAAS,MAAM,CAAC,CAAC,OAAO;CACpC,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;AAUA,SAAgB,iBAAiB,WAA4B;CAC3D,MAAM,YAAY,KAAK,KAAK,WAAW,aAAa;CACpD,OACE,yBAAyB,SAAS,KAClC,OAAO,KAAK,KAAK,WAAW,WAAW,CAAC,KACxC,YAAY,SAAS,KACrB,OAAO,SAAS;AAEpB;;;;;;;;AASA,SAAgB,mBAAmB,OAAuB;CACxD,IAAI,YAAY,KAAK,QAAQ,KAAK;CAClC,OAAO,MAAM;EACX,IAAI,iBAAiB,SAAS,GAAG,OAAO;EACxC,MAAM,SAAS,KAAK,QAAQ,SAAS;EACrC,IAAI,WAAW,WAAW,MAAM,IAAI,MAAM,uCAAuC,OAAO;EACxF,YAAY;CACd;AACF;;AAGA,SAAgB,2BAA2B,OAAe,eAA+B;CACvF,IAAI;EACF,OAAO,mBAAmB,KAAK;CACjC,QAAQ;EACN,OAAO,wBAAwB,aAAa;CAC9C;AACF"}
@@ -17,6 +17,7 @@ let node_child_process = require("node:child_process");
17
17
  let _agimon_ai_po_config_config = require("@agimon-ai/po-config/config");
18
18
  let _agimon_ai_po_config_majorModes = require("@agimon-ai/po-config/majorModes");
19
19
  let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
20
+ let _agimon_ai_po_core_moduleResolution = require("@agimon-ai/po-core/moduleResolution");
20
21
  let node_crypto = require("node:crypto");
21
22
  node_crypto = require_runtime.__toESM(node_crypto, 1);
22
23
  let _agimon_ai_po_core_history = require("@agimon-ai/po-core/history");
@@ -174,7 +175,7 @@ function webPluginRootsOf(globalRoot, rootPackageRoots, environment) {
174
175
  * leaves it out of the build when it cannot compose it.
175
176
  */
176
177
  function globalWebPluginRoots(targetRoot, homeDirectory, environment, onNotice) {
177
- const globalRoot = (0, _agimon_ai_po_config_config.globalDoomConfigDirectory)(homeDirectory);
178
+ const globalRoot = (0, _agimon_ai_po_config_config.globalPoConfigDirectory)(homeDirectory);
178
179
  const admitted = workspaceRegistry(homeDirectory, environment, onNotice).list().map((workspace) => workspace.root).filter((root) => node_fs.default.existsSync(root));
179
180
  return webPluginRootsOf(globalRoot, packageRootsByRoot(composeRoots([.../* @__PURE__ */ new Set([
180
181
  globalRoot,
@@ -230,14 +231,14 @@ function resolveRoots(options, progress) {
230
231
  ...repository === void 0 ? [] : [repository]
231
232
  ])];
232
233
  }
233
- /** The packages a root's layers name by local path, each resolved against its layer's base directory. */
234
- function localPackages(config) {
234
+ /** Local-path selections and checkout test overrides, stamped and built by the same local build pipeline. */
235
+ function localPackages(config, environment) {
235
236
  const definitions = [...config.default ? [config.default] : [], ...Object.values(config.layers)];
236
237
  const packages = /* @__PURE__ */ new Map();
237
238
  for (const definition of definitions) for (const configured of definition.packages ?? []) {
238
239
  const selector = typeof configured === "string" ? configured : configured.name;
239
- if (!(0, _agimon_ai_po_config_majorModes.isLocalPackageSpecifier)(selector)) continue;
240
- const directory = node_path.default.resolve(definition.baseDirectory, selector);
240
+ const directory = (0, _agimon_ai_po_config_majorModes.isLocalPackageSpecifier)(selector) ? node_path.default.resolve(definition.baseDirectory, selector) : (0, _agimon_ai_po_core_moduleResolution.testPackageRoot)((0, _agimon_ai_po_core_moduleResolution.splitPackageSpecifier)(selector).name, environment);
241
+ if (directory === void 0) continue;
241
242
  if (!packages.has(directory)) packages.set(directory, {
242
243
  selector,
243
244
  directory
@@ -278,7 +279,8 @@ function poPackageVersion() {
278
279
  * refuses that pointer's builds and syncs with its own install.
279
280
  */
280
281
  function syncHostIdentity(globalRoot, environment) {
281
- return `po@${poPackageVersion()}+po-web@${require_index.webHostVersion(globalRoot, environment)}`;
282
+ const checkout = environment.PO_TEST === "1" && environment.PO_TEST_PACKAGES ? `+checkout@${node_crypto.default.createHash("sha256").update(environment.PO_TEST_PACKAGES).digest("hex")}` : "";
283
+ return `po@${poPackageVersion()}+po-web@${require_index.webHostVersion(globalRoot, environment)}${checkout}`;
282
284
  }
283
285
  /** The fast-exit signature: catalogue hash, each root's selection and local build stamps, host identity. */
284
286
  function syncSignature(options, roots, catalogueHash) {
@@ -289,7 +291,7 @@ function syncSignature(options, roots, catalogueHash) {
289
291
  roots: roots.map((root) => ({
290
292
  root,
291
293
  selection: rootSelectionFingerprint(root, homeDirectory, environment),
292
- local: localPackages((0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config).map(({ directory }) => [directory, require_localBuilds.localBuildStamp(directory)])
294
+ local: localPackages((0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config, environment).map(({ directory }) => [directory, require_localBuilds.localBuildStamp(directory)])
293
295
  })),
294
296
  host: syncHostIdentity(options.globalRoot, environment)
295
297
  };
@@ -507,6 +509,24 @@ function realPath(file) {
507
509
  }
508
510
  }
509
511
  /**
512
+ * Whether the MCP app build the server will look for exists for every root. Its key hashes the
513
+ * widget packages' built files, which the signature does not cover, so a rebuilt `dist/` moves
514
+ * the key without moving the signature.
515
+ */
516
+ function mcpAppsBuilt(globalRoot, roots, homeDirectory, environment) {
517
+ for (const compositions of composeRoots(roots, homeDirectory, environment).values()) {
518
+ if (compositions instanceof Error) continue;
519
+ let key;
520
+ try {
521
+ key = require_mcpAppBuild.mcpAppKey(require_mcpBundle.mcpPluginCandidates(compositions));
522
+ } catch {
523
+ return false;
524
+ }
525
+ if (key !== void 0 && !node_fs.default.existsSync(node_path.default.join(globalRoot, BUILD_DIRECTORY, "mcp-app", key, MCP_APP_FILE))) return false;
526
+ }
527
+ return true;
528
+ }
529
+ /**
510
530
  * One sync pass under the lock. A failed step ends the pass with a `failed` report and leaves
511
531
  * the pointer alone; a lock that no longer names this holder (`lost`) ends it as busy.
512
532
  */
@@ -517,7 +537,7 @@ async function syncOnce(options, deps, emit, lost) {
517
537
  const roots = resolveRoots(options, progress);
518
538
  const catalogueHash = require_index$2.packageCatalogHash(environment);
519
539
  const previous = readSyncPointer(globalRoot);
520
- if (previous !== void 0 && (options.origin === "background" || previous.roots.every((root) => root.unsynced.length === 0)) && previous.signature === syncSignature(options, roots, catalogueHash) && pointerArtifacts(globalRoot, previous).every((file) => node_fs.default.existsSync(file))) {
540
+ if (previous !== void 0 && (options.origin === "background" || previous.roots.every((root) => root.unsynced.length === 0)) && previous.signature === syncSignature(options, roots, catalogueHash) && pointerArtifacts(globalRoot, previous).every((file) => node_fs.default.existsSync(file)) && mcpAppsBuilt(globalRoot, roots, homeDirectory, environment)) {
521
541
  progress.line(ROOTS_LABEL, `nothing changed since generation ${String(previous.generation)}`);
522
542
  return {
523
543
  ...emptyReport("noop", [], deps),
@@ -575,7 +595,7 @@ async function syncOnce(options, deps, emit, lost) {
575
595
  return report("failed", [`Installing packages failed: ${errorMessage(error)}`], null, []);
576
596
  }
577
597
  packagesDone(packageSummary(packages));
578
- const localByRoot = new Map(roots.map((root) => [root, localPackages((0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config)]));
598
+ const localByRoot = new Map(roots.map((root) => [root, localPackages((0, _agimon_ai_po_config_majorModes.loadMajorModesConfigLenient)(root, homeDirectory, environment).config, environment)]));
579
599
  const localDirectories = [...localByRoot.values()].flat().map(({ directory }) => directory);
580
600
  if (localDirectories.length > 0) {
581
601
  const localDone = progress.start(LOCAL_LABEL, "building local packages");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["path","ensureLayerPackages","ensureGlobalWebBuild","ensureGlobalNativeBuild","ensureMcpAppBuild","pruneAfterSync","createWorkspaceRegistry","piAgentDirectory","rootCompositions","compositionPackageRoots","catalogPackageRoots","globalDoomConfigDirectory","fs","identifyWorkspace","readWorkspaceMarker","isLocalPackageSpecifier","crypto","poPackageRoot","webHostVersion","loadMajorModesConfigLenient","localBuildStamp","BUILD_RECORD","spawnSync","packageCatalogHash","catalogInstallSpecifiers","runtimeLayerPackageSpecifiers","buildLocalPackages","mcpPluginCandidates","duplicatePluginCopies"],"sources":["../../../../src/composition/syncService/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalDoomConfigDirectory } from '@agimon-ai/po-config/config';\nimport { isLocalPackageSpecifier, loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport {\n createWorkspaceRegistry,\n identifyWorkspace,\n readWorkspaceMarker,\n type WorkspaceRegistry,\n writeWorkspaceMarker,\n} from '@agimon-ai/po-core/history';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\nimport { writeFileAtomic } from '@agimon-ai/po-core/runtimeJson';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { rootCompositions } from '../../builders/cli/sessionComposition';\nimport { ensureGlobalNativeBuild } from '../../builders/native';\nimport { ensureMcpAppBuild } from '../../builders/server/mcpAppBuild';\nimport { mcpPluginCandidates } from '../../builders/server/mcpBundle';\nimport {\n BUILD_RECORD,\n compositionPackageRoots,\n duplicatePluginCopies,\n ensureGlobalWebBuild,\n webHostVersion,\n} from '../../builders/web';\nimport {\n catalogInstallSpecifiers,\n catalogPackageRoots,\n ensureLayerPackages,\n type LayerPackageResult,\n packageCatalogHash,\n runtimeLayerPackageSpecifiers,\n} from '../layerPackageInstaller';\nimport { pruneAfterSync, type SyncPruneInput } from '../syncPrune';\nimport { buildLocalPackages, type LocalPackage, localBuildStamp } from './localBuilds';\n\nexport { localBuildStamp } from './localBuilds';\n\n/**\n * The sync service: installs what the configuration names, ensures the global builds,\n * prunes, and reports what happened as one `SyncReport`.\n *\n * The roots are the Po home, every registered workspace whose folder exists, and the\n * repository sync runs from, which it registers. One install covers the catalogue and every\n * root's published packages. When the signature over the catalogue, each root's selection,\n * each local package's build stamp and the host identity (the po package and po-web host\n * versions) matches `current.json` and every artifact it names exists, sync returns `noop`\n * without installing or building. The pointer records that identity, so a server from another\n * Po install can tell the build is not its own.\n *\n * Only one sync runs at a time per Po home, guarded by `<po home>/build/.sync.lock`. A CLI\n * run that finds the lock held reports `busy`. A background run instead leaves\n * `.sync.rerun`, and the holder runs once more, so the background request is never lost.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst LOCK_FILE = '.sync.lock';\nconst RERUN_FILE = '.sync.rerun';\nconst POINTER_FILE = 'current.json';\nconst LAST_ATTEMPT_FILE = 'last-attempt.json';\nconst MCP_APP_FILE = 'index.html';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst ROOTS_LABEL = 'roots';\nconst PACKAGES_LABEL = 'packages';\nconst WEB_LABEL = 'web';\nconst NATIVE_LABEL = 'native';\nconst MCP_LABEL = 'mcp app';\nconst PRUNE_LABEL = 'prune';\nconst HOOKS_LABEL = 'hooks';\nconst LOCAL_LABEL = 'local';\nconst BYTES_PER_MEGABYTE = 1024 * 1024;\n/** A lock file younger than this that cannot be parsed is still being written by its owner. */\nconst UNREADABLE_LOCK_GRACE_MS = 10_000;\nconst NO_SUCH_PROCESS = 'ESRCH';\n/**\n * Bumped when the pointer gains a field a reader relies on, so an older pointer never matches\n * the fast-exit signature and the next sync rewrites it. 2: per-root `fingerprints`. 3: `host`.\n */\nconst SIGNATURE_FORMAT = 3;\nconst PACKAGE_MANIFEST = 'package.json';\nconst ALREADY_EXISTS = 'EEXIST';\nconst NO_SUCH_FILE = 'ENOENT';\n\nexport const SYNC_EXIT_OK = 0;\nexport const SYNC_EXIT_FAILED = 1;\n/** EX_TEMPFAIL: another sync holds the lock. */\nexport const SYNC_EXIT_BUSY = 75;\n\nexport type SyncOrigin = 'cli' | 'background';\nexport type SyncStatus = 'ok' | 'noop' | 'partial' | 'failed' | 'busy';\n\nexport interface SyncResult {\n packages: Pick<LayerPackageResult, 'installed' | 'updated' | 'unchecked'>;\n /** The global web build key, or why there is none. */\n web: { status: 'built' | 'cached'; key: string } | { status: 'skipped'; reason: string };\n /** The global native build key, or why there is none. */\n native?: { status: 'built' | 'cached'; key: string } | { status: 'skipped'; reason: string };\n /** The MCP app build keys, comma separated, when any root's packages declare MCP UI widgets. */\n mcpApp?: string;\n}\n\nexport interface SyncRootReport {\n root: string;\n status: 'ok' | 'partial' | 'failed';\n unsynced: { selector: string; reason: string; stderr?: string[] }[];\n}\n\nexport interface SyncReport {\n status: SyncStatus;\n /** Assigned once sync writes a pointer; null until then. */\n generation: number | null;\n /** Assigned once sync computes the fast-exit signature; null until then. */\n catalogueHash: string | null;\n webKey: string | null;\n mcpKeys: string[];\n roots: SyncRootReport[];\n /** External commands sync ran, such as local package builds. */\n commands: string[];\n errors: string[];\n finishedAt: string;\n}\n\n/** One progress event; the CLI renders these as text or as JSON lines. */\nexport type SyncEvent =\n | { type: 'start'; label: string; message: string }\n | { type: 'line'; label: string; message: string }\n | { type: 'done'; label: string; summary: string }\n | { type: 'result'; result: SyncResult };\n\nexport interface SyncLockHolder {\n pid: number;\n /** Unique per acquisition, so a holder can tell its lock from a later one, even under its pid. */\n token?: string;\n startedAt: string;\n origin: SyncOrigin;\n}\n\nexport interface SyncOptions {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The Po home every global build and the lock live under. */\n globalRoot: string;\n /**\n * The repository sync runs from: registered as a workspace, synced as a root, and its hooks\n * regenerated. Undefined with `--global`, which registers nothing.\n */\n repoRoot?: string;\n origin: SyncOrigin;\n onEvent?: (event: SyncEvent) => void;\n}\n\nexport interface SyncDeps {\n install: typeof ensureLayerPackages;\n buildWeb: typeof ensureGlobalWebBuild;\n buildNative: typeof ensureGlobalNativeBuild;\n bundleMcpApp: typeof ensureMcpAppBuild;\n prune: typeof pruneAfterSync;\n /** Whether a lock holder's process still runs. */\n isAlive: (pid: number) => boolean;\n pid: number;\n now: () => Date;\n}\n\n/** `process.kill(pid, 0)` probes without signalling; only ESRCH means the process is gone. */\nexport function processIsAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means it runs under another user, which still holds the lock.\n return (error as NodeJS.ErrnoException).code !== NO_SUCH_PROCESS;\n }\n}\n\nconst DEFAULT_DEPS: SyncDeps = {\n install: ensureLayerPackages,\n buildWeb: ensureGlobalWebBuild,\n buildNative: ensureGlobalNativeBuild,\n bundleMcpApp: ensureMcpAppBuild,\n prune: pruneAfterSync,\n isAlive: processIsAlive,\n pid: process.pid,\n now: () => new Date(),\n};\n\nexport function syncExitCode(status: SyncStatus): number {\n if (status === 'busy') return SYNC_EXIT_BUSY;\n return status === 'ok' || status === 'noop' ? SYNC_EXIT_OK : SYNC_EXIT_FAILED;\n}\n\nexport function syncLockPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, LOCK_FILE);\n}\n\nexport function syncRerunPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, RERUN_FILE);\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${String(count)} ${noun}${count === 1 ? '' : 's'}`;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction packageSummary(result: SyncResult['packages']): string {\n const parts: string[] = [];\n if (result.updated.length > 0) parts.push(`updated ${pluralize(result.updated.length, 'package')}`);\n if (result.installed.length > 0) parts.push(`installed ${pluralize(result.installed.length, 'missing package')}`);\n if (parts.length === 0) parts.push('already up to date');\n if (result.unchecked.length > 0) parts.push(`${pluralize(result.unchecked.length, 'package')} left unchecked`);\n return parts.join(', ');\n}\n\nexport function formatSyncResult(result: SyncResult): string {\n return [\n `packages: ${packageSummary(result.packages)}`,\n `web: ${result.web.status === 'skipped' ? result.web.reason : `${result.web.key} (${result.web.status})`}`,\n ...(result.native === undefined\n ? []\n : [\n `native: ${result.native.status === 'skipped' ? result.native.reason : `${result.native.key} (${result.native.status})`}`,\n ]),\n ...(result.mcpApp === undefined ? [] : [`mcp app: ${result.mcpApp}`]),\n '',\n ].join('\\n');\n}\n\nfunction workspaceRegistry(\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): WorkspaceRegistry {\n return createWorkspaceRegistry({\n directory: path.join(piAgentDirectory(environment, homeDirectory), 'server'),\n onNotice,\n });\n}\n\ntype RootCompositions = ReturnType<typeof rootCompositions>;\n\n/**\n * Each root's compositions, resolved the way the server resolves them: a selection that does\n * not resolve yet (an unbuilt local package, say) is left out with a diagnostic instead of\n * failing the whole root, so sync and the server derive the same web, MCP and fingerprint\n * inputs. A root that cannot be composed at all maps to why.\n */\nfunction composeRoots(\n roots: readonly string[],\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): Map<string, RootCompositions | Error> {\n return new Map(\n roots.map((root): [string, RootCompositions | Error] => {\n try {\n return [root, rootCompositions({ root, homeDirectory, environment, tolerateUnsynced: true })];\n } catch (error) {\n return [root, error instanceof Error ? error : new Error(String(error))];\n }\n }),\n );\n}\n\n/** Each root's composition package roots; a root that cannot be composed is left out with a notice. */\nfunction packageRootsByRoot(\n composed: ReadonlyMap<string, RootCompositions | Error>,\n onNotice: (message: string) => void,\n): Map<string, string[]> {\n return new Map(\n [...composed].map(([root, compositions]) => {\n if (!(compositions instanceof Error)) return [root, compositionPackageRoots(compositions)];\n onNotice(`'${root}' is left out of the web build: ${compositions.message}`);\n return [root, []];\n }),\n );\n}\n\n/** The selectors a lenient composition left out, each once with the first diagnostic that explains it. */\nfunction skippedSelections(compositions: RootCompositions): SyncRootReport['unsynced'] {\n const skipped = new Map<string, string>();\n for (const composition of compositions)\n for (const selection of composition.selections)\n if (selection.outcome === 'missing-optional' && !selection.optional && !skipped.has(selection.selector))\n skipped.set(selection.selector, selection.diagnostic ?? 'it does not resolve');\n return [...skipped].map(([selector, reason]) => ({ selector, reason }));\n}\n\n/**\n * The plugin roots one global web build covers: every installed catalogue package, so each\n * first-party plugin has a slot whether or not a config names it yet, then each root's own\n * composition package roots. Sync builds with these and the server derives the same key.\n */\nfunction webPluginRootsOf(\n globalRoot: string,\n rootPackageRoots: ReadonlyMap<string, readonly string[]>,\n environment: NodeJS.ProcessEnv,\n): string[] {\n return [...catalogPackageRoots(globalRoot, environment), ...[...rootPackageRoots.values()].flat()];\n}\n\n/**\n * Every package root the global web build covers: the catalogue packages, the global root,\n * every workspace the server has admitted, and `targetRoot`, which the server admits when it\n * opens it. A root whose configuration cannot be read is left out with a notice, as sync\n * leaves it out of the build when it cannot compose it.\n */\nexport function globalWebPluginRoots(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): string[] {\n const globalRoot = globalDoomConfigDirectory(homeDirectory);\n const admitted = workspaceRegistry(homeDirectory, environment, onNotice)\n .list()\n .map((workspace) => workspace.root)\n .filter((root) => fs.existsSync(root));\n const roots = [...new Set([globalRoot, ...admitted, targetRoot])];\n return webPluginRootsOf(\n globalRoot,\n packageRootsByRoot(composeRoots(roots, homeDirectory, environment), onNotice),\n environment,\n );\n}\n\n/**\n * Registers the repository as a workspace the way the server admits one, so one repository\n * never gets two ids, and returns the workspace root it belongs to.\n */\nfunction registerRepository(\n registry: WorkspaceRegistry,\n repoRoot: string,\n onNotice: (message: string) => void,\n): string {\n const checkoutRoot = fs.realpathSync(repoRoot);\n const { id, root, moved } = identifyWorkspace({\n records: registry.list(),\n checkoutRoot,\n marker: readWorkspaceMarker(checkoutRoot),\n });\n const record = registry.list().find((workspace) => workspace.id === id);\n if (record === undefined || moved)\n registry.add({ id, root, ...(record?.name === undefined ? {} : { name: record.name }) });\n if (moved) onNotice(`workspace '${id}' moved to '${root}'`);\n try {\n if (readWorkspaceMarker(root) === undefined) writeWorkspaceMarker(root, id);\n } catch (error) {\n onNotice(`'${root}' id could not be recorded in its git data: ${errorMessage(error)}`);\n }\n return root;\n}\n\n/**\n * The roots this sync covers: the Po home, every registered workspace whose folder exists,\n * and the repository, registered first. Entries whose folder is gone are removed with a warning.\n */\nfunction resolveRoots(options: SyncOptions, progress: Steps): string[] {\n const notice = (message: string): void => progress.line(ROOTS_LABEL, message);\n const registry = workspaceRegistry(options.homeDirectory, options.environment, notice);\n const repository =\n options.repoRoot === undefined || path.resolve(options.repoRoot) === path.resolve(options.globalRoot)\n ? undefined\n : registerRepository(registry, options.repoRoot, notice);\n const live: string[] = [];\n for (const workspace of registry.list()) {\n if (fs.existsSync(workspace.root)) {\n live.push(workspace.root);\n continue;\n }\n notice(`warning: removed workspace '${workspace.id}': '${workspace.root}' no longer exists`);\n registry.remove(workspace.id);\n }\n return [...new Set([options.globalRoot, ...live, ...(repository === undefined ? [] : [repository])])];\n}\n\n/** The packages a root's layers name by local path, each resolved against its layer's base directory. */\nfunction localPackages(config: ReturnType<typeof loadMajorModesConfigLenient>['config']): LocalPackage[] {\n const definitions = [...(config.default ? [config.default] : []), ...Object.values(config.layers)];\n const packages = new Map<string, LocalPackage>();\n for (const definition of definitions)\n for (const configured of definition.packages ?? []) {\n const selector = typeof configured === 'string' ? configured : configured.name;\n if (!isLocalPackageSpecifier(selector)) continue;\n const directory = path.resolve(definition.baseDirectory, selector);\n if (!packages.has(directory)) packages.set(directory, { selector, directory });\n }\n return [...packages.values()];\n}\n\n/**\n * SHA-256 over every mode's composition fingerprint, or why the root cannot be composed. The\n * pointer records it per root, so a server can tell a root whose selection changed since the\n * last sync by computing it again with the environment sync ran under.\n */\nexport function rootSelectionFingerprint(root: string, homeDirectory: string, environment: NodeJS.ProcessEnv): string {\n try {\n const fingerprints = rootCompositions({ root, homeDirectory, environment, tolerateUnsynced: true }).map(\n (composition) => composition.fingerprint,\n );\n return crypto.createHash('sha256').update(fingerprints.join('\\n')).digest('hex');\n } catch (error) {\n return `unresolved:${errorMessage(error)}`;\n }\n}\n\n/** The po package version this process runs from, or why it cannot be read. */\nfunction poPackageVersion(): string {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(poPackageRoot(), PACKAGE_MANIFEST), 'utf8')) as {\n version?: unknown;\n };\n return typeof manifest.version === 'string' ? manifest.version : 'unversioned';\n } catch (error) {\n return `unreadable:${errorMessage(error)}`;\n }\n}\n\n/**\n * The Po install a sync or a server runs from: its po package version and the po-web host\n * version it builds with. Sync records it in the pointer; a server whose identity differs\n * refuses that pointer's builds and syncs with its own install.\n */\nexport function syncHostIdentity(globalRoot: string, environment: NodeJS.ProcessEnv): string {\n return `po@${poPackageVersion()}+po-web@${webHostVersion(globalRoot, environment)}`;\n}\n\n/** The fast-exit signature: catalogue hash, each root's selection and local build stamps, host identity. */\nfunction syncSignature(options: SyncOptions, roots: readonly string[], catalogueHash: string): string {\n const { homeDirectory, environment } = options;\n const value = {\n format: SIGNATURE_FORMAT,\n catalogueHash,\n roots: roots.map((root) => ({\n root,\n selection: rootSelectionFingerprint(root, homeDirectory, environment),\n local: localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config).map(\n ({ directory }) => [directory, localBuildStamp(directory)],\n ),\n })),\n host: syncHostIdentity(options.globalRoot, environment),\n };\n return crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex');\n}\n\n/** `current.json`: the last successful report minus its transient fields, plus what fast exit needs. */\nexport interface SyncPointer {\n generation: number;\n signature: string;\n catalogueHash: string;\n webKey: string | null;\n nativeKey: string | null;\n mcpKeys: string[];\n roots: SyncRootReport[];\n commands: string[];\n /** Each root's `rootSelectionFingerprint` at the time of the sync; absent in older pointers. */\n fingerprints?: Record<string, string>;\n /** The `syncHostIdentity` of the install that wrote the pointer; absent in older pointers. */\n host?: string;\n}\n\nexport function syncPointerPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, POINTER_FILE);\n}\n\nexport function syncLastAttemptPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, LAST_ATTEMPT_FILE);\n}\n\n/** The current pointer, or undefined when sync has not written one yet or it is unreadable. */\nexport function readSyncPointer(globalRoot: string): SyncPointer | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(syncPointerPath(globalRoot), 'utf8')) as Partial<SyncPointer>;\n return typeof parsed.signature === 'string' && typeof parsed.generation === 'number'\n ? (parsed as SyncPointer)\n : undefined;\n } catch {\n // Missing or unreadable: there is nothing to fast-exit against.\n return undefined;\n }\n}\n\n/** The files whose presence proves each artifact a pointer names is complete. */\nfunction pointerArtifacts(\n globalRoot: string,\n pointer: Pick<SyncPointer, 'webKey' | 'nativeKey' | 'mcpKeys'>,\n): string[] {\n const build = path.join(globalRoot, BUILD_DIRECTORY);\n return [\n ...(pointer.webKey === null ? [] : [path.join(build, WEB_LABEL, pointer.webKey, BUILD_RECORD)]),\n ...(pointer.nativeKey === null ? [] : [path.join(build, NATIVE_LABEL, pointer.nativeKey, BUILD_RECORD)]),\n ...pointer.mcpKeys.map((key) => path.join(build, 'mcp-app', key, MCP_APP_FILE)),\n ];\n}\n\n/** The report of the last sync attempt, successful or not, or undefined when there is none. */\nexport function readSyncLastAttempt(globalRoot: string): SyncReport | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(syncLastAttemptPath(globalRoot), 'utf8')) as Partial<SyncReport>;\n return Array.isArray(parsed.roots) ? (parsed as SyncReport) : undefined;\n } catch {\n // Missing or unreadable: no attempt to report reasons from.\n return undefined;\n }\n}\n\nfunction writeJsonFile(file: string, value: unknown): void {\n writeFileAtomic(file, `${JSON.stringify(value, null, 2)}\\n`);\n}\n\ntype LockAttempt = { acquired: true; token: string } | { acquired: false; holder: SyncLockHolder | undefined };\n\nfunction readHolder(lockPath: string): SyncLockHolder | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(lockPath, 'utf8')) as Partial<SyncLockHolder>;\n return typeof parsed.pid === 'number' ? (parsed as SyncLockHolder) : undefined;\n } catch {\n // Missing or half-written: the caller decides from the file's age.\n return undefined;\n }\n}\n\nfunction lockIsStale(lockPath: string, deps: SyncDeps): boolean {\n const holder = readHolder(lockPath);\n if (holder !== undefined) return !deps.isAlive(holder.pid);\n try {\n return deps.now().getTime() - fs.statSync(lockPath).mtimeMs > UNREADABLE_LOCK_GRACE_MS;\n } catch {\n // Gone between the failed create and this check: free to retry.\n return true;\n }\n}\n\nfunction tryCreateLock(lockPath: string, holder: SyncLockHolder): boolean {\n try {\n const descriptor = fs.openSync(lockPath, 'wx');\n try {\n fs.writeSync(descriptor, JSON.stringify(holder));\n } finally {\n fs.closeSync(descriptor);\n }\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === ALREADY_EXISTS) return false;\n throw error;\n }\n}\n\n/**\n * Takes over a lock judged stale. Removing it by path could remove a lock another taker created\n * since the check, so it is first renamed to a name only this process knows and checked again\n * there: a lock that turns out live is linked back (link never replaces), a stale one is dropped\n * before the exclusive create, which at most one taker wins.\n */\nfunction takeOverStaleLock(lockPath: string, holder: SyncLockHolder, deps: SyncDeps): boolean {\n const moved = `${lockPath}.${String(deps.pid)}.${crypto.randomUUID()}.stale`;\n try {\n fs.renameSync(lockPath, moved);\n } catch (error) {\n // Already gone: released, or moved by another taker; the create decides.\n if ((error as NodeJS.ErrnoException).code === NO_SUCH_FILE) return tryCreateLock(lockPath, holder);\n throw error;\n }\n try {\n if (!lockIsStale(moved, deps)) {\n try {\n fs.linkSync(moved, lockPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== ALREADY_EXISTS) throw error;\n }\n return false;\n }\n } finally {\n fs.rmSync(moved, { force: true });\n }\n return tryCreateLock(lockPath, holder);\n}\n\n/** Creates the lock, taking over one whose holder is dead. Never inspects other processes beyond `kill(pid, 0)`. */\nfunction acquireLock(lockPath: string, origin: SyncOrigin, deps: SyncDeps): LockAttempt {\n fs.mkdirSync(path.dirname(lockPath), { recursive: true });\n const token = crypto.randomUUID();\n const holder: SyncLockHolder = { pid: deps.pid, token, startedAt: deps.now().toISOString(), origin };\n if (tryCreateLock(lockPath, holder)) return { acquired: true, token };\n // A racing taker that wins the takeover makes this attempt report busy, as it should.\n if (lockIsStale(lockPath, deps) && takeOverStaleLock(lockPath, holder, deps)) return { acquired: true, token };\n return { acquired: false, holder: readHolder(lockPath) };\n}\n\n/**\n * The lock as the holder with `token` sees it: undefined while the lock still names it, else\n * the busy report to stop with. A takeover that moved a live lock aside can let a third taker\n * create a new one, so a holder checks before each step whose overlap would do harm.\n */\nfunction lostLock(lockPath: string, token: string, deps: SyncDeps): SyncReport | undefined {\n const holder = readHolder(lockPath);\n if (holder?.token === token) return undefined;\n const by = holder === undefined ? 'another process' : `pid ${String(holder.pid)}`;\n return emptyReport('busy', [`po sync lost its lock to ${by}`], deps);\n}\n\nfunction releaseLock(lockPath: string, token: string): void {\n if (readHolder(lockPath)?.token === token) fs.rmSync(lockPath, { force: true });\n}\n\n/** Consumes the rerun marker; true when a background run asked for another pass. */\nfunction takeRerunRequest(rerunPath: string): boolean {\n if (!fs.existsSync(rerunPath)) return false;\n fs.rmSync(rerunPath, { force: true });\n return true;\n}\n\nfunction emptyReport(status: SyncStatus, errors: string[], deps: SyncDeps): SyncReport {\n return {\n status,\n generation: null,\n catalogueHash: null,\n webKey: null,\n mcpKeys: [],\n roots: [],\n commands: [],\n errors,\n finishedAt: deps.now().toISOString(),\n };\n}\n\n/** A step reporter over the event stream, mirroring the presenter's start/done/line. */\nfunction steps(emit: (event: SyncEvent) => void) {\n return {\n start(label: string, message: string): (summary: string) => void {\n emit({ type: 'start', label, message });\n return (summary) => emit({ type: 'done', label, summary });\n },\n line(label: string, message: string): void {\n emit({ type: 'line', label, message });\n },\n };\n}\n\ntype Steps = ReturnType<typeof steps>;\n\n/**\n * Drops old builds and unreferenced store content once installs and builds are done.\n * Never fatal: a failed prune leaves everything for the next explicit sync.\n */\nasync function pruneStep(progress: Steps, prune: SyncDeps['prune'], input: SyncPruneInput): Promise<void> {\n const done = progress.start(PRUNE_LABEL, 'dropping old builds and unused packages');\n try {\n const result = await prune(input);\n const runtime =\n 'skipped' in result.runtime\n ? result.runtime.skipped\n : `${(result.runtime.bytes / BYTES_PER_MEGABYTE).toFixed(1)} MB of packages released`;\n done(`removed ${pluralize(result.builds.length, 'old build')}, ${runtime}`);\n } catch (error) {\n done(`failed: ${errorMessage(error)}`);\n }\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs, in a root that has the emitter. */\nfunction emitFrontendHooks(root: string, progress: Steps, commands: string[]): void {\n const emitter = path.join(root, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n commands.push(`${process.execPath} ${emitter} --write`);\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: root, encoding: 'utf8' });\n if (result.status === 0) {\n progress.line(HOOKS_LABEL, `regenerated for Claude Code and Codex in '${root}'`);\n return;\n }\n progress.line(\n HOOKS_LABEL,\n `emit-hooks failed in '${root}' (${result.stderr?.trim() || `exit ${String(result.status)}`})`,\n );\n}\n\n/** A path with its symlinks resolved, or as given when it does not exist. */\nfunction realPath(file: string): string {\n try {\n return fs.realpathSync(file);\n } catch {\n // Missing: compare it as written.\n return path.resolve(file);\n }\n}\n\n/**\n * One sync pass under the lock. A failed step ends the pass with a `failed` report and leaves\n * the pointer alone; a lock that no longer names this holder (`lost`) ends it as busy.\n */\nasync function syncOnce(\n options: SyncOptions,\n deps: SyncDeps,\n emit: (event: SyncEvent) => void,\n lost: () => SyncReport | undefined,\n): Promise<SyncReport> {\n const { homeDirectory, environment, globalRoot } = options;\n const progress = steps(emit);\n const commands: string[] = [];\n const roots = resolveRoots(options, progress);\n const catalogueHash = packageCatalogHash(environment);\n const previous = readSyncPointer(globalRoot);\n if (\n previous !== undefined &&\n // Unsynced selectors are retried only when a person runs sync: with an unchanged signature a\n // background retry repeats the same failure, while something outside the signature (a package\n // manager installed since) is what a manual `po sync` is for. The pointer keeps the reasons.\n (options.origin === 'background' || previous.roots.every((root) => root.unsynced.length === 0)) &&\n previous.signature === syncSignature(options, roots, catalogueHash) &&\n pointerArtifacts(globalRoot, previous).every((file) => fs.existsSync(file))\n ) {\n progress.line(ROOTS_LABEL, `nothing changed since generation ${String(previous.generation)}`);\n return {\n ...emptyReport('noop', [], deps),\n generation: previous.generation,\n catalogueHash,\n webKey: previous.webKey,\n mcpKeys: previous.mcpKeys,\n roots: previous.roots,\n };\n }\n const unsynced = new Map<string, SyncRootReport['unsynced']>(roots.map((root) => [root, []]));\n const report = (status: 'ok' | 'failed', errors: string[], webKey: string | null, mcpKeys: string[]) => {\n const rootReports = roots.map((root): SyncRootReport => {\n const entries = unsynced.get(root) ?? [];\n return { root, status: status === 'ok' && entries.length > 0 ? 'partial' : status, unsynced: entries };\n });\n const partial = status === 'ok' && rootReports.some((root) => root.status === 'partial');\n return {\n ...emptyReport(partial ? 'partial' : status, errors, deps),\n generation: previous?.generation ?? null,\n catalogueHash,\n webKey,\n mcpKeys,\n roots: rootReports,\n commands,\n };\n };\n\n const lostBeforeInstall = lost();\n if (lostBeforeInstall !== undefined) return lostBeforeInstall;\n const packagesDone = progress.start(PACKAGES_LABEL, 'checking configured packages for updates');\n let packages: SyncResult['packages'];\n try {\n const configOf = (root: string) => loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n const globalConfig = configOf(globalRoot);\n // One install covers the catalogue and every package some root does not get from its own\n // node_modules, including those the runtime already provides; the runtime manifest declares\n // exactly those, so pruning can drop anything no root needs. A name a root resolves from its\n // own node_modules stays out, so a workspace's local copy is never shadowed by, or blocked\n // on, a registry install.\n const specifiers = new Set(catalogInstallSpecifiers(environment));\n for (const root of roots) {\n const config = configOf(root);\n for (const specifier of runtimeLayerPackageSpecifiers(config, Object.keys(config.layers), root))\n specifiers.add(specifier);\n }\n packages = await deps.install({\n repoRoot: globalRoot,\n config: globalConfig,\n // Every declared layer, so a later mode switch finds its packages installed.\n layers: Object.keys(globalConfig.layers),\n environment,\n // A background run never bumps versions; only a person running sync asks for updates.\n refresh: options.origin === 'cli',\n specifiers: [...specifiers],\n exactManifest: true,\n onProgress: (message) => progress.line(PACKAGES_LABEL, message),\n });\n } catch (error) {\n packagesDone('failed');\n return report('failed', [`Installing packages failed: ${errorMessage(error)}`], null, []);\n }\n packagesDone(packageSummary(packages));\n\n const localByRoot = new Map(\n roots.map((root) => [root, localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config)]),\n );\n const localDirectories = [...localByRoot.values()].flat().map(({ directory }) => directory);\n if (localDirectories.length > 0) {\n const localDone = progress.start(LOCAL_LABEL, 'building local packages');\n const outcomes = await buildLocalPackages({\n globalRoot,\n environment,\n directories: localDirectories,\n onCommand: (command) => commands.push(command),\n onNotice: (message) => progress.line(LOCAL_LABEL, message),\n });\n let failed = 0;\n for (const [root, packagesOfRoot] of localByRoot)\n for (const { selector, directory } of packagesOfRoot) {\n const outcome = outcomes.get(directory);\n if (outcome?.status !== 'failed') continue;\n unsynced.get(root)?.push({\n selector,\n reason: outcome.reason,\n ...(outcome.stderr === undefined ? {} : { stderr: outcome.stderr }),\n });\n }\n for (const outcome of outcomes.values()) if (outcome.status === 'failed') failed += 1;\n localDone(failed === 0 ? `${pluralize(outcomes.size, 'package')} ready` : `${String(failed)} failed`);\n }\n\n const composed = composeRoots(roots, homeDirectory, environment);\n // What a root's selection leaves out still syncs the rest of the root; each is reported once.\n for (const [root, compositions] of composed) {\n if (compositions instanceof Error) continue;\n const entries = unsynced.get(root) ?? [];\n for (const skipped of skippedSelections(compositions))\n if (!entries.some((entry) => entry.selector === skipped.selector)) entries.push(skipped);\n }\n\n const webDone = progress.start(WEB_LABEL, 'ensuring the global web build');\n let rootPackageRoots = packageRootsByRoot(composed, (message) => progress.line(WEB_LABEL, message));\n const buildWeb = (packageRoots: Map<string, string[]>) =>\n deps.buildWeb({\n poHome: globalRoot,\n pluginRoots: webPluginRootsOf(globalRoot, packageRoots, environment),\n environment,\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n let built = await buildWeb(rootPackageRoots);\n if (built.status === 'failed') {\n // A local copy is the likeliest cause; one retry without them keeps the rest serving.\n const local = new Set(localDirectories.map(realPath));\n const withoutLocal = new Map(\n [...rootPackageRoots].map(([root, packageRoots]) => [\n root,\n packageRoots.filter((packageRoot) => !local.has(realPath(packageRoot))),\n ]),\n );\n const leftOut = [...rootPackageRoots].some(\n ([root, packageRoots]) => withoutLocal.get(root)?.length !== packageRoots.length,\n );\n const retried = leftOut ? await buildWeb(withoutLocal) : built;\n if (retried.status === 'failed') {\n webDone('failed');\n const retryReason = leftOut ? `; without local copies: ${retried.reason}` : '';\n return report('failed', [`The global web build failed: ${built.reason}${retryReason}`], null, []);\n }\n for (const [root, packagesOfRoot] of localByRoot) {\n const included = new Set((rootPackageRoots.get(root) ?? []).map(realPath));\n const entries = unsynced.get(root) ?? [];\n for (const { selector, directory } of packagesOfRoot)\n if (included.has(realPath(directory)) && !entries.some((entry) => entry.selector === selector))\n entries.push({\n selector,\n reason: `left out of the web build, which failed with it: ${built.reason}`,\n });\n }\n progress.line(WEB_LABEL, `built without local copies after: ${built.reason}`);\n rootPackageRoots = withoutLocal;\n built = retried;\n }\n const pluginRoots = webPluginRootsOf(globalRoot, rootPackageRoots, environment);\n const web: SyncResult['web'] = built.status === 'skipped' ? built : { status: built.status, key: built.build.key };\n webDone(web.status === 'skipped' ? web.reason : `${web.key} (${web.status})`);\n const webKey = web.status === 'skipped' ? null : web.key;\n\n const nativeDone = progress.start(NATIVE_LABEL, 'ensuring the global native build');\n const nativeBuilt = await deps.buildNative({\n poHome: globalRoot,\n pluginRoots,\n onNotice: (message) => progress.line(NATIVE_LABEL, message),\n });\n if (nativeBuilt.status === 'failed') {\n nativeDone('failed');\n return report('failed', [`The global native build failed: ${nativeBuilt.reason}`], webKey, []);\n }\n const native: NonNullable<SyncResult['native']> =\n nativeBuilt.status === 'skipped' ? nativeBuilt : { status: nativeBuilt.status, key: nativeBuilt.build.key };\n nativeDone(native.status === 'skipped' ? native.reason : `${native.key} (${native.status})`);\n const nativeKey = native.status === 'skipped' ? null : native.key;\n\n // One MCP app build per root; its key is a content hash, so roots with one widget set share it.\n const mcpDone = progress.start(MCP_LABEL, 'ensuring the MCP app build of each root');\n const mcpKeys: string[] = [];\n for (const [root, compositions] of composed) {\n if (compositions instanceof Error) {\n progress.line(MCP_LABEL, `'${root}' is left out of the MCP app build: ${compositions.message}`);\n continue;\n }\n try {\n const app = await deps.bundleMcpApp({ poHome: globalRoot, candidates: mcpPluginCandidates(compositions) });\n if (app !== undefined && !mcpKeys.includes(app.key)) mcpKeys.push(app.key);\n } catch (error) {\n unsynced.get(root)?.push({ selector: MCP_LABEL, reason: `the MCP app build failed: ${errorMessage(error)}` });\n }\n }\n mcpDone(mcpKeys.length === 0 ? 'no MCP UI widgets' : mcpKeys.join(', '));\n const mcpApp = mcpKeys.length === 0 ? undefined : mcpKeys.join(', ');\n\n // The pointer names only artifacts that exist; a missing one keeps the previous pointer.\n const missing = pointerArtifacts(globalRoot, { webKey, nativeKey, mcpKeys }).filter((file) => !fs.existsSync(file));\n if (missing.length > 0)\n return report('failed', [`Build artifacts are missing: ${missing.join(', ')}`], webKey, mcpKeys);\n // A root that names two copies of one plugin serves only one of them under its plugin id.\n if (built.status !== 'skipped')\n for (const [root, packageRoots] of rootPackageRoots)\n for (const [pluginId, slots] of duplicatePluginCopies(built.build, packageRoots))\n unsynced.get(root)?.push({\n selector: pluginId,\n reason: `two copies of plugin '${pluginId}' are selected (${slots.join(', ')})`,\n });\n const succeeded = report('ok', [], webKey, mcpKeys);\n const generation = (previous?.generation ?? 0) + 1;\n const pointer: SyncPointer = {\n generation,\n signature: syncSignature(options, roots, catalogueHash),\n catalogueHash,\n webKey,\n nativeKey,\n mcpKeys,\n roots: succeeded.roots,\n commands,\n fingerprints: Object.fromEntries(\n roots.map((root) => [root, rootSelectionFingerprint(root, homeDirectory, environment)]),\n ),\n host: syncHostIdentity(globalRoot, environment),\n };\n const lostBeforePointer = lost();\n if (lostBeforePointer !== undefined) return lostBeforePointer;\n writeJsonFile(syncPointerPath(globalRoot), pointer);\n\n await pruneStep(progress, deps.prune, {\n homeDirectory,\n environment,\n buildsRoot: globalRoot,\n ...(webKey === null ? {} : { webKey }),\n ...(nativeKey === null ? {} : { nativeKey }),\n ...(mcpKeys.length === 0 ? {} : { mcpAppKeys: mcpKeys }),\n });\n // The checkout itself too: a linked worktree registers under its main workspace root.\n for (const root of new Set([...roots, ...(options.repoRoot === undefined ? [] : [realPath(options.repoRoot)])]))\n emitFrontendHooks(root, progress, commands);\n emit({ type: 'result', result: { packages, web, native, ...(mcpApp === undefined ? {} : { mcpApp }) } });\n return { ...succeeded, generation };\n}\n\n/**\n * One pass whose report lands in `last-attempt.json`, so a failed background run leaves its\n * reasons. A pass that lost the lock leaves the file to the holder that took it.\n */\nasync function attempt(\n options: SyncOptions,\n deps: SyncDeps,\n emit: (event: SyncEvent) => void,\n lost: () => SyncReport | undefined,\n): Promise<SyncReport> {\n let report: SyncReport;\n try {\n report = await syncOnce(options, deps, emit, lost);\n } catch (error) {\n report = emptyReport('failed', [`po sync failed: ${errorMessage(error)}`], deps);\n }\n if (report.status === 'busy') return report;\n try {\n writeJsonFile(syncLastAttemptPath(options.globalRoot), report);\n } catch (error) {\n report = {\n ...report,\n errors: [...report.errors, `last-attempt.json could not be written: ${errorMessage(error)}`],\n };\n }\n return report;\n}\n\n/**\n * Runs sync under the Po home lock and reports the outcome.\n *\n * Busy when another live sync holds the lock; a background caller leaves a rerun marker\n * first. The holder repeats its pass while a marker is present. A marker that lands after\n * its last check but before the release is caught after the release: the holder takes the\n * lock again and runs once more, or leaves the marker to whoever took the lock first.\n */\nexport async function runSync(options: SyncOptions, overrides: Partial<SyncDeps> = {}): Promise<SyncReport> {\n const deps: SyncDeps = { ...DEFAULT_DEPS, ...overrides };\n const emit = options.onEvent ?? ((): void => {});\n const lockPath = syncLockPath(options.globalRoot);\n const rerunPath = syncRerunPath(options.globalRoot);\n let lock = acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) {\n if (options.origin === 'background') fs.writeFileSync(rerunPath, deps.now().toISOString());\n const holder = lock.holder === undefined ? 'another process' : `pid ${String(lock.holder.pid)}`;\n return emptyReport('busy', [`po sync is already running (${holder})`], deps);\n }\n for (;;) {\n const { token } = lock;\n const lost = () => lostLock(lockPath, token, deps);\n let report: SyncReport;\n try {\n // A marker left before this pass started is satisfied by this pass.\n takeRerunRequest(rerunPath);\n report = await attempt(options, deps, emit, lost);\n // A pass that lost the lock leaves the rerun marker to the holder that took it.\n while (report.status !== 'busy' && takeRerunRequest(rerunPath)) report = await attempt(options, deps, emit, lost);\n } finally {\n releaseLock(lockPath, token);\n }\n if (report.status === 'busy' || !fs.existsSync(rerunPath)) return report;\n lock = acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) return report;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2DA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAeA,UAAAA,QAAK,KAAK,SAAS,WAAW,gBAAgB;AACnE,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,cAAc;AACpB,MAAM,qBAAqB;;AAE3B,MAAM,2BAA2B;AACjC,MAAM,kBAAkB;;;;;AAKxB,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;AACvB,MAAM,eAAe;;AAmFrB,SAAgB,eAAe,KAAsB;CACnD,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EAEd,OAAQ,MAAgC,SAAS;CACnD;AACF;AAEA,MAAM,eAAyB;CAC7B,SAASC,gBAAAA;CACT,UAAUC,cAAAA;CACV,aAAaC,gBAAAA;CACb,cAAcC,oBAAAA;CACd,OAAOC,gBAAAA;CACP,SAAS;CACT,KAAK,QAAQ;CACb,2BAAW,IAAI,KAAK;AACtB;AAEA,SAAgB,aAAa,QAA4B;CACvD,IAAI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Q,QAAQ,IAAI;CACrD,IAAI,CAAC,KAAK,UAAU;EAClB,IAAI,QAAQ,WAAW,cAAc,QAAA,QAAG,cAAc,WAAW,KAAK,IAAI,CAAC,CAAC,YAAY,CAAC;EAEzF,OAAO,YAAY,QAAQ,CAAC,+BADb,KAAK,WAAW,KAAA,IAAY,oBAAoB,OAAO,OAAO,KAAK,OAAO,GAAG,IAC1B,EAAE,GAAG,IAAI;CAC7E;CACA,SAAS;EACP,MAAM,EAAE,UAAU;EAClB,MAAM,aAAa,SAAS,UAAU,OAAO,IAAI;EACjD,IAAI;EACJ,IAAI;GAEF,iBAAiB,SAAS;GAC1B,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;GAEhD,OAAO,OAAO,WAAW,UAAU,iBAAiB,SAAS,GAAG,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;EAClH,UAAU;GACR,YAAY,UAAU,KAAK;EAC7B;EACA,IAAI,OAAO,WAAW,UAAU,CAAChB,QAAAA,QAAG,WAAW,SAAS,GAAG,OAAO;EAClE,OAAO,YAAY,UAAU,QAAQ,QAAQ,IAAI;EACjD,IAAI,CAAC,KAAK,UAAU,OAAO;CAC7B;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["path","ensureLayerPackages","ensureGlobalWebBuild","ensureGlobalNativeBuild","ensureMcpAppBuild","pruneAfterSync","createWorkspaceRegistry","piAgentDirectory","rootCompositions","compositionPackageRoots","catalogPackageRoots","globalPoConfigDirectory","fs","identifyWorkspace","readWorkspaceMarker","isLocalPackageSpecifier","testPackageRoot","splitPackageSpecifier","crypto","poPackageRoot","webHostVersion","loadMajorModesConfigLenient","localBuildStamp","BUILD_RECORD","spawnSync","mcpAppKey","mcpPluginCandidates","packageCatalogHash","catalogInstallSpecifiers","runtimeLayerPackageSpecifiers","buildLocalPackages","duplicatePluginCopies"],"sources":["../../../../src/composition/syncService/index.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process';\nimport crypto from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport { globalPoConfigDirectory } from '@agimon-ai/po-config/config';\nimport { isLocalPackageSpecifier, loadMajorModesConfigLenient } from '@agimon-ai/po-config/majorModes';\nimport {\n createWorkspaceRegistry,\n identifyWorkspace,\n readWorkspaceMarker,\n type WorkspaceRegistry,\n writeWorkspaceMarker,\n} from '@agimon-ai/po-core/history';\nimport { splitPackageSpecifier, testPackageRoot } from '@agimon-ai/po-core/moduleResolution';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\nimport { writeFileAtomic } from '@agimon-ai/po-core/runtimeJson';\n\nimport { poPackageRoot } from '../../builders/cli/entryResolution';\nimport { rootCompositions } from '../../builders/cli/sessionComposition';\nimport { ensureGlobalNativeBuild } from '../../builders/native';\nimport { ensureMcpAppBuild, mcpAppKey } from '../../builders/server/mcpAppBuild';\nimport { mcpPluginCandidates } from '../../builders/server/mcpBundle';\nimport {\n BUILD_RECORD,\n compositionPackageRoots,\n duplicatePluginCopies,\n ensureGlobalWebBuild,\n webHostVersion,\n} from '../../builders/web';\nimport {\n catalogInstallSpecifiers,\n catalogPackageRoots,\n ensureLayerPackages,\n type LayerPackageResult,\n packageCatalogHash,\n runtimeLayerPackageSpecifiers,\n} from '../layerPackageInstaller';\nimport { pruneAfterSync, type SyncPruneInput } from '../syncPrune';\nimport { buildLocalPackages, type LocalPackage, localBuildStamp } from './localBuilds';\n\nexport { localBuildStamp } from './localBuilds';\n\n/**\n * The sync service: installs what the configuration names, ensures the global builds,\n * prunes, and reports what happened as one `SyncReport`.\n *\n * The roots are the Po home, every registered workspace whose folder exists, and the\n * repository sync runs from, which it registers. One install covers the catalogue and every\n * root's published packages. When the signature over the catalogue, each root's selection,\n * each local package's build stamp and the host identity (the po package and po-web host\n * versions) matches `current.json` and every artifact it names exists, sync returns `noop`\n * without installing or building. The pointer records that identity, so a server from another\n * Po install can tell the build is not its own.\n *\n * Only one sync runs at a time per Po home, guarded by `<po home>/build/.sync.lock`. A CLI\n * run that finds the lock held reports `busy`. A background run instead leaves\n * `.sync.rerun`, and the holder runs once more, so the background request is never lost.\n */\n\nconst BUILD_DIRECTORY = 'build';\nconst LOCK_FILE = '.sync.lock';\nconst RERUN_FILE = '.sync.rerun';\nconst POINTER_FILE = 'current.json';\nconst LAST_ATTEMPT_FILE = 'last-attempt.json';\nconst MCP_APP_FILE = 'index.html';\nconst HOOK_EMITTER = path.join('tools', 'harness', 'emit-hooks.mjs');\nconst ROOTS_LABEL = 'roots';\nconst PACKAGES_LABEL = 'packages';\nconst WEB_LABEL = 'web';\nconst NATIVE_LABEL = 'native';\nconst MCP_LABEL = 'mcp app';\nconst PRUNE_LABEL = 'prune';\nconst HOOKS_LABEL = 'hooks';\nconst LOCAL_LABEL = 'local';\nconst BYTES_PER_MEGABYTE = 1024 * 1024;\n/** A lock file younger than this that cannot be parsed is still being written by its owner. */\nconst UNREADABLE_LOCK_GRACE_MS = 10_000;\nconst NO_SUCH_PROCESS = 'ESRCH';\n/**\n * Bumped when the pointer gains a field a reader relies on, so an older pointer never matches\n * the fast-exit signature and the next sync rewrites it. 2: per-root `fingerprints`. 3: `host`.\n */\nconst SIGNATURE_FORMAT = 3;\nconst PACKAGE_MANIFEST = 'package.json';\nconst ALREADY_EXISTS = 'EEXIST';\nconst NO_SUCH_FILE = 'ENOENT';\n\nexport const SYNC_EXIT_OK = 0;\nexport const SYNC_EXIT_FAILED = 1;\n/** EX_TEMPFAIL: another sync holds the lock. */\nexport const SYNC_EXIT_BUSY = 75;\n\nexport type SyncOrigin = 'cli' | 'background';\nexport type SyncStatus = 'ok' | 'noop' | 'partial' | 'failed' | 'busy';\n\nexport interface SyncResult {\n packages: Pick<LayerPackageResult, 'installed' | 'updated' | 'unchecked'>;\n /** The global web build key, or why there is none. */\n web: { status: 'built' | 'cached'; key: string } | { status: 'skipped'; reason: string };\n /** The global native build key, or why there is none. */\n native?: { status: 'built' | 'cached'; key: string } | { status: 'skipped'; reason: string };\n /** The MCP app build keys, comma separated, when any root's packages declare MCP UI widgets. */\n mcpApp?: string;\n}\n\nexport interface SyncRootReport {\n root: string;\n status: 'ok' | 'partial' | 'failed';\n unsynced: { selector: string; reason: string; stderr?: string[] }[];\n}\n\nexport interface SyncReport {\n status: SyncStatus;\n /** Assigned once sync writes a pointer; null until then. */\n generation: number | null;\n /** Assigned once sync computes the fast-exit signature; null until then. */\n catalogueHash: string | null;\n webKey: string | null;\n mcpKeys: string[];\n roots: SyncRootReport[];\n /** External commands sync ran, such as local package builds. */\n commands: string[];\n errors: string[];\n finishedAt: string;\n}\n\n/** One progress event; the CLI renders these as text or as JSON lines. */\nexport type SyncEvent =\n | { type: 'start'; label: string; message: string }\n | { type: 'line'; label: string; message: string }\n | { type: 'done'; label: string; summary: string }\n | { type: 'result'; result: SyncResult };\n\nexport interface SyncLockHolder {\n pid: number;\n /** Unique per acquisition, so a holder can tell its lock from a later one, even under its pid. */\n token?: string;\n startedAt: string;\n origin: SyncOrigin;\n}\n\nexport interface SyncOptions {\n homeDirectory: string;\n environment: NodeJS.ProcessEnv;\n /** The Po home every global build and the lock live under. */\n globalRoot: string;\n /**\n * The repository sync runs from: registered as a workspace, synced as a root, and its hooks\n * regenerated. Undefined with `--global`, which registers nothing.\n */\n repoRoot?: string;\n origin: SyncOrigin;\n onEvent?: (event: SyncEvent) => void;\n}\n\nexport interface SyncDeps {\n install: typeof ensureLayerPackages;\n buildWeb: typeof ensureGlobalWebBuild;\n buildNative: typeof ensureGlobalNativeBuild;\n bundleMcpApp: typeof ensureMcpAppBuild;\n prune: typeof pruneAfterSync;\n /** Whether a lock holder's process still runs. */\n isAlive: (pid: number) => boolean;\n pid: number;\n now: () => Date;\n}\n\n/** `process.kill(pid, 0)` probes without signalling; only ESRCH means the process is gone. */\nexport function processIsAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // EPERM means it runs under another user, which still holds the lock.\n return (error as NodeJS.ErrnoException).code !== NO_SUCH_PROCESS;\n }\n}\n\nconst DEFAULT_DEPS: SyncDeps = {\n install: ensureLayerPackages,\n buildWeb: ensureGlobalWebBuild,\n buildNative: ensureGlobalNativeBuild,\n bundleMcpApp: ensureMcpAppBuild,\n prune: pruneAfterSync,\n isAlive: processIsAlive,\n pid: process.pid,\n now: () => new Date(),\n};\n\nexport function syncExitCode(status: SyncStatus): number {\n if (status === 'busy') return SYNC_EXIT_BUSY;\n return status === 'ok' || status === 'noop' ? SYNC_EXIT_OK : SYNC_EXIT_FAILED;\n}\n\nexport function syncLockPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, LOCK_FILE);\n}\n\nexport function syncRerunPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, RERUN_FILE);\n}\n\nfunction pluralize(count: number, noun: string): string {\n return `${String(count)} ${noun}${count === 1 ? '' : 's'}`;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction packageSummary(result: SyncResult['packages']): string {\n const parts: string[] = [];\n if (result.updated.length > 0) parts.push(`updated ${pluralize(result.updated.length, 'package')}`);\n if (result.installed.length > 0) parts.push(`installed ${pluralize(result.installed.length, 'missing package')}`);\n if (parts.length === 0) parts.push('already up to date');\n if (result.unchecked.length > 0) parts.push(`${pluralize(result.unchecked.length, 'package')} left unchecked`);\n return parts.join(', ');\n}\n\nexport function formatSyncResult(result: SyncResult): string {\n return [\n `packages: ${packageSummary(result.packages)}`,\n `web: ${result.web.status === 'skipped' ? result.web.reason : `${result.web.key} (${result.web.status})`}`,\n ...(result.native === undefined\n ? []\n : [\n `native: ${result.native.status === 'skipped' ? result.native.reason : `${result.native.key} (${result.native.status})`}`,\n ]),\n ...(result.mcpApp === undefined ? [] : [`mcp app: ${result.mcpApp}`]),\n '',\n ].join('\\n');\n}\n\nfunction workspaceRegistry(\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): WorkspaceRegistry {\n return createWorkspaceRegistry({\n directory: path.join(piAgentDirectory(environment, homeDirectory), 'server'),\n onNotice,\n });\n}\n\ntype RootCompositions = ReturnType<typeof rootCompositions>;\n\n/**\n * Each root's compositions, resolved the way the server resolves them: a selection that does\n * not resolve yet (an unbuilt local package, say) is left out with a diagnostic instead of\n * failing the whole root, so sync and the server derive the same web, MCP and fingerprint\n * inputs. A root that cannot be composed at all maps to why.\n */\nfunction composeRoots(\n roots: readonly string[],\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): Map<string, RootCompositions | Error> {\n return new Map(\n roots.map((root): [string, RootCompositions | Error] => {\n try {\n return [root, rootCompositions({ root, homeDirectory, environment, tolerateUnsynced: true })];\n } catch (error) {\n return [root, error instanceof Error ? error : new Error(String(error))];\n }\n }),\n );\n}\n\n/** Each root's composition package roots; a root that cannot be composed is left out with a notice. */\nfunction packageRootsByRoot(\n composed: ReadonlyMap<string, RootCompositions | Error>,\n onNotice: (message: string) => void,\n): Map<string, string[]> {\n return new Map(\n [...composed].map(([root, compositions]) => {\n if (!(compositions instanceof Error)) return [root, compositionPackageRoots(compositions)];\n onNotice(`'${root}' is left out of the web build: ${compositions.message}`);\n return [root, []];\n }),\n );\n}\n\n/** The selectors a lenient composition left out, each once with the first diagnostic that explains it. */\nfunction skippedSelections(compositions: RootCompositions): SyncRootReport['unsynced'] {\n const skipped = new Map<string, string>();\n for (const composition of compositions)\n for (const selection of composition.selections)\n if (selection.outcome === 'missing-optional' && !selection.optional && !skipped.has(selection.selector))\n skipped.set(selection.selector, selection.diagnostic ?? 'it does not resolve');\n return [...skipped].map(([selector, reason]) => ({ selector, reason }));\n}\n\n/**\n * The plugin roots one global web build covers: every installed catalogue package, so each\n * first-party plugin has a slot whether or not a config names it yet, then each root's own\n * composition package roots. Sync builds with these and the server derives the same key.\n */\nfunction webPluginRootsOf(\n globalRoot: string,\n rootPackageRoots: ReadonlyMap<string, readonly string[]>,\n environment: NodeJS.ProcessEnv,\n): string[] {\n return [...catalogPackageRoots(globalRoot, environment), ...[...rootPackageRoots.values()].flat()];\n}\n\n/**\n * Every package root the global web build covers: the catalogue packages, the global root,\n * every workspace the server has admitted, and `targetRoot`, which the server admits when it\n * opens it. A root whose configuration cannot be read is left out with a notice, as sync\n * leaves it out of the build when it cannot compose it.\n */\nexport function globalWebPluginRoots(\n targetRoot: string,\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n onNotice: (message: string) => void,\n): string[] {\n const globalRoot = globalPoConfigDirectory(homeDirectory);\n const admitted = workspaceRegistry(homeDirectory, environment, onNotice)\n .list()\n .map((workspace) => workspace.root)\n .filter((root) => fs.existsSync(root));\n const roots = [...new Set([globalRoot, ...admitted, targetRoot])];\n return webPluginRootsOf(\n globalRoot,\n packageRootsByRoot(composeRoots(roots, homeDirectory, environment), onNotice),\n environment,\n );\n}\n\n/**\n * Registers the repository as a workspace the way the server admits one, so one repository\n * never gets two ids, and returns the workspace root it belongs to.\n */\nfunction registerRepository(\n registry: WorkspaceRegistry,\n repoRoot: string,\n onNotice: (message: string) => void,\n): string {\n const checkoutRoot = fs.realpathSync(repoRoot);\n const { id, root, moved } = identifyWorkspace({\n records: registry.list(),\n checkoutRoot,\n marker: readWorkspaceMarker(checkoutRoot),\n });\n const record = registry.list().find((workspace) => workspace.id === id);\n if (record === undefined || moved)\n registry.add({ id, root, ...(record?.name === undefined ? {} : { name: record.name }) });\n if (moved) onNotice(`workspace '${id}' moved to '${root}'`);\n try {\n if (readWorkspaceMarker(root) === undefined) writeWorkspaceMarker(root, id);\n } catch (error) {\n onNotice(`'${root}' id could not be recorded in its git data: ${errorMessage(error)}`);\n }\n return root;\n}\n\n/**\n * The roots this sync covers: the Po home, every registered workspace whose folder exists,\n * and the repository, registered first. Entries whose folder is gone are removed with a warning.\n */\nfunction resolveRoots(options: SyncOptions, progress: Steps): string[] {\n const notice = (message: string): void => progress.line(ROOTS_LABEL, message);\n const registry = workspaceRegistry(options.homeDirectory, options.environment, notice);\n const repository =\n options.repoRoot === undefined || path.resolve(options.repoRoot) === path.resolve(options.globalRoot)\n ? undefined\n : registerRepository(registry, options.repoRoot, notice);\n const live: string[] = [];\n for (const workspace of registry.list()) {\n if (fs.existsSync(workspace.root)) {\n live.push(workspace.root);\n continue;\n }\n notice(`warning: removed workspace '${workspace.id}': '${workspace.root}' no longer exists`);\n registry.remove(workspace.id);\n }\n return [...new Set([options.globalRoot, ...live, ...(repository === undefined ? [] : [repository])])];\n}\n\n/** Local-path selections and checkout test overrides, stamped and built by the same local build pipeline. */\nfunction localPackages(\n config: ReturnType<typeof loadMajorModesConfigLenient>['config'],\n environment: NodeJS.ProcessEnv,\n): LocalPackage[] {\n const definitions = [...(config.default ? [config.default] : []), ...Object.values(config.layers)];\n const packages = new Map<string, LocalPackage>();\n for (const definition of definitions)\n for (const configured of definition.packages ?? []) {\n const selector = typeof configured === 'string' ? configured : configured.name;\n const directory = isLocalPackageSpecifier(selector)\n ? path.resolve(definition.baseDirectory, selector)\n : testPackageRoot(splitPackageSpecifier(selector).name, environment);\n if (directory === undefined) continue;\n if (!packages.has(directory)) packages.set(directory, { selector, directory });\n }\n return [...packages.values()];\n}\n\n/**\n * SHA-256 over every mode's composition fingerprint, or why the root cannot be composed. The\n * pointer records it per root, so a server can tell a root whose selection changed since the\n * last sync by computing it again with the environment sync ran under.\n */\nexport function rootSelectionFingerprint(root: string, homeDirectory: string, environment: NodeJS.ProcessEnv): string {\n try {\n const fingerprints = rootCompositions({ root, homeDirectory, environment, tolerateUnsynced: true }).map(\n (composition) => composition.fingerprint,\n );\n return crypto.createHash('sha256').update(fingerprints.join('\\n')).digest('hex');\n } catch (error) {\n return `unresolved:${errorMessage(error)}`;\n }\n}\n\n/** The po package version this process runs from, or why it cannot be read. */\nfunction poPackageVersion(): string {\n try {\n const manifest = JSON.parse(fs.readFileSync(path.join(poPackageRoot(), PACKAGE_MANIFEST), 'utf8')) as {\n version?: unknown;\n };\n return typeof manifest.version === 'string' ? manifest.version : 'unversioned';\n } catch (error) {\n return `unreadable:${errorMessage(error)}`;\n }\n}\n\n/**\n * The Po install a sync or a server runs from: its po package version and the po-web host\n * version it builds with. Sync records it in the pointer; a server whose identity differs\n * refuses that pointer's builds and syncs with its own install.\n */\nexport function syncHostIdentity(globalRoot: string, environment: NodeJS.ProcessEnv): string {\n const checkout =\n environment.PO_TEST === '1' && environment.PO_TEST_PACKAGES\n ? `+checkout@${crypto.createHash('sha256').update(environment.PO_TEST_PACKAGES).digest('hex')}`\n : '';\n return `po@${poPackageVersion()}+po-web@${webHostVersion(globalRoot, environment)}${checkout}`;\n}\n\n/** The fast-exit signature: catalogue hash, each root's selection and local build stamps, host identity. */\nfunction syncSignature(options: SyncOptions, roots: readonly string[], catalogueHash: string): string {\n const { homeDirectory, environment } = options;\n const value = {\n format: SIGNATURE_FORMAT,\n catalogueHash,\n roots: roots.map((root) => ({\n root,\n selection: rootSelectionFingerprint(root, homeDirectory, environment),\n local: localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config, environment).map(\n ({ directory }) => [directory, localBuildStamp(directory)],\n ),\n })),\n host: syncHostIdentity(options.globalRoot, environment),\n };\n return crypto.createHash('sha256').update(JSON.stringify(value)).digest('hex');\n}\n\n/** `current.json`: the last successful report minus its transient fields, plus what fast exit needs. */\nexport interface SyncPointer {\n generation: number;\n signature: string;\n catalogueHash: string;\n webKey: string | null;\n nativeKey: string | null;\n mcpKeys: string[];\n roots: SyncRootReport[];\n commands: string[];\n /** Each root's `rootSelectionFingerprint` at the time of the sync; absent in older pointers. */\n fingerprints?: Record<string, string>;\n /** The `syncHostIdentity` of the install that wrote the pointer; absent in older pointers. */\n host?: string;\n}\n\nexport function syncPointerPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, POINTER_FILE);\n}\n\nexport function syncLastAttemptPath(globalRoot: string): string {\n return path.join(globalRoot, BUILD_DIRECTORY, LAST_ATTEMPT_FILE);\n}\n\n/** The current pointer, or undefined when sync has not written one yet or it is unreadable. */\nexport function readSyncPointer(globalRoot: string): SyncPointer | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(syncPointerPath(globalRoot), 'utf8')) as Partial<SyncPointer>;\n return typeof parsed.signature === 'string' && typeof parsed.generation === 'number'\n ? (parsed as SyncPointer)\n : undefined;\n } catch {\n // Missing or unreadable: there is nothing to fast-exit against.\n return undefined;\n }\n}\n\n/** The files whose presence proves each artifact a pointer names is complete. */\nfunction pointerArtifacts(\n globalRoot: string,\n pointer: Pick<SyncPointer, 'webKey' | 'nativeKey' | 'mcpKeys'>,\n): string[] {\n const build = path.join(globalRoot, BUILD_DIRECTORY);\n return [\n ...(pointer.webKey === null ? [] : [path.join(build, WEB_LABEL, pointer.webKey, BUILD_RECORD)]),\n ...(pointer.nativeKey === null ? [] : [path.join(build, NATIVE_LABEL, pointer.nativeKey, BUILD_RECORD)]),\n ...pointer.mcpKeys.map((key) => path.join(build, 'mcp-app', key, MCP_APP_FILE)),\n ];\n}\n\n/** The report of the last sync attempt, successful or not, or undefined when there is none. */\nexport function readSyncLastAttempt(globalRoot: string): SyncReport | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(syncLastAttemptPath(globalRoot), 'utf8')) as Partial<SyncReport>;\n return Array.isArray(parsed.roots) ? (parsed as SyncReport) : undefined;\n } catch {\n // Missing or unreadable: no attempt to report reasons from.\n return undefined;\n }\n}\n\nfunction writeJsonFile(file: string, value: unknown): void {\n writeFileAtomic(file, `${JSON.stringify(value, null, 2)}\\n`);\n}\n\ntype LockAttempt = { acquired: true; token: string } | { acquired: false; holder: SyncLockHolder | undefined };\n\nfunction readHolder(lockPath: string): SyncLockHolder | undefined {\n try {\n const parsed = JSON.parse(fs.readFileSync(lockPath, 'utf8')) as Partial<SyncLockHolder>;\n return typeof parsed.pid === 'number' ? (parsed as SyncLockHolder) : undefined;\n } catch {\n // Missing or half-written: the caller decides from the file's age.\n return undefined;\n }\n}\n\nfunction lockIsStale(lockPath: string, deps: SyncDeps): boolean {\n const holder = readHolder(lockPath);\n if (holder !== undefined) return !deps.isAlive(holder.pid);\n try {\n return deps.now().getTime() - fs.statSync(lockPath).mtimeMs > UNREADABLE_LOCK_GRACE_MS;\n } catch {\n // Gone between the failed create and this check: free to retry.\n return true;\n }\n}\n\nfunction tryCreateLock(lockPath: string, holder: SyncLockHolder): boolean {\n try {\n const descriptor = fs.openSync(lockPath, 'wx');\n try {\n fs.writeSync(descriptor, JSON.stringify(holder));\n } finally {\n fs.closeSync(descriptor);\n }\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === ALREADY_EXISTS) return false;\n throw error;\n }\n}\n\n/**\n * Takes over a lock judged stale. Removing it by path could remove a lock another taker created\n * since the check, so it is first renamed to a name only this process knows and checked again\n * there: a lock that turns out live is linked back (link never replaces), a stale one is dropped\n * before the exclusive create, which at most one taker wins.\n */\nfunction takeOverStaleLock(lockPath: string, holder: SyncLockHolder, deps: SyncDeps): boolean {\n const moved = `${lockPath}.${String(deps.pid)}.${crypto.randomUUID()}.stale`;\n try {\n fs.renameSync(lockPath, moved);\n } catch (error) {\n // Already gone: released, or moved by another taker; the create decides.\n if ((error as NodeJS.ErrnoException).code === NO_SUCH_FILE) return tryCreateLock(lockPath, holder);\n throw error;\n }\n try {\n if (!lockIsStale(moved, deps)) {\n try {\n fs.linkSync(moved, lockPath);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== ALREADY_EXISTS) throw error;\n }\n return false;\n }\n } finally {\n fs.rmSync(moved, { force: true });\n }\n return tryCreateLock(lockPath, holder);\n}\n\n/** Creates the lock, taking over one whose holder is dead. Never inspects other processes beyond `kill(pid, 0)`. */\nfunction acquireLock(lockPath: string, origin: SyncOrigin, deps: SyncDeps): LockAttempt {\n fs.mkdirSync(path.dirname(lockPath), { recursive: true });\n const token = crypto.randomUUID();\n const holder: SyncLockHolder = { pid: deps.pid, token, startedAt: deps.now().toISOString(), origin };\n if (tryCreateLock(lockPath, holder)) return { acquired: true, token };\n // A racing taker that wins the takeover makes this attempt report busy, as it should.\n if (lockIsStale(lockPath, deps) && takeOverStaleLock(lockPath, holder, deps)) return { acquired: true, token };\n return { acquired: false, holder: readHolder(lockPath) };\n}\n\n/**\n * The lock as the holder with `token` sees it: undefined while the lock still names it, else\n * the busy report to stop with. A takeover that moved a live lock aside can let a third taker\n * create a new one, so a holder checks before each step whose overlap would do harm.\n */\nfunction lostLock(lockPath: string, token: string, deps: SyncDeps): SyncReport | undefined {\n const holder = readHolder(lockPath);\n if (holder?.token === token) return undefined;\n const by = holder === undefined ? 'another process' : `pid ${String(holder.pid)}`;\n return emptyReport('busy', [`po sync lost its lock to ${by}`], deps);\n}\n\nfunction releaseLock(lockPath: string, token: string): void {\n if (readHolder(lockPath)?.token === token) fs.rmSync(lockPath, { force: true });\n}\n\n/** Consumes the rerun marker; true when a background run asked for another pass. */\nfunction takeRerunRequest(rerunPath: string): boolean {\n if (!fs.existsSync(rerunPath)) return false;\n fs.rmSync(rerunPath, { force: true });\n return true;\n}\n\nfunction emptyReport(status: SyncStatus, errors: string[], deps: SyncDeps): SyncReport {\n return {\n status,\n generation: null,\n catalogueHash: null,\n webKey: null,\n mcpKeys: [],\n roots: [],\n commands: [],\n errors,\n finishedAt: deps.now().toISOString(),\n };\n}\n\n/** A step reporter over the event stream, mirroring the presenter's start/done/line. */\nfunction steps(emit: (event: SyncEvent) => void) {\n return {\n start(label: string, message: string): (summary: string) => void {\n emit({ type: 'start', label, message });\n return (summary) => emit({ type: 'done', label, summary });\n },\n line(label: string, message: string): void {\n emit({ type: 'line', label, message });\n },\n };\n}\n\ntype Steps = ReturnType<typeof steps>;\n\n/**\n * Drops old builds and unreferenced store content once installs and builds are done.\n * Never fatal: a failed prune leaves everything for the next explicit sync.\n */\nasync function pruneStep(progress: Steps, prune: SyncDeps['prune'], input: SyncPruneInput): Promise<void> {\n const done = progress.start(PRUNE_LABEL, 'dropping old builds and unused packages');\n try {\n const result = await prune(input);\n const runtime =\n 'skipped' in result.runtime\n ? result.runtime.skipped\n : `${(result.runtime.bytes / BYTES_PER_MEGABYTE).toFixed(1)} MB of packages released`;\n done(`removed ${pluralize(result.builds.length, 'old build')}, ${runtime}`);\n } catch (error) {\n done(`failed: ${errorMessage(error)}`);\n }\n}\n\n/** Regenerates the hook files the other frontends read before any harness code runs, in a root that has the emitter. */\nfunction emitFrontendHooks(root: string, progress: Steps, commands: string[]): void {\n const emitter = path.join(root, HOOK_EMITTER);\n if (!fs.existsSync(emitter)) return;\n commands.push(`${process.execPath} ${emitter} --write`);\n const result = spawnSync(process.execPath, [emitter, '--write'], { cwd: root, encoding: 'utf8' });\n if (result.status === 0) {\n progress.line(HOOKS_LABEL, `regenerated for Claude Code and Codex in '${root}'`);\n return;\n }\n progress.line(\n HOOKS_LABEL,\n `emit-hooks failed in '${root}' (${result.stderr?.trim() || `exit ${String(result.status)}`})`,\n );\n}\n\n/** A path with its symlinks resolved, or as given when it does not exist. */\nfunction realPath(file: string): string {\n try {\n return fs.realpathSync(file);\n } catch {\n // Missing: compare it as written.\n return path.resolve(file);\n }\n}\n\n/**\n * Whether the MCP app build the server will look for exists for every root. Its key hashes the\n * widget packages' built files, which the signature does not cover, so a rebuilt `dist/` moves\n * the key without moving the signature.\n */\nfunction mcpAppsBuilt(\n globalRoot: string,\n roots: readonly string[],\n homeDirectory: string,\n environment: NodeJS.ProcessEnv,\n): boolean {\n for (const compositions of composeRoots(roots, homeDirectory, environment).values()) {\n if (compositions instanceof Error) continue;\n let key: string | undefined;\n try {\n key = mcpAppKey(mcpPluginCandidates(compositions));\n } catch {\n // A widget package that cannot be read: not built; the full pass reports why.\n return false;\n }\n if (key !== undefined && !fs.existsSync(path.join(globalRoot, BUILD_DIRECTORY, 'mcp-app', key, MCP_APP_FILE)))\n return false;\n }\n return true;\n}\n/**\n * One sync pass under the lock. A failed step ends the pass with a `failed` report and leaves\n * the pointer alone; a lock that no longer names this holder (`lost`) ends it as busy.\n */\nasync function syncOnce(\n options: SyncOptions,\n deps: SyncDeps,\n emit: (event: SyncEvent) => void,\n lost: () => SyncReport | undefined,\n): Promise<SyncReport> {\n const { homeDirectory, environment, globalRoot } = options;\n const progress = steps(emit);\n const commands: string[] = [];\n const roots = resolveRoots(options, progress);\n const catalogueHash = packageCatalogHash(environment);\n const previous = readSyncPointer(globalRoot);\n if (\n previous !== undefined &&\n // Unsynced selectors are retried only when a person runs sync: with an unchanged signature a\n // background retry repeats the same failure, while something outside the signature (a package\n // manager installed since) is what a manual `po sync` is for. The pointer keeps the reasons.\n (options.origin === 'background' || previous.roots.every((root) => root.unsynced.length === 0)) &&\n previous.signature === syncSignature(options, roots, catalogueHash) &&\n pointerArtifacts(globalRoot, previous).every((file) => fs.existsSync(file)) &&\n mcpAppsBuilt(globalRoot, roots, homeDirectory, environment)\n ) {\n progress.line(ROOTS_LABEL, `nothing changed since generation ${String(previous.generation)}`);\n return {\n ...emptyReport('noop', [], deps),\n generation: previous.generation,\n catalogueHash,\n webKey: previous.webKey,\n mcpKeys: previous.mcpKeys,\n roots: previous.roots,\n };\n }\n const unsynced = new Map<string, SyncRootReport['unsynced']>(roots.map((root) => [root, []]));\n const report = (status: 'ok' | 'failed', errors: string[], webKey: string | null, mcpKeys: string[]) => {\n const rootReports = roots.map((root): SyncRootReport => {\n const entries = unsynced.get(root) ?? [];\n return { root, status: status === 'ok' && entries.length > 0 ? 'partial' : status, unsynced: entries };\n });\n const partial = status === 'ok' && rootReports.some((root) => root.status === 'partial');\n return {\n ...emptyReport(partial ? 'partial' : status, errors, deps),\n generation: previous?.generation ?? null,\n catalogueHash,\n webKey,\n mcpKeys,\n roots: rootReports,\n commands,\n };\n };\n\n const lostBeforeInstall = lost();\n if (lostBeforeInstall !== undefined) return lostBeforeInstall;\n const packagesDone = progress.start(PACKAGES_LABEL, 'checking configured packages for updates');\n let packages: SyncResult['packages'];\n try {\n const configOf = (root: string) => loadMajorModesConfigLenient(root, homeDirectory, environment).config;\n const globalConfig = configOf(globalRoot);\n // One install covers the catalogue and every package some root does not get from its own\n // node_modules, including those the runtime already provides; the runtime manifest declares\n // exactly those, so pruning can drop anything no root needs. A name a root resolves from its\n // own node_modules stays out, so a workspace's local copy is never shadowed by, or blocked\n // on, a registry install.\n const specifiers = new Set(catalogInstallSpecifiers(environment));\n for (const root of roots) {\n const config = configOf(root);\n for (const specifier of runtimeLayerPackageSpecifiers(config, Object.keys(config.layers), root))\n specifiers.add(specifier);\n }\n packages = await deps.install({\n repoRoot: globalRoot,\n config: globalConfig,\n // Every declared layer, so a later mode switch finds its packages installed.\n layers: Object.keys(globalConfig.layers),\n environment,\n // A background run never bumps versions; only a person running sync asks for updates.\n refresh: options.origin === 'cli',\n specifiers: [...specifiers],\n exactManifest: true,\n onProgress: (message) => progress.line(PACKAGES_LABEL, message),\n });\n } catch (error) {\n packagesDone('failed');\n return report('failed', [`Installing packages failed: ${errorMessage(error)}`], null, []);\n }\n packagesDone(packageSummary(packages));\n\n const localByRoot = new Map(\n roots.map((root) => [\n root,\n localPackages(loadMajorModesConfigLenient(root, homeDirectory, environment).config, environment),\n ]),\n );\n const localDirectories = [...localByRoot.values()].flat().map(({ directory }) => directory);\n if (localDirectories.length > 0) {\n const localDone = progress.start(LOCAL_LABEL, 'building local packages');\n const outcomes = await buildLocalPackages({\n globalRoot,\n environment,\n directories: localDirectories,\n onCommand: (command) => commands.push(command),\n onNotice: (message) => progress.line(LOCAL_LABEL, message),\n });\n let failed = 0;\n for (const [root, packagesOfRoot] of localByRoot)\n for (const { selector, directory } of packagesOfRoot) {\n const outcome = outcomes.get(directory);\n if (outcome?.status !== 'failed') continue;\n unsynced.get(root)?.push({\n selector,\n reason: outcome.reason,\n ...(outcome.stderr === undefined ? {} : { stderr: outcome.stderr }),\n });\n }\n for (const outcome of outcomes.values()) if (outcome.status === 'failed') failed += 1;\n localDone(failed === 0 ? `${pluralize(outcomes.size, 'package')} ready` : `${String(failed)} failed`);\n }\n\n const composed = composeRoots(roots, homeDirectory, environment);\n // What a root's selection leaves out still syncs the rest of the root; each is reported once.\n for (const [root, compositions] of composed) {\n if (compositions instanceof Error) continue;\n const entries = unsynced.get(root) ?? [];\n for (const skipped of skippedSelections(compositions))\n if (!entries.some((entry) => entry.selector === skipped.selector)) entries.push(skipped);\n }\n\n const webDone = progress.start(WEB_LABEL, 'ensuring the global web build');\n let rootPackageRoots = packageRootsByRoot(composed, (message) => progress.line(WEB_LABEL, message));\n const buildWeb = (packageRoots: Map<string, string[]>) =>\n deps.buildWeb({\n poHome: globalRoot,\n pluginRoots: webPluginRootsOf(globalRoot, packageRoots, environment),\n environment,\n onNotice: (message) => progress.line(WEB_LABEL, message),\n });\n let built = await buildWeb(rootPackageRoots);\n if (built.status === 'failed') {\n // A local copy is the likeliest cause; one retry without them keeps the rest serving.\n const local = new Set(localDirectories.map(realPath));\n const withoutLocal = new Map(\n [...rootPackageRoots].map(([root, packageRoots]) => [\n root,\n packageRoots.filter((packageRoot) => !local.has(realPath(packageRoot))),\n ]),\n );\n const leftOut = [...rootPackageRoots].some(\n ([root, packageRoots]) => withoutLocal.get(root)?.length !== packageRoots.length,\n );\n const retried = leftOut ? await buildWeb(withoutLocal) : built;\n if (retried.status === 'failed') {\n webDone('failed');\n const retryReason = leftOut ? `; without local copies: ${retried.reason}` : '';\n return report('failed', [`The global web build failed: ${built.reason}${retryReason}`], null, []);\n }\n for (const [root, packagesOfRoot] of localByRoot) {\n const included = new Set((rootPackageRoots.get(root) ?? []).map(realPath));\n const entries = unsynced.get(root) ?? [];\n for (const { selector, directory } of packagesOfRoot)\n if (included.has(realPath(directory)) && !entries.some((entry) => entry.selector === selector))\n entries.push({\n selector,\n reason: `left out of the web build, which failed with it: ${built.reason}`,\n });\n }\n progress.line(WEB_LABEL, `built without local copies after: ${built.reason}`);\n rootPackageRoots = withoutLocal;\n built = retried;\n }\n const pluginRoots = webPluginRootsOf(globalRoot, rootPackageRoots, environment);\n const web: SyncResult['web'] = built.status === 'skipped' ? built : { status: built.status, key: built.build.key };\n webDone(web.status === 'skipped' ? web.reason : `${web.key} (${web.status})`);\n const webKey = web.status === 'skipped' ? null : web.key;\n\n const nativeDone = progress.start(NATIVE_LABEL, 'ensuring the global native build');\n const nativeBuilt = await deps.buildNative({\n poHome: globalRoot,\n pluginRoots,\n onNotice: (message) => progress.line(NATIVE_LABEL, message),\n });\n if (nativeBuilt.status === 'failed') {\n nativeDone('failed');\n return report('failed', [`The global native build failed: ${nativeBuilt.reason}`], webKey, []);\n }\n const native: NonNullable<SyncResult['native']> =\n nativeBuilt.status === 'skipped' ? nativeBuilt : { status: nativeBuilt.status, key: nativeBuilt.build.key };\n nativeDone(native.status === 'skipped' ? native.reason : `${native.key} (${native.status})`);\n const nativeKey = native.status === 'skipped' ? null : native.key;\n\n // One MCP app build per root; its key is a content hash, so roots with one widget set share it.\n const mcpDone = progress.start(MCP_LABEL, 'ensuring the MCP app build of each root');\n const mcpKeys: string[] = [];\n for (const [root, compositions] of composed) {\n if (compositions instanceof Error) {\n progress.line(MCP_LABEL, `'${root}' is left out of the MCP app build: ${compositions.message}`);\n continue;\n }\n try {\n const app = await deps.bundleMcpApp({ poHome: globalRoot, candidates: mcpPluginCandidates(compositions) });\n if (app !== undefined && !mcpKeys.includes(app.key)) mcpKeys.push(app.key);\n } catch (error) {\n unsynced.get(root)?.push({ selector: MCP_LABEL, reason: `the MCP app build failed: ${errorMessage(error)}` });\n }\n }\n mcpDone(mcpKeys.length === 0 ? 'no MCP UI widgets' : mcpKeys.join(', '));\n const mcpApp = mcpKeys.length === 0 ? undefined : mcpKeys.join(', ');\n\n // The pointer names only artifacts that exist; a missing one keeps the previous pointer.\n const missing = pointerArtifacts(globalRoot, { webKey, nativeKey, mcpKeys }).filter((file) => !fs.existsSync(file));\n if (missing.length > 0)\n return report('failed', [`Build artifacts are missing: ${missing.join(', ')}`], webKey, mcpKeys);\n // A root that names two copies of one plugin serves only one of them under its plugin id.\n if (built.status !== 'skipped')\n for (const [root, packageRoots] of rootPackageRoots)\n for (const [pluginId, slots] of duplicatePluginCopies(built.build, packageRoots))\n unsynced.get(root)?.push({\n selector: pluginId,\n reason: `two copies of plugin '${pluginId}' are selected (${slots.join(', ')})`,\n });\n const succeeded = report('ok', [], webKey, mcpKeys);\n const generation = (previous?.generation ?? 0) + 1;\n const pointer: SyncPointer = {\n generation,\n signature: syncSignature(options, roots, catalogueHash),\n catalogueHash,\n webKey,\n nativeKey,\n mcpKeys,\n roots: succeeded.roots,\n commands,\n fingerprints: Object.fromEntries(\n roots.map((root) => [root, rootSelectionFingerprint(root, homeDirectory, environment)]),\n ),\n host: syncHostIdentity(globalRoot, environment),\n };\n const lostBeforePointer = lost();\n if (lostBeforePointer !== undefined) return lostBeforePointer;\n writeJsonFile(syncPointerPath(globalRoot), pointer);\n\n await pruneStep(progress, deps.prune, {\n homeDirectory,\n environment,\n buildsRoot: globalRoot,\n ...(webKey === null ? {} : { webKey }),\n ...(nativeKey === null ? {} : { nativeKey }),\n ...(mcpKeys.length === 0 ? {} : { mcpAppKeys: mcpKeys }),\n });\n // The checkout itself too: a linked worktree registers under its main workspace root.\n for (const root of new Set([...roots, ...(options.repoRoot === undefined ? [] : [realPath(options.repoRoot)])]))\n emitFrontendHooks(root, progress, commands);\n emit({ type: 'result', result: { packages, web, native, ...(mcpApp === undefined ? {} : { mcpApp }) } });\n return { ...succeeded, generation };\n}\n\n/**\n * One pass whose report lands in `last-attempt.json`, so a failed background run leaves its\n * reasons. A pass that lost the lock leaves the file to the holder that took it.\n */\nasync function attempt(\n options: SyncOptions,\n deps: SyncDeps,\n emit: (event: SyncEvent) => void,\n lost: () => SyncReport | undefined,\n): Promise<SyncReport> {\n let report: SyncReport;\n try {\n report = await syncOnce(options, deps, emit, lost);\n } catch (error) {\n report = emptyReport('failed', [`po sync failed: ${errorMessage(error)}`], deps);\n }\n if (report.status === 'busy') return report;\n try {\n writeJsonFile(syncLastAttemptPath(options.globalRoot), report);\n } catch (error) {\n report = {\n ...report,\n errors: [...report.errors, `last-attempt.json could not be written: ${errorMessage(error)}`],\n };\n }\n return report;\n}\n\n/**\n * Runs sync under the Po home lock and reports the outcome.\n *\n * Busy when another live sync holds the lock; a background caller leaves a rerun marker\n * first. The holder repeats its pass while a marker is present. A marker that lands after\n * its last check but before the release is caught after the release: the holder takes the\n * lock again and runs once more, or leaves the marker to whoever took the lock first.\n */\nexport async function runSync(options: SyncOptions, overrides: Partial<SyncDeps> = {}): Promise<SyncReport> {\n const deps: SyncDeps = { ...DEFAULT_DEPS, ...overrides };\n const emit = options.onEvent ?? ((): void => {});\n const lockPath = syncLockPath(options.globalRoot);\n const rerunPath = syncRerunPath(options.globalRoot);\n let lock = acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) {\n if (options.origin === 'background') fs.writeFileSync(rerunPath, deps.now().toISOString());\n const holder = lock.holder === undefined ? 'another process' : `pid ${String(lock.holder.pid)}`;\n return emptyReport('busy', [`po sync is already running (${holder})`], deps);\n }\n for (;;) {\n const { token } = lock;\n const lost = () => lostLock(lockPath, token, deps);\n let report: SyncReport;\n try {\n // A marker left before this pass started is satisfied by this pass.\n takeRerunRequest(rerunPath);\n report = await attempt(options, deps, emit, lost);\n // A pass that lost the lock leaves the rerun marker to the holder that took it.\n while (report.status !== 'busy' && takeRerunRequest(rerunPath)) report = await attempt(options, deps, emit, lost);\n } finally {\n releaseLock(lockPath, token);\n }\n if (report.status === 'busy' || !fs.existsSync(rerunPath)) return report;\n lock = acquireLock(lockPath, options.origin, deps);\n if (!lock.acquired) return report;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,MAAM,kBAAkB;AACxB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAeA,UAAAA,QAAK,KAAK,SAAS,WAAW,gBAAgB;AACnE,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAClB,MAAM,eAAe;AACrB,MAAM,YAAY;AAClB,MAAM,cAAc;AACpB,MAAM,cAA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,YAAY,UAAU,QAAQ,QAAQ,IAAI;CACrD,IAAI,CAAC,KAAK,UAAU;EAClB,IAAI,QAAQ,WAAW,cAAc,QAAA,QAAG,cAAc,WAAW,KAAK,IAAI,CAAC,CAAC,YAAY,CAAC;EAEzF,OAAO,YAAY,QAAQ,CAAC,+BADb,KAAK,WAAW,KAAA,IAAY,oBAAoB,OAAO,OAAO,KAAK,OAAO,GAAG,IAC1B,EAAE,GAAG,IAAI;CAC7E;CACA,SAAS;EACP,MAAM,EAAE,UAAU;EAClB,MAAM,aAAa,SAAS,UAAU,OAAO,IAAI;EACjD,IAAI;EACJ,IAAI;GAEF,iBAAiB,SAAS;GAC1B,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;GAEhD,OAAO,OAAO,WAAW,UAAU,iBAAiB,SAAS,GAAG,SAAS,MAAM,QAAQ,SAAS,MAAM,MAAM,IAAI;EAClH,UAAU;GACR,YAAY,UAAU,KAAK;EAC7B;EACA,IAAI,OAAO,WAAW,UAAU,CAACnB,QAAAA,QAAG,WAAW,SAAS,GAAG,OAAO;EAClE,OAAO,YAAY,UAAU,QAAQ,QAAQ,IAAI;EACjD,IAAI,CAAC,KAAK,UAAU,OAAO;CAC7B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/syncService/index.ts"],"mappings":";;;;;;YA6FY;iBAEK;EACf,UAAU,KAAK;;EAEf;IAAO;IAA4B;;IAAkB;IAAmB;;;EAExE;IAAW;IAA4B;;IAAkB;IAAmB;;;EAE5E;;iBAGe;EACf;EACA;EACA;IAAY;IAAkB;IAAgB;;;iBAG/B;EACf,QAAQ;;EAER;;EAEA;EACA;EACA;EACA,OAAO;;EAEP;EACA;EACA;;iBAgCe;EACf,gBAAgB;EAChB,iBAAiB;EACjB,oBAAoB;EACpB,qBAAqB;EACrB,cAAc;;EAEd,UAAU;EACV;EACA,WAAW;;wBAuDG,iBAAiB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/composition/syncService/index.ts"],"mappings":";;;;;;YA8FY;iBAEK;EACf,UAAU,KAAK;;EAEf;IAAO;IAA4B;;IAAkB;IAAmB;;;EAExE;IAAW;IAA4B;;IAAkB;IAAmB;;;EAE5E;;iBAGe;EACf;EACA;EACA;IAAY;IAAkB;IAAgB;;;iBAG/B;EACf,QAAQ;;EAER;;EAEA;EACA;EACA;EACA,OAAO;;EAEP;EACA;EACA;;iBAgCe;EACf,gBAAgB;EAChB,iBAAiB;EACjB,oBAAoB;EACpB,qBAAqB;EACrB,cAAc;;EAEd,UAAU;EACV;EACA,WAAW;;wBAuDG,iBAAiB,QAAQ"}