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,769 @@
1
+ # New Command Specification
2
+
3
+ The `opkg new` command creates new packages with explicit scope support. It replaces the deprecated `opkg init` command with clearer semantics and better UX.
4
+
5
+ ## Overview
6
+
7
+ ```bash
8
+ opkg new [package-name] [options]
9
+ ```
10
+
11
+ Creates a new package with an `openpackage.yml` manifest in one of three predefined scopes or at a custom path:
12
+ - **root**: Current directory as package
13
+ - **local**: Workspace-scoped package (default)
14
+ - **global**: User-scoped package shared across workspaces
15
+ - **custom**: User-specified directory path
16
+
17
+ ## Command Signature
18
+
19
+ ### Arguments
20
+ - `[package-name]` (optional for root scope, required for local/global)
21
+ - Package name following OpenPackage naming conventions
22
+ - Supports scoped packages (`@org/package-name`)
23
+ - Validated against naming rules (lowercase, alphanumeric, hyphens, slashes for scopes)
24
+
25
+ ### Options
26
+ - `--scope <scope>` - Package scope: `root`, `local`, or `global` (prompts if not specified in interactive mode)
27
+ - `--path <path>` - Custom directory path for package (overrides `--scope`)
28
+ - `-f, --force` - Overwrite existing package without prompting
29
+ - `--non-interactive` - Skip interactive prompts, use defaults
30
+ - `-h, --help` - Display help for command
31
+
32
+ **Note:** Either `--scope` or `--path` is required in non-interactive mode. If both are provided, `--path` takes precedence and a warning is issued.
33
+
34
+ ### Scope Selection
35
+
36
+ When running interactively **without** the `--scope` or `--path` flag, you'll be prompted to choose:
37
+
38
+ ```bash
39
+ $ opkg new my-package
40
+ ? Where should this package be created? ›
41
+ ❯ Root (current directory) - Create openpackage.yml here - for standalone/distributable packages
42
+ Local (workspace-scoped) - Create in .openpackage/packages/ - for project-specific packages
43
+ Global (cross-workspace) - Create in ~/.openpackage/packages/ - shared across all workspaces on this machine
44
+ Custom (specify path) - Create at a custom location you specify
45
+ ```
46
+
47
+ If you select **Custom**, you'll be prompted to enter a directory path:
48
+
49
+ ```bash
50
+ ? Enter the directory path for the package: › ./my-custom-location
51
+ ```
52
+
53
+ This ensures you make an explicit choice about where your package lives. For CI/CD and automation, use the `--scope` or `--path` flag to skip the prompt.
54
+
55
+ ## Scopes
56
+
57
+ ### Root Scope
58
+
59
+ **Location:** Current directory (`./openpackage.yml`)
60
+
61
+ ```bash
62
+ opkg new my-package --scope root
63
+ opkg new --scope root # Interactive: prompts for name
64
+ ```
65
+
66
+ **Use Cases:**
67
+ - Dedicated package repository
68
+ - Standalone package development
69
+ - Similar to `npm init`, `cargo init`
70
+
71
+ **Behavior:**
72
+ - Creates `openpackage.yml` at cwd
73
+ - Does not create workspace structure
74
+ - Package content lives at cwd
75
+
76
+ **Example Structure:**
77
+ ```
78
+ my-package/
79
+ ├── openpackage.yml # Package manifest
80
+ ├── .cursor/ # Platform-specific content
81
+ │ ├── rules/
82
+ │ └── commands/
83
+ ├── root/ # Root files
84
+ │ └── AGENTS.md
85
+ └── README.md
86
+ ```
87
+
88
+ ### Local Scope
89
+
90
+ **Location:** `.openpackage/packages/<package-name>/`
91
+
92
+ ```bash
93
+ opkg new my-package # Interactive: prompts for scope
94
+ opkg new my-package --scope local # Explicit
95
+ ```
96
+
97
+ **Use Cases:**
98
+ - Project-specific packages
99
+ - Workspace-scoped development
100
+ - Packages tied to single project
101
+
102
+ **Behavior:**
103
+ - Creates package in `.openpackage/packages/<name>/`
104
+ - Package content lives in nested directory
105
+ - Not automatically added to workspace (use `opkg install` to add)
106
+
107
+ **Example Structure:**
108
+ ```
109
+ project/
110
+ ├── .openpackage/
111
+ │ └── packages/
112
+ │ └── my-package/
113
+ │ ├── openpackage.yml # Package manifest
114
+ │ ├── .cursor/
115
+ │ │ ├── rules/
116
+ │ │ └── commands/
117
+ │ └── root/
118
+ └── src/ # Project source code
119
+ ```
120
+
121
+ **Installation:**
122
+ ```bash
123
+ opkg install my-package # Adds to workspace manifest and installs files
124
+ ```
125
+
126
+ ### Global Scope
127
+
128
+ **Location:** `~/.openpackage/packages/<package-name>/`
129
+
130
+ ```bash
131
+ opkg new shared-utils --scope global
132
+ ```
133
+
134
+ **Use Cases:**
135
+ - Personal utilities shared across projects
136
+ - Common rules and prompts
137
+ - Cross-workspace shared packages
138
+
139
+ **Behavior:**
140
+ - Creates package in global directory
141
+ - Not added to workspace manifest (used via path reference)
142
+ - Persists across all workspaces
143
+
144
+ **Installation:**
145
+ - **By name**: `opkg install <package-name>` (automatic discovery with version-aware resolution)
146
+ - **By path**: `opkg install ~/.openpackage/packages/<package-name>/` (explicit)
147
+
148
+ **Priority**: Global packages are checked after workspace-local packages. When both global packages and registry versions exist, the system compares versions and uses the newer one (with tie-breaker preferring global for mutability).
149
+
150
+ **Example Structure:**
151
+ ```
152
+ ~/.openpackage/
153
+ └── packages/
154
+ └── shared-utils/
155
+ ├── openpackage.yml
156
+ ├── .cursor/
157
+ │ ├── rules/
158
+ │ └── commands/
159
+ └── root/
160
+ ```
161
+
162
+ **Usage in Workspace:**
163
+ ```bash
164
+ # Install by name - automatic discovery
165
+ opkg install shared-utils
166
+
167
+ # Or explicit path
168
+ opkg install ~/.openpackage/packages/shared-utils/
169
+
170
+ # Or add to openpackage.yml manually
171
+ ```
172
+
173
+ ```yaml
174
+ # Any workspace's .openpackage/openpackage.yml
175
+ packages:
176
+ - name: shared-utils
177
+ path: ~/.openpackage/packages/shared-utils/
178
+ ```
179
+
180
+ ### Custom Path
181
+
182
+ **Location:** User-specified directory path
183
+
184
+ ```bash
185
+ opkg new my-package --path ./custom-location
186
+ opkg new my-package --path /opt/packages/my-package
187
+ opkg new my-package --path ~/projects/my-package
188
+ ```
189
+
190
+ **Use Cases:**
191
+ - Monorepo structures with custom package organization
192
+ - Shared team directories outside standard locations
193
+ - Integration with existing project structures
194
+ - Special organizational requirements
195
+
196
+ **Behavior:**
197
+ - Creates package at the exact path specified
198
+ - Supports relative paths (resolved from cwd)
199
+ - Supports absolute paths
200
+ - Supports tilde expansion (`~` → home directory)
201
+ - Validates parent directory exists before creation
202
+ - Blocks dangerous system directories
203
+
204
+ **Path Types:**
205
+
206
+ | Type | Example | Description |
207
+ |------|---------|-------------|
208
+ | Relative | `./my-package` | Relative to current directory |
209
+ | Relative Parent | `../shared/my-package` | Up and across directory tree |
210
+ | Absolute | `/opt/packages/my-package` | Full path from root |
211
+ | Tilde | `~/projects/my-package` | Relative to home directory |
212
+
213
+ **Example Structure:**
214
+ ```
215
+ /custom/location/
216
+ └── my-package/
217
+ ├── openpackage.yml # Package manifest
218
+ ├── .cursor/ # Platform-specific content
219
+ │ ├── rules/
220
+ │ └── commands/
221
+ └── root/ # Root files
222
+ ```
223
+
224
+ **Safety Features:**
225
+ - **Parent Validation**: Ensures parent directory exists before creating package
226
+ - **System Directory Protection**: Blocks creation in `/usr`, `/bin`, `/etc`, etc.
227
+ - **Existence Checking**: Detects existing packages and requires `--force` to overwrite
228
+ - **Clear Errors**: Provides actionable error messages when validation fails
229
+
230
+ **Installation:**
231
+ Custom path packages can be installed by path:
232
+ ```bash
233
+ opkg install --path ./custom-location/my-package
234
+ # or
235
+ opkg install /opt/packages/my-package
236
+ ```
237
+
238
+ **Priority**: When using custom paths, the package is treated similarly to root-scoped packages. Installation and management are done via explicit path references.
239
+
240
+ **Interactive Example:**
241
+ ```bash
242
+ $ opkg new
243
+ ? Where should this package be created? › Custom (specify path)
244
+ ? Enter the directory path for the package: › ./my-custom-location
245
+ ? Package name: › my-package
246
+ ? Description: › My custom package
247
+ ✓ my-custom-location/openpackage.yml created
248
+
249
+ 📍 Location: Custom path (./my-custom-location)
250
+ 💡 This package is at a custom location you specified
251
+
252
+ 💡 Next steps:
253
+ 1. Add files to your package at: ./my-custom-location
254
+ 2. Install to workspace with path: opkg install --path ./my-custom-location
255
+ ```
256
+
257
+ **Non-Interactive Example:**
258
+ ```bash
259
+ $ opkg new my-package --path ./custom-location --non-interactive
260
+ ✓ custom-location/openpackage.yml created
261
+ - Name: my-package
262
+
263
+ 📍 Location: Custom path (./custom-location)
264
+ 💡 This package is at a custom location you specified
265
+ ```
266
+
267
+ **Error Examples:**
268
+ ```bash
269
+ # Parent directory doesn't exist
270
+ $ opkg new test --path ./non-existent/package
271
+ Error: Parent directory does not exist: /path/to/non-existent
272
+ Please create it first or choose a different path.
273
+
274
+ # System directory blocked
275
+ $ opkg new test --path /usr/my-package
276
+ Error: Cannot create package in system directory: /usr/my-package
277
+
278
+ # Both flags provided (warning)
279
+ $ opkg new test --scope local --path ./custom
280
+ # Uses custom path, logs warning about --scope being ignored
281
+ ```
282
+
283
+ ## Behavior Details
284
+
285
+ ### Interactive Mode (Default)
286
+
287
+ When `--non-interactive` is not specified, prompts user for:
288
+ - Package name (if not provided and scope allows)
289
+ - Description
290
+ - Keywords (space-separated)
291
+ - Private flag
292
+
293
+ **Example Session:**
294
+ ```bash
295
+ $ opkg new my-package
296
+ ? Package name: › my-package
297
+ ? Description: › My awesome package
298
+ ? Keywords (space-separated): › tools utils
299
+ ? Private package? › No
300
+ ✓ .openpackage/packages/my-package/openpackage.yml created
301
+ ```
302
+
303
+ ### Non-Interactive Mode
304
+
305
+ When `--non-interactive` is specified:
306
+ - Uses provided package name or cwd basename
307
+ - Skips all prompts
308
+ - Creates minimal manifest with name only
309
+
310
+ **Example:**
311
+ ```bash
312
+ $ opkg new my-package --non-interactive
313
+ ✓ .openpackage/packages/my-package/openpackage.yml created
314
+ - Name: my-package
315
+ ```
316
+
317
+ ### Conflict Handling
318
+
319
+ #### Existing Package Without Force
320
+
321
+ If package already exists and `--force` is not specified:
322
+ - Displays existing package information
323
+ - Does not overwrite
324
+ - Exits successfully
325
+
326
+ ```bash
327
+ $ opkg new existing-package
328
+ ✓ .openpackage/packages/existing-package/openpackage.yml already exists
329
+ - Name: existing-package
330
+ - Version: 1.0.0
331
+ - Description: Existing package
332
+ ```
333
+
334
+ #### Existing Package With Force
335
+
336
+ If package already exists and `--force` is specified:
337
+ - Overwrites `openpackage.yml`
338
+ - Preserves existing content directories
339
+ - Logs overwrite action
340
+
341
+ ```bash
342
+ $ opkg new existing-package --force
343
+ ✓ .openpackage/packages/existing-package/openpackage.yml created
344
+ - Name: existing-package
345
+ ```
346
+
347
+ ### Workspace Integration
348
+
349
+ The `opkg new` command **creates** packages but does **not** automatically add them to the workspace manifest.
350
+
351
+ To use a package after creation, explicitly install it:
352
+ ```bash
353
+ opkg new my-package --scope local
354
+ opkg install my-package # Adds to workspace manifest and installs files
355
+ ```
356
+
357
+ This separation keeps package creation (scaffolding) distinct from package usage (dependency management).
358
+
359
+ ### Error Handling
360
+
361
+ #### Missing Scope or Path (Non-Interactive)
362
+ ```bash
363
+ $ opkg new my-package --non-interactive
364
+ Error: Either --scope or --path is required in non-interactive mode.
365
+
366
+ Usage with scope:
367
+ opkg new [package-name] --scope <root|local|global> --non-interactive
368
+
369
+ Usage with custom path:
370
+ opkg new [package-name] --path <directory> --non-interactive
371
+
372
+ Available scopes:
373
+ root - Create in current directory
374
+ local - Create in .openpackage/packages/
375
+ global - Create in ~/.openpackage/packages/
376
+ ```
377
+
378
+ #### Missing Package Name
379
+ ```bash
380
+ $ opkg new --scope local --non-interactive
381
+ Error: Package name is required for local scope in non-interactive mode.
382
+ Usage: opkg new <package-name> --scope local --non-interactive
383
+ ```
384
+
385
+ #### Invalid Scope
386
+ ```bash
387
+ $ opkg new my-package --scope invalid
388
+ Error: Invalid scope: 'invalid'
389
+ Valid scopes: root, local, global
390
+ ```
391
+
392
+ #### Invalid Package Name
393
+ ```bash
394
+ $ opkg new My-Package
395
+ Error: Package name 'My-Package' is invalid.
396
+ Package names must be lowercase...
397
+ ```
398
+
399
+ #### Custom Path: Non-Existent Parent Directory
400
+ ```bash
401
+ $ opkg new my-package --path ./non-existent/package
402
+ Error: Parent directory does not exist: /path/to/non-existent
403
+ Please create it first or choose a different path.
404
+ ```
405
+
406
+ #### Custom Path: System Directory Blocked
407
+ ```bash
408
+ $ opkg new my-package --path /usr/my-package
409
+ Error: Cannot create package in system directory: /usr/my-package
410
+ ```
411
+
412
+ #### Custom Path: Already Exists Without Force
413
+ ```bash
414
+ $ opkg new my-package --path ./existing
415
+ Error: Package already exists at: /path/to/existing
416
+ Use --force to overwrite.
417
+ ```
418
+
419
+ #### Custom Path: Empty Path
420
+ ```bash
421
+ $ opkg new my-package --path ""
422
+ Error: Path cannot be empty
423
+ ```
424
+
425
+ ## Output Format
426
+
427
+ ### Success Output
428
+
429
+ ```bash
430
+ ✓ <path-to-openpackage.yml> created
431
+ - Name: <package-name>
432
+ [- Version: <version>] # If specified
433
+ [- Description: <desc>] # If specified
434
+
435
+ 📍 Scope: <scope-description>
436
+ 💡 <scope-specific-tip>
437
+
438
+ 💡 Next steps:
439
+ 1. <step-1>
440
+ 2. <step-2>
441
+ 3. <step-3>
442
+ ```
443
+
444
+ ### Error Output
445
+
446
+ ```bash
447
+ Error: <error-message>
448
+ [Additional context or suggestions]
449
+ ```
450
+
451
+ ## Examples
452
+
453
+ ### Create Package with Interactive Scope Selection
454
+ ```bash
455
+ $ opkg new my-tools
456
+ ? Where should this package be created? ›
457
+ ❯ Root (current directory) - Create openpackage.yml here - for standalone/distributable packages
458
+ Local (workspace-scoped) - Create in .openpackage/packages/ - for project-specific packages
459
+ Global (cross-workspace) - Create in ~/.openpackage/packages/ - shared across all workspaces on this machine
460
+
461
+ # User selects "Root"
462
+ ? Package name: › my-tools
463
+ ? Description: › My project tools
464
+ ? Keywords (space-separated): › tools utils
465
+ ? Private package? › No
466
+
467
+ ✓ openpackage.yml created
468
+ - Name: my-tools
469
+ - Description: My project tools
470
+ - Keywords: tools, utils
471
+
472
+ 📍 Scope: Current directory (root package)
473
+
474
+ 💡 Next steps:
475
+ 1. Add files to your package in current directory
476
+ 2. Save to registry: opkg pack
477
+ 3. Install in other workspaces: opkg install my-tools
478
+ ```
479
+
480
+ ### Create Local Package (Explicit Scope)
481
+ ```bash
482
+ $ opkg new my-tools --scope local
483
+ # Skips scope prompt, goes directly to package details
484
+ ✓ .openpackage/packages/my-tools/openpackage.yml created
485
+ - Name: my-tools
486
+
487
+ 📍 Scope: Workspace-local (.openpackage/packages/)
488
+ 💡 This package is local to the current workspace
489
+
490
+ 💡 Next steps:
491
+ 1. Add files to your package: cd .openpackage/packages/my-tools/
492
+ 2. Install to this workspace: opkg install my-tools
493
+ ```
494
+
495
+ ### Create Global Package
496
+ ```bash
497
+ $ opkg new shared-prompts --scope global
498
+ ✓ /Users/user/.openpackage/packages/shared-prompts/openpackage.yml created
499
+ - Name: shared-prompts
500
+
501
+ 📍 Scope: Global shared (~/.openpackage/packages/)
502
+ 💡 This package can be used across all workspaces
503
+
504
+ 💡 Next steps:
505
+ 1. Add files to your package: cd ~/.openpackage/packages/shared-prompts/
506
+ 2. Install to any workspace: opkg install shared-prompts
507
+ 3. Or use explicit path: opkg install ~/.openpackage/packages/shared-prompts/
508
+ ```
509
+
510
+ ### Create Root Package
511
+ ```bash
512
+ $ opkg new my-package --scope root
513
+ ✓ openpackage.yml created
514
+ - Name: my-package
515
+
516
+ 📍 Scope: Current directory (root package)
517
+
518
+ 💡 Next steps:
519
+ 1. Add files to your package in current directory
520
+ 2. Save to registry: opkg pack
521
+ 3. Install in other workspaces: opkg install my-package
522
+ ```
523
+
524
+ ### Create with Force Overwrite
525
+ ```bash
526
+ $ opkg new existing-package --scope local --force --non-interactive
527
+ ✓ .openpackage/packages/existing-package/openpackage.yml created
528
+ - Name: existing-package
529
+
530
+ 📍 Scope: Workspace-local (.openpackage/packages/)
531
+ 💡 This package is local to the current workspace
532
+ ```
533
+
534
+ ### Non-Interactive Mode Requires Scope
535
+ ```bash
536
+ $ opkg new my-package --non-interactive
537
+ Error: The --scope flag is required in non-interactive mode.
538
+ Usage: opkg new [package-name] --scope <root|local|global> --non-interactive
539
+
540
+ Available scopes:
541
+ root - Create in current directory
542
+ local - Create in .openpackage/packages/
543
+ global - Create in ~/.openpackage/packages/
544
+
545
+ $ opkg new my-package --scope local --non-interactive
546
+ ✓ .openpackage/packages/my-package/openpackage.yml created
547
+ - Name: my-package
548
+ ```
549
+
550
+ ### Create Scoped Package
551
+ ```bash
552
+ $ opkg new @myorg/utils
553
+ ✓ .openpackage/packages/@myorg/utils/openpackage.yml created
554
+ - Name: @myorg/utils
555
+
556
+ 📍 Scope: Workspace-local (.openpackage/packages/)
557
+ 💡 This package is local to the current workspace
558
+ ```
559
+
560
+ ### Create Package at Custom Path (Interactive)
561
+ ```bash
562
+ $ opkg new my-package
563
+ ? Where should this package be created? › Custom (specify path)
564
+ ? Enter the directory path for the package: › ./custom-location
565
+ ? Package name: › my-package
566
+ ? Description: › Custom location package
567
+ ? Keywords (space-separated): ›
568
+ ? Private package? › No
569
+
570
+ ✓ custom-location/openpackage.yml created
571
+ - Name: my-package
572
+ - Description: Custom location package
573
+
574
+ 📍 Location: Custom path (./custom-location)
575
+ 💡 This package is at a custom location you specified
576
+
577
+ 💡 Next steps:
578
+ 1. Add files to your package at: ./custom-location
579
+ 2. Install to workspace with path: opkg install --path ./custom-location
580
+ ```
581
+
582
+ ### Create Package at Custom Path (Relative)
583
+ ```bash
584
+ $ opkg new my-package --path ./custom-location --non-interactive
585
+ ✓ custom-location/openpackage.yml created
586
+ - Name: my-package
587
+
588
+ 📍 Location: Custom path (./custom-location)
589
+ 💡 This package is at a custom location you specified
590
+
591
+ 💡 Next steps:
592
+ 1. Add files to your package at: ./custom-location
593
+ 2. Install to workspace with path: opkg install --path ./custom-location
594
+ ```
595
+
596
+ ### Create Package at Custom Path (Absolute)
597
+ ```bash
598
+ $ opkg new my-package --path /opt/packages/my-package --non-interactive
599
+ ✓ /opt/packages/my-package/openpackage.yml created
600
+ - Name: my-package
601
+
602
+ 📍 Location: Custom path (/opt/packages/my-package)
603
+ 💡 This package is at a custom location you specified
604
+
605
+ 💡 Next steps:
606
+ 1. Add files to your package at: /opt/packages/my-package
607
+ 2. Install to workspace with path: opkg install --path /opt/packages/my-package
608
+ ```
609
+
610
+ ### Create Package at Custom Path (Tilde)
611
+ ```bash
612
+ $ opkg new my-package --path ~/projects/my-package --non-interactive
613
+ ✓ /Users/user/projects/my-package/openpackage.yml created
614
+ - Name: my-package
615
+
616
+ 📍 Location: Custom path (~/projects/my-package)
617
+ 💡 This package is at a custom location you specified
618
+
619
+ 💡 Next steps:
620
+ 1. Add files to your package at: ~/projects/my-package
621
+ 2. Install to workspace with path: opkg install --path ~/projects/my-package
622
+ ```
623
+
624
+ ### Custom Path with Monorepo Structure
625
+ ```bash
626
+ # Create package in monorepo packages directory
627
+ $ opkg new shared-components --path ../packages/shared-components --non-interactive
628
+ ✓ ../packages/shared-components/openpackage.yml created
629
+ - Name: shared-components
630
+
631
+ 📍 Location: Custom path (../packages/shared-components)
632
+ 💡 This package is at a custom location you specified
633
+
634
+ # Resulting structure:
635
+ # project-root/
636
+ # ├── workspace-a/ (current directory)
637
+ # └── packages/
638
+ # └── shared-components/
639
+ # └── openpackage.yml
640
+ ```
641
+
642
+ ## Integration with Other Commands
643
+
644
+ ### After `opkg new`
645
+
646
+ **Local Package Workflow:**
647
+ ```bash
648
+ opkg new my-package # Create package
649
+ cd .openpackage/packages/my-package/
650
+ # Add files (rules, commands, etc.)
651
+ opkg install my-package # Install to workspace
652
+ opkg save my-package # Save changes back to package
653
+ opkg pack my-package # Create stable release
654
+ ```
655
+
656
+ **Global Package Workflow:**
657
+ ```bash
658
+ opkg new shared-utils --scope global # Create global package
659
+ cd ~/.openpackage/packages/shared-utils/
660
+ # Add files
661
+ opkg pack shared-utils # Pack to registry
662
+
663
+ # In any workspace:
664
+ # Add to .openpackage/openpackage.yml:
665
+ # - name: shared-utils
666
+ # path: ~/.openpackage/packages/shared-utils/
667
+ opkg install # Install all deps including shared-utils
668
+ ```
669
+
670
+ **Root Package Workflow:**
671
+ ```bash
672
+ mkdir my-package && cd my-package
673
+ opkg new --scope root # Create root package
674
+ # Add files to current directory
675
+ opkg pack # Pack to registry
676
+ opkg push my-package # Share to remote registry
677
+ ```
678
+
679
+ **Custom Path Package Workflow:**
680
+ ```bash
681
+ opkg new my-package --path ./custom-location # Create at custom path
682
+ cd custom-location/
683
+ # Add files (rules, commands, etc.)
684
+ opkg save --path ./custom-location # Save changes (if applicable)
685
+ opkg pack --path ./custom-location # Create stable release
686
+
687
+ # In any workspace:
688
+ opkg install --path /path/to/custom-location # Install by path
689
+ ```
690
+
691
+ ### Auto-Creation by Other Commands
692
+
693
+ The `opkg add` command may auto-create a root package if needed:
694
+ ```bash
695
+ $ cd my-package/
696
+ $ opkg add ./rules/example.md
697
+ # No package detected - prompts to create root package
698
+ ? Create package for current directory? › Yes
699
+ ? Package name: › my-package
700
+ ? Description: › ...
701
+ ✓ Created root package
702
+ ✓ Added ./rules/example.md to package
703
+ ```
704
+
705
+ ## Comparison with Deprecated `opkg init`
706
+
707
+ | Aspect | Old `opkg init` | New `opkg new` |
708
+ |--------|----------------|----------------|
709
+ | **Command** | `opkg init` | `opkg new` |
710
+ | **Dual Purpose** | ✅ Yes (workspace + package) | ❌ No (package only) |
711
+ | **Root Package** | `opkg init` | `opkg new --scope root` |
712
+ | **Local Package** | `opkg init <name>` | `opkg new <name>` |
713
+ | **Global Package** | ❌ Not supported | `opkg new <name> --scope global` |
714
+ | **Custom Path** | ❌ Not supported | `opkg new <name> --path <dir>` |
715
+ | **Workspace Init** | Manual required | Auto-created when needed |
716
+ | **Scope Clarity** | Implicit | Explicit with `--scope` or `--path` |
717
+ | **Overwrite** | `--force` | `--force` (same) |
718
+ | **Interactive** | Yes (default) | Yes (default) |
719
+
720
+ ## Implementation Notes
721
+
722
+ ### Core Logic
723
+ - Implemented in `src/commands/new.ts` (CLI interface)
724
+ - Core logic in `src/core/package-creation.ts` (business logic)
725
+ - Scope-based path resolution in `src/utils/scope-resolution.ts` (pure functions)
726
+ - Custom path resolution in `src/utils/custom-path-resolution.ts` (pure functions)
727
+
728
+ ### Design Patterns
729
+ - **Separation of Concerns**: CLI, business logic, and utilities separated
730
+ - **Single Responsibility**: Each module has one clear purpose
731
+ - **Reusability**: `createPackage()` used by both `new` command and `add` pipeline
732
+ - **Testability**: Pure functions for path resolution, testable business logic
733
+ - **Modularity**: Custom path logic isolated in dedicated utility module
734
+
735
+ ### Custom Path Implementation
736
+ The custom path feature follows these principles:
737
+ 1. **Validation First**: Validate path before any file operations
738
+ 2. **Clear Errors**: Provide actionable error messages with context
739
+ 3. **Safety Checks**: Block dangerous system directories
740
+ 4. **Path Types**: Support relative, absolute, and tilde paths
741
+ 5. **Precedence**: `--path` takes precedence over `--scope` when both provided
742
+
743
+ **Key Functions** (`src/utils/custom-path-resolution.ts`):
744
+ - `resolveCustomPath()` - Resolves any path type to absolute path
745
+ - `validateCustomPath()` - Validates path safety and existence
746
+ - `formatCustomPathForDisplay()` - Formats paths for user output
747
+
748
+ ### Extensibility
749
+
750
+ #### Adding a New Predefined Scope (e.g., "team")
751
+ 1. Add to `PackageScope` type in `scope-resolution.ts`
752
+ 2. Add path resolution in `getScopePackageDir()`
753
+ 3. Add description in `getScopeDescription()`
754
+ 4. Update command help text
755
+ 5. Add to interactive prompt choices
756
+
757
+ #### Adding Custom Path Validation Rules
758
+ 1. Extend `validateCustomPath()` in `custom-path-resolution.ts`
759
+ 2. Add new validation checks as needed
760
+ 3. Return structured error messages
761
+ 4. Update tests to cover new rules
762
+
763
+ ## See Also
764
+
765
+ - [Scope Management](../scope-management.md) - Details on local/global scopes
766
+ - [Directory Layout](../directory-layout.md) - Package directory structure
767
+ - [Package Sources](../package-sources.md) - Path-based source resolution
768
+ - [Save Command](../save/) - Syncing changes back to packages
769
+ - [Pack Command](../pack/) - Creating registry snapshots