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.
- package/README.md +109 -186
- package/assets/openpackage_ascii_dark.png +0 -0
- package/assets/openpackage_ascii_light.png +0 -0
- package/dist/commands/add.js +34 -10
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/apply.js +16 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/delete.js +1 -1
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/install.js +177 -8
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/list.js +2 -2
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/login.js +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/new.js +125 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/pack.js +7 -13
- package/dist/commands/pack.js.map +1 -1
- package/dist/commands/pull.js +1 -1
- package/dist/commands/pull.js.map +1 -1
- package/dist/commands/push.js +1 -1
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/remove.js +63 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/save.js +11 -17
- package/dist/commands/save.js.map +1 -1
- package/dist/commands/set.js +33 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/show.js +16 -94
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/status.js +26 -701
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/uninstall.js +14 -427
- package/dist/commands/uninstall.js.map +1 -1
- package/dist/constants/index.js +72 -16
- package/dist/constants/index.js.map +1 -1
- package/dist/core/add/add-conflict-handler.js +1 -8
- package/dist/core/add/add-conflict-handler.js.map +1 -1
- package/dist/core/add/add-pipeline.js +12 -10
- package/dist/core/add/add-pipeline.js.map +1 -1
- package/dist/core/add/add-to-source-pipeline.js +123 -0
- package/dist/core/add/add-to-source-pipeline.js.map +1 -0
- package/dist/core/add/package-index-updater.js +77 -78
- package/dist/core/add/package-index-updater.js.map +1 -1
- package/dist/core/add/platform-path-transformer.js +6 -4
- package/dist/core/add/platform-path-transformer.js.map +1 -1
- package/dist/core/add/source-collector.js +2 -3
- package/dist/core/add/source-collector.js.map +1 -1
- package/dist/core/apply/apply-pipeline.js +110 -0
- package/dist/core/apply/apply-pipeline.js.map +1 -0
- package/dist/core/dependency-resolver.js +263 -21
- package/dist/core/dependency-resolver.js.map +1 -1
- package/dist/core/discovery/file-discovery.js +1 -2
- package/dist/core/discovery/file-discovery.js.map +1 -1
- package/dist/core/discovery/platform-files-discovery.js +33 -18
- package/dist/core/discovery/platform-files-discovery.js.map +1 -1
- package/dist/core/flows/flow-executor.js +974 -0
- package/dist/core/flows/flow-executor.js.map +1 -0
- package/dist/core/flows/flow-inverter.js +442 -0
- package/dist/core/flows/flow-inverter.js.map +1 -0
- package/dist/core/flows/flow-key-extractor.js +101 -0
- package/dist/core/flows/flow-key-extractor.js.map +1 -0
- package/dist/core/flows/flow-key-mapper.js +382 -0
- package/dist/core/flows/flow-key-mapper.js.map +1 -0
- package/dist/core/flows/flow-transforms.js +632 -0
- package/dist/core/flows/flow-transforms.js.map +1 -0
- package/dist/core/flows/map-pipeline/context.js +73 -0
- package/dist/core/flows/map-pipeline/context.js.map +1 -0
- package/dist/core/flows/map-pipeline/index.js +156 -0
- package/dist/core/flows/map-pipeline/index.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/copy.js +104 -0
- package/dist/core/flows/map-pipeline/operations/copy.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/pipe.js +70 -0
- package/dist/core/flows/map-pipeline/operations/pipe.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/rename.js +102 -0
- package/dist/core/flows/map-pipeline/operations/rename.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/set.js +50 -0
- package/dist/core/flows/map-pipeline/operations/set.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/switch.js +79 -0
- package/dist/core/flows/map-pipeline/operations/switch.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/transform.js +543 -0
- package/dist/core/flows/map-pipeline/operations/transform.js.map +1 -0
- package/dist/core/flows/map-pipeline/operations/unset.js +65 -0
- package/dist/core/flows/map-pipeline/operations/unset.js.map +1 -0
- package/dist/core/flows/map-pipeline/types.js +8 -0
- package/dist/core/flows/map-pipeline/types.js.map +1 -0
- package/dist/core/flows/map-pipeline/utils.js +278 -0
- package/dist/core/flows/map-pipeline/utils.js.map +1 -0
- package/dist/core/flows/platform-converter.js +328 -0
- package/dist/core/flows/platform-converter.js.map +1 -0
- package/dist/core/flows/source-resolver.js +192 -0
- package/dist/core/flows/source-resolver.js.map +1 -0
- package/dist/core/flows/toml-domain-transforms.js +23 -0
- package/dist/core/flows/toml-domain-transforms.js.map +1 -0
- package/dist/core/install/bulk-install-pipeline.js +68 -7
- package/dist/core/install/bulk-install-pipeline.js.map +1 -1
- package/dist/core/install/canonical-plan.js +3 -3
- package/dist/core/install/canonical-plan.js.map +1 -1
- package/dist/core/install/dry-run.js +3 -3
- package/dist/core/install/dry-run.js.map +1 -1
- package/dist/core/install/flow-based-installer.js +1158 -0
- package/dist/core/install/flow-based-installer.js.map +1 -0
- package/dist/core/install/flow-workspace-tracker.js +111 -0
- package/dist/core/install/flow-workspace-tracker.js.map +1 -0
- package/dist/core/install/format-detector.js +228 -0
- package/dist/core/install/format-detector.js.map +1 -0
- package/dist/core/install/git-package-loader.js +20 -0
- package/dist/core/install/git-package-loader.js.map +1 -0
- package/dist/core/install/install-errors.js +1 -1
- package/dist/core/install/install-errors.js.map +1 -1
- package/dist/core/install/install-flow.js +34 -14
- package/dist/core/install/install-flow.js.map +1 -1
- package/dist/core/install/install-pipeline.js +52 -17
- package/dist/core/install/install-pipeline.js.map +1 -1
- package/dist/core/install/install-reporting.js +26 -8
- package/dist/core/install/install-reporting.js.map +1 -1
- package/dist/core/install/local-source-resolution.js +103 -0
- package/dist/core/install/local-source-resolution.js.map +1 -0
- package/dist/core/install/marketplace-handler.js +221 -0
- package/dist/core/install/marketplace-handler.js.map +1 -0
- package/dist/core/install/path-install-pipeline.js +241 -0
- package/dist/core/install/path-install-pipeline.js.map +1 -0
- package/dist/core/install/path-package-loader.js +116 -0
- package/dist/core/install/path-package-loader.js.map +1 -0
- package/dist/core/install/plugin-detector.js +72 -0
- package/dist/core/install/plugin-detector.js.map +1 -0
- package/dist/core/install/plugin-to-universal-converter.js +218 -0
- package/dist/core/install/plugin-to-universal-converter.js.map +1 -0
- package/dist/core/install/plugin-transformer.js +191 -0
- package/dist/core/install/plugin-transformer.js.map +1 -0
- package/dist/core/install/version-selection.js +1 -1
- package/dist/core/install/version-selection.js.map +1 -1
- package/dist/core/openpackage.js +40 -22
- package/dist/core/openpackage.js.map +1 -1
- package/dist/core/pack/pack-output.js +62 -0
- package/dist/core/pack/pack-output.js.map +1 -0
- package/dist/core/pack/pack-pipeline.js +186 -0
- package/dist/core/pack/pack-pipeline.js.map +1 -0
- package/dist/core/package-context.js +45 -70
- package/dist/core/package-context.js.map +1 -1
- package/dist/core/package-creation.js +203 -0
- package/dist/core/package-creation.js.map +1 -0
- package/dist/core/package.js +20 -6
- package/dist/core/package.js.map +1 -1
- package/dist/core/platforms.js +665 -209
- package/dist/core/platforms.js.map +1 -1
- package/dist/core/push/push-context.js +1 -1
- package/dist/core/push/push-context.js.map +1 -1
- package/dist/core/push/push-upload.js +2 -2
- package/dist/core/push/push-upload.js.map +1 -1
- package/dist/core/registry.js +6 -6
- package/dist/core/registry.js.map +1 -1
- package/dist/core/remote-pull.js +2 -2
- package/dist/core/remote-pull.js.map +1 -1
- package/dist/core/remove/removal-collector.js +52 -0
- package/dist/core/remove/removal-collector.js.map +1 -0
- package/dist/core/remove/removal-confirmation.js +39 -0
- package/dist/core/remove/removal-confirmation.js.map +1 -0
- package/dist/core/remove/remove-from-source-pipeline.js +173 -0
- package/dist/core/remove/remove-from-source-pipeline.js.map +1 -0
- package/dist/core/save/constants.js +3 -3
- package/dist/core/save/constants.js.map +1 -1
- package/dist/core/save/flow-based-saver.js +270 -0
- package/dist/core/save/flow-based-saver.js.map +1 -0
- package/dist/core/save/name-resolution.js +1 -1
- package/dist/core/save/name-resolution.js.map +1 -1
- package/dist/core/save/package-yml-generator.js +4 -5
- package/dist/core/save/package-yml-generator.js.map +1 -1
- package/dist/core/save/save-candidate-builder.js +215 -0
- package/dist/core/save/save-candidate-builder.js.map +1 -0
- package/dist/core/save/save-candidate-loader.js +12 -11
- package/dist/core/save/save-candidate-loader.js.map +1 -1
- package/dist/core/save/save-conflict-analyzer.js +150 -0
- package/dist/core/save/save-conflict-analyzer.js.map +1 -0
- package/dist/core/save/save-conflict-resolution.js +28 -14
- package/dist/core/save/save-conflict-resolution.js.map +1 -1
- package/dist/core/save/save-conflict-resolver.js +31 -275
- package/dist/core/save/save-conflict-resolver.js.map +1 -1
- package/dist/core/save/save-group-builder.js +52 -0
- package/dist/core/save/save-group-builder.js.map +1 -0
- package/dist/core/save/save-interactive-resolver.js +190 -0
- package/dist/core/save/save-interactive-resolver.js.map +1 -0
- package/dist/core/save/save-pipeline.js +58 -34
- package/dist/core/save/save-pipeline.js.map +1 -1
- package/dist/core/save/save-platform-handler.js +53 -0
- package/dist/core/save/save-platform-handler.js.map +1 -0
- package/dist/core/save/save-resolution-executor.js +145 -0
- package/dist/core/save/save-resolution-executor.js.map +1 -0
- package/dist/core/save/save-result-reporter.js +167 -0
- package/dist/core/save/save-result-reporter.js.map +1 -0
- package/dist/core/save/save-to-source-pipeline.js +154 -0
- package/dist/core/save/save-to-source-pipeline.js.map +1 -0
- package/dist/core/save/save-versioning.js +4 -4
- package/dist/core/save/save-versioning.js.map +1 -1
- package/dist/core/save/save-write-coordinator.js +204 -0
- package/dist/core/save/save-write-coordinator.js.map +1 -0
- package/dist/core/save/save-yml-resolution.js +28 -216
- package/dist/core/save/save-yml-resolution.js.map +1 -1
- package/dist/core/save/workspace-rename.js +7 -8
- package/dist/core/save/workspace-rename.js.map +1 -1
- package/dist/core/set/set-output.js +72 -0
- package/dist/core/set/set-output.js.map +1 -0
- package/dist/core/set/set-pipeline.js +361 -0
- package/dist/core/set/set-pipeline.js.map +1 -0
- package/dist/core/set/set-types.js +5 -0
- package/dist/core/set/set-types.js.map +1 -0
- package/dist/core/show/package-resolver.js +257 -0
- package/dist/core/show/package-resolver.js.map +1 -0
- package/dist/core/show/scope-discovery.js +165 -0
- package/dist/core/show/scope-discovery.js.map +1 -0
- package/dist/core/show/show-output.js +168 -0
- package/dist/core/show/show-output.js.map +1 -0
- package/dist/core/show/show-pipeline.js +113 -0
- package/dist/core/show/show-pipeline.js.map +1 -0
- package/dist/core/show/show-types.js +5 -0
- package/dist/core/show/show-types.js.map +1 -0
- package/dist/core/source-resolution/dependency-graph.js +104 -0
- package/dist/core/source-resolution/dependency-graph.js.map +1 -0
- package/dist/core/source-resolution/resolve-mutable-source.js +109 -0
- package/dist/core/source-resolution/resolve-mutable-source.js.map +1 -0
- package/dist/core/source-resolution/resolve-package-source.js +29 -0
- package/dist/core/source-resolution/resolve-package-source.js.map +1 -0
- package/dist/core/source-resolution/resolve-registry-version.js +35 -0
- package/dist/core/source-resolution/resolve-registry-version.js.map +1 -0
- package/dist/core/source-resolution/types.js.map +1 -0
- package/dist/core/status/status-file-discovery.js +23 -12
- package/dist/core/status/status-file-discovery.js.map +1 -1
- package/dist/core/status/status-pipeline.js +134 -0
- package/dist/core/status/status-pipeline.js.map +1 -0
- package/dist/core/sync/platform-sync-summary.js +27 -0
- package/dist/core/sync/platform-sync-summary.js.map +1 -0
- package/dist/core/uninstall/flow-aware-uninstaller.js +189 -0
- package/dist/core/uninstall/flow-aware-uninstaller.js.map +1 -0
- package/dist/core/uninstall/uninstall-file-discovery.js +11 -6
- package/dist/core/uninstall/uninstall-file-discovery.js.map +1 -1
- package/dist/core/uninstall/uninstall-pipeline.js +141 -0
- package/dist/core/uninstall/uninstall-pipeline.js.map +1 -0
- package/dist/core/universal-patterns.js +64 -0
- package/dist/core/universal-patterns.js.map +1 -0
- package/dist/index.js +99 -6
- package/dist/index.js.map +1 -1
- package/dist/types/flows.js +8 -0
- package/dist/types/flows.js.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/platform-flows.js +8 -0
- package/dist/types/platform-flows.js.map +1 -0
- package/dist/types/workspace-index.js +6 -0
- package/dist/types/workspace-index.js.map +1 -0
- package/dist/utils/custom-path-resolution.js +160 -0
- package/dist/utils/custom-path-resolution.js.map +1 -0
- package/dist/utils/dependency-coverage.js +1 -1
- package/dist/utils/dependency-coverage.js.map +1 -1
- package/dist/utils/file-processing.js +1 -1
- package/dist/utils/flow-index-installer.js +209 -0
- package/dist/utils/flow-index-installer.js.map +1 -0
- package/dist/utils/formatters.js +47 -1
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/fs.js +17 -0
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/git-clone-registry.js +88 -0
- package/dist/utils/git-clone-registry.js.map +1 -0
- package/dist/utils/git-clone.js +69 -0
- package/dist/utils/git-clone.js.map +1 -0
- package/dist/utils/git-spec.js +96 -0
- package/dist/utils/git-spec.js.map +1 -0
- package/dist/utils/http-client.js +7 -0
- package/dist/utils/http-client.js.map +1 -1
- package/dist/utils/index-based-installer.js +356 -163
- package/dist/utils/index-based-installer.js.map +1 -1
- package/dist/utils/install-conflict-handler.js +2 -2
- package/dist/utils/install-conflict-handler.js.map +1 -1
- package/dist/utils/install-file-discovery.js +18 -13
- package/dist/utils/install-file-discovery.js.map +1 -1
- package/dist/utils/install-helpers.js +43 -20
- package/dist/utils/install-helpers.js.map +1 -1
- package/dist/utils/jsonc.js +23 -1
- package/dist/utils/jsonc.js.map +1 -1
- package/dist/utils/manifest-paths.js +1 -1
- package/dist/utils/manifest-paths.js.map +1 -1
- package/dist/utils/markdown-frontmatter.js +46 -0
- package/dist/utils/markdown-frontmatter.js.map +1 -1
- package/dist/utils/package-copy.js +5 -103
- package/dist/utils/package-copy.js.map +1 -1
- package/dist/utils/package-filters.js +9 -105
- package/dist/utils/package-filters.js.map +1 -1
- package/dist/utils/package-index-yml.js +27 -6
- package/dist/utils/package-index-yml.js.map +1 -1
- package/dist/utils/package-input.js +98 -0
- package/dist/utils/package-input.js.map +1 -0
- package/dist/utils/package-management.js +80 -28
- package/dist/utils/package-management.js.map +1 -1
- package/dist/utils/package-name-resolution.js +327 -0
- package/dist/utils/package-name-resolution.js.map +1 -0
- package/dist/utils/package-name.js +18 -16
- package/dist/utils/package-name.js.map +1 -1
- package/dist/utils/package-versioning.js +2 -33
- package/dist/utils/package-versioning.js.map +1 -1
- package/dist/utils/package-yml.js +19 -28
- package/dist/utils/package-yml.js.map +1 -1
- package/dist/utils/path-resolution.js +102 -0
- package/dist/utils/path-resolution.js.map +1 -0
- package/dist/utils/paths.js +6 -6
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/platform-file.js +36 -24
- package/dist/utils/platform-file.js.map +1 -1
- package/dist/utils/platform-mapper.js +222 -68
- package/dist/utils/platform-mapper.js.map +1 -1
- package/dist/utils/platform-root-files.js +44 -0
- package/dist/utils/platform-root-files.js.map +1 -0
- package/dist/utils/platform-utils.js +35 -54
- package/dist/utils/platform-utils.js.map +1 -1
- package/dist/utils/platform-yaml-merge.js +20 -140
- package/dist/utils/platform-yaml-merge.js.map +1 -1
- package/dist/utils/prompts.js +92 -7
- package/dist/utils/prompts.js.map +1 -1
- package/dist/utils/registry-entry-filter.js +50 -27
- package/dist/utils/registry-entry-filter.js.map +1 -1
- package/dist/utils/registry-paths.js +5 -4
- package/dist/utils/registry-paths.js.map +1 -1
- package/dist/utils/scope-resolution.js +156 -0
- package/dist/utils/scope-resolution.js.map +1 -0
- package/dist/utils/source-mutability.js +15 -0
- package/dist/utils/source-mutability.js.map +1 -0
- package/dist/utils/tarball.js +29 -4
- package/dist/utils/tarball.js.map +1 -1
- package/dist/utils/version-ranges.js +1 -32
- package/dist/utils/version-ranges.js.map +1 -1
- package/dist/utils/workspace-index-helpers.js +28 -0
- package/dist/utils/workspace-index-helpers.js.map +1 -0
- package/dist/utils/workspace-index-ownership.js +100 -0
- package/dist/utils/workspace-index-ownership.js.map +1 -0
- package/dist/utils/workspace-index-yml.js +173 -0
- package/dist/utils/workspace-index-yml.js.map +1 -0
- package/examples/custom-subdirs-platform.jsonc +157 -0
- package/package.json +7 -2
- package/platforms.jsonc +531 -84
- package/schemas/map-pipeline-v1.json +256 -0
- package/schemas/platforms-v1.json +400 -0
- package/specs/README.md +88 -0
- package/specs/add/README.md +166 -0
- package/specs/agents-claude.md +570 -0
- package/specs/agents-opencode.md +622 -0
- package/specs/apply/README.md +21 -0
- package/specs/apply/apply-behavior.md +58 -0
- package/specs/apply/apply-command.md +51 -0
- package/specs/apply/conflicts.md +41 -0
- package/specs/apply/index-effects.md +81 -0
- package/specs/architecture.md +107 -0
- package/specs/auth/README.md +17 -0
- package/specs/auth/auth-http-contract.md +25 -0
- package/specs/auth/cli/credentials.md +39 -0
- package/specs/auth/cli/login.md +32 -0
- package/specs/auth/cli/logout.md +16 -0
- package/specs/claude-mcp.md +1065 -0
- package/specs/claude-plugins-marketplace.md +363 -0
- package/specs/claude-plugins.md +413 -0
- package/specs/cli-options.md +52 -0
- package/specs/codex-mcp.md +114 -0
- package/specs/commands-overview.md +175 -0
- package/specs/directory-layout.md +95 -0
- package/specs/install/README.md +12 -4
- package/specs/install/git-sources.md +230 -0
- package/specs/install/install-behavior.md +483 -73
- package/specs/install/package-yml-canonical.md +67 -35
- package/specs/install/version-resolution.md +69 -115
- package/specs/new/README.md +769 -0
- package/specs/new/SUMMARY.md +310 -0
- package/specs/new/scope-behavior.md +793 -0
- package/specs/pack/README.md +77 -0
- package/specs/pack/package-name-resolution.md +330 -0
- package/specs/package/README.md +18 -17
- package/specs/package/nested-packages-and-parent-packages.md +32 -31
- package/specs/package/package-index-yml.md +95 -101
- package/specs/package/package-root-layout.md +64 -46
- package/specs/package/registry-payload-and-copy.md +50 -44
- package/specs/package/universal-content.md +33 -56
- package/specs/package-sources.md +248 -0
- package/specs/platforms/README.md +52 -0
- package/specs/platforms/configuration.md +571 -0
- package/specs/platforms/detection.md +552 -0
- package/specs/platforms/directory-layout.md +599 -0
- package/specs/platforms/examples.md +1146 -0
- package/specs/platforms/flow-reference.md +1240 -0
- package/specs/platforms/flows.md +1488 -0
- package/specs/platforms/map-pipeline.md +801 -0
- package/specs/platforms/overview.md +349 -0
- package/specs/platforms/specification.md +700 -0
- package/specs/platforms/troubleshooting.md +697 -0
- package/specs/platforms/universal-converter.md +520 -0
- package/specs/push/README.md +1 -0
- package/specs/push/push-behavior.md +11 -3
- package/specs/push/push-remote-upload.md +1 -1
- package/specs/push/push-scoping.md +1 -1
- package/specs/push/push-version-selection.md +1 -1
- package/specs/registry.md +111 -0
- package/specs/remove/README.md +257 -0
- package/specs/save/README.md +21 -17
- package/specs/save/save-conflict-resolution.md +205 -83
- package/specs/save/save-file-discovery.md +6 -4
- package/specs/save/save-frontmatter-overrides.md +11 -15
- package/specs/save/save-modes-inputs.md +9 -39
- package/specs/save/save-naming-scoping.md +4 -4
- package/specs/save/save-package-detection.md +13 -13
- package/specs/save/save-registry-sync.md +16 -106
- package/specs/save/save-versioning.md +80 -0
- package/specs/scope-management.md +92 -0
- package/specs/set/README.md +520 -0
- package/specs/set/set-behavior.md +563 -0
- package/specs/show/README.md +483 -0
- package/specs/show/show-remote.md +494 -0
- package/specs/status/README.md +38 -0
- package/specs/uninstall/README.md +231 -0
- package/dist/commands/duplicate.js +0 -69
- package/dist/commands/duplicate.js.map +0 -1
- package/dist/commands/init.js +0 -117
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/prune.js +0 -357
- package/dist/commands/prune.js.map +0 -1
- package/dist/commands/tui.js +0 -61
- package/dist/commands/tui.js.map +0 -1
- package/dist/core/install/index.js +0 -3
- package/dist/core/install/index.js.map +0 -1
- package/dist/core/push/push-single-file.js +0 -56
- package/dist/core/push/push-single-file.js.map +0 -1
- package/dist/core/save/package-detection.js +0 -147
- package/dist/core/save/package-detection.js.map +0 -1
- package/dist/core/save/save-single-file.js +0 -124
- package/dist/core/save/save-single-file.js.map +0 -1
- package/dist/core/token-store.js +0 -73
- package/dist/core/token-store.js.map +0 -1
- package/dist/tui/app.js +0 -95
- package/dist/tui/app.js.map +0 -1
- package/dist/tui/components/package-list.js +0 -73
- package/dist/tui/components/package-list.js.map +0 -1
- package/dist/tui/controller.js +0 -365
- package/dist/tui/controller.js.map +0 -1
- package/dist/tui/index.js +0 -12
- package/dist/tui/index.js.map +0 -1
- package/dist/tui/services/file-index.js +0 -64
- package/dist/tui/services/file-index.js.map +0 -1
- package/dist/tui/services/packages.js +0 -18
- package/dist/tui/services/packages.js.map +0 -1
- package/dist/tui/services/save.js +0 -21
- package/dist/tui/services/save.js.map +0 -1
- package/dist/tui/state/app-state.js +0 -15
- package/dist/tui/state/app-state.js.map +0 -1
- package/dist/tui/state.js +0 -17
- package/dist/tui/state.js.map +0 -1
- package/dist/tui/types.js.map +0 -1
- package/dist/tui/views/add-file-modal.js +0 -129
- package/dist/tui/views/add-file-modal.js.map +0 -1
- package/dist/tui/views/file-preview.js +0 -44
- package/dist/tui/views/file-preview.js.map +0 -1
- package/dist/tui/views/list-packages.js +0 -73
- package/dist/tui/views/list-packages.js.map +0 -1
- package/dist/tui/views/main-menu.js +0 -29
- package/dist/tui/views/main-menu.js.map +0 -1
- package/dist/tui/views/manage-view.js +0 -81
- package/dist/tui/views/manage-view.js.map +0 -1
- package/dist/tui/views/package-hub.js +0 -120
- package/dist/tui/views/package-hub.js.map +0 -1
- package/dist/tui/views/placeholder.js +0 -24
- package/dist/tui/views/placeholder.js.map +0 -1
- package/dist/utils/bun-bootstrap.js +0 -72
- package/dist/utils/bun-bootstrap.js.map +0 -1
- package/dist/utils/entity-id.js +0 -19
- package/dist/utils/entity-id.js.map +0 -1
- package/dist/utils/package-local-files.js +0 -5
- package/dist/utils/package-local-files.js.map +0 -1
- package/dist/utils/path-matching.js +0 -74
- package/dist/utils/path-matching.js.map +0 -1
- package/dist/utils/root-file-operations.js +0 -39
- package/dist/utils/root-file-operations.js.map +0 -1
- package/dist/utils/root-file-transformer.js +0 -27
- package/dist/utils/root-file-transformer.js.map +0 -1
- package/dist/utils/yaml-frontmatter.js +0 -25
- package/dist/utils/yaml-frontmatter.js.map +0 -1
- package/specs/auth/auth-device-flow.md +0 -70
- package/specs/login/login-device-flow.md +0 -70
- package/specs/platforms.md +0 -193
- package/specs/save-pack-versioning.md +0 -224
- package/specs/save-pack.md +0 -68
- /package/dist/{tui → core/source-resolution}/types.js +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Context Resolution
|
|
3
|
+
*
|
|
4
|
+
* Resolves context variables ($$filename, $$dirname, etc.) in map operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Resolve context variables in a value
|
|
8
|
+
*
|
|
9
|
+
* Context variables use $$ prefix:
|
|
10
|
+
* - $$filename → context.filename
|
|
11
|
+
* - $$dirname → context.dirname
|
|
12
|
+
* - $$path → context.path
|
|
13
|
+
* - $$ext → context.ext
|
|
14
|
+
*
|
|
15
|
+
* Literal values (no $$ prefix) are returned unchanged.
|
|
16
|
+
* Escaped literal (\$$) has backslash removed to get literal "$$".
|
|
17
|
+
*
|
|
18
|
+
* Examples:
|
|
19
|
+
* - resolveValue("$$filename", ctx) → "my-agent"
|
|
20
|
+
* - resolveValue("static-value", ctx) → "static-value"
|
|
21
|
+
* - resolveValue("\\$$literal", ctx) → "$$literal"
|
|
22
|
+
* - resolveValue({ name: "$$filename" }, ctx) → { name: "my-agent" }
|
|
23
|
+
*/
|
|
24
|
+
export function resolveValue(value, context) {
|
|
25
|
+
// Handle strings with context variables
|
|
26
|
+
if (typeof value === 'string') {
|
|
27
|
+
// Check for escaped literal (\$$)
|
|
28
|
+
if (value.startsWith('\\$$')) {
|
|
29
|
+
return value.substring(1); // Remove escape backslash
|
|
30
|
+
}
|
|
31
|
+
// Check for context variable ($$)
|
|
32
|
+
if (value.startsWith('$$')) {
|
|
33
|
+
const varName = value.substring(2);
|
|
34
|
+
// Return context value if it exists
|
|
35
|
+
if (varName in context) {
|
|
36
|
+
return context[varName];
|
|
37
|
+
}
|
|
38
|
+
// Return original value if context variable doesn't exist
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
// Literal string - return as-is
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
// Handle objects - recursively resolve nested values
|
|
45
|
+
if (typeof value === 'object' && value !== null) {
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
return value.map(item => resolveValue(item, context));
|
|
48
|
+
}
|
|
49
|
+
const result = {};
|
|
50
|
+
for (const [key, val] of Object.entries(value)) {
|
|
51
|
+
result[key] = resolveValue(val, context);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
// Return primitive values unchanged
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if a value contains context variables
|
|
60
|
+
*/
|
|
61
|
+
export function hasContextVariables(value) {
|
|
62
|
+
if (typeof value === 'string') {
|
|
63
|
+
return value.startsWith('$$') && !value.startsWith('\\$$');
|
|
64
|
+
}
|
|
65
|
+
if (typeof value === 'object' && value !== null) {
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return value.some(item => hasContextVariables(item));
|
|
68
|
+
}
|
|
69
|
+
return Object.values(value).some(val => hasContextVariables(val));
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/core/flows/map-pipeline/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,OAAmB;IAC1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,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map Pipeline
|
|
3
|
+
*
|
|
4
|
+
* MongoDB-inspired document transformation pipeline.
|
|
5
|
+
* Executes operations sequentially on documents.
|
|
6
|
+
*/
|
|
7
|
+
import { deepClone } from './utils.js';
|
|
8
|
+
import { executeSet, validateSet } from './operations/set.js';
|
|
9
|
+
import { executeRename, validateRename } from './operations/rename.js';
|
|
10
|
+
import { executeUnset, validateUnset } from './operations/unset.js';
|
|
11
|
+
import { executeSwitch, validateSwitch } from './operations/switch.js';
|
|
12
|
+
import { executePipeline, validatePipeline } from './operations/transform.js';
|
|
13
|
+
import { executeCopy, validateCopy } from './operations/copy.js';
|
|
14
|
+
import { executePipe, validatePipe } from './operations/pipe.js';
|
|
15
|
+
/**
|
|
16
|
+
* Apply map pipeline to a document
|
|
17
|
+
*
|
|
18
|
+
* Executes operations sequentially, passing the result of each operation
|
|
19
|
+
* to the next operation in the pipeline.
|
|
20
|
+
*
|
|
21
|
+
* @param document - Input document to transform
|
|
22
|
+
* @param pipeline - Array of operations to apply
|
|
23
|
+
* @param context - Context for variable resolution
|
|
24
|
+
* @param transformRegistry - Optional transform registry for $pipe operations
|
|
25
|
+
* @returns Transformed document
|
|
26
|
+
*/
|
|
27
|
+
export function applyMapPipeline(document, pipeline, context, transformRegistry) {
|
|
28
|
+
// Start with a deep clone to avoid mutating input
|
|
29
|
+
let result = deepClone(document);
|
|
30
|
+
// Execute each operation in sequence
|
|
31
|
+
for (const operation of pipeline) {
|
|
32
|
+
result = executeOperation(result, operation, context, transformRegistry);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Execute a single operation
|
|
38
|
+
*/
|
|
39
|
+
function executeOperation(document, operation, context, transformRegistry) {
|
|
40
|
+
if ('$set' in operation) {
|
|
41
|
+
return executeSet(document, operation, context);
|
|
42
|
+
}
|
|
43
|
+
if ('$rename' in operation) {
|
|
44
|
+
return executeRename(document, operation);
|
|
45
|
+
}
|
|
46
|
+
if ('$unset' in operation) {
|
|
47
|
+
return executeUnset(document, operation);
|
|
48
|
+
}
|
|
49
|
+
if ('$switch' in operation) {
|
|
50
|
+
return executeSwitch(document, operation);
|
|
51
|
+
}
|
|
52
|
+
if ('$pipeline' in operation) {
|
|
53
|
+
return executePipeline(document, operation, context);
|
|
54
|
+
}
|
|
55
|
+
if ('$copy' in operation) {
|
|
56
|
+
return executeCopy(document, operation);
|
|
57
|
+
}
|
|
58
|
+
if ('$pipe' in operation) {
|
|
59
|
+
if (!transformRegistry) {
|
|
60
|
+
throw new Error('$pipe operation requires transform registry to be provided');
|
|
61
|
+
}
|
|
62
|
+
return executePipe(document, operation, transformRegistry);
|
|
63
|
+
}
|
|
64
|
+
// Unknown operation - return document unchanged
|
|
65
|
+
return document;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Validate a map pipeline
|
|
69
|
+
*
|
|
70
|
+
* Checks all operations for validity before execution.
|
|
71
|
+
*/
|
|
72
|
+
export function validateMapPipeline(pipeline) {
|
|
73
|
+
const errors = [];
|
|
74
|
+
if (!Array.isArray(pipeline)) {
|
|
75
|
+
return {
|
|
76
|
+
valid: false,
|
|
77
|
+
errors: ['Map pipeline must be an array'],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (pipeline.length === 0) {
|
|
81
|
+
return {
|
|
82
|
+
valid: false,
|
|
83
|
+
errors: ['Map pipeline must have at least one operation'],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
for (let i = 0; i < pipeline.length; i++) {
|
|
87
|
+
const operation = pipeline[i];
|
|
88
|
+
if (!operation || typeof operation !== 'object') {
|
|
89
|
+
errors.push(`Operation at index ${i} must be an object`);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Check that operation has exactly one operation key
|
|
93
|
+
const operationKeys = Object.keys(operation);
|
|
94
|
+
const validOperations = ['$set', '$rename', '$unset', '$switch', '$pipeline', '$copy', '$pipe'];
|
|
95
|
+
const operationKey = operationKeys.find(key => validOperations.includes(key));
|
|
96
|
+
if (!operationKey) {
|
|
97
|
+
errors.push(`Operation at index ${i} must have one of: ${validOperations.join(', ')}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (operationKeys.length > 1) {
|
|
101
|
+
errors.push(`Operation at index ${i} must have exactly one operation (found: ${operationKeys.join(', ')})`);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
// Validate specific operation
|
|
105
|
+
const validation = validateOperation(operation);
|
|
106
|
+
if (!validation.valid) {
|
|
107
|
+
errors.push(`Operation at index ${i} (${operationKey}): ${validation.errors.join(', ')}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
valid: errors.length === 0,
|
|
112
|
+
errors,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Validate a single operation
|
|
117
|
+
*/
|
|
118
|
+
function validateOperation(operation) {
|
|
119
|
+
if ('$set' in operation) {
|
|
120
|
+
return validateSet(operation);
|
|
121
|
+
}
|
|
122
|
+
if ('$rename' in operation) {
|
|
123
|
+
return validateRename(operation);
|
|
124
|
+
}
|
|
125
|
+
if ('$unset' in operation) {
|
|
126
|
+
return validateUnset(operation);
|
|
127
|
+
}
|
|
128
|
+
if ('$switch' in operation) {
|
|
129
|
+
return validateSwitch(operation);
|
|
130
|
+
}
|
|
131
|
+
if ('$pipeline' in operation) {
|
|
132
|
+
return validatePipeline(operation);
|
|
133
|
+
}
|
|
134
|
+
if ('$copy' in operation) {
|
|
135
|
+
return validateCopy(operation);
|
|
136
|
+
}
|
|
137
|
+
if ('$pipe' in operation) {
|
|
138
|
+
return validatePipe(operation);
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
valid: false,
|
|
142
|
+
errors: ['Unknown operation type'],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create a map context from file information
|
|
147
|
+
*/
|
|
148
|
+
export function createMapContext(options) {
|
|
149
|
+
return {
|
|
150
|
+
filename: options.filename,
|
|
151
|
+
dirname: options.dirname,
|
|
152
|
+
path: options.path,
|
|
153
|
+
ext: options.ext,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/flows/map-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,eAA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,SAAS,IAAI,SAAS,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;QACzB,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAED,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,CAAC,wBAAwB,CAAC;KACnC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAKhC;IACC,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* $copy Operation
|
|
3
|
+
*
|
|
4
|
+
* Copy field with optional pattern-based transformation.
|
|
5
|
+
*/
|
|
6
|
+
import { getNestedValue, setNestedValue, matchPattern } from '../utils.js';
|
|
7
|
+
/**
|
|
8
|
+
* Execute $copy operation
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* {
|
|
12
|
+
* "$copy": {
|
|
13
|
+
* "from": "permission",
|
|
14
|
+
* "to": "permissionMode",
|
|
15
|
+
* "transform": {
|
|
16
|
+
* "cases": [
|
|
17
|
+
* { "pattern": { "edit": "deny", "bash": "deny" }, "value": "plan" }
|
|
18
|
+
* ],
|
|
19
|
+
* "default": "default"
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
export function executeCopy(document, operation) {
|
|
25
|
+
const result = { ...document };
|
|
26
|
+
const { from, to, transform } = operation.$copy;
|
|
27
|
+
// Get source value
|
|
28
|
+
const sourceValue = getNestedValue(result, from);
|
|
29
|
+
// If source doesn't exist, don't set target
|
|
30
|
+
if (sourceValue === undefined) {
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
let targetValue = sourceValue;
|
|
34
|
+
// Apply transformation if provided
|
|
35
|
+
if (transform) {
|
|
36
|
+
targetValue = applyTransform(sourceValue, transform);
|
|
37
|
+
}
|
|
38
|
+
// Set target value
|
|
39
|
+
setNestedValue(result, to, targetValue);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Apply pattern-based transformation
|
|
44
|
+
*/
|
|
45
|
+
function applyTransform(value, transform) {
|
|
46
|
+
// Try each case in order (first match wins)
|
|
47
|
+
for (const { pattern, value: caseValue } of transform.cases) {
|
|
48
|
+
if (matchPattern(value, pattern)) {
|
|
49
|
+
return caseValue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// No match - use default if provided, otherwise return original
|
|
53
|
+
return transform.default !== undefined ? transform.default : value;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Validate $copy operation
|
|
57
|
+
*/
|
|
58
|
+
export function validateCopy(operation) {
|
|
59
|
+
const errors = [];
|
|
60
|
+
if (!operation.$copy || typeof operation.$copy !== 'object') {
|
|
61
|
+
errors.push('$copy must be an object');
|
|
62
|
+
return { valid: false, errors };
|
|
63
|
+
}
|
|
64
|
+
const config = operation.$copy;
|
|
65
|
+
if (!config.from || typeof config.from !== 'string') {
|
|
66
|
+
errors.push('$copy.from must be a non-empty string');
|
|
67
|
+
}
|
|
68
|
+
if (!config.to || typeof config.to !== 'string') {
|
|
69
|
+
errors.push('$copy.to must be a non-empty string');
|
|
70
|
+
}
|
|
71
|
+
// Validate transform if provided
|
|
72
|
+
if (config.transform) {
|
|
73
|
+
if (typeof config.transform !== 'object') {
|
|
74
|
+
errors.push('$copy.transform must be an object');
|
|
75
|
+
return { valid: errors.length === 0, errors };
|
|
76
|
+
}
|
|
77
|
+
if (!config.transform.cases || !Array.isArray(config.transform.cases)) {
|
|
78
|
+
errors.push('$copy.transform.cases must be an array');
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (config.transform.cases.length === 0) {
|
|
82
|
+
errors.push('$copy.transform.cases must have at least one case');
|
|
83
|
+
}
|
|
84
|
+
for (let i = 0; i < config.transform.cases.length; i++) {
|
|
85
|
+
const caseItem = config.transform.cases[i];
|
|
86
|
+
if (!caseItem || typeof caseItem !== 'object') {
|
|
87
|
+
errors.push(`$copy.transform.cases[${i}] must be an object`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!('pattern' in caseItem)) {
|
|
91
|
+
errors.push(`$copy.transform.cases[${i}] must have a "pattern" field`);
|
|
92
|
+
}
|
|
93
|
+
if (!('value' in caseItem)) {
|
|
94
|
+
errors.push(`$copy.transform.cases[${i}] must have a "value" field`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
valid: errors.length === 0,
|
|
101
|
+
errors,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=copy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copy.js","sourceRoot":"","sources":["../../../../../src/core/flows/map-pipeline/operations/copy.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CACzB,QAAa,EACb,SAAwB;IAExB,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,EAAE,IAAI,EAAE,EAA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AI,CAAC,yBAAyB,CAAC,qBAAqB,CAAC,CAAC;oBAC7D,SAAS;gBACX,CAAC;gBAED,IAAI,CAAC,CAAC,SAAS,IAAI,QAAQ,CAAC,EAAE,CAAC;oBAC7B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,+BAA+B,CAAC,CAAC;gBACzE,CAAC;gBAED,IAAI,CAAC,CAAC,OAAO,IAAI,QAAQ,CAAC,EAAE,CAAC;oBAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,6BAA6B,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* $pipe Operation
|
|
3
|
+
*
|
|
4
|
+
* Applies external pipe transforms within the map pipeline.
|
|
5
|
+
* Enables interleaving format conversions with schema transformations.
|
|
6
|
+
*
|
|
7
|
+
* This operation bridges the map pipeline (document transformations)
|
|
8
|
+
* with the transform registry (format conversions, validations).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Execute $pipe operation
|
|
12
|
+
*
|
|
13
|
+
* Applies a sequence of transforms from the transform registry.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
16
|
+
* {
|
|
17
|
+
* "$pipe": ["filter-comments", "json-to-toml"]
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* @param document - Input document
|
|
21
|
+
* @param operation - Pipe operation configuration
|
|
22
|
+
* @param transformRegistry - Transform registry to execute transforms from
|
|
23
|
+
* @returns Transformed document
|
|
24
|
+
*/
|
|
25
|
+
export function executePipe(document, operation, transformRegistry) {
|
|
26
|
+
let result = document;
|
|
27
|
+
// Apply each transform sequentially
|
|
28
|
+
for (const transformName of operation.$pipe) {
|
|
29
|
+
try {
|
|
30
|
+
result = transformRegistry.execute(transformName, result);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error(`$pipe transform '${transformName}' failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Validate $pipe operation
|
|
40
|
+
*
|
|
41
|
+
* Ensures the pipe configuration is valid.
|
|
42
|
+
*/
|
|
43
|
+
export function validatePipe(operation) {
|
|
44
|
+
const errors = [];
|
|
45
|
+
if (!operation.$pipe) {
|
|
46
|
+
errors.push('$pipe must be defined');
|
|
47
|
+
return { valid: false, errors };
|
|
48
|
+
}
|
|
49
|
+
if (!Array.isArray(operation.$pipe)) {
|
|
50
|
+
errors.push('$pipe must be an array of transform names');
|
|
51
|
+
return { valid: false, errors };
|
|
52
|
+
}
|
|
53
|
+
if (operation.$pipe.length === 0) {
|
|
54
|
+
errors.push('$pipe must have at least one transform');
|
|
55
|
+
}
|
|
56
|
+
for (let i = 0; i < operation.$pipe.length; i++) {
|
|
57
|
+
const transformName = operation.$pipe[i];
|
|
58
|
+
if (typeof transformName !== 'string') {
|
|
59
|
+
errors.push(`$pipe[${i}] must be a string (transform name)`);
|
|
60
|
+
}
|
|
61
|
+
else if (!transformName || transformName.trim() === '') {
|
|
62
|
+
errors.push(`$pipe[${i}] transform name cannot be empty`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
valid: errors.length === 0,
|
|
67
|
+
errors,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=pipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../../../../src/core/flows/map-pipeline/operations/pipe.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CACzB,QAAa,EACb,SAAwB,EACx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C,CAAC,CAAC;QAEzC,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,qCAAqC,CAAC,CAAC;QAC/D,CAAC;aAAM,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* $rename Operation
|
|
3
|
+
*
|
|
4
|
+
* Renames fields with support for:
|
|
5
|
+
* - Simple renames
|
|
6
|
+
* - Nested paths with dot notation
|
|
7
|
+
* - Wildcard patterns (mcp.* → mcpServers.*)
|
|
8
|
+
*/
|
|
9
|
+
import { getNestedValue, setNestedValue, deleteNestedValue, parseWildcard, getMatchingKeys, extractWildcardPart, } from '../utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* Execute $rename operation
|
|
12
|
+
*
|
|
13
|
+
* Examples:
|
|
14
|
+
* - { "$rename": { "oldName": "newName" } }
|
|
15
|
+
* - { "$rename": { "mcp.*": "mcpServers.*" } }
|
|
16
|
+
* - { "$rename": { "config.old": "settings.new" } }
|
|
17
|
+
*/
|
|
18
|
+
export function executeRename(document, operation) {
|
|
19
|
+
const result = { ...document };
|
|
20
|
+
const mappings = operation.$rename;
|
|
21
|
+
for (const [oldPath, newPath] of Object.entries(mappings)) {
|
|
22
|
+
if (oldPath.includes('*')) {
|
|
23
|
+
// Handle wildcard rename
|
|
24
|
+
renameWithWildcard(result, oldPath, newPath);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
// Simple rename
|
|
28
|
+
renameSimple(result, oldPath, newPath);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Simple rename without wildcards
|
|
35
|
+
*/
|
|
36
|
+
function renameSimple(obj, oldPath, newPath) {
|
|
37
|
+
const value = getNestedValue(obj, oldPath);
|
|
38
|
+
if (value !== undefined) {
|
|
39
|
+
setNestedValue(obj, newPath, value);
|
|
40
|
+
deleteNestedValue(obj, oldPath);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Rename with wildcard patterns
|
|
45
|
+
* Both oldPath and newPath must have exactly one wildcard
|
|
46
|
+
*/
|
|
47
|
+
function renameWithWildcard(obj, oldPattern, newPattern) {
|
|
48
|
+
// Parse wildcards
|
|
49
|
+
const { prefix: oldPrefix, suffix: oldSuffix } = parseWildcard(oldPattern);
|
|
50
|
+
const { prefix: newPrefix, suffix: newSuffix } = parseWildcard(newPattern);
|
|
51
|
+
// Find all matching keys
|
|
52
|
+
const matchingKeys = getMatchingKeys(obj, oldPrefix, oldSuffix);
|
|
53
|
+
// Rename each matching key
|
|
54
|
+
for (const oldKey of matchingKeys) {
|
|
55
|
+
// Extract the wildcard part
|
|
56
|
+
const wildcardPart = extractWildcardPart(oldKey, oldPrefix, oldSuffix);
|
|
57
|
+
// Construct new key
|
|
58
|
+
const newKey = newPrefix + wildcardPart + newSuffix;
|
|
59
|
+
// Get value and rename
|
|
60
|
+
const value = getNestedValue(obj, oldKey);
|
|
61
|
+
if (value !== undefined) {
|
|
62
|
+
setNestedValue(obj, newKey, value);
|
|
63
|
+
deleteNestedValue(obj, oldKey);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Validate $rename operation
|
|
69
|
+
*/
|
|
70
|
+
export function validateRename(operation) {
|
|
71
|
+
const errors = [];
|
|
72
|
+
if (!operation.$rename || typeof operation.$rename !== 'object') {
|
|
73
|
+
errors.push('$rename must be an object');
|
|
74
|
+
return { valid: false, errors };
|
|
75
|
+
}
|
|
76
|
+
if (Object.keys(operation.$rename).length === 0) {
|
|
77
|
+
errors.push('$rename must have at least one field mapping');
|
|
78
|
+
}
|
|
79
|
+
for (const [oldPath, newPath] of Object.entries(operation.$rename)) {
|
|
80
|
+
if (!oldPath || oldPath.trim() === '') {
|
|
81
|
+
errors.push('$rename source path cannot be empty');
|
|
82
|
+
}
|
|
83
|
+
if (!newPath || newPath.trim() === '') {
|
|
84
|
+
errors.push('$rename target path cannot be empty');
|
|
85
|
+
}
|
|
86
|
+
// Validate wildcard usage
|
|
87
|
+
const oldWildcards = (oldPath.match(/\*/g) || []).length;
|
|
88
|
+
const newWildcards = (newPath.match(/\*/g) || []).length;
|
|
89
|
+
if (oldWildcards !== newWildcards) {
|
|
90
|
+
errors.push(`$rename wildcard mismatch: "${oldPath}" has ${oldWildcards} wildcard(s), ` +
|
|
91
|
+
`but "${newPath}" has ${newWildcards} wildcard(s). Both must have the same count.`);
|
|
92
|
+
}
|
|
93
|
+
if (oldWildcards > 1) {
|
|
94
|
+
errors.push(`$rename does not support multiple wildcards in one pattern: "${oldPath}"`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
valid: errors.length === 0,
|
|
99
|
+
errors,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=rename.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename.js","sourceRoot":"","sources":["../../../../../src/core/flows/map-pipeline/operations/rename.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EACL,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,QAAa,EACb,SAA0B;IAE1B,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,QAAQ,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CAAC,CAAC;QACrD,CAAC;QAED,0BAA0B;QAC1B,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QACzD,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QAEzD,IAAI,YAAY,KAAK,YAAY,EAAE,CAAC;YAClC,MAAM,CAAC,IAAI,CACT,+BAA+B,OAAO,SAAS,YAAY,gBAAgB;gBAC3E,QAAQ,OAAO,SAAS,YAAY,8CAA8C,CACnF,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,IAAI,CAAC,gEAAgE,OAAO,GAAG,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;QAC1B,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* $set Operation
|
|
3
|
+
*
|
|
4
|
+
* Sets field values with context variable resolution.
|
|
5
|
+
* Supports dot notation for nested fields.
|
|
6
|
+
*/
|
|
7
|
+
import { setNestedValue } from '../utils.js';
|
|
8
|
+
import { resolveValue } from '../context.js';
|
|
9
|
+
/**
|
|
10
|
+
* Execute $set operation
|
|
11
|
+
*
|
|
12
|
+
* Examples:
|
|
13
|
+
* - { "$set": { "name": "$$filename" } }
|
|
14
|
+
* - { "$set": { "name": "$$filename", "version": "1.0.0" } }
|
|
15
|
+
* - { "$set": { "config.model": "sonnet" } }
|
|
16
|
+
*/
|
|
17
|
+
export function executeSet(document, operation, context) {
|
|
18
|
+
const result = { ...document };
|
|
19
|
+
const fields = operation.$set;
|
|
20
|
+
for (const [fieldPath, value] of Object.entries(fields)) {
|
|
21
|
+
// Resolve context variables in the value
|
|
22
|
+
const resolvedValue = resolveValue(value, context);
|
|
23
|
+
// Set the value using dot notation
|
|
24
|
+
setNestedValue(result, fieldPath, resolvedValue);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validate $set operation
|
|
30
|
+
*/
|
|
31
|
+
export function validateSet(operation) {
|
|
32
|
+
const errors = [];
|
|
33
|
+
if (!operation.$set || typeof operation.$set !== 'object') {
|
|
34
|
+
errors.push('$set must be an object');
|
|
35
|
+
return { valid: false, errors };
|
|
36
|
+
}
|
|
37
|
+
if (Object.keys(operation.$set).length === 0) {
|
|
38
|
+
errors.push('$set must have at least one field');
|
|
39
|
+
}
|
|
40
|
+
for (const [key, value] of Object.entries(operation.$set)) {
|
|
41
|
+
if (!key || key.trim() === '') {
|
|
42
|
+
errors.push('$set field path cannot be empty');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
valid: errors.length === 0,
|
|
47
|
+
errors,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../../../src/core/flows/map-pipeline/operations/set.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,QAAa,EACb,SAAuB,EACvB,OAAmB;IAEnB,MAAM,MAAM,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC;IAE9B,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,yCAAyC;QACzC,MAAM,aAAa,GAAG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