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
@@ -0,0 +1,793 @@
1
+ # Scope Behavior
2
+
3
+ This document details the behavior of each scope in the `opkg new` command, including path resolution, workspace integration, and use case patterns.
4
+
5
+ ## Scope Selection
6
+
7
+ When running `opkg new` **interactively without the `--scope` or `--path` flag**, you'll be prompted to choose:
8
+
9
+ ```bash
10
+ $ opkg new my-package
11
+ ? Where should this package be created? ›
12
+ ❯ Root (current directory) - Create openpackage.yml here - for standalone/distributable packages
13
+ Local (workspace-scoped) - Create in .openpackage/packages/ - for project-specific packages
14
+ Global (cross-workspace) - Create in ~/.openpackage/packages/ - shared across all workspaces on this machine
15
+ Custom (specify path) - Create at a custom location you specify
16
+ ```
17
+
18
+ - **Interactive mode**: Prompts for scope/path selection
19
+ - **Non-interactive mode**: Requires `--scope` or `--path` flag (error if neither provided)
20
+ - **Explicit `--scope` flag**: Skips prompt, uses specified scope
21
+ - **Explicit `--path` flag**: Skips prompt, uses custom path (takes precedence over `--scope`)
22
+
23
+ This ensures you make an explicit choice about where your package lives, without relying on an implicit default.
24
+
25
+ ## Scope Types and Custom Paths
26
+
27
+ OpenPackage supports three predefined scopes plus custom paths:
28
+
29
+ | Type | Location | Shared? | Workspace Integration | Use Case |
30
+ |------|----------|---------|----------------------|----------|
31
+ | `root` | `./openpackage.yml` | No | Optional | Dedicated package repos |
32
+ | `local` | `./.openpackage/packages/<name>/` | No | Automatic | Project-specific packages |
33
+ | `global` | `~/.openpackage/packages/<name>/` | Yes | Manual | Cross-workspace utilities |
34
+ | `custom` | User-specified path | Varies | Manual | Flexible organization |
35
+
36
+ ## Root Scope
37
+
38
+ ### Path Resolution
39
+
40
+ ```
41
+ Current Directory (cwd)
42
+ ├── openpackage.yml # Created here
43
+ ├── .cursor/ # Platform content
44
+ ├── root/ # Root files
45
+ └── [other package content]
46
+ ```
47
+
48
+ **Package Directory:** `cwd/`
49
+ **Manifest Path:** `cwd/openpackage.yml`
50
+ **Package Root:** `cwd/`
51
+
52
+ ### Creation Behavior
53
+
54
+ ```bash
55
+ # In /Users/alice/my-package/
56
+ $ opkg new --scope root
57
+ ```
58
+
59
+ **Steps:**
60
+ 1. Validates cwd is writable
61
+ 2. Checks for existing `openpackage.yml`
62
+ 3. If exists and no `--force`: displays existing, exits
63
+ 4. If exists and `--force`: overwrites
64
+ 5. Prompts for package details (interactive mode)
65
+ 6. Creates `openpackage.yml` at cwd
66
+ 7. Does NOT create workspace structure
67
+ 8. Does NOT add to any workspace manifest
68
+
69
+ **Result:**
70
+ ```
71
+ /Users/alice/my-package/
72
+ └── openpackage.yml
73
+ ```
74
+
75
+ ### Use Case Patterns
76
+
77
+ #### Dedicated Package Repository
78
+
79
+ **Scenario:** Creating a standalone package to distribute
80
+
81
+ ```bash
82
+ # Create package repo
83
+ mkdir my-awesome-package
84
+ cd my-awesome-package
85
+ opkg new --scope root
86
+
87
+ # Develop package
88
+ mkdir -p .cursor/rules
89
+ echo "# Rule 1" > .cursor/rules/rule1.md
90
+
91
+ # Package and publish
92
+ opkg pack
93
+ opkg push my-awesome-package
94
+ ```
95
+
96
+ #### Monorepo Package
97
+
98
+ **Scenario:** Package within a larger repository
99
+
100
+ ```bash
101
+ # In monorepo
102
+ cd packages/shared-components/
103
+ opkg new --scope root
104
+
105
+ # Package exists alongside other code
106
+ packages/
107
+ ├── shared-components/
108
+ │ ├── openpackage.yml # Root package
109
+ │ ├── src/ # Other code
110
+ │ └── .cursor/
111
+ └── other-package/
112
+ ```
113
+
114
+ ### Workspace Integration
115
+
116
+ Root packages do NOT auto-integrate with workspaces. To use in a workspace:
117
+
118
+ ```yaml
119
+ # Manually add to .openpackage/openpackage.yml
120
+ packages:
121
+ - name: my-package
122
+ path: /absolute/path/to/my-package/
123
+ # or relative to workspace
124
+ path: ../../packages/my-package/
125
+ ```
126
+
127
+ ### Advantages
128
+ - ✅ Clean package root (no nested directories)
129
+ - ✅ Similar to npm/cargo/pypi patterns
130
+ - ✅ Easy to distribute
131
+ - ✅ Minimal metadata overhead
132
+
133
+ ### Disadvantages
134
+ - ❌ No automatic workspace integration
135
+ - ❌ Requires manual path management
136
+ - ❌ Not isolated from other cwd content
137
+
138
+ ## Local Scope
139
+
140
+ ### Path Resolution
141
+
142
+ ```
143
+ Project Root
144
+ ├── .openpackage/
145
+ │ ├── openpackage.yml # Workspace manifest (auto-created)
146
+ │ └── packages/
147
+ │ └── my-package/ # Package directory
148
+ │ ├── openpackage.yml # Package manifest
149
+ │ ├── .cursor/
150
+ │ └── root/
151
+ └── src/ # Project code
152
+ ```
153
+
154
+ **Package Directory:** `cwd/.openpackage/packages/<name>/`
155
+ **Manifest Path:** `cwd/.openpackage/packages/<name>/openpackage.yml`
156
+ **Package Root:** `cwd/.openpackage/packages/<name>/`
157
+
158
+ ### Creation Behavior
159
+
160
+ ```bash
161
+ # In /Users/alice/my-project/
162
+ $ opkg new my-package
163
+ ```
164
+
165
+ **Steps:**
166
+ 1. Validates package name provided
167
+ 2. Normalizes package name (lowercase)
168
+ 3. Resolves path: `cwd/.openpackage/packages/<name>/`
169
+ 4. Checks for existing package
170
+ 5. If exists and no `--force`: displays existing, exits
171
+ 6. If exists and `--force`: overwrites
172
+ 7. Ensures `.openpackage/packages/` directory exists
173
+ 8. Prompts for package details (interactive mode)
174
+ 9. Creates `openpackage.yml` in package directory
175
+ 10. **Auto-creates workspace manifest** if not exists
176
+ 11. **Adds package to workspace manifest** with path reference
177
+
178
+ **Result:**
179
+ ```
180
+ /Users/alice/my-project/
181
+ ├── .openpackage/
182
+ │ ├── openpackage.yml
183
+ │ └── packages/
184
+ │ └── my-package/
185
+ │ └── openpackage.yml
186
+ └── src/
187
+ ```
188
+
189
+ **Workspace Manifest Entry:**
190
+ ```yaml
191
+ name: my-project
192
+ packages:
193
+ - name: my-package
194
+ path: ./.openpackage/packages/my-package/
195
+ dev-packages: []
196
+ ```
197
+
198
+ ### Use Case Patterns
199
+
200
+ #### Project-Specific Rules
201
+
202
+ **Scenario:** Custom rules for a specific project
203
+
204
+ ```bash
205
+ cd my-project/
206
+ opkg new project-rules
207
+
208
+ # Develop rules
209
+ cd .openpackage/packages/project-rules/
210
+ mkdir -p .cursor/rules
211
+ echo "# Project-specific rule" > .cursor/rules/style-guide.md
212
+
213
+ # Save and apply
214
+ opkg save project-rules
215
+ opkg apply project-rules
216
+ ```
217
+
218
+ #### Temporary Development Package
219
+
220
+ **Scenario:** Testing package before publishing
221
+
222
+ ```bash
223
+ # Create local package for development
224
+ opkg new experimental-feature
225
+
226
+ # Develop and test locally
227
+ cd .openpackage/packages/experimental-feature/
228
+ # Add content
229
+
230
+ # Test in workspace
231
+ opkg apply experimental-feature
232
+
233
+ # When ready, pack and publish
234
+ opkg pack experimental-feature
235
+ opkg push experimental-feature
236
+ ```
237
+
238
+ #### Multiple Related Packages
239
+
240
+ **Scenario:** Multiple packages in one project
241
+
242
+ ```bash
243
+ opkg new frontend-rules
244
+ opkg new backend-rules
245
+ opkg new shared-prompts
246
+
247
+ # All packages available in project
248
+ .openpackage/
249
+ └── packages/
250
+ ├── frontend-rules/
251
+ ├── backend-rules/
252
+ └── shared-prompts/
253
+ ```
254
+
255
+ ### Workspace Integration
256
+
257
+ Local packages are **automatically integrated**:
258
+ - Workspace manifest auto-created if needed
259
+ - Package added with relative path
260
+ - Available for `opkg install`, `opkg apply`, etc.
261
+
262
+ ### Advantages
263
+ - ✅ Automatic workspace integration
264
+ - ✅ Relative paths (portable)
265
+ - ✅ Clear separation from project code
266
+ - ✅ Easy to manage multiple packages
267
+ - ✅ Isolated in `.openpackage/` directory
268
+
269
+ ### Disadvantages
270
+ - ❌ Not shared across workspaces
271
+ - ❌ Nested directory structure
272
+ - ❌ Requires workspace context
273
+
274
+ ## Global Scope
275
+
276
+ ### Path Resolution
277
+
278
+ ```
279
+ ~/.openpackage/
280
+ └── packages/
281
+ └── shared-utils/ # Package directory
282
+ ├── openpackage.yml # Package manifest
283
+ ├── .cursor/
284
+ └── root/
285
+ ```
286
+
287
+ **Package Directory:** `~/.openpackage/packages/<name>/`
288
+ **Manifest Path:** `~/.openpackage/packages/<name>/openpackage.yml`
289
+ **Package Root:** `~/.openpackage/packages/<name>/`
290
+
291
+ ### Creation Behavior
292
+
293
+ ```bash
294
+ # In any directory
295
+ $ opkg new shared-utils --scope global
296
+ ```
297
+
298
+ **Steps:**
299
+ 1. Validates package name provided
300
+ 2. Normalizes package name
301
+ 3. Resolves path: `~/.openpackage/packages/<name>/`
302
+ 4. Expands tilde to user home directory
303
+ 5. Checks for existing package
304
+ 6. If exists and no `--force`: displays existing, exits
305
+ 7. If exists and `--force`: overwrites
306
+ 8. Ensures `~/.openpackage/packages/` directory exists
307
+ 9. Prompts for package details (interactive mode)
308
+ 10. Creates `openpackage.yml` in global package directory
309
+ 11. Does NOT add to any workspace manifest
310
+
311
+ **Result:**
312
+ ```
313
+ ~/.openpackage/
314
+ └── packages/
315
+ └── shared-utils/
316
+ └── openpackage.yml
317
+ ```
318
+
319
+ ### Use Case Patterns
320
+
321
+ #### Personal Utility Library
322
+
323
+ **Scenario:** Rules/prompts used across all projects
324
+
325
+ ```bash
326
+ # Create global utilities
327
+ opkg new personal-rules --scope global
328
+
329
+ # Add content
330
+ cd ~/.openpackage/packages/personal-rules/
331
+ mkdir -p .cursor/rules
332
+ echo "# My coding standards" > .cursor/rules/standards.md
333
+
334
+ # Pack to registry
335
+ opkg pack personal-rules
336
+
337
+ # Use in any project
338
+ cd ~/projects/any-project/
339
+ # Add to .openpackage/openpackage.yml:
340
+ # packages:
341
+ # - name: personal-rules
342
+ # path: ~/.openpackage/packages/personal-rules/
343
+ opkg install
344
+ ```
345
+
346
+ #### Team Shared Packages
347
+
348
+ **Scenario:** Packages shared within team (via git)
349
+
350
+ ```bash
351
+ # Team member creates package
352
+ opkg new team-conventions --scope global
353
+
354
+ # Add to version control
355
+ cd ~/.openpackage/packages/team-conventions/
356
+ git init
357
+ git add .
358
+ git commit -m "Initial conventions"
359
+ git remote add origin git@github.com:team/conventions.git
360
+ git push
361
+
362
+ # Other team members clone
363
+ cd ~/.openpackage/packages/
364
+ git clone git@github.com:team/conventions.git team-conventions
365
+
366
+ # Use in projects
367
+ cd ~/projects/any-project/
368
+ # Add to .openpackage/openpackage.yml:
369
+ # packages:
370
+ # - name: team-conventions
371
+ # path: ~/.openpackage/packages/team-conventions/
372
+ ```
373
+
374
+ #### Development Templates
375
+
376
+ **Scenario:** Reusable templates for new projects
377
+
378
+ ```bash
379
+ # Create template package
380
+ opkg new project-template --scope global
381
+ cd ~/.openpackage/packages/project-template/
382
+
383
+ # Add template content
384
+ mkdir -p root/
385
+ echo "# Template README" > root/README.md
386
+ mkdir -p .cursor/rules
387
+ echo "# Template rule" > .cursor/rules/setup.md
388
+
389
+ opkg pack project-template
390
+
391
+ # Use in new projects
392
+ cd ~/new-project/
393
+ # Add template to manifest
394
+ opkg install
395
+ opkg apply project-template
396
+ ```
397
+
398
+ ### Workspace Integration
399
+
400
+ Global packages require **manual integration**:
401
+
402
+ ```yaml
403
+ # Add to any workspace's .openpackage/openpackage.yml
404
+ packages:
405
+ - name: shared-utils
406
+ path: ~/.openpackage/packages/shared-utils/
407
+ ```
408
+
409
+ Then install:
410
+ ```bash
411
+ opkg install
412
+ # or
413
+ opkg install shared-utils
414
+ ```
415
+
416
+ ### Advantages
417
+ - ✅ Shared across all workspaces
418
+ - ✅ Single source of truth
419
+ - ✅ Easy to maintain in one place
420
+ - ✅ Persists across projects
421
+ - ✅ Tilde expansion (portable home path)
422
+
423
+ ### Disadvantages
424
+ - ❌ Requires manual workspace integration
425
+ - ❌ User-specific (not in project repo)
426
+ - ❌ Needs documentation for team use
427
+ - ❌ Potential path conflicts between users
428
+
429
+ ## Custom Path
430
+
431
+ ### Path Resolution
432
+
433
+ ```
434
+ /any/user/specified/path/
435
+ └── my-package/
436
+ ├── openpackage.yml # Package manifest
437
+ ├── .cursor/
438
+ └── root/
439
+ ```
440
+
441
+ **Package Directory:** User-specified (can be relative, absolute, or tilde)
442
+ **Manifest Path:** `<specified-path>/openpackage.yml`
443
+ **Package Root:** `<specified-path>/`
444
+
445
+ **Path Types Supported:**
446
+ - Relative: `./my-package`, `../shared/package`
447
+ - Absolute: `/opt/packages/my-package`
448
+ - Tilde: `~/projects/my-package`
449
+
450
+ ### Creation Behavior
451
+
452
+ ```bash
453
+ # Various path types
454
+ $ opkg new my-package --path ./custom-location
455
+ $ opkg new my-package --path /opt/packages/my-package
456
+ $ opkg new my-package --path ~/projects/my-package
457
+ ```
458
+
459
+ **Steps:**
460
+ 1. Validates package name provided
461
+ 2. Normalizes package name
462
+ 3. Resolves custom path (expands tilde, converts to absolute)
463
+ 4. Validates parent directory exists
464
+ 5. Checks path is not in dangerous system directory
465
+ 6. Checks for existing package
466
+ 7. If exists and no `--force`: displays error, exits
467
+ 8. If exists and `--force`: overwrites
468
+ 9. Prompts for package details (interactive mode)
469
+ 10. Creates directory if needed
470
+ 11. Creates `openpackage.yml` at specified path
471
+ 12. Does NOT add to any workspace manifest
472
+
473
+ **Result (for relative path `./custom-location`):**
474
+ ```
475
+ current-directory/
476
+ └── custom-location/
477
+ └── openpackage.yml
478
+ ```
479
+
480
+ ### Use Case Patterns
481
+
482
+ #### Monorepo Structure
483
+
484
+ **Scenario:** Integrate with existing monorepo organization
485
+
486
+ ```bash
487
+ # Project structure:
488
+ # project-root/
489
+ # ├── apps/
490
+ # ├── packages/
491
+ # └── shared/
492
+
493
+ # Create package in shared/
494
+ cd project-root/apps/app-1/
495
+ opkg new app-configs --path ../../shared/app-configs
496
+
497
+ # Resulting structure:
498
+ # project-root/
499
+ # ├── apps/
500
+ # │ └── app-1/ (current directory)
501
+ # ├── packages/
502
+ # └── shared/
503
+ # └── app-configs/
504
+ # └── openpackage.yml
505
+ ```
506
+
507
+ #### Team Shared Directory
508
+
509
+ **Scenario:** Shared network or team directory
510
+
511
+ ```bash
512
+ # Create package in team shared location
513
+ opkg new team-standards --path /mnt/team-share/packages/team-standards
514
+
515
+ # Team members can reference same location
516
+ # In any workspace:
517
+ opkg install --path /mnt/team-share/packages/team-standards
518
+ ```
519
+
520
+ #### Custom Project Layout
521
+
522
+ **Scenario:** Match existing project conventions
523
+
524
+ ```bash
525
+ # Project with custom structure:
526
+ # project/
527
+ # ├── src/
528
+ # ├── docs/
529
+ # └── ai-configs/
530
+
531
+ # Create package in ai-configs/
532
+ cd project/src/
533
+ opkg new project-rules --path ../ai-configs/project-rules
534
+
535
+ # Resulting structure:
536
+ # project/
537
+ # ├── src/
538
+ # ├── docs/
539
+ # └── ai-configs/
540
+ # └── project-rules/
541
+ # └── openpackage.yml
542
+ ```
543
+
544
+ #### Parent Directory Reference
545
+
546
+ **Scenario:** Package in parent directory for multi-workspace use
547
+
548
+ ```bash
549
+ # Structure:
550
+ # project-root/
551
+ # ├── workspace-a/ (current directory)
552
+ # ├── workspace-b/
553
+ # └── shared-packages/
554
+
555
+ cd project-root/workspace-a/
556
+ opkg new shared-utils --path ../shared-packages/shared-utils
557
+
558
+ # Both workspaces can reference:
559
+ opkg install --path ../shared-packages/shared-utils
560
+ ```
561
+
562
+ ### Workspace Integration
563
+
564
+ Custom path packages require **manual integration** via path reference:
565
+
566
+ ```bash
567
+ # Install by explicit path
568
+ opkg install --path /custom/location/my-package
569
+
570
+ # Or add to manifest manually
571
+ ```
572
+
573
+ ```yaml
574
+ # .openpackage/openpackage.yml
575
+ packages:
576
+ - name: my-package
577
+ path: ../custom-location/my-package # Relative to workspace
578
+ - name: other-package
579
+ path: /opt/packages/other-package # Absolute path
580
+ ```
581
+
582
+ ### Advantages
583
+ - ✅ Complete flexibility in package location
584
+ - ✅ Can match existing project structures
585
+ - ✅ Support for monorepo patterns
586
+ - ✅ Can use team shared directories
587
+ - ✅ Relative paths portable within repo
588
+ - ✅ Tilde paths portable across users' home dirs
589
+
590
+ ### Disadvantages
591
+ - ❌ Requires manual workspace integration
592
+ - ❌ Path management responsibility on user
593
+ - ❌ Absolute paths not portable across systems
594
+ - ❌ Needs clear documentation for team members
595
+ - ❌ No automatic discovery
596
+
597
+ ### Safety Features
598
+
599
+ Custom paths include safety validations:
600
+
601
+ **Parent Directory Check:**
602
+ ```bash
603
+ $ opkg new test --path ./non-existent/package
604
+ Error: Parent directory does not exist: /path/to/non-existent
605
+ Please create it first or choose a different path.
606
+ ```
607
+
608
+ **System Directory Protection:**
609
+ ```bash
610
+ $ opkg new test --path /usr/my-package
611
+ Error: Cannot create package in system directory: /usr/my-package
612
+ ```
613
+
614
+ Protected directories include: `/bin`, `/sbin`, `/usr`, `/etc`, `/sys`, `/proc`, `/dev`, etc.
615
+
616
+ **Exceptions:** Temp directories like `/tmp` and macOS `/var/folders/` are allowed for testing purposes.
617
+
618
+ ## Scope Comparison
619
+
620
+ ### Path Portability
621
+
622
+ | Type | Path Example | Portable? | Notes |
623
+ |------|--------------|-----------|-------|
624
+ | Root | `./openpackage.yml` | ✅ In repo | Relative to repo root |
625
+ | Local | `./.openpackage/packages/pkg/` | ✅ In repo | Relative to workspace |
626
+ | Global | `~/.openpackage/packages/pkg/` | ⚠️ Per-user | Tilde expands to home |
627
+ | Custom (relative) | `./custom/pkg/` | ✅ In repo | Relative to workspace |
628
+ | Custom (absolute) | `/opt/packages/pkg/` | ❌ No | System-specific path |
629
+ | Custom (tilde) | `~/projects/pkg/` | ⚠️ Per-user | User home specific |
630
+
631
+ ### Version Control
632
+
633
+ | Type | In Git? | Shared? | Notes |
634
+ |------|---------|---------|-------|
635
+ | Root | ✅ Yes | Team | Part of repo |
636
+ | Local | ✅ Yes | Team | In `.openpackage/` |
637
+ | Global | ❌ No* | No* | User-specific, can be git repo itself |
638
+ | Custom | ⚠️ Varies | Varies | Depends on path location |
639
+
640
+ *Global packages can be separate git repos
641
+
642
+ ### Workspace Integration
643
+
644
+ | Type | Auto-Added? | Manual Steps | Install Command |
645
+ |------|-------------|--------------|-----------------|
646
+ | Root | ❌ No | Add path to manifest | `opkg install` |
647
+ | Local | ✅ Yes | None | Auto-available |
648
+ | Global | ❌ No | Add path to manifest | `opkg install` |
649
+ | Custom | ❌ No | Add path to manifest | `opkg install --path <path>` |
650
+
651
+ ## Scope Selection Decision Tree
652
+
653
+ ```
654
+ Do you need to match an existing directory structure?
655
+ ├─ Yes → Use CUSTOM PATH
656
+ │ opkg new my-package --path ./your/structure/here
657
+
658
+ └─ No → Is this package for one project only?
659
+ ├─ Yes → Use LOCAL scope
660
+ │ opkg new my-package
661
+
662
+ └─ No → Is this package shareable?
663
+ ├─ Yes → Is it personal or team-wide?
664
+ │ ├─ Personal → Use GLOBAL scope
665
+ │ │ opkg new utils --scope global
666
+ │ │
667
+ │ ├─ Team (shared location) → Use CUSTOM PATH
668
+ │ │ opkg new team-utils --path /mnt/team-share/packages/team-utils
669
+ │ │
670
+ │ └─ Team (separate repo) → Use ROOT scope
671
+ │ mkdir shared-package
672
+ │ cd shared-package
673
+ │ opkg new --scope root
674
+
675
+ └─ No → Are you distributing this package?
676
+ ├─ Yes → Use ROOT scope
677
+ │ opkg new my-package --scope root
678
+
679
+ └─ No → Use LOCAL scope (default)
680
+ opkg new my-package
681
+ ```
682
+
683
+ **When to use each:**
684
+ - **LOCAL**: Default choice for project-specific packages
685
+ - **ROOT**: Standalone package repositories for distribution
686
+ - **GLOBAL**: Personal utilities used across your projects
687
+ - **CUSTOM**: When you need to integrate with existing structures or team conventions
688
+
689
+ ## Scope Migration
690
+
691
+ ### Local → Global
692
+
693
+ When a local package becomes useful across projects:
694
+
695
+ ```bash
696
+ # Copy to global location
697
+ cp -r .openpackage/packages/my-package ~/.openpackage/packages/
698
+
699
+ # Update workspace manifest
700
+ # Change:
701
+ # path: ./.openpackage/packages/my-package/
702
+ # To:
703
+ # path: ~/.openpackage/packages/my-package/
704
+
705
+ # Remove local copy (optional)
706
+ rm -rf .openpackage/packages/my-package/
707
+
708
+ # Reinstall from global
709
+ opkg install my-package
710
+ ```
711
+
712
+ ### Global → Root (for distribution)
713
+
714
+ When a global package should be distributed:
715
+
716
+ ```bash
717
+ # Create new repo
718
+ mkdir my-package-repo
719
+ cd my-package-repo
720
+
721
+ # Copy content from global
722
+ cp -r ~/.openpackage/packages/my-package/* .
723
+
724
+ # Already has openpackage.yml at root
725
+ # Just add git
726
+ git init
727
+ git add .
728
+ git commit -m "Initial commit"
729
+
730
+ # Pack and publish
731
+ opkg pack
732
+ opkg push my-package
733
+ ```
734
+
735
+ ### Local → Root (for monorepo)
736
+
737
+ When restructuring to monorepo:
738
+
739
+ ```bash
740
+ # Move package to monorepo location
741
+ mv .openpackage/packages/my-package ../monorepo/packages/my-package/
742
+
743
+ # Update workspace manifest to point to new location
744
+ # packages:
745
+ # - name: my-package
746
+ # path: ../monorepo/packages/my-package/
747
+ ```
748
+
749
+ ## Scope and Path Best Practices
750
+
751
+ ### Choose Local When:
752
+ - Package is specific to one project
753
+ - Team collaboration through git
754
+ - Need automatic workspace integration
755
+ - Just starting development
756
+ - Standard OpenPackage workflow
757
+
758
+ ### Choose Global When:
759
+ - Package used across multiple projects
760
+ - Personal development utilities
761
+ - Want to maintain once, use everywhere
762
+ - Independent of any single project
763
+ - Personal, not team-shared
764
+
765
+ ### Choose Root When:
766
+ - Creating standalone package for distribution
767
+ - Package has its own repository
768
+ - Monorepo structure with packages/ directory
769
+ - Following npm/cargo patterns
770
+ - Planning to publish to registry
771
+
772
+ ### Choose Custom Path When:
773
+ - Need to match existing project structure
774
+ - Working with monorepo conventions
775
+ - Integrating with team's directory standards
776
+ - Using shared network/team directories
777
+ - Have specific organizational requirements
778
+ - Want packages outside `.openpackage/` structure
779
+
780
+ ### Custom Path Best Practices:
781
+ 1. **Use Relative Paths When Possible**: More portable within repo
782
+ 2. **Document Path Conventions**: Ensure team knows where packages live
783
+ 3. **Validate Parent Exists**: Create parent directories before running `opkg new`
784
+ 4. **Consider Portability**: Absolute paths won't work across different systems
785
+ 5. **Use Tilde for User Dirs**: `~/` works across user home directories
786
+ 6. **Add to .gitignore if Needed**: Decide if custom location should be in version control
787
+
788
+ ## See Also
789
+
790
+ - [New Command README](./README.md) - Full command specification
791
+ - [Scope Management](../scope-management.md) - Scope transitions and management
792
+ - [Directory Layout](../directory-layout.md) - Directory structure details
793
+ - [Package Sources](../package-sources.md) - Source resolution and paths