opkg 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (487) hide show
  1. package/README.md +109 -186
  2. package/assets/openpackage_ascii_dark.png +0 -0
  3. package/assets/openpackage_ascii_light.png +0 -0
  4. package/dist/commands/add.js +34 -10
  5. package/dist/commands/add.js.map +1 -1
  6. package/dist/commands/apply.js +16 -0
  7. package/dist/commands/apply.js.map +1 -0
  8. package/dist/commands/delete.js +1 -1
  9. package/dist/commands/delete.js.map +1 -1
  10. package/dist/commands/install.js +177 -8
  11. package/dist/commands/install.js.map +1 -1
  12. package/dist/commands/list.js +2 -2
  13. package/dist/commands/list.js.map +1 -1
  14. package/dist/commands/login.js +1 -1
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/logout.js +1 -1
  17. package/dist/commands/logout.js.map +1 -1
  18. package/dist/commands/new.js +125 -0
  19. package/dist/commands/new.js.map +1 -0
  20. package/dist/commands/pack.js +7 -13
  21. package/dist/commands/pack.js.map +1 -1
  22. package/dist/commands/pull.js +1 -1
  23. package/dist/commands/pull.js.map +1 -1
  24. package/dist/commands/push.js +1 -1
  25. package/dist/commands/push.js.map +1 -1
  26. package/dist/commands/remove.js +63 -0
  27. package/dist/commands/remove.js.map +1 -0
  28. package/dist/commands/save.js +11 -17
  29. package/dist/commands/save.js.map +1 -1
  30. package/dist/commands/set.js +33 -0
  31. package/dist/commands/set.js.map +1 -0
  32. package/dist/commands/show.js +16 -94
  33. package/dist/commands/show.js.map +1 -1
  34. package/dist/commands/status.js +26 -701
  35. package/dist/commands/status.js.map +1 -1
  36. package/dist/commands/uninstall.js +14 -427
  37. package/dist/commands/uninstall.js.map +1 -1
  38. package/dist/constants/index.js +72 -16
  39. package/dist/constants/index.js.map +1 -1
  40. package/dist/core/add/add-conflict-handler.js +1 -8
  41. package/dist/core/add/add-conflict-handler.js.map +1 -1
  42. package/dist/core/add/add-pipeline.js +12 -10
  43. package/dist/core/add/add-pipeline.js.map +1 -1
  44. package/dist/core/add/add-to-source-pipeline.js +123 -0
  45. package/dist/core/add/add-to-source-pipeline.js.map +1 -0
  46. package/dist/core/add/package-index-updater.js +77 -78
  47. package/dist/core/add/package-index-updater.js.map +1 -1
  48. package/dist/core/add/platform-path-transformer.js +6 -4
  49. package/dist/core/add/platform-path-transformer.js.map +1 -1
  50. package/dist/core/add/source-collector.js +2 -3
  51. package/dist/core/add/source-collector.js.map +1 -1
  52. package/dist/core/apply/apply-pipeline.js +110 -0
  53. package/dist/core/apply/apply-pipeline.js.map +1 -0
  54. package/dist/core/dependency-resolver.js +263 -21
  55. package/dist/core/dependency-resolver.js.map +1 -1
  56. package/dist/core/discovery/file-discovery.js +1 -2
  57. package/dist/core/discovery/file-discovery.js.map +1 -1
  58. package/dist/core/discovery/platform-files-discovery.js +33 -18
  59. package/dist/core/discovery/platform-files-discovery.js.map +1 -1
  60. package/dist/core/flows/flow-executor.js +974 -0
  61. package/dist/core/flows/flow-executor.js.map +1 -0
  62. package/dist/core/flows/flow-inverter.js +442 -0
  63. package/dist/core/flows/flow-inverter.js.map +1 -0
  64. package/dist/core/flows/flow-key-extractor.js +101 -0
  65. package/dist/core/flows/flow-key-extractor.js.map +1 -0
  66. package/dist/core/flows/flow-key-mapper.js +382 -0
  67. package/dist/core/flows/flow-key-mapper.js.map +1 -0
  68. package/dist/core/flows/flow-transforms.js +632 -0
  69. package/dist/core/flows/flow-transforms.js.map +1 -0
  70. package/dist/core/flows/map-pipeline/context.js +73 -0
  71. package/dist/core/flows/map-pipeline/context.js.map +1 -0
  72. package/dist/core/flows/map-pipeline/index.js +156 -0
  73. package/dist/core/flows/map-pipeline/index.js.map +1 -0
  74. package/dist/core/flows/map-pipeline/operations/copy.js +104 -0
  75. package/dist/core/flows/map-pipeline/operations/copy.js.map +1 -0
  76. package/dist/core/flows/map-pipeline/operations/pipe.js +70 -0
  77. package/dist/core/flows/map-pipeline/operations/pipe.js.map +1 -0
  78. package/dist/core/flows/map-pipeline/operations/rename.js +102 -0
  79. package/dist/core/flows/map-pipeline/operations/rename.js.map +1 -0
  80. package/dist/core/flows/map-pipeline/operations/set.js +50 -0
  81. package/dist/core/flows/map-pipeline/operations/set.js.map +1 -0
  82. package/dist/core/flows/map-pipeline/operations/switch.js +79 -0
  83. package/dist/core/flows/map-pipeline/operations/switch.js.map +1 -0
  84. package/dist/core/flows/map-pipeline/operations/transform.js +543 -0
  85. package/dist/core/flows/map-pipeline/operations/transform.js.map +1 -0
  86. package/dist/core/flows/map-pipeline/operations/unset.js +65 -0
  87. package/dist/core/flows/map-pipeline/operations/unset.js.map +1 -0
  88. package/dist/core/flows/map-pipeline/types.js +8 -0
  89. package/dist/core/flows/map-pipeline/types.js.map +1 -0
  90. package/dist/core/flows/map-pipeline/utils.js +278 -0
  91. package/dist/core/flows/map-pipeline/utils.js.map +1 -0
  92. package/dist/core/flows/platform-converter.js +328 -0
  93. package/dist/core/flows/platform-converter.js.map +1 -0
  94. package/dist/core/flows/source-resolver.js +192 -0
  95. package/dist/core/flows/source-resolver.js.map +1 -0
  96. package/dist/core/flows/toml-domain-transforms.js +23 -0
  97. package/dist/core/flows/toml-domain-transforms.js.map +1 -0
  98. package/dist/core/install/bulk-install-pipeline.js +68 -7
  99. package/dist/core/install/bulk-install-pipeline.js.map +1 -1
  100. package/dist/core/install/canonical-plan.js +3 -3
  101. package/dist/core/install/canonical-plan.js.map +1 -1
  102. package/dist/core/install/dry-run.js +3 -3
  103. package/dist/core/install/dry-run.js.map +1 -1
  104. package/dist/core/install/flow-based-installer.js +1158 -0
  105. package/dist/core/install/flow-based-installer.js.map +1 -0
  106. package/dist/core/install/flow-workspace-tracker.js +111 -0
  107. package/dist/core/install/flow-workspace-tracker.js.map +1 -0
  108. package/dist/core/install/format-detector.js +228 -0
  109. package/dist/core/install/format-detector.js.map +1 -0
  110. package/dist/core/install/git-package-loader.js +20 -0
  111. package/dist/core/install/git-package-loader.js.map +1 -0
  112. package/dist/core/install/install-errors.js +1 -1
  113. package/dist/core/install/install-errors.js.map +1 -1
  114. package/dist/core/install/install-flow.js +34 -14
  115. package/dist/core/install/install-flow.js.map +1 -1
  116. package/dist/core/install/install-pipeline.js +52 -17
  117. package/dist/core/install/install-pipeline.js.map +1 -1
  118. package/dist/core/install/install-reporting.js +26 -8
  119. package/dist/core/install/install-reporting.js.map +1 -1
  120. package/dist/core/install/local-source-resolution.js +103 -0
  121. package/dist/core/install/local-source-resolution.js.map +1 -0
  122. package/dist/core/install/marketplace-handler.js +221 -0
  123. package/dist/core/install/marketplace-handler.js.map +1 -0
  124. package/dist/core/install/path-install-pipeline.js +241 -0
  125. package/dist/core/install/path-install-pipeline.js.map +1 -0
  126. package/dist/core/install/path-package-loader.js +116 -0
  127. package/dist/core/install/path-package-loader.js.map +1 -0
  128. package/dist/core/install/plugin-detector.js +72 -0
  129. package/dist/core/install/plugin-detector.js.map +1 -0
  130. package/dist/core/install/plugin-to-universal-converter.js +218 -0
  131. package/dist/core/install/plugin-to-universal-converter.js.map +1 -0
  132. package/dist/core/install/plugin-transformer.js +191 -0
  133. package/dist/core/install/plugin-transformer.js.map +1 -0
  134. package/dist/core/install/version-selection.js +1 -1
  135. package/dist/core/install/version-selection.js.map +1 -1
  136. package/dist/core/openpackage.js +40 -22
  137. package/dist/core/openpackage.js.map +1 -1
  138. package/dist/core/pack/pack-output.js +62 -0
  139. package/dist/core/pack/pack-output.js.map +1 -0
  140. package/dist/core/pack/pack-pipeline.js +186 -0
  141. package/dist/core/pack/pack-pipeline.js.map +1 -0
  142. package/dist/core/package-context.js +45 -70
  143. package/dist/core/package-context.js.map +1 -1
  144. package/dist/core/package-creation.js +203 -0
  145. package/dist/core/package-creation.js.map +1 -0
  146. package/dist/core/package.js +20 -6
  147. package/dist/core/package.js.map +1 -1
  148. package/dist/core/platforms.js +665 -209
  149. package/dist/core/platforms.js.map +1 -1
  150. package/dist/core/push/push-context.js +1 -1
  151. package/dist/core/push/push-context.js.map +1 -1
  152. package/dist/core/push/push-upload.js +2 -2
  153. package/dist/core/push/push-upload.js.map +1 -1
  154. package/dist/core/registry.js +6 -6
  155. package/dist/core/registry.js.map +1 -1
  156. package/dist/core/remote-pull.js +2 -2
  157. package/dist/core/remote-pull.js.map +1 -1
  158. package/dist/core/remove/removal-collector.js +52 -0
  159. package/dist/core/remove/removal-collector.js.map +1 -0
  160. package/dist/core/remove/removal-confirmation.js +39 -0
  161. package/dist/core/remove/removal-confirmation.js.map +1 -0
  162. package/dist/core/remove/remove-from-source-pipeline.js +173 -0
  163. package/dist/core/remove/remove-from-source-pipeline.js.map +1 -0
  164. package/dist/core/save/constants.js +3 -3
  165. package/dist/core/save/constants.js.map +1 -1
  166. package/dist/core/save/flow-based-saver.js +270 -0
  167. package/dist/core/save/flow-based-saver.js.map +1 -0
  168. package/dist/core/save/name-resolution.js +1 -1
  169. package/dist/core/save/name-resolution.js.map +1 -1
  170. package/dist/core/save/package-yml-generator.js +4 -5
  171. package/dist/core/save/package-yml-generator.js.map +1 -1
  172. package/dist/core/save/save-candidate-builder.js +215 -0
  173. package/dist/core/save/save-candidate-builder.js.map +1 -0
  174. package/dist/core/save/save-candidate-loader.js +12 -11
  175. package/dist/core/save/save-candidate-loader.js.map +1 -1
  176. package/dist/core/save/save-conflict-analyzer.js +150 -0
  177. package/dist/core/save/save-conflict-analyzer.js.map +1 -0
  178. package/dist/core/save/save-conflict-resolution.js +28 -14
  179. package/dist/core/save/save-conflict-resolution.js.map +1 -1
  180. package/dist/core/save/save-conflict-resolver.js +31 -275
  181. package/dist/core/save/save-conflict-resolver.js.map +1 -1
  182. package/dist/core/save/save-group-builder.js +52 -0
  183. package/dist/core/save/save-group-builder.js.map +1 -0
  184. package/dist/core/save/save-interactive-resolver.js +190 -0
  185. package/dist/core/save/save-interactive-resolver.js.map +1 -0
  186. package/dist/core/save/save-pipeline.js +58 -34
  187. package/dist/core/save/save-pipeline.js.map +1 -1
  188. package/dist/core/save/save-platform-handler.js +53 -0
  189. package/dist/core/save/save-platform-handler.js.map +1 -0
  190. package/dist/core/save/save-resolution-executor.js +145 -0
  191. package/dist/core/save/save-resolution-executor.js.map +1 -0
  192. package/dist/core/save/save-result-reporter.js +167 -0
  193. package/dist/core/save/save-result-reporter.js.map +1 -0
  194. package/dist/core/save/save-to-source-pipeline.js +154 -0
  195. package/dist/core/save/save-to-source-pipeline.js.map +1 -0
  196. package/dist/core/save/save-versioning.js +4 -4
  197. package/dist/core/save/save-versioning.js.map +1 -1
  198. package/dist/core/save/save-write-coordinator.js +204 -0
  199. package/dist/core/save/save-write-coordinator.js.map +1 -0
  200. package/dist/core/save/save-yml-resolution.js +28 -216
  201. package/dist/core/save/save-yml-resolution.js.map +1 -1
  202. package/dist/core/save/workspace-rename.js +7 -8
  203. package/dist/core/save/workspace-rename.js.map +1 -1
  204. package/dist/core/set/set-output.js +72 -0
  205. package/dist/core/set/set-output.js.map +1 -0
  206. package/dist/core/set/set-pipeline.js +361 -0
  207. package/dist/core/set/set-pipeline.js.map +1 -0
  208. package/dist/core/set/set-types.js +5 -0
  209. package/dist/core/set/set-types.js.map +1 -0
  210. package/dist/core/show/package-resolver.js +257 -0
  211. package/dist/core/show/package-resolver.js.map +1 -0
  212. package/dist/core/show/scope-discovery.js +165 -0
  213. package/dist/core/show/scope-discovery.js.map +1 -0
  214. package/dist/core/show/show-output.js +168 -0
  215. package/dist/core/show/show-output.js.map +1 -0
  216. package/dist/core/show/show-pipeline.js +113 -0
  217. package/dist/core/show/show-pipeline.js.map +1 -0
  218. package/dist/core/show/show-types.js +5 -0
  219. package/dist/core/show/show-types.js.map +1 -0
  220. package/dist/core/source-resolution/dependency-graph.js +104 -0
  221. package/dist/core/source-resolution/dependency-graph.js.map +1 -0
  222. package/dist/core/source-resolution/resolve-mutable-source.js +109 -0
  223. package/dist/core/source-resolution/resolve-mutable-source.js.map +1 -0
  224. package/dist/core/source-resolution/resolve-package-source.js +29 -0
  225. package/dist/core/source-resolution/resolve-package-source.js.map +1 -0
  226. package/dist/core/source-resolution/resolve-registry-version.js +35 -0
  227. package/dist/core/source-resolution/resolve-registry-version.js.map +1 -0
  228. package/dist/core/source-resolution/types.js.map +1 -0
  229. package/dist/core/status/status-file-discovery.js +23 -12
  230. package/dist/core/status/status-file-discovery.js.map +1 -1
  231. package/dist/core/status/status-pipeline.js +134 -0
  232. package/dist/core/status/status-pipeline.js.map +1 -0
  233. package/dist/core/sync/platform-sync-summary.js +27 -0
  234. package/dist/core/sync/platform-sync-summary.js.map +1 -0
  235. package/dist/core/uninstall/flow-aware-uninstaller.js +189 -0
  236. package/dist/core/uninstall/flow-aware-uninstaller.js.map +1 -0
  237. package/dist/core/uninstall/uninstall-file-discovery.js +11 -6
  238. package/dist/core/uninstall/uninstall-file-discovery.js.map +1 -1
  239. package/dist/core/uninstall/uninstall-pipeline.js +141 -0
  240. package/dist/core/uninstall/uninstall-pipeline.js.map +1 -0
  241. package/dist/core/universal-patterns.js +64 -0
  242. package/dist/core/universal-patterns.js.map +1 -0
  243. package/dist/index.js +99 -6
  244. package/dist/index.js.map +1 -1
  245. package/dist/types/flows.js +8 -0
  246. package/dist/types/flows.js.map +1 -0
  247. package/dist/types/index.js +3 -0
  248. package/dist/types/index.js.map +1 -1
  249. package/dist/types/platform-flows.js +8 -0
  250. package/dist/types/platform-flows.js.map +1 -0
  251. package/dist/types/workspace-index.js +6 -0
  252. package/dist/types/workspace-index.js.map +1 -0
  253. package/dist/utils/custom-path-resolution.js +160 -0
  254. package/dist/utils/custom-path-resolution.js.map +1 -0
  255. package/dist/utils/dependency-coverage.js +1 -1
  256. package/dist/utils/dependency-coverage.js.map +1 -1
  257. package/dist/utils/file-processing.js +1 -1
  258. package/dist/utils/flow-index-installer.js +209 -0
  259. package/dist/utils/flow-index-installer.js.map +1 -0
  260. package/dist/utils/formatters.js +47 -1
  261. package/dist/utils/formatters.js.map +1 -1
  262. package/dist/utils/fs.js +17 -0
  263. package/dist/utils/fs.js.map +1 -1
  264. package/dist/utils/git-clone-registry.js +88 -0
  265. package/dist/utils/git-clone-registry.js.map +1 -0
  266. package/dist/utils/git-clone.js +69 -0
  267. package/dist/utils/git-clone.js.map +1 -0
  268. package/dist/utils/git-spec.js +96 -0
  269. package/dist/utils/git-spec.js.map +1 -0
  270. package/dist/utils/http-client.js +7 -0
  271. package/dist/utils/http-client.js.map +1 -1
  272. package/dist/utils/index-based-installer.js +356 -163
  273. package/dist/utils/index-based-installer.js.map +1 -1
  274. package/dist/utils/install-conflict-handler.js +2 -2
  275. package/dist/utils/install-conflict-handler.js.map +1 -1
  276. package/dist/utils/install-file-discovery.js +18 -13
  277. package/dist/utils/install-file-discovery.js.map +1 -1
  278. package/dist/utils/install-helpers.js +43 -20
  279. package/dist/utils/install-helpers.js.map +1 -1
  280. package/dist/utils/jsonc.js +23 -1
  281. package/dist/utils/jsonc.js.map +1 -1
  282. package/dist/utils/manifest-paths.js +1 -1
  283. package/dist/utils/manifest-paths.js.map +1 -1
  284. package/dist/utils/markdown-frontmatter.js +46 -0
  285. package/dist/utils/markdown-frontmatter.js.map +1 -1
  286. package/dist/utils/package-copy.js +5 -103
  287. package/dist/utils/package-copy.js.map +1 -1
  288. package/dist/utils/package-filters.js +9 -105
  289. package/dist/utils/package-filters.js.map +1 -1
  290. package/dist/utils/package-index-yml.js +27 -6
  291. package/dist/utils/package-index-yml.js.map +1 -1
  292. package/dist/utils/package-input.js +98 -0
  293. package/dist/utils/package-input.js.map +1 -0
  294. package/dist/utils/package-management.js +80 -28
  295. package/dist/utils/package-management.js.map +1 -1
  296. package/dist/utils/package-name-resolution.js +327 -0
  297. package/dist/utils/package-name-resolution.js.map +1 -0
  298. package/dist/utils/package-name.js +18 -16
  299. package/dist/utils/package-name.js.map +1 -1
  300. package/dist/utils/package-versioning.js +2 -33
  301. package/dist/utils/package-versioning.js.map +1 -1
  302. package/dist/utils/package-yml.js +19 -28
  303. package/dist/utils/package-yml.js.map +1 -1
  304. package/dist/utils/path-resolution.js +102 -0
  305. package/dist/utils/path-resolution.js.map +1 -0
  306. package/dist/utils/paths.js +6 -6
  307. package/dist/utils/paths.js.map +1 -1
  308. package/dist/utils/platform-file.js +36 -24
  309. package/dist/utils/platform-file.js.map +1 -1
  310. package/dist/utils/platform-mapper.js +222 -68
  311. package/dist/utils/platform-mapper.js.map +1 -1
  312. package/dist/utils/platform-root-files.js +44 -0
  313. package/dist/utils/platform-root-files.js.map +1 -0
  314. package/dist/utils/platform-utils.js +35 -54
  315. package/dist/utils/platform-utils.js.map +1 -1
  316. package/dist/utils/platform-yaml-merge.js +20 -140
  317. package/dist/utils/platform-yaml-merge.js.map +1 -1
  318. package/dist/utils/prompts.js +92 -7
  319. package/dist/utils/prompts.js.map +1 -1
  320. package/dist/utils/registry-entry-filter.js +50 -27
  321. package/dist/utils/registry-entry-filter.js.map +1 -1
  322. package/dist/utils/registry-paths.js +5 -4
  323. package/dist/utils/registry-paths.js.map +1 -1
  324. package/dist/utils/scope-resolution.js +156 -0
  325. package/dist/utils/scope-resolution.js.map +1 -0
  326. package/dist/utils/source-mutability.js +15 -0
  327. package/dist/utils/source-mutability.js.map +1 -0
  328. package/dist/utils/tarball.js +29 -4
  329. package/dist/utils/tarball.js.map +1 -1
  330. package/dist/utils/version-ranges.js +1 -32
  331. package/dist/utils/version-ranges.js.map +1 -1
  332. package/dist/utils/workspace-index-helpers.js +28 -0
  333. package/dist/utils/workspace-index-helpers.js.map +1 -0
  334. package/dist/utils/workspace-index-ownership.js +100 -0
  335. package/dist/utils/workspace-index-ownership.js.map +1 -0
  336. package/dist/utils/workspace-index-yml.js +173 -0
  337. package/dist/utils/workspace-index-yml.js.map +1 -0
  338. package/examples/custom-subdirs-platform.jsonc +157 -0
  339. package/package.json +7 -2
  340. package/platforms.jsonc +531 -84
  341. package/schemas/map-pipeline-v1.json +256 -0
  342. package/schemas/platforms-v1.json +400 -0
  343. package/specs/README.md +88 -0
  344. package/specs/add/README.md +166 -0
  345. package/specs/agents-claude.md +570 -0
  346. package/specs/agents-opencode.md +622 -0
  347. package/specs/apply/README.md +21 -0
  348. package/specs/apply/apply-behavior.md +58 -0
  349. package/specs/apply/apply-command.md +51 -0
  350. package/specs/apply/conflicts.md +41 -0
  351. package/specs/apply/index-effects.md +81 -0
  352. package/specs/architecture.md +107 -0
  353. package/specs/auth/README.md +17 -0
  354. package/specs/auth/auth-http-contract.md +25 -0
  355. package/specs/auth/cli/credentials.md +39 -0
  356. package/specs/auth/cli/login.md +32 -0
  357. package/specs/auth/cli/logout.md +16 -0
  358. package/specs/claude-mcp.md +1065 -0
  359. package/specs/claude-plugins-marketplace.md +363 -0
  360. package/specs/claude-plugins.md +413 -0
  361. package/specs/cli-options.md +52 -0
  362. package/specs/codex-mcp.md +114 -0
  363. package/specs/commands-overview.md +175 -0
  364. package/specs/directory-layout.md +95 -0
  365. package/specs/install/README.md +12 -4
  366. package/specs/install/git-sources.md +230 -0
  367. package/specs/install/install-behavior.md +483 -73
  368. package/specs/install/package-yml-canonical.md +67 -35
  369. package/specs/install/version-resolution.md +69 -115
  370. package/specs/new/README.md +769 -0
  371. package/specs/new/SUMMARY.md +310 -0
  372. package/specs/new/scope-behavior.md +793 -0
  373. package/specs/pack/README.md +77 -0
  374. package/specs/pack/package-name-resolution.md +330 -0
  375. package/specs/package/README.md +18 -17
  376. package/specs/package/nested-packages-and-parent-packages.md +32 -31
  377. package/specs/package/package-index-yml.md +95 -101
  378. package/specs/package/package-root-layout.md +64 -46
  379. package/specs/package/registry-payload-and-copy.md +50 -44
  380. package/specs/package/universal-content.md +33 -56
  381. package/specs/package-sources.md +248 -0
  382. package/specs/platforms/README.md +52 -0
  383. package/specs/platforms/configuration.md +571 -0
  384. package/specs/platforms/detection.md +552 -0
  385. package/specs/platforms/directory-layout.md +599 -0
  386. package/specs/platforms/examples.md +1146 -0
  387. package/specs/platforms/flow-reference.md +1240 -0
  388. package/specs/platforms/flows.md +1488 -0
  389. package/specs/platforms/map-pipeline.md +801 -0
  390. package/specs/platforms/overview.md +349 -0
  391. package/specs/platforms/specification.md +700 -0
  392. package/specs/platforms/troubleshooting.md +697 -0
  393. package/specs/platforms/universal-converter.md +520 -0
  394. package/specs/push/README.md +1 -0
  395. package/specs/push/push-behavior.md +11 -3
  396. package/specs/push/push-remote-upload.md +1 -1
  397. package/specs/push/push-scoping.md +1 -1
  398. package/specs/push/push-version-selection.md +1 -1
  399. package/specs/registry.md +111 -0
  400. package/specs/remove/README.md +257 -0
  401. package/specs/save/README.md +21 -17
  402. package/specs/save/save-conflict-resolution.md +205 -83
  403. package/specs/save/save-file-discovery.md +6 -4
  404. package/specs/save/save-frontmatter-overrides.md +11 -15
  405. package/specs/save/save-modes-inputs.md +9 -39
  406. package/specs/save/save-naming-scoping.md +4 -4
  407. package/specs/save/save-package-detection.md +13 -13
  408. package/specs/save/save-registry-sync.md +16 -106
  409. package/specs/save/save-versioning.md +80 -0
  410. package/specs/scope-management.md +92 -0
  411. package/specs/set/README.md +520 -0
  412. package/specs/set/set-behavior.md +563 -0
  413. package/specs/show/README.md +483 -0
  414. package/specs/show/show-remote.md +494 -0
  415. package/specs/status/README.md +38 -0
  416. package/specs/uninstall/README.md +231 -0
  417. package/dist/commands/duplicate.js +0 -69
  418. package/dist/commands/duplicate.js.map +0 -1
  419. package/dist/commands/init.js +0 -117
  420. package/dist/commands/init.js.map +0 -1
  421. package/dist/commands/prune.js +0 -357
  422. package/dist/commands/prune.js.map +0 -1
  423. package/dist/commands/tui.js +0 -61
  424. package/dist/commands/tui.js.map +0 -1
  425. package/dist/core/install/index.js +0 -3
  426. package/dist/core/install/index.js.map +0 -1
  427. package/dist/core/push/push-single-file.js +0 -56
  428. package/dist/core/push/push-single-file.js.map +0 -1
  429. package/dist/core/save/package-detection.js +0 -147
  430. package/dist/core/save/package-detection.js.map +0 -1
  431. package/dist/core/save/save-single-file.js +0 -124
  432. package/dist/core/save/save-single-file.js.map +0 -1
  433. package/dist/core/token-store.js +0 -73
  434. package/dist/core/token-store.js.map +0 -1
  435. package/dist/tui/app.js +0 -95
  436. package/dist/tui/app.js.map +0 -1
  437. package/dist/tui/components/package-list.js +0 -73
  438. package/dist/tui/components/package-list.js.map +0 -1
  439. package/dist/tui/controller.js +0 -365
  440. package/dist/tui/controller.js.map +0 -1
  441. package/dist/tui/index.js +0 -12
  442. package/dist/tui/index.js.map +0 -1
  443. package/dist/tui/services/file-index.js +0 -64
  444. package/dist/tui/services/file-index.js.map +0 -1
  445. package/dist/tui/services/packages.js +0 -18
  446. package/dist/tui/services/packages.js.map +0 -1
  447. package/dist/tui/services/save.js +0 -21
  448. package/dist/tui/services/save.js.map +0 -1
  449. package/dist/tui/state/app-state.js +0 -15
  450. package/dist/tui/state/app-state.js.map +0 -1
  451. package/dist/tui/state.js +0 -17
  452. package/dist/tui/state.js.map +0 -1
  453. package/dist/tui/types.js.map +0 -1
  454. package/dist/tui/views/add-file-modal.js +0 -129
  455. package/dist/tui/views/add-file-modal.js.map +0 -1
  456. package/dist/tui/views/file-preview.js +0 -44
  457. package/dist/tui/views/file-preview.js.map +0 -1
  458. package/dist/tui/views/list-packages.js +0 -73
  459. package/dist/tui/views/list-packages.js.map +0 -1
  460. package/dist/tui/views/main-menu.js +0 -29
  461. package/dist/tui/views/main-menu.js.map +0 -1
  462. package/dist/tui/views/manage-view.js +0 -81
  463. package/dist/tui/views/manage-view.js.map +0 -1
  464. package/dist/tui/views/package-hub.js +0 -120
  465. package/dist/tui/views/package-hub.js.map +0 -1
  466. package/dist/tui/views/placeholder.js +0 -24
  467. package/dist/tui/views/placeholder.js.map +0 -1
  468. package/dist/utils/bun-bootstrap.js +0 -72
  469. package/dist/utils/bun-bootstrap.js.map +0 -1
  470. package/dist/utils/entity-id.js +0 -19
  471. package/dist/utils/entity-id.js.map +0 -1
  472. package/dist/utils/package-local-files.js +0 -5
  473. package/dist/utils/package-local-files.js.map +0 -1
  474. package/dist/utils/path-matching.js +0 -74
  475. package/dist/utils/path-matching.js.map +0 -1
  476. package/dist/utils/root-file-operations.js +0 -39
  477. package/dist/utils/root-file-operations.js.map +0 -1
  478. package/dist/utils/root-file-transformer.js +0 -27
  479. package/dist/utils/root-file-transformer.js.map +0 -1
  480. package/dist/utils/yaml-frontmatter.js +0 -25
  481. package/dist/utils/yaml-frontmatter.js.map +0 -1
  482. package/specs/auth/auth-device-flow.md +0 -70
  483. package/specs/login/login-device-flow.md +0 -70
  484. package/specs/platforms.md +0 -193
  485. package/specs/save-pack-versioning.md +0 -224
  486. package/specs/save-pack.md +0 -68
  487. /package/dist/{tui → core/source-resolution}/types.js +0 -0
@@ -4,14 +4,15 @@
4
4
  * file patterns, and other constants used throughout the application.
5
5
  */
6
6
  export const DIR_PATTERNS = {
7
- OPENPACKAGE: '.openpackage'
7
+ OPENPACKAGE: '.openpackage',
8
+ CLAUDE_PLUGIN: '.claude-plugin'
8
9
  };
9
10
  export const FILE_PATTERNS = {
10
11
  MD_FILES: '.md',
11
12
  MDC_FILES: '.mdc',
12
13
  TOML_FILES: '.toml',
13
- PACKAGE_YML: 'package.yml',
14
- PACKAGE_INDEX_YML: 'package.index.yml',
14
+ OPENPACKAGE_YML: 'openpackage.yml',
15
+ OPENPACKAGE_INDEX_YML: 'openpackage.index.yml',
15
16
  README_MD: 'README.md',
16
17
  // Platform-specific root files
17
18
  AGENTS_MD: 'AGENTS.md',
@@ -23,13 +24,8 @@ export const FILE_PATTERNS = {
23
24
  MARKDOWN_FILES: ['.md', '.mdc'],
24
25
  YML_FILE: '.yml',
25
26
  };
26
- // Universal subdirectory names used across all platforms
27
- export const UNIVERSAL_SUBDIRS = {
28
- RULES: 'rules',
29
- COMMANDS: 'commands',
30
- AGENTS: 'agents',
31
- SKILLS: 'skills'
32
- };
27
+ // Universal subdirectory names are now dynamically discovered from platform configs
28
+ // No hardcoded subdirs - platforms define their own universal directories
33
29
  export const OPENPACKAGE_DIRS = {
34
30
  REGISTRY: 'registry',
35
31
  PACKAGES: 'packages',
@@ -37,19 +33,29 @@ export const OPENPACKAGE_DIRS = {
37
33
  RUNTIME: 'runtime'
38
34
  };
39
35
  /**
40
- * Canonical paths within a package (relative to the package root).
36
+ * Package root directory names (relative to package root).
37
+ */
38
+ export const PACKAGE_ROOT_DIRS = {
39
+ /**
40
+ * Direct copy directory: files under `root/**` are copied 1:1 to workspace root
41
+ * with the `root/` prefix stripped during install.
42
+ */
43
+ ROOT_COPY: 'root'
44
+ };
45
+ /**
46
+ * Canonical paths within a package or cached copy (relative to the package root).
41
47
  */
42
48
  export const PACKAGE_PATHS = {
43
49
  /**
44
50
  * The canonical location of the package manifest within a package:
45
- * <package-root>/.openpackage/package.yml
51
+ * <package-root>/openpackage.yml
46
52
  */
47
- MANIFEST_RELATIVE: `${DIR_PATTERNS.OPENPACKAGE}/${FILE_PATTERNS.PACKAGE_YML}`,
53
+ MANIFEST_RELATIVE: `${FILE_PATTERNS.OPENPACKAGE_YML}`,
48
54
  /**
49
- * The canonical location of the package index file within a package:
50
- * <package-root>/.openpackage/package.index.yml
55
+ * The canonical location of the package index file within a cached package copy:
56
+ * <cached-package-root>/openpackage.index.yml
51
57
  */
52
- INDEX_RELATIVE: `${DIR_PATTERNS.OPENPACKAGE}/${FILE_PATTERNS.PACKAGE_INDEX_YML}`,
58
+ INDEX_RELATIVE: `${FILE_PATTERNS.OPENPACKAGE_INDEX_YML}`,
53
59
  };
54
60
  export const DEPENDENCY_ARRAYS = {
55
61
  PACKAGES: 'packages',
@@ -61,4 +67,54 @@ export const CONFLICT_RESOLUTION = {
61
67
  OVERWRITTEN: 'overwritten'
62
68
  };
63
69
  export const UNVERSIONED = '0.0.0';
70
+ /**
71
+ * Source type constants for package resolution.
72
+ */
73
+ export const SOURCE_TYPES = {
74
+ PATH: 'path',
75
+ REGISTRY: 'registry',
76
+ GIT: 'git'
77
+ };
78
+ /**
79
+ * Mutability constants for package sources.
80
+ */
81
+ export const MUTABILITY = {
82
+ MUTABLE: 'mutable',
83
+ IMMUTABLE: 'immutable'
84
+ };
85
+ /**
86
+ * Resolution source constants (where version was resolved from).
87
+ */
88
+ export const RESOLUTION_SOURCES = {
89
+ LOCAL: 'local',
90
+ REMOTE: 'remote'
91
+ };
92
+ /**
93
+ * Git-related constants.
94
+ */
95
+ export const GIT = {
96
+ DIRECTORY: 'git',
97
+ DEFAULT_REF: 'HEAD',
98
+ COMMANDS: {
99
+ CLONE: 'clone',
100
+ FETCH: 'fetch',
101
+ CHECKOUT: 'checkout',
102
+ PULL: 'pull',
103
+ DEPTH_FLAG: '--depth',
104
+ DEPTH_VALUE: '1',
105
+ BRANCH_FLAG: '--branch',
106
+ ORIGIN: 'origin'
107
+ }
108
+ };
109
+ /**
110
+ * Default version constraint (wildcard/latest).
111
+ */
112
+ export const DEFAULT_VERSION_CONSTRAINT = '*';
113
+ /**
114
+ * Registry path prefixes (for constructing declared paths).
115
+ */
116
+ export const REGISTRY_PATH_PREFIXES = {
117
+ BASE: '~/.openpackage/registry/',
118
+ GIT: '~/.openpackage/registry/git/'
119
+ };
64
120
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,cAAc;CACnB,CAAC;AAEX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,MAAM;IACjB,UAAU,EAAE,OAAO;IACnB,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,SAAS,EAAE,WAAW;IACtB,+BAA+B;IAC/B,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,uBAAuB;IACvB,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;IAC/B,QAAQ,EAAE,MAAM;CACR,CAAC;AAEX,yDAAyD;AACzD,MAAM,CAAC,MA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M,EAAE,QAAQ;CACR,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,MAAM;IACnB,QAAQ,EAAE;QACR,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,SAAS;QACrB,WAAW,EAAE,GAAG;QAChB,WAAW,EAAE,UAAU;QACvB,MAAM,EAAE,QAAQ;KACjB;CACO,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAY,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,IAAI,EAAE,0BAA0B;IAChC,GAAG,EAAE,8BAA8B;CAC3B,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { dirname, join } from 'path';
2
- import { DIR_PATTERNS } from '../../constants/index.js';
3
2
  import { ensureDir, exists, readTextFile, writeTextFile } from '../../utils/fs.js';
4
3
  import { safePrompts } from '../../utils/prompts.js';
5
4
  import { UserCancellationError } from '../../utils/errors.js';
@@ -10,13 +9,7 @@ import { logger } from '../../utils/logger.js';
10
9
  * - Otherwise, write to package root directory
11
10
  */
12
11
  function resolveTargetPath(packageContext, registryPath) {
13
- const openpackagePrefix = `${DIR_PATTERNS.OPENPACKAGE}/`;
14
- if (registryPath.startsWith(openpackagePrefix)) {
15
- // Universal content: strip prefix and write to content directory
16
- const relativePath = registryPath.slice(openpackagePrefix.length);
17
- return join(packageContext.packageFilesDir, relativePath);
18
- }
19
- // Root-level content: write to package root directory
12
+ // V2: registry paths are package-root-relative (universal subdirs already at root)
20
13
  return join(packageContext.packageRootDir, registryPath);
21
14
  }
22
15
  export async function copyFilesWithConflictResolution(packageContext, entries) {
@@ -1 +1 @@
1
- {"version":3,"file":"add-conflict-handler.js","sourceRoot":"","sources":["../../../src/core/add/add-conflict-handler.ts"],"names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Q,EAAE,CAAC;QACnC,MAAM,IAAI,qBAAqB,EAAE,CAAC;IACpC,CAAC;IAED,OAAO,QAAQ,CAAC,QAA4B,CAAC;AAC/C,CAAC"}
@@ -5,13 +5,12 @@ import { readPackageFilesForRegistry } from '../../utils/package-copy.js';
5
5
  import { ensurePackageWithYml } from '../../utils/package-management.js';
6
6
  import { isWithinDirectory } from '../../utils/path-normalization.js';
7
7
  import { exists, isDirectory, isFile, ensureDir } from '../../utils/fs.js';
8
- import { writePackageYml } from '../../utils/package-yml.js';
9
- import { promptPackageDetails } from '../../utils/prompts.js';
10
8
  import { logger } from '../../utils/logger.js';
11
9
  import { collectSourceEntries } from './source-collector.js';
12
10
  import { applyPlatformSpecificPaths } from './platform-path-transformer.js';
13
11
  import { copyFilesWithConflictResolution } from './add-conflict-handler.js';
14
- import { detectPackageContext, getNoPackageDetectedMessage, getPackageFilesDir, getPackageYmlPath, createPackageContext } from '../package-context.js';
12
+ import { detectPackageContext, getNoPackageDetectedMessage, getPackageYmlPath } from '../package-context.js';
13
+ import { createPackage } from '../package-creation.js';
15
14
  import { DIR_PATTERNS } from '../../constants/index.js';
16
15
  export async function runAddPipeline(packageOrPath, pathArg, options = {}) {
17
16
  const cwd = process.cwd();
@@ -79,13 +78,16 @@ async function resolveAddTargets(cwd, packageOrPath, pathArg) {
79
78
  return { type: 'detected', context, inputPath: singleArg };
80
79
  }
81
80
  async function initRootPackageForAdd(cwd) {
82
- const packageFilesDir = getPackageFilesDir(cwd, 'root');
83
- const packageYmlPath = getPackageYmlPath(cwd, 'root');
84
- logger.info(`No package detected at current directory; initializing root package in: ${packageFilesDir}`);
85
- await ensureDir(packageFilesDir);
86
- const packageConfig = await promptPackageDetails();
87
- await writePackageYml(packageYmlPath, packageConfig);
88
- return createPackageContext(cwd, packageConfig, 'root');
81
+ logger.info(`No package detected at current directory; creating root package for add operation`);
82
+ const result = await createPackage({
83
+ cwd,
84
+ scope: 'root',
85
+ interactive: true
86
+ });
87
+ if (!result.success || !result.context) {
88
+ throw new Error(result.error || 'Failed to create root package for add operation');
89
+ }
90
+ return result.context;
89
91
  }
90
92
  async function buildAddPackageContext(cwd, resolved) {
91
93
  if (resolved.type === 'detected') {
@@ -1 +1 @@
1
- {"version":3,"file":"add-pipeline.js","sourceRoot":"","sources":["../../../src/core/add/add-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAIlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EACL,0BAA0B,EAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAkBxD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAiC,EACjC,OAA2B,EAC3B,UAA8B,EAAE;IAEhC,MAAM,G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
3
+ import { resolveMutableSource } from '../source-resolution/resolve-mutable-source.js';
4
+ import { resolvePackageSource } from '../source-resolution/resolve-package-source.js';
5
+ import { assertMutableSourceOrThrow } from '../../utils/source-mutability.js';
6
+ import { collectSourceEntries } from './source-collector.js';
7
+ import { copyFilesWithConflictResolution } from './add-conflict-handler.js';
8
+ import { normalizePathForProcessing } from '../../utils/path-normalization.js';
9
+ import { getPlatformRootFileNames } from '../../utils/platform-root-files.js';
10
+ import { getAllUniversalSubdirs, getAllPlatforms } from '../platforms.js';
11
+ import { parsePackageYml } from '../../utils/package-yml.js';
12
+ import { exists } from '../../utils/fs.js';
13
+ import { logger } from '../../utils/logger.js';
14
+ export async function runAddToSourcePipeline(packageName, pathArg, options = {}) {
15
+ const cwd = process.cwd();
16
+ if (!packageName) {
17
+ return { success: false, error: 'Package name is required for add.' };
18
+ }
19
+ if (!pathArg) {
20
+ return { success: false, error: 'Path argument is required for add.' };
21
+ }
22
+ const absInputPath = resolvePath(cwd, pathArg);
23
+ if (!(await exists(absInputPath))) {
24
+ return { success: false, error: `Path not found: ${pathArg}` };
25
+ }
26
+ // Resolve mutable package source (workspace or global, but not registry)
27
+ let source;
28
+ try {
29
+ source = await resolveMutableSource({ cwd, packageName });
30
+ }
31
+ catch (error) {
32
+ return { success: false, error: error instanceof Error ? error.message : String(error) };
33
+ }
34
+ // Additional safety check (should never fail given resolveMutableSource guarantees)
35
+ assertMutableSourceOrThrow(source.absolutePath, { packageName: source.packageName, command: 'add' });
36
+ logger.info('Adding files to package source', {
37
+ packageName: source.packageName,
38
+ sourcePath: source.absolutePath,
39
+ sourceType: source.sourceType,
40
+ inputPath: pathArg
41
+ });
42
+ const rawEntries = await collectSourceEntries(absInputPath, cwd);
43
+ const entries = applyCopyToRootRule(rawEntries, cwd);
44
+ const packageContext = await buildPackageContext(source);
45
+ const changed = await copyFilesWithConflictResolution(packageContext, entries);
46
+ logger.info('Files copied to package source', {
47
+ packageName: source.packageName,
48
+ filesAdded: changed.length
49
+ });
50
+ // Determine source type for result
51
+ const sourceType = source.absolutePath.includes(`${cwd}/.openpackage/packages/`)
52
+ ? 'workspace'
53
+ : 'global';
54
+ // Handle --apply flag: requires package to be installed in current workspace
55
+ if (options.apply) {
56
+ logger.info('Applying changes to workspace (--apply flag)', { packageName: source.packageName });
57
+ try {
58
+ // Check if package is installed in current workspace
59
+ await resolvePackageSource(cwd, packageName);
60
+ // Apply changes to workspace
61
+ const { runApplyPipeline } = await import('../apply/apply-pipeline.js');
62
+ const applyResult = await runApplyPipeline(source.packageName, {});
63
+ if (!applyResult.success) {
64
+ return {
65
+ success: false,
66
+ error: `Files added to package source, but apply failed:\n${applyResult.error}`
67
+ };
68
+ }
69
+ logger.info('Changes applied to workspace', { packageName: source.packageName });
70
+ }
71
+ catch (error) {
72
+ return {
73
+ success: false,
74
+ error: `Files added to package source at: ${source.absolutePath}\n\n` +
75
+ `However, --apply failed because package '${packageName}' is not installed in this workspace.\n\n` +
76
+ `To sync changes to your workspace:\n` +
77
+ ` 1. Install the package: opkg install ${packageName}\n` +
78
+ ` 2. Apply the changes: opkg apply ${packageName}\n\n` +
79
+ `Or run 'opkg add' without --apply flag to skip workspace sync.`
80
+ };
81
+ }
82
+ }
83
+ return {
84
+ success: true,
85
+ data: {
86
+ packageName: source.packageName,
87
+ filesAdded: changed.length,
88
+ sourcePath: source.absolutePath,
89
+ sourceType
90
+ }
91
+ };
92
+ }
93
+ function applyCopyToRootRule(entries, cwd) {
94
+ const universalSubdirs = getAllUniversalSubdirs(cwd);
95
+ const rootFileNames = getPlatformRootFileNames(getAllPlatforms(undefined, cwd), cwd);
96
+ return entries.map(entry => {
97
+ const normalized = normalizePathForProcessing(entry.registryPath) || entry.registryPath;
98
+ const isUniversal = universalSubdirs.has(normalized.split('/')[0] || '') ||
99
+ normalized.startsWith(`${FILE_PATTERNS.AGENTS_MD}`) ||
100
+ normalized.startsWith('root/');
101
+ const isRootFile = rootFileNames.has(normalized);
102
+ if (isUniversal || isRootFile) {
103
+ return { ...entry, registryPath: normalized };
104
+ }
105
+ // Everything else → copy-to-root
106
+ return { ...entry, registryPath: normalizePathForProcessing(`root/${normalized}`) || `root/${normalized}` };
107
+ });
108
+ }
109
+ async function buildPackageContext(source) {
110
+ const packageYmlPath = join(source.absolutePath, FILE_PATTERNS.OPENPACKAGE_YML);
111
+ const config = await parsePackageYml(packageYmlPath);
112
+ return {
113
+ name: source.packageName,
114
+ version: config.version,
115
+ config,
116
+ packageYmlPath,
117
+ packageRootDir: source.absolutePath,
118
+ packageFilesDir: source.absolutePath,
119
+ location: 'nested',
120
+ isCwdPackage: false
121
+ };
122
+ }
123
+ //# sourceMappingURL=add-to-source-pipeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-to-source-pipeline.js","sourceRoot":"","sources":["../../../src/core/add/add-to-source-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAoB,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,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G,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,WAAW,IAAI,UAAU,EAAE,CAAC;YAC9B,OAAO,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;QAChD,CAAC;QAED,iCAAiC;QACjC,OAAO,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,0BAA0B,CAAC,QAAQ,UAAU,EAAE,CAAC,IAAI,QAAQ,UAAU,EAAE,EAAE,CAAC;IAC9G,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,MAAwD;IACzF,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,cAAc,CAAC,CAAC;IAErD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,WAAW;QACxB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,MAAM;QACN,cAAc;QACd,cAAc,EAAE,MAAM,CAAC,YAAY;QACnC,eAAe,EAAE,MAAM,CAAC,YAAY;QACpC,QAAQ,EAAE,QAAQ;QAClB,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { dirname, join } from 'path';
1
+ import { join } from 'path';
2
2
  import { FILE_PATTERNS } from '../../constants/index.js';
3
3
  import { exists } from '../../utils/fs.js';
4
4
  import { logger } from '../../utils/logger.js';
@@ -8,20 +8,22 @@ import { buildIndexMappingForPackageFiles, loadOtherPackageIndexes } from '../..
8
8
  import { UNVERSIONED } from '../../constants/index.js';
9
9
  import { parseUniversalPath } from '../../utils/platform-file.js';
10
10
  import { mapUniversalToPlatform } from '../../utils/platform-mapper.js';
11
- import { isPlatformId } from '../platforms.js';
11
+ import { getAllUniversalSubdirs, isPlatformId } from '../platforms.js';
12
12
  import { normalizeRegistryPath, isRootRegistryPath, isSkippableRegistryPath, isAllowedRegistryPath } from '../../utils/registry-entry-filter.js';
13
13
  import { createWorkspaceHash } from '../../utils/version-generator.js';
14
+ import { getPlatformRootFileNames, stripRootCopyPrefix, isRootCopyPath } from '../../utils/platform-root-files.js';
14
15
  /**
15
16
  * Compute the directory key (registry side) to collapse file mappings under.
16
17
  * Mirrors the grouping behavior used by install/index mapping logic.
17
18
  */
18
- export function computeDirKeyFromRegistryPath(registryPath) {
19
+ export function computeDirKeyFromRegistryPath(registryPath, cwd) {
19
20
  const normalized = registryPath.replace(/\\/g, '/').replace(/^\/+|\/+$/g, '');
20
21
  const parts = normalized.split('/');
21
22
  if (parts.length <= 1)
22
23
  return '';
23
- const universal = new Set(['ai', 'rules', 'commands', 'agents', 'skills']);
24
- if (universal.has(parts[0])) {
24
+ // Use dynamically discovered universal subdirs instead of hardcoded list
25
+ const universalSubdirs = getAllUniversalSubdirs(cwd);
26
+ if (universalSubdirs.has(parts[0])) {
25
27
  if (parts.length >= 2)
26
28
  return `${parts[0]}/${parts[1]}/`;
27
29
  return `${parts[0]}/`;
@@ -88,59 +90,6 @@ function mergeMappingsRespectingExisting(previous, updates, replaceExact = false
88
90
  }
89
91
  return sortMapping(merged);
90
92
  }
91
- /**
92
- * Collapse file entries into directory keys when appropriate.
93
- * Groups file entries by their directory key and automatically collapses them into dir key entries.
94
- * This is universally applied to all eligible groups to ensure consistent index structure.
95
- */
96
- function collapseFileEntriesToDirKeys(mapping) {
97
- const collapsed = {};
98
- const dirKeyGroups = new Map();
99
- // Group file entries by their directory key
100
- for (const [key, values] of Object.entries(mapping)) {
101
- // Skip directory keys (they already end with /)
102
- if (key.endsWith('/')) {
103
- collapsed[key] = values;
104
- continue;
105
- }
106
- const dirKey = computeDirKeyFromRegistryPath(key);
107
- if (!dirKey) {
108
- // No dir key possible, keep as file entry
109
- collapsed[key] = values;
110
- continue;
111
- }
112
- if (!dirKeyGroups.has(dirKey)) {
113
- dirKeyGroups.set(dirKey, []);
114
- }
115
- dirKeyGroups.get(dirKey).push({ key, values });
116
- }
117
- // Process each directory group - always collapse when multiple files share a dir key
118
- for (const [dirKey, entries] of dirKeyGroups.entries()) {
119
- // Collapse: collect all installed directories from file entries
120
- const dirValues = new Set();
121
- for (const entry of entries) {
122
- for (const v of entry.values) {
123
- const d = dirname(v);
124
- if (d && d !== '.') {
125
- const normalized = d.endsWith('/') ? d : `${d}/`;
126
- dirValues.add(normalized);
127
- }
128
- }
129
- }
130
- if (dirValues.size > 0) {
131
- // Replace file entries with a single dir key entry
132
- const pruned = pruneNestedDirectories(Array.from(dirValues));
133
- collapsed[dirKey] = pruned.sort();
134
- }
135
- else {
136
- // No directories found, keep as individual file entries
137
- for (const entry of entries) {
138
- collapsed[entry.key] = entry.values;
139
- }
140
- }
141
- }
142
- return sortMapping(collapsed);
143
- }
144
93
  /**
145
94
  * Build a mapping that preserves exact file keys for the provided packageFiles.
146
95
  * For universal subdirs, maps to platform-specific installed paths that ACTUALLY EXIST.
@@ -172,22 +121,27 @@ async function buildExactFileMapping(cwd, packageFiles, platforms) {
172
121
  const absPath = join(cwd, relPath);
173
122
  return await exists(absPath);
174
123
  };
124
+ const rootFileNames = getPlatformRootFileNames(platforms, cwd);
125
+ const explicitRootKeys = new Set();
126
+ const hasAgents = packageFiles.some(file => normalizeRegistryPath(file.path) === FILE_PATTERNS.AGENTS_MD);
175
127
  // First pass: record platform-specific target files keyed by base universal key
176
128
  for (const file of packageFiles) {
177
129
  const normalized = normalizeRegistryPath(file.path);
178
- if (isRootRegistryPath(normalized))
130
+ if (isRootCopyPath(normalized))
131
+ continue;
132
+ if (isRootRegistryPath(normalized) || rootFileNames.has(normalized))
179
133
  continue;
180
- if (isSkippableRegistryPath(normalized))
134
+ if (isSkippableRegistryPath(normalized, cwd))
181
135
  continue;
182
- if (!isAllowedRegistryPath(normalized))
136
+ if (!isAllowedRegistryPath(normalized, cwd))
183
137
  continue;
184
138
  const parsed = parseUniversalPath(normalized);
185
139
  if (parsed && parsed.platformSuffix && isPlatformId(parsed.platformSuffix)) {
186
140
  try {
187
- const { absFile } = mapUniversalToPlatform(parsed.platformSuffix, parsed.universalSubdir, parsed.relPath);
141
+ const { relFile } = mapUniversalToPlatform(parsed.platformSuffix, parsed.universalSubdir, parsed.relPath, cwd);
188
142
  const baseKey = `${parsed.universalSubdir}/${parsed.relPath}`;
189
143
  const set = platformSpecificTargetsByBase.get(baseKey) ?? new Set();
190
- set.add(absFile.replace(/\\/g, '/'));
144
+ set.add(relFile.replace(/\\/g, '/'));
191
145
  platformSpecificTargetsByBase.set(baseKey, set);
192
146
  }
193
147
  catch {
@@ -198,21 +152,37 @@ async function buildExactFileMapping(cwd, packageFiles, platforms) {
198
152
  // Second pass: build exact mappings, only including paths that actually exist
199
153
  for (const file of packageFiles) {
200
154
  const normalized = normalizeRegistryPath(file.path);
201
- if (isRootRegistryPath(normalized))
202
- continue;
203
- if (isSkippableRegistryPath(normalized))
204
- continue;
205
- if (!isAllowedRegistryPath(normalized))
155
+ if (isSkippableRegistryPath(normalized, cwd))
206
156
  continue;
207
157
  const key = normalized.replace(/\\/g, '/');
208
158
  const values = new Set();
159
+ // Copy-to-root: root/** → strip prefix in workspace
160
+ const stripped = stripRootCopyPrefix(key);
161
+ if (stripped !== null) {
162
+ if (await checkExists(stripped)) {
163
+ values.add(stripped);
164
+ }
165
+ addTargets(key, values);
166
+ continue;
167
+ }
168
+ // Root files: store at workspace root with same name; AGENTS.md may also populate platform root files
169
+ if (rootFileNames.has(key) || isRootRegistryPath(key)) {
170
+ explicitRootKeys.add(key);
171
+ if (await checkExists(key)) {
172
+ values.add(key);
173
+ }
174
+ addTargets(key, values);
175
+ continue;
176
+ }
177
+ if (!isAllowedRegistryPath(normalized, cwd))
178
+ continue;
209
179
  const parsed = parseUniversalPath(key);
210
180
  if (parsed) {
211
181
  if (parsed.platformSuffix && isPlatformId(parsed.platformSuffix)) {
212
182
  // Platform-specific registry key → only that platform target if it exists
213
183
  try {
214
- const { absFile } = mapUniversalToPlatform(parsed.platformSuffix, parsed.universalSubdir, parsed.relPath);
215
- const relPath = absFile.replace(/\\/g, '/');
184
+ const { relFile } = mapUniversalToPlatform(parsed.platformSuffix, parsed.universalSubdir, parsed.relPath, cwd);
185
+ const relPath = relFile.replace(/\\/g, '/');
216
186
  if (await checkExists(relPath)) {
217
187
  values.add(relPath);
218
188
  }
@@ -225,8 +195,8 @@ async function buildExactFileMapping(cwd, packageFiles, platforms) {
225
195
  // Universal registry key → only include platform paths that actually exist
226
196
  for (const platform of platforms) {
227
197
  try {
228
- const { absFile } = mapUniversalToPlatform(platform, parsed.universalSubdir, parsed.relPath);
229
- const relPath = absFile.replace(/\\/g, '/');
198
+ const { relFile } = mapUniversalToPlatform(platform, parsed.universalSubdir, parsed.relPath, cwd);
199
+ const relPath = relFile.replace(/\\/g, '/');
230
200
  if (await checkExists(relPath)) {
231
201
  values.add(relPath);
232
202
  }
@@ -235,6 +205,12 @@ async function buildExactFileMapping(cwd, packageFiles, platforms) {
235
205
  // Ignore unsupported platforms
236
206
  }
237
207
  }
208
+ // Also record the workspace-relative key itself when it exists.
209
+ // This is important for root packages (and add flows) where the source path may be the only
210
+ // concrete workspace location before any apply/install expansion.
211
+ if (await checkExists(key)) {
212
+ values.add(key);
213
+ }
238
214
  // Prune: if platform-specific keys exist for this base, remove their targets from universal
239
215
  const baseKey = `${parsed.universalSubdir}/${parsed.relPath}`;
240
216
  const covered = platformSpecificTargetsByBase.get(baseKey);
@@ -253,22 +229,45 @@ async function buildExactFileMapping(cwd, packageFiles, platforms) {
253
229
  }
254
230
  addTargets(key, values);
255
231
  }
232
+ // If AGENTS.md exists in the package and platform root files exist in the workspace (without explicit overrides),
233
+ // record them as installed paths for AGENTS.md.
234
+ if (hasAgents) {
235
+ const values = new Set(mapping[FILE_PATTERNS.AGENTS_MD] ?? []);
236
+ for (const rootFile of rootFileNames) {
237
+ if (rootFile === FILE_PATTERNS.AGENTS_MD)
238
+ continue;
239
+ if (explicitRootKeys.has(rootFile))
240
+ continue;
241
+ if (await checkExists(rootFile)) {
242
+ values.add(rootFile);
243
+ }
244
+ }
245
+ addTargets(FILE_PATTERNS.AGENTS_MD, values);
246
+ }
256
247
  return mapping;
257
248
  }
258
249
  export async function buildMappingAndWriteIndex(cwd, packageContext, packageFiles, platforms, options = {}) {
259
250
  const packageName = packageContext.name;
260
251
  const packageLocation = packageContext.location;
261
252
  try {
262
- // Filter to index-eligible files only (excludes package.yml, package index file, etc.)
253
+ // Filter to index-eligible files only (excludes openpackage.yml, package index file, etc.)
263
254
  // These are manifest/metadata files that are NOT synced to workspace locations
264
255
  const indexEligibleFiles = packageFiles.filter(f => {
265
256
  const normalized = normalizeRegistryPath(f.path);
266
- return isAllowedRegistryPath(normalized) && !isSkippableRegistryPath(normalized);
257
+ if (isSkippableRegistryPath(normalized, cwd))
258
+ return false;
259
+ if (isAllowedRegistryPath(normalized, cwd))
260
+ return true;
261
+ if (isRootRegistryPath(normalized))
262
+ return true;
263
+ if (isRootCopyPath(normalized))
264
+ return true;
265
+ return false;
267
266
  });
268
267
  // Read existing index and other indexes for conflict context
269
268
  const previousIndex = await readPackageIndex(cwd, packageName, packageLocation);
270
269
  const otherIndexes = await loadOtherPackageIndexes(cwd, packageName);
271
- // Resolve version (prefer previous index; otherwise read from package.yml)
270
+ // Resolve version (prefer previous index; otherwise read from openpackage.yml)
272
271
  let version = options.versionOverride || previousIndex?.workspace?.version || undefined;
273
272
  if (!version) {
274
273
  const packageYmlPath = packageContext.packageYmlPath;
@@ -278,7 +277,7 @@ export async function buildMappingAndWriteIndex(cwd, packageContext, packageFile
278
277
  version = packageYml.version;
279
278
  }
280
279
  catch (error) {
281
- logger.warn(`Failed to read package.yml for version: ${error}`);
280
+ logger.warn(`Failed to read openpackage.yml for version: ${error}`);
282
281
  return;
283
282
  }
284
283
  }
@@ -315,10 +314,10 @@ export async function buildMappingAndWriteIndex(cwd, packageContext, packageFile
315
314
  files: mergedFiles
316
315
  };
317
316
  await writePackageIndex(indexRecord);
318
- logger.debug(`Updated ${FILE_PATTERNS.PACKAGE_INDEX_YML} for ${packageName}@${version}`);
317
+ logger.debug(`Updated ${FILE_PATTERNS.OPENPACKAGE_INDEX_YML} for ${packageName}@${version}`);
319
318
  }
320
319
  catch (error) {
321
- logger.warn(`Failed to update ${FILE_PATTERNS.PACKAGE_INDEX_YML} for ${packageName}: ${error}`);
320
+ logger.warn(`Failed to update ${FILE_PATTERNS.OPENPACKAGE_INDEX_YML} for ${packageName}: ${error}`);
322
321
  }
323
322
  }
324
323
  //# sourceMappingURL=package-index-updater.js.map