@dev-sergeev/datalab-kit 0.1.2 → 0.1.3
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/CHANGELOG.md +6 -0
- package/README.md +23 -5
- package/THIRD_PARTY_NOTICES.md +6 -2
- package/dist/extension.js +8 -1
- package/dist/recap.d.ts +2 -0
- package/dist/recap.js +31 -0
- package/docs/adr/0002-package-delivery.md +2 -0
- package/node_modules/@pi-plugins/elapsed/LICENSE +21 -0
- package/node_modules/@pi-plugins/elapsed/README.md +45 -0
- package/node_modules/@pi-plugins/elapsed/dist/index.d.mts +8 -0
- package/node_modules/@pi-plugins/elapsed/dist/index.d.mts.map +1 -0
- package/node_modules/@pi-plugins/elapsed/dist/index.mjs +47 -0
- package/node_modules/@pi-plugins/elapsed/dist/index.mjs.map +1 -0
- package/node_modules/@pi-plugins/elapsed/package.json +65 -0
- package/node_modules/@tifan/pi-recap/README.md +61 -0
- package/node_modules/@tifan/pi-recap/package.json +43 -0
- package/node_modules/@tifan/pi-recap/src/index.ts +584 -0
- package/node_modules/@tifan/pi-recap/src/model-picker.ts +233 -0
- package/node_modules/@tifan/pi-recap/src/models.ts +183 -0
- package/node_modules/@tifan/pi-recap/src/sanitize.ts +119 -0
- package/node_modules/@tifan/pi-recap/src/tui.ts +155 -0
- package/node_modules/@zigai/pi-extension-internals/README.md +24 -0
- package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.d.ts +21 -0
- package/node_modules/@zigai/pi-extension-internals/dist/editor-enhancer-registry.js +233 -0
- package/node_modules/@zigai/pi-extension-internals/dist/index.d.ts +6 -0
- package/node_modules/@zigai/pi-extension-internals/dist/index.js +3 -0
- package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.d.ts +34 -0
- package/node_modules/@zigai/pi-extension-internals/dist/linked-method-patch.js +272 -0
- package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.d.ts +11 -0
- package/node_modules/@zigai/pi-extension-internals/dist/pi-internal-import.js +139 -0
- package/node_modules/@zigai/pi-extension-internals/package.json +41 -0
- package/node_modules/@zigai/pi-extension-settings/LICENSE +21 -0
- package/node_modules/@zigai/pi-extension-settings/README.md +36 -0
- package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts +23 -0
- package/node_modules/@zigai/pi-extension-settings/dist/artifacts.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js +75 -0
- package/node_modules/@zigai/pi-extension-settings/dist/artifacts.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts +3 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js +5 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli-entry.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts +6 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli.js +87 -0
- package/node_modules/@zigai/pi-extension-settings/dist/cli.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts +2 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js +2 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition-marker.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts +159 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition.js +248 -0
- package/node_modules/@zigai/pi-extension-settings/dist/definition.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts +10 -0
- package/node_modules/@zigai/pi-extension-settings/dist/file-system.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/file-system.js +115 -0
- package/node_modules/@zigai/pi-extension-settings/dist/file-system.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts +2 -0
- package/node_modules/@zigai/pi-extension-settings/dist/index.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/index.js +2 -0
- package/node_modules/@zigai/pi-extension-settings/dist/index.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts +18 -0
- package/node_modules/@zigai/pi-extension-settings/dist/json-value.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/json-value.js +56 -0
- package/node_modules/@zigai/pi-extension-settings/dist/json-value.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts +11 -0
- package/node_modules/@zigai/pi-extension-settings/dist/paths.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/paths.js +23 -0
- package/node_modules/@zigai/pi-extension-settings/dist/paths.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts +5 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js +21 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi-host-paths.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts +106 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi.js +122 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi.ts +2537 -0
- package/node_modules/@zigai/pi-extension-settings/dist/pi.ts.map +7 -0
- package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts +10 -0
- package/node_modules/@zigai/pi-extension-settings/dist/projects.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/projects.js +177 -0
- package/node_modules/@zigai/pi-extension-settings/dist/projects.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts +40 -0
- package/node_modules/@zigai/pi-extension-settings/dist/runtime.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/runtime.js +158 -0
- package/node_modules/@zigai/pi-extension-settings/dist/runtime.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts +158 -0
- package/node_modules/@zigai/pi-extension-settings/dist/runtime.ts.map +7 -0
- package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts +19 -0
- package/node_modules/@zigai/pi-extension-settings/dist/schema-document.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js +168 -0
- package/node_modules/@zigai/pi-extension-settings/dist/schema-document.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts +9 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js +242 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-documentation.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts +59 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js +98 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-layer.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts +80 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js +144 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-loader.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts +5 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js +30 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-merge.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts +10 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js +16 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-revision.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts +54 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js +202 -0
- package/node_modules/@zigai/pi-extension-settings/dist/settings-transaction.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts +5 -0
- package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.d.ts.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js +9 -0
- package/node_modules/@zigai/pi-extension-settings/dist/typebox-runtime.js.map +1 -0
- package/node_modules/@zigai/pi-extension-settings/docs/generation.md +71 -0
- package/node_modules/@zigai/pi-extension-settings/docs/manual-setup.md +98 -0
- package/node_modules/@zigai/pi-extension-settings/docs/runtime.md +100 -0
- package/node_modules/@zigai/pi-extension-settings/docs/ui-controls.md +31 -0
- package/node_modules/@zigai/pi-extension-settings/package.json +97 -0
- package/node_modules/@zigai/pi-mention-anything/README.md +113 -0
- package/node_modules/@zigai/pi-mention-anything/config.schema.json +313 -0
- package/node_modules/@zigai/pi-mention-anything/docs/command-protocol.md +106 -0
- package/node_modules/@zigai/pi-mention-anything/docs/providers.md +128 -0
- package/node_modules/@zigai/pi-mention-anything/examples/query-command.mjs +96 -0
- package/node_modules/@zigai/pi-mention-anything/examples/recursive-tree.ts +28 -0
- package/node_modules/@zigai/pi-mention-anything/examples/static.ts +28 -0
- package/node_modules/@zigai/pi-mention-anything/examples/tmux.ts +90 -0
- package/node_modules/@zigai/pi-mention-anything/examples/tree-settings.json +25 -0
- package/node_modules/@zigai/pi-mention-anything/package.json +58 -0
- package/node_modules/@zigai/pi-mention-anything/src/api.ts +75 -0
- package/node_modules/@zigai/pi-mention-anything/src/autocomplete.ts +231 -0
- package/node_modules/@zigai/pi-mention-anything/src/chain-autocomplete.ts +596 -0
- package/node_modules/@zigai/pi-mention-anything/src/chain-syntax.ts +345 -0
- package/node_modules/@zigai/pi-mention-anything/src/command-provider.ts +291 -0
- package/node_modules/@zigai/pi-mention-anything/src/configured-source.ts +66 -0
- package/node_modules/@zigai/pi-mention-anything/src/editor.ts +180 -0
- package/node_modules/@zigai/pi-mention-anything/src/expand-mentions.ts +162 -0
- package/node_modules/@zigai/pi-mention-anything/src/index.ts +54 -0
- package/node_modules/@zigai/pi-mention-anything/src/initial-suggestions.ts +190 -0
- package/node_modules/@zigai/pi-mention-anything/src/list-provider.ts +71 -0
- package/node_modules/@zigai/pi-mention-anything/src/mention-hub.ts +307 -0
- package/node_modules/@zigai/pi-mention-anything/src/mention-resolution.ts +374 -0
- package/node_modules/@zigai/pi-mention-anything/src/mention-syntax.ts +105 -0
- package/node_modules/@zigai/pi-mention-anything/src/register-mention.ts +89 -0
- package/node_modules/@zigai/pi-mention-anything/src/rendering.ts +53 -0
- package/node_modules/@zigai/pi-mention-anything/src/selected-items.ts +21 -0
- package/node_modules/@zigai/pi-mention-anything/src/selection-history.ts +135 -0
- package/node_modules/@zigai/pi-mention-anything/src/settings-input.ts +317 -0
- package/node_modules/@zigai/pi-mention-anything/src/settings.prevalidated.ts +57 -0
- package/node_modules/@zigai/pi-mention-anything/src/settings.ts +52 -0
- package/node_modules/@zigai/pi-mention-anything/src/source-contract.ts +174 -0
- package/node_modules/@zigai/pi-mention-anything/src/source-controller.ts +1070 -0
- package/node_modules/@zigai/pi-mention-anything/src/source-runtime.ts +99 -0
- package/node_modules/@zigai/pi-mention-skill/README.md +60 -0
- package/node_modules/@zigai/pi-mention-skill/config.schema.json +81 -0
- package/node_modules/@zigai/pi-mention-skill/package.json +56 -0
- package/node_modules/@zigai/pi-mention-skill/src/index.ts +60 -0
- package/node_modules/@zigai/pi-mention-skill/src/settings-input.ts +74 -0
- package/node_modules/@zigai/pi-mention-skill/src/settings.prevalidated.ts +18 -0
- package/node_modules/@zigai/pi-mention-skill/src/settings.ts +54 -0
- package/node_modules/@zigai/pi-mention-skill/src/skill-commands.ts +18 -0
- package/node_modules/@zigai/pi-mention-skill/src/skill-content.ts +60 -0
- package/node_modules/@zigai/pi-mention-skill/src/skill-provider.ts +105 -0
- package/node_modules/@zigai/pi-mention-skill/src/slash-skill-filter.ts +29 -0
- package/node_modules/argparse/LICENSE +21 -0
- package/node_modules/argparse/README.md +257 -0
- package/node_modules/argparse/index.js +3 -0
- package/node_modules/argparse/lib/action/append/constant.js +47 -0
- package/node_modules/argparse/lib/action/append.js +53 -0
- package/node_modules/argparse/lib/action/count.js +40 -0
- package/node_modules/argparse/lib/action/help.js +47 -0
- package/node_modules/argparse/lib/action/store/constant.js +43 -0
- package/node_modules/argparse/lib/action/store/false.js +27 -0
- package/node_modules/argparse/lib/action/store/true.js +26 -0
- package/node_modules/argparse/lib/action/store.js +50 -0
- package/node_modules/argparse/lib/action/subparsers.js +149 -0
- package/node_modules/argparse/lib/action/version.js +47 -0
- package/node_modules/argparse/lib/action.js +146 -0
- package/node_modules/argparse/lib/action_container.js +482 -0
- package/node_modules/argparse/lib/argparse.js +14 -0
- package/node_modules/argparse/lib/argument/error.js +50 -0
- package/node_modules/argparse/lib/argument/exclusive.js +54 -0
- package/node_modules/argparse/lib/argument/group.js +75 -0
- package/node_modules/argparse/lib/argument_parser.js +1161 -0
- package/node_modules/argparse/lib/const.js +21 -0
- package/node_modules/argparse/lib/help/added_formatters.js +87 -0
- package/node_modules/argparse/lib/help/formatter.js +795 -0
- package/node_modules/argparse/lib/namespace.js +76 -0
- package/node_modules/argparse/lib/utils.js +57 -0
- package/node_modules/argparse/package.json +34 -0
- package/node_modules/esprima/LICENSE.BSD +21 -0
- package/node_modules/esprima/README.md +46 -0
- package/node_modules/esprima/bin/esparse.js +139 -0
- package/node_modules/esprima/bin/esvalidate.js +236 -0
- package/node_modules/esprima/dist/esprima.js +6709 -0
- package/node_modules/esprima/package.json +112 -0
- package/node_modules/extend-shallow/LICENSE +21 -0
- package/node_modules/extend-shallow/README.md +61 -0
- package/node_modules/extend-shallow/index.js +33 -0
- package/node_modules/extend-shallow/package.json +56 -0
- package/node_modules/graceful-fs/LICENSE +15 -0
- package/node_modules/graceful-fs/README.md +143 -0
- package/node_modules/graceful-fs/clone.js +23 -0
- package/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/node_modules/graceful-fs/package.json +53 -0
- package/node_modules/graceful-fs/polyfills.js +355 -0
- package/node_modules/gray-matter/LICENSE +21 -0
- package/node_modules/gray-matter/README.md +565 -0
- package/node_modules/gray-matter/gray-matter.d.ts +114 -0
- package/node_modules/gray-matter/index.js +228 -0
- package/node_modules/gray-matter/lib/defaults.js +18 -0
- package/node_modules/gray-matter/lib/engine.js +30 -0
- package/node_modules/gray-matter/lib/engines.js +54 -0
- package/node_modules/gray-matter/lib/excerpt.js +32 -0
- package/node_modules/gray-matter/lib/parse.js +13 -0
- package/node_modules/gray-matter/lib/stringify.js +56 -0
- package/node_modules/gray-matter/lib/to-file.js +43 -0
- package/node_modules/gray-matter/lib/utils.js +66 -0
- package/node_modules/gray-matter/package.json +127 -0
- package/node_modules/is-extendable/LICENSE +21 -0
- package/node_modules/is-extendable/README.md +72 -0
- package/node_modules/is-extendable/index.js +13 -0
- package/node_modules/is-extendable/package.json +51 -0
- package/node_modules/js-yaml/LICENSE +21 -0
- package/node_modules/js-yaml/README.md +302 -0
- package/node_modules/js-yaml/bin/js-yaml.js +132 -0
- package/node_modules/js-yaml/dist/js-yaml.js +4024 -0
- package/node_modules/js-yaml/dist/js-yaml.min.js +1 -0
- package/node_modules/js-yaml/index.js +7 -0
- package/node_modules/js-yaml/lib/js-yaml/common.js +59 -0
- package/node_modules/js-yaml/lib/js-yaml/dumper.js +850 -0
- package/node_modules/js-yaml/lib/js-yaml/exception.js +43 -0
- package/node_modules/js-yaml/lib/js-yaml/loader.js +1679 -0
- package/node_modules/js-yaml/lib/js-yaml/mark.js +76 -0
- package/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
- package/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
- package/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
- package/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
- package/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
- package/node_modules/js-yaml/lib/js-yaml/schema.js +108 -0
- package/node_modules/js-yaml/lib/js-yaml/type/binary.js +138 -0
- package/node_modules/js-yaml/lib/js-yaml/type/bool.js +35 -0
- package/node_modules/js-yaml/lib/js-yaml/type/float.js +116 -0
- package/node_modules/js-yaml/lib/js-yaml/type/int.js +173 -0
- package/node_modules/js-yaml/lib/js-yaml/type/js/function.js +93 -0
- package/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +60 -0
- package/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +28 -0
- package/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
- package/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
- package/node_modules/js-yaml/lib/js-yaml/type/null.js +34 -0
- package/node_modules/js-yaml/lib/js-yaml/type/omap.js +44 -0
- package/node_modules/js-yaml/lib/js-yaml/type/pairs.js +53 -0
- package/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
- package/node_modules/js-yaml/lib/js-yaml/type/set.js +29 -0
- package/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
- package/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +88 -0
- package/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
- package/node_modules/js-yaml/lib/js-yaml.js +39 -0
- package/node_modules/js-yaml/package.json +52 -0
- package/node_modules/kind-of/LICENSE +21 -0
- package/node_modules/kind-of/README.md +367 -0
- package/node_modules/kind-of/index.js +129 -0
- package/node_modules/kind-of/package.json +88 -0
- package/node_modules/pi-toggle-skills/README.md +213 -0
- package/node_modules/pi-toggle-skills/package.json +60 -0
- package/node_modules/pi-toggle-skills/src/index.ts +112 -0
- package/node_modules/pi-toggle-skills/src/skill-discovery.ts +258 -0
- package/node_modules/pi-toggle-skills/src/skill-selector.ts +435 -0
- package/node_modules/pi-toggle-skills/toggle-skills.ts +316 -0
- package/node_modules/pi-toggle-skills/vitest.config.ts +15 -0
- package/node_modules/proper-lockfile/LICENSE +21 -0
- package/node_modules/proper-lockfile/README.md +183 -0
- package/node_modules/proper-lockfile/index.js +40 -0
- package/node_modules/proper-lockfile/lib/adapter.js +85 -0
- package/node_modules/proper-lockfile/lib/lockfile.js +342 -0
- package/node_modules/proper-lockfile/lib/mtime-precision.js +55 -0
- package/node_modules/proper-lockfile/node_modules/retry/.npmignore +3 -0
- package/node_modules/proper-lockfile/node_modules/retry/.travis.yml +15 -0
- package/node_modules/proper-lockfile/node_modules/retry/License +21 -0
- package/node_modules/proper-lockfile/node_modules/retry/Makefile +18 -0
- package/node_modules/proper-lockfile/node_modules/retry/README.md +227 -0
- package/node_modules/proper-lockfile/node_modules/retry/equation.gif +0 -0
- package/node_modules/proper-lockfile/node_modules/retry/example/dns.js +31 -0
- package/node_modules/proper-lockfile/node_modules/retry/example/stop.js +40 -0
- package/node_modules/proper-lockfile/node_modules/retry/index.js +1 -0
- package/node_modules/proper-lockfile/node_modules/retry/lib/retry.js +100 -0
- package/node_modules/proper-lockfile/node_modules/retry/lib/retry_operation.js +158 -0
- package/node_modules/proper-lockfile/node_modules/retry/package.json +32 -0
- package/node_modules/proper-lockfile/node_modules/retry/test/common.js +10 -0
- package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-forever.js +24 -0
- package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-operation.js +258 -0
- package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-retry-wrap.js +101 -0
- package/node_modules/proper-lockfile/node_modules/retry/test/integration/test-timeouts.js +69 -0
- package/node_modules/proper-lockfile/package.json +71 -0
- package/node_modules/section-matter/LICENSE +21 -0
- package/node_modules/section-matter/README.md +236 -0
- package/node_modules/section-matter/index.js +136 -0
- package/node_modules/section-matter/package.json +55 -0
- package/node_modules/signal-exit/LICENSE.txt +16 -0
- package/node_modules/signal-exit/README.md +39 -0
- package/node_modules/signal-exit/index.js +202 -0
- package/node_modules/signal-exit/package.json +38 -0
- package/node_modules/signal-exit/signals.js +53 -0
- package/node_modules/sprintf-js/.npmignore +1 -0
- package/node_modules/sprintf-js/LICENSE +24 -0
- package/node_modules/sprintf-js/README.md +88 -0
- package/node_modules/sprintf-js/bower.json +14 -0
- package/node_modules/sprintf-js/demo/angular.html +20 -0
- package/node_modules/sprintf-js/dist/angular-sprintf.min.js +4 -0
- package/node_modules/sprintf-js/dist/angular-sprintf.min.js.map +1 -0
- package/node_modules/sprintf-js/dist/angular-sprintf.min.map +1 -0
- package/node_modules/sprintf-js/dist/sprintf.min.js +4 -0
- package/node_modules/sprintf-js/dist/sprintf.min.js.map +1 -0
- package/node_modules/sprintf-js/dist/sprintf.min.map +1 -0
- package/node_modules/sprintf-js/gruntfile.js +36 -0
- package/node_modules/sprintf-js/package.json +22 -0
- package/node_modules/sprintf-js/src/angular-sprintf.js +18 -0
- package/node_modules/sprintf-js/src/sprintf.js +208 -0
- package/node_modules/sprintf-js/test/test.js +82 -0
- package/node_modules/strip-bom-string/LICENSE +21 -0
- package/node_modules/strip-bom-string/README.md +66 -0
- package/node_modules/strip-bom-string/index.js +15 -0
- package/node_modules/strip-bom-string/package.json +60 -0
- package/package.json +13 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,OAAO,EA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";\nimport { dirname, isAbsolute, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { SettingsArtifactTargets } from \"./artifacts.ts\";\nimport {\n defineExtensionSettings,\n ExtensionSettingsDefinitionCandidateSchema,\n type ExtensionSettingsDefinition,\n} from \"./definition.ts\";\nimport { readTextIfPresent } from \"./file-system.ts\";\nimport { isJsonObject, isJsonString, parseJson, type JsonObject } from \"./json-value.ts\";\nimport { Type, Value } from \"./typebox-runtime.ts\";\n\nexport const PACKAGE_MANIFEST_KEY = \"piExtensionSettings\";\n\nconst ImportedDefinitionModuleSchema = Type.Object({\n default: ExtensionSettingsDefinitionCandidateSchema,\n});\n\ntype SettingsProjectManifest = {\n readonly definition: string;\n readonly schema: string;\n readonly readme: string;\n readonly prevalidation?: string;\n readonly globalPath?: string;\n};\n\nexport type SettingsArtifactProject = {\n readonly packageRoot: string;\n readonly definition: ExtensionSettingsDefinition;\n readonly targets: SettingsArtifactTargets;\n};\n\nfunction manifestError(path: string, reason: string): Error {\n return new Error(`Invalid Pi extension settings manifest in ${path}: ${reason}`);\n}\n\nfunction stringProperty(object: JsonObject, key: string): string | undefined {\n const value = object[key];\n return isJsonString(value) && value.trim() !== \"\" ? value : undefined;\n}\n\nfunction parseSettingsManifest(\n packagePath: string,\n packageJson: JsonObject,\n): SettingsProjectManifest | undefined {\n const raw = packageJson[PACKAGE_MANIFEST_KEY];\n if (raw === undefined) return undefined;\n if (!isJsonObject(raw)) {\n throw manifestError(packagePath, `${PACKAGE_MANIFEST_KEY} must be an object`);\n }\n\n const supported = new Set([\"definition\", \"schema\", \"readme\", \"prevalidation\", \"globalPath\"]);\n const unknownKeys = Object.keys(raw).filter((key) => !supported.has(key));\n if (unknownKeys.length > 0) {\n throw manifestError(packagePath, `unknown keys: ${unknownKeys.join(\", \")}`);\n }\n\n const definition = stringProperty(raw, \"definition\");\n if (definition === undefined) {\n throw manifestError(packagePath, \"definition must be a non-empty relative path\");\n }\n\n const schema = stringProperty(raw, \"schema\") ?? \"config.schema.json\";\n const readme = stringProperty(raw, \"readme\") ?? \"README.md\";\n const prevalidation = stringProperty(raw, \"prevalidation\");\n const globalPath = stringProperty(raw, \"globalPath\");\n if (prevalidation === undefined) {\n return globalPath === undefined\n ? { definition, schema, readme }\n : { definition, schema, readme, globalPath };\n }\n return globalPath === undefined\n ? { definition, schema, readme, prevalidation }\n : { definition, schema, readme, prevalidation, globalPath };\n}\n\nfunction resolveInside(packageRoot: string, configuredPath: string): string | undefined {\n if (isAbsolute(configuredPath)) return undefined;\n const resolved = resolve(packageRoot, configuredPath);\n const relativePath = relative(packageRoot, resolved);\n if (relativePath === \"\" || (!relativePath.startsWith(\"..\") && !isAbsolute(relativePath))) {\n return resolved;\n }\n return undefined;\n}\n\nfunction workspacePatterns(packageJson: JsonObject): readonly string[] {\n const workspaces = packageJson.workspaces;\n if (Array.isArray(workspaces)) {\n return workspaces.filter(isJsonString);\n }\n if (!isJsonObject(workspaces) || !Array.isArray(workspaces.packages)) return [];\n return workspaces.packages.filter(isJsonString);\n}\n\nfunction readPackageJson(path: string): JsonObject {\n const content = readTextIfPresent(path);\n if (content === undefined) throw manifestError(path, \"file does not exist\");\n\n const parsed = parseJson(content);\n if (!isJsonObject(parsed)) throw manifestError(path, \"file is not valid JSON\");\n return parsed;\n}\n\nasync function packageJsonPaths(root: string): Promise<readonly string[]> {\n const rootPackagePath = resolve(root, \"package.json\");\n const rootPackage = readPackageJson(rootPackagePath);\n\n const paths = new Set<string>([rootPackagePath]);\n for (const pattern of workspacePatterns(rootPackage)) {\n const packagePattern = pattern.endsWith(\"package.json\")\n ? pattern\n : `${pattern.replace(/\\/$/, \"\")}/package.json`;\n for await (const match of glob(packagePattern, {\n cwd: root,\n exclude: [\"**/node_modules/**\"],\n })) {\n paths.add(resolve(root, match));\n }\n }\n return [...paths].sort();\n}\n\nasync function importDefinition(path: string): Promise<ExtensionSettingsDefinition> {\n let imported: unknown;\n try {\n imported = await import(pathToFileURL(path).href);\n } catch (cause: unknown) {\n throw new Error(\n `Invalid settings definition module ${path}: module could not be imported`,\n {\n cause,\n },\n );\n }\n\n const invalidDefaultMessage = `Invalid settings definition module ${path}: default export must be created by defineExtensionSettings or be a valid definition input`;\n let candidateModule;\n try {\n candidateModule = Value.Parse(ImportedDefinitionModuleSchema, imported);\n } catch (cause: unknown) {\n throw new Error(invalidDefaultMessage, { cause });\n }\n try {\n // Always execute exhaustive authoring validation, including when the module exported a\n // pre-existing definition created through a runtime fast path.\n return defineExtensionSettings(candidateModule.default);\n } catch (cause: unknown) {\n throw new Error(invalidDefaultMessage, { cause });\n }\n}\n\nasync function loadProject(packagePath: string): Promise<SettingsArtifactProject | undefined> {\n const packageJson = readPackageJson(packagePath);\n const manifest = parseSettingsManifest(packagePath, packageJson);\n if (manifest === undefined) return undefined;\n\n const packageRoot = dirname(packagePath);\n const definitionPath = resolveInside(packageRoot, manifest.definition);\n const schemaPath = resolveInside(packageRoot, manifest.schema);\n const readmePath = resolveInside(packageRoot, manifest.readme);\n const prevalidationPath =\n manifest.prevalidation === undefined\n ? undefined\n : resolveInside(packageRoot, manifest.prevalidation);\n if (\n definitionPath === undefined ||\n schemaPath === undefined ||\n readmePath === undefined ||\n (manifest.prevalidation !== undefined && prevalidationPath === undefined)\n ) {\n throw manifestError(\n packagePath,\n \"definition, schema, readme, and prevalidation paths must stay inside the package\",\n );\n }\n\n const definition = await importDefinition(definitionPath);\n let targets: SettingsArtifactTargets;\n if (prevalidationPath === undefined) {\n targets =\n manifest.globalPath === undefined\n ? { schemaPath, readmePath }\n : { schemaPath, readmePath, globalPath: manifest.globalPath };\n } else {\n targets =\n manifest.globalPath === undefined\n ? { schemaPath, readmePath, prevalidationPath }\n : {\n schemaPath,\n readmePath,\n prevalidationPath,\n globalPath: manifest.globalPath,\n };\n }\n return { packageRoot, definition, targets };\n}\n\nexport async function discoverSettingsProjects(\n root: string,\n): Promise<readonly SettingsArtifactProject[]> {\n const paths = await packageJsonPaths(root);\n const projects: SettingsArtifactProject[] = [];\n for (const path of paths) {\n const project = await loadProject(path);\n if (project !== undefined) projects.push(project);\n }\n return projects;\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TObject } from "typebox";
|
|
2
|
+
import type { ExtensionSettingsDefinition, ExtensionSettingsDefinitionInput } from "./definition.ts";
|
|
3
|
+
import type { JsonObject } from "./json-value.ts";
|
|
4
|
+
declare const PREVALIDATION_FORMAT_VERSION: 1;
|
|
5
|
+
type SettingsDefinitionFingerprintInput = {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
readonly description: string;
|
|
9
|
+
readonly schemaId?: string;
|
|
10
|
+
readonly schema: TObject;
|
|
11
|
+
readonly exampleSettings?: unknown;
|
|
12
|
+
};
|
|
13
|
+
/** Generated, authoring-validated values used by the startup-only definition fast path. */
|
|
14
|
+
export type PrevalidatedExtensionSettingsArtifact = {
|
|
15
|
+
readonly formatVersion: typeof PREVALIDATION_FORMAT_VERSION;
|
|
16
|
+
/** Fast runtime proof over the complete JSON-visible definition contract. */
|
|
17
|
+
readonly fingerprint: string;
|
|
18
|
+
/** Authoring-only fingerprint checked by `check`; codec function text can change in Pi. */
|
|
19
|
+
readonly semanticFingerprint: string;
|
|
20
|
+
readonly defaultSettings: JsonObject;
|
|
21
|
+
readonly exampleSettings?: JsonObject;
|
|
22
|
+
};
|
|
23
|
+
export declare class InvalidPrevalidatedSettingsArtifact extends Error {
|
|
24
|
+
readonly name = "InvalidPrevalidatedSettingsArtifact";
|
|
25
|
+
}
|
|
26
|
+
/** Computes the inexpensive runtime proof stored beside a prevalidated definition. */
|
|
27
|
+
export declare function prevalidatedExtensionSettingsFingerprint(input: SettingsDefinitionFingerprintInput, defaultSettings: JsonObject, exampleSettings: JsonObject | undefined): string;
|
|
28
|
+
/** Creates the generated artifact payload from a fully authoring-validated definition. */
|
|
29
|
+
export declare function createPrevalidatedExtensionSettingsArtifact<Schema extends TObject>(definition: ExtensionSettingsDefinition<Schema>): PrevalidatedExtensionSettingsArtifact;
|
|
30
|
+
/**
|
|
31
|
+
* Hydrates a settings definition from a checked-in authoring-validated artifact.
|
|
32
|
+
*
|
|
33
|
+
* This startup path deliberately omits schema documentation/default/example validation. Generation
|
|
34
|
+
* performs those exhaustive checks. Runtime fingerprints reject JSON-visible drift before any
|
|
35
|
+
* settings files are loaded. Codec function text is checked only by the authoring `check` command:
|
|
36
|
+
* Pi and bundlers transform functions without changing their behavior.
|
|
37
|
+
*/
|
|
38
|
+
export declare function definePrevalidatedExtensionSettings<const Schema extends TObject>(input: ExtensionSettingsDefinitionInput<Schema>, artifact: PrevalidatedExtensionSettingsArtifact): ExtensionSettingsDefinition<Schema>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,KAAK,EACR,2BAA2B,EAC3B,gCAAgC,EACnC,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,QAAA,MAAM,4BAA4B,EAAG,CAAU,CAAC;AAEhD,KAAK,kCAAkC,GAAG;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACtC,CAAC;AAaF,2FAA2F;AAC3F,MAAM,MAAM,qCAAqC,GAAG;IAChD,QAAQ,CAAC,aAAa,EAAE,OAAO,4BAA4B,CAAC;IAC5D,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2FAA2F;IAC3F,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC;IACrC,QAAQ,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;CACzC,CAAC;AAEF,qBAAa,mCAAoC,SAAQ,KAAK;IAC1D,SAAkB,IAAI,yCAAyC;CAClE;AA4DD,sFAAsF;AACtF,wBAAgB,wCAAwC,CACpD,KAAK,EAAE,kCAAkC,EACzC,eAAe,EAAE,UAAU,EAC3B,eAAe,EAAE,UAAU,GAAG,SAAS,GACxC,MAAM,CAGR;AAYD,0FAA0F;AAC1F,wBAAgB,2CAA2C,CAAC,MAAM,SAAS,OAAO,EAC9E,UAAU,EAAE,2BAA2B,CAAC,MAAM,CAAC,GAChD,qCAAqC,CA2CvC;AAWD;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,CAAC,MAAM,SAAS,OAAO,EAC5E,KAAK,EAAE,gCAAgC,CAAC,MAAM,CAAC,EAC/C,QAAQ,EAAE,qCAAqC,GAChD,2BAA2B,CAAC,MAAM,CAAC,CAmDrC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
import { extensionSettingsDefinitionMarker as definitionMarker } from "./definition-marker.js";
|
|
4
|
+
const PREVALIDATION_FORMAT_VERSION = 1;
|
|
5
|
+
export class InvalidPrevalidatedSettingsArtifact extends Error {
|
|
6
|
+
name = "InvalidPrevalidatedSettingsArtifact";
|
|
7
|
+
}
|
|
8
|
+
function cloneJson(value) {
|
|
9
|
+
return structuredClone(value);
|
|
10
|
+
}
|
|
11
|
+
function freezeRecursively(value, original) {
|
|
12
|
+
const pending = [original, value];
|
|
13
|
+
while (pending.length > 0) {
|
|
14
|
+
const current = pending.pop();
|
|
15
|
+
const source = pending.pop();
|
|
16
|
+
if (current === undefined ||
|
|
17
|
+
source === undefined ||
|
|
18
|
+
current === source ||
|
|
19
|
+
Object.isFrozen(current))
|
|
20
|
+
continue;
|
|
21
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
22
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(current, key);
|
|
23
|
+
if (descriptor === undefined || !("value" in descriptor))
|
|
24
|
+
continue;
|
|
25
|
+
const child = descriptor.value;
|
|
26
|
+
if (Object.isFrozen(child))
|
|
27
|
+
continue;
|
|
28
|
+
const sourceDescriptor = Reflect.getOwnPropertyDescriptor(source, key);
|
|
29
|
+
if (sourceDescriptor === undefined || !("value" in sourceDescriptor))
|
|
30
|
+
continue;
|
|
31
|
+
const originalChild = sourceDescriptor.value;
|
|
32
|
+
// TypeBox retains codec functions and other atomic values by identity. Only descend
|
|
33
|
+
// into values that were copied; never mutate those caller-owned references.
|
|
34
|
+
if (child === originalChild)
|
|
35
|
+
continue;
|
|
36
|
+
// SAFETY: Object.isFrozen false proves child is an object/function. Both clone
|
|
37
|
+
// operations preserve primitives, so its distinct data-property source is an object
|
|
38
|
+
// too. Ownership, codec, array and shared-reference tests cover this correspondence.
|
|
39
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- SAFETY: the clone/source correspondence proves both worklist values are objects.
|
|
40
|
+
pending.push(...[originalChild, child]);
|
|
41
|
+
}
|
|
42
|
+
Object.freeze(current);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function normalizedSchemaId(input) {
|
|
46
|
+
return input.schemaId ?? `urn:pi-extension-settings:${input.id}`;
|
|
47
|
+
}
|
|
48
|
+
function fingerprintPayload(input, defaultSettings, exampleSettings) {
|
|
49
|
+
return {
|
|
50
|
+
id: input.id,
|
|
51
|
+
title: input.title,
|
|
52
|
+
description: input.description,
|
|
53
|
+
schemaId: normalizedSchemaId(input),
|
|
54
|
+
schema: input.schema,
|
|
55
|
+
inputExampleSettings: input.exampleSettings,
|
|
56
|
+
defaultSettings,
|
|
57
|
+
exampleSettings,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Computes the inexpensive runtime proof stored beside a prevalidated definition. */
|
|
61
|
+
export function prevalidatedExtensionSettingsFingerprint(input, defaultSettings, exampleSettings) {
|
|
62
|
+
const serialized = JSON.stringify(fingerprintPayload(input, defaultSettings, exampleSettings));
|
|
63
|
+
return `json-sha256-v1:${createHash("sha256").update(serialized).digest("hex")}`;
|
|
64
|
+
}
|
|
65
|
+
function semanticFingerprint(input, defaultSettings, exampleSettings) {
|
|
66
|
+
return `typebox-value-hash-v1:${Value.Hash(fingerprintPayload(input, defaultSettings, exampleSettings))}`;
|
|
67
|
+
}
|
|
68
|
+
/** Creates the generated artifact payload from a fully authoring-validated definition. */
|
|
69
|
+
export function createPrevalidatedExtensionSettingsArtifact(definition) {
|
|
70
|
+
const input = definition.exampleSettings === undefined
|
|
71
|
+
? {
|
|
72
|
+
id: definition.id,
|
|
73
|
+
title: definition.title,
|
|
74
|
+
description: definition.description,
|
|
75
|
+
schemaId: definition.schemaId,
|
|
76
|
+
schema: definition.schema,
|
|
77
|
+
}
|
|
78
|
+
: {
|
|
79
|
+
id: definition.id,
|
|
80
|
+
title: definition.title,
|
|
81
|
+
description: definition.description,
|
|
82
|
+
schemaId: definition.schemaId,
|
|
83
|
+
schema: definition.schema,
|
|
84
|
+
exampleSettings: definition.exampleSettings,
|
|
85
|
+
};
|
|
86
|
+
const defaultSettings = cloneJson(definition.defaultSettings);
|
|
87
|
+
const exampleSettings = definition.exampleSettings === undefined
|
|
88
|
+
? undefined
|
|
89
|
+
: cloneJson(definition.exampleSettings);
|
|
90
|
+
const fingerprint = prevalidatedExtensionSettingsFingerprint(input, defaultSettings, exampleSettings);
|
|
91
|
+
const semantic = semanticFingerprint(input, defaultSettings, exampleSettings);
|
|
92
|
+
return exampleSettings === undefined
|
|
93
|
+
? {
|
|
94
|
+
formatVersion: PREVALIDATION_FORMAT_VERSION,
|
|
95
|
+
fingerprint,
|
|
96
|
+
semanticFingerprint: semantic,
|
|
97
|
+
defaultSettings,
|
|
98
|
+
}
|
|
99
|
+
: {
|
|
100
|
+
formatVersion: PREVALIDATION_FORMAT_VERSION,
|
|
101
|
+
fingerprint,
|
|
102
|
+
semanticFingerprint: semantic,
|
|
103
|
+
defaultSettings,
|
|
104
|
+
exampleSettings,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function hasPlainObjectPrototype(value) {
|
|
108
|
+
try {
|
|
109
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
110
|
+
return prototype === Object.prototype || prototype === null;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Hydrates a settings definition from a checked-in authoring-validated artifact.
|
|
118
|
+
*
|
|
119
|
+
* This startup path deliberately omits schema documentation/default/example validation. Generation
|
|
120
|
+
* performs those exhaustive checks. Runtime fingerprints reject JSON-visible drift before any
|
|
121
|
+
* settings files are loaded. Codec function text is checked only by the authoring `check` command:
|
|
122
|
+
* Pi and bundlers transform functions without changing their behavior.
|
|
123
|
+
*/
|
|
124
|
+
export function definePrevalidatedExtensionSettings(input, artifact) {
|
|
125
|
+
if (artifact.formatVersion !== PREVALIDATION_FORMAT_VERSION) {
|
|
126
|
+
throw new InvalidPrevalidatedSettingsArtifact(`unsupported prevalidation format version: ${String(artifact.formatVersion)}`);
|
|
127
|
+
}
|
|
128
|
+
if (!hasPlainObjectPrototype(artifact.defaultSettings)) {
|
|
129
|
+
throw new InvalidPrevalidatedSettingsArtifact("prevalidated defaultSettings must be a JSON object");
|
|
130
|
+
}
|
|
131
|
+
if (artifact.exampleSettings !== undefined &&
|
|
132
|
+
!hasPlainObjectPrototype(artifact.exampleSettings)) {
|
|
133
|
+
throw new InvalidPrevalidatedSettingsArtifact("prevalidated exampleSettings must be a JSON object");
|
|
134
|
+
}
|
|
135
|
+
const expectedFingerprint = prevalidatedExtensionSettingsFingerprint(input, artifact.defaultSettings, artifact.exampleSettings);
|
|
136
|
+
if (artifact.fingerprint !== expectedFingerprint) {
|
|
137
|
+
throw new InvalidPrevalidatedSettingsArtifact("prevalidated settings artifact is stale; run pi-extension-settings generate");
|
|
138
|
+
}
|
|
139
|
+
const schema = Value.Clone(input.schema);
|
|
140
|
+
const defaultSettings = cloneJson(artifact.defaultSettings);
|
|
141
|
+
const exampleSettings = artifact.exampleSettings === undefined ? undefined : cloneJson(artifact.exampleSettings);
|
|
142
|
+
freezeRecursively(schema, input.schema);
|
|
143
|
+
freezeRecursively(defaultSettings, artifact.defaultSettings);
|
|
144
|
+
if (exampleSettings !== undefined && artifact.exampleSettings !== undefined) {
|
|
145
|
+
freezeRecursively(exampleSettings, artifact.exampleSettings);
|
|
146
|
+
}
|
|
147
|
+
return Object.freeze({
|
|
148
|
+
[definitionMarker]: true,
|
|
149
|
+
id: input.id,
|
|
150
|
+
title: input.title,
|
|
151
|
+
description: input.description,
|
|
152
|
+
schemaId: normalizedSchemaId(input),
|
|
153
|
+
schema,
|
|
154
|
+
defaultSettings,
|
|
155
|
+
exampleSettings,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAMtC,OAAO,EAAE,iCAAiC,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/F,MAAM,4BAA4B,GAAG,CAAU,CAAC;AAiChD,MAAM,OAAO,mCAAoC,SAAQ,KAAK;IACxC,IAAI,GAAG,qCAAqC,CAAC;CAClE;AAED,SAAS,SAAS,CAA2B,KAAY;IACrD,OAAO,eAAe,CAAC,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C;IAC7D,IAAI,eAAe,KAAK,SAAS,IAAI,QAAQ,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;QAC1E,iBAAiB,CAAC,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,CAAC,gBAAgB,CAAC,EAAE,IAAa;QACjC,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,QAAQ,EAAE,kBAAkB,CAAC,KAAK,CAAC;QACnC,MAAM;QACN,eAAe;QACf,eAAe;KAClB,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\n\nimport type { TObject } from \"typebox\";\nimport { Value } from \"typebox/value\";\n\nimport type {\n ExtensionSettingsDefinition,\n ExtensionSettingsDefinitionInput,\n} from \"./definition.ts\";\nimport { extensionSettingsDefinitionMarker as definitionMarker } from \"./definition-marker.ts\";\nimport type { JsonObject } from \"./json-value.ts\";\n\nconst PREVALIDATION_FORMAT_VERSION = 1 as const;\n\ntype SettingsDefinitionFingerprintInput = {\n readonly id: string;\n readonly title: string;\n readonly description: string;\n readonly schemaId?: string;\n readonly schema: TObject;\n readonly exampleSettings?: unknown;\n};\n\ntype SettingsFingerprintPayload = {\n readonly id: string;\n readonly title: string;\n readonly description: string;\n readonly schemaId: string;\n readonly schema: TObject;\n readonly inputExampleSettings: unknown;\n readonly defaultSettings: JsonObject;\n readonly exampleSettings: JsonObject | undefined;\n};\n\n/** Generated, authoring-validated values used by the startup-only definition fast path. */\nexport type PrevalidatedExtensionSettingsArtifact = {\n readonly formatVersion: typeof PREVALIDATION_FORMAT_VERSION;\n /** Fast runtime proof over the complete JSON-visible definition contract. */\n readonly fingerprint: string;\n /** Authoring-only fingerprint checked by `check`; codec function text can change in Pi. */\n readonly semanticFingerprint: string;\n readonly defaultSettings: JsonObject;\n readonly exampleSettings?: JsonObject;\n};\n\nexport class InvalidPrevalidatedSettingsArtifact extends Error {\n override readonly name = \"InvalidPrevalidatedSettingsArtifact\";\n}\n\nfunction cloneJson<Value extends JsonObject>(value: Value): Value {\n return structuredClone(value);\n}\n\nfunction freezeRecursively<Value extends object>(value: Value, original: Value): void {\n const pending: object[] = [original, value];\n while (pending.length > 0) {\n const current = pending.pop();\n const source = pending.pop();\n if (\n current === undefined ||\n source === undefined ||\n current === source ||\n Object.isFrozen(current)\n )\n continue;\n for (const key of Reflect.ownKeys(current)) {\n const descriptor = Reflect.getOwnPropertyDescriptor(current, key);\n if (descriptor === undefined || !(\"value\" in descriptor)) continue;\n const child: unknown = descriptor.value;\n if (Object.isFrozen(child)) continue;\n const sourceDescriptor = Reflect.getOwnPropertyDescriptor(source, key);\n if (sourceDescriptor === undefined || !(\"value\" in sourceDescriptor)) continue;\n const originalChild: unknown = sourceDescriptor.value;\n // TypeBox retains codec functions and other atomic values by identity. Only descend\n // into values that were copied; never mutate those caller-owned references.\n if (child === originalChild) continue;\n // SAFETY: Object.isFrozen false proves child is an object/function. Both clone\n // operations preserve primitives, so its distinct data-property source is an object\n // too. Ownership, codec, array and shared-reference tests cover this correspondence.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- SAFETY: the clone/source correspondence proves both worklist values are objects.\n pending.push(...([originalChild, child] as [object, object]));\n }\n Object.freeze(current);\n }\n}\n\nfunction normalizedSchemaId(input: SettingsDefinitionFingerprintInput): string {\n return input.schemaId ?? `urn:pi-extension-settings:${input.id}`;\n}\n\nfunction fingerprintPayload(\n input: SettingsDefinitionFingerprintInput,\n defaultSettings: JsonObject,\n exampleSettings: JsonObject | undefined,\n): SettingsFingerprintPayload {\n return {\n id: input.id,\n title: input.title,\n description: input.description,\n schemaId: normalizedSchemaId(input),\n schema: input.schema,\n inputExampleSettings: input.exampleSettings,\n defaultSettings,\n exampleSettings,\n };\n}\n\n/** Computes the inexpensive runtime proof stored beside a prevalidated definition. */\nexport function prevalidatedExtensionSettingsFingerprint(\n input: SettingsDefinitionFingerprintInput,\n defaultSettings: JsonObject,\n exampleSettings: JsonObject | undefined,\n): string {\n const serialized = JSON.stringify(fingerprintPayload(input, defaultSettings, exampleSettings));\n return `json-sha256-v1:${createHash(\"sha256\").update(serialized).digest(\"hex\")}`;\n}\n\nfunction semanticFingerprint(\n input: SettingsDefinitionFingerprintInput,\n defaultSettings: JsonObject,\n exampleSettings: JsonObject | undefined,\n): string {\n return `typebox-value-hash-v1:${Value.Hash(\n fingerprintPayload(input, defaultSettings, exampleSettings),\n )}`;\n}\n\n/** Creates the generated artifact payload from a fully authoring-validated definition. */\nexport function createPrevalidatedExtensionSettingsArtifact<Schema extends TObject>(\n definition: ExtensionSettingsDefinition<Schema>,\n): PrevalidatedExtensionSettingsArtifact {\n const input: SettingsDefinitionFingerprintInput =\n definition.exampleSettings === undefined\n ? {\n id: definition.id,\n title: definition.title,\n description: definition.description,\n schemaId: definition.schemaId,\n schema: definition.schema,\n }\n : {\n id: definition.id,\n title: definition.title,\n description: definition.description,\n schemaId: definition.schemaId,\n schema: definition.schema,\n exampleSettings: definition.exampleSettings,\n };\n const defaultSettings = cloneJson(definition.defaultSettings);\n const exampleSettings =\n definition.exampleSettings === undefined\n ? undefined\n : cloneJson(definition.exampleSettings);\n const fingerprint = prevalidatedExtensionSettingsFingerprint(\n input,\n defaultSettings,\n exampleSettings,\n );\n const semantic = semanticFingerprint(input, defaultSettings, exampleSettings);\n return exampleSettings === undefined\n ? {\n formatVersion: PREVALIDATION_FORMAT_VERSION,\n fingerprint,\n semanticFingerprint: semantic,\n defaultSettings,\n }\n : {\n formatVersion: PREVALIDATION_FORMAT_VERSION,\n fingerprint,\n semanticFingerprint: semantic,\n defaultSettings,\n exampleSettings,\n };\n}\n\nfunction hasPlainObjectPrototype(value: JsonObject): boolean {\n try {\n const prototype = Reflect.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n } catch {\n return false;\n }\n}\n\n/**\n * Hydrates a settings definition from a checked-in authoring-validated artifact.\n *\n * This startup path deliberately omits schema documentation/default/example validation. Generation\n * performs those exhaustive checks. Runtime fingerprints reject JSON-visible drift before any\n * settings files are loaded. Codec function text is checked only by the authoring `check` command:\n * Pi and bundlers transform functions without changing their behavior.\n */\nexport function definePrevalidatedExtensionSettings<const Schema extends TObject>(\n input: ExtensionSettingsDefinitionInput<Schema>,\n artifact: PrevalidatedExtensionSettingsArtifact,\n): ExtensionSettingsDefinition<Schema> {\n if (artifact.formatVersion !== PREVALIDATION_FORMAT_VERSION) {\n throw new InvalidPrevalidatedSettingsArtifact(\n `unsupported prevalidation format version: ${String(artifact.formatVersion)}`,\n );\n }\n if (!hasPlainObjectPrototype(artifact.defaultSettings)) {\n throw new InvalidPrevalidatedSettingsArtifact(\n \"prevalidated defaultSettings must be a JSON object\",\n );\n }\n if (\n artifact.exampleSettings !== undefined &&\n !hasPlainObjectPrototype(artifact.exampleSettings)\n ) {\n throw new InvalidPrevalidatedSettingsArtifact(\n \"prevalidated exampleSettings must be a JSON object\",\n );\n }\n\n const expectedFingerprint = prevalidatedExtensionSettingsFingerprint(\n input,\n artifact.defaultSettings,\n artifact.exampleSettings,\n );\n if (artifact.fingerprint !== expectedFingerprint) {\n throw new InvalidPrevalidatedSettingsArtifact(\n \"prevalidated settings artifact is stale; run pi-extension-settings generate\",\n );\n }\n\n const schema = Value.Clone(input.schema);\n const defaultSettings = cloneJson(artifact.defaultSettings);\n const exampleSettings =\n artifact.exampleSettings === undefined ? undefined : cloneJson(artifact.exampleSettings);\n freezeRecursively(schema, input.schema);\n freezeRecursively(defaultSettings, artifact.defaultSettings);\n if (exampleSettings !== undefined && artifact.exampleSettings !== undefined) {\n freezeRecursively(exampleSettings, artifact.exampleSettings);\n }\n\n return Object.freeze({\n [definitionMarker]: true as const,\n id: input.id,\n title: input.title,\n description: input.description,\n schemaId: normalizedSchemaId(input),\n schema,\n defaultSettings,\n exampleSettings,\n });\n}\n"]}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { Value } from "typebox/value";
|
|
4
|
+
|
|
5
|
+
// src/definition-marker.ts
|
|
6
|
+
var extensionSettingsDefinitionMarker = /* @__PURE__ */ Symbol.for(
|
|
7
|
+
"@zigai/pi-extension-settings/definition"
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
// src/runtime.ts
|
|
11
|
+
var PREVALIDATION_FORMAT_VERSION = 1;
|
|
12
|
+
var InvalidPrevalidatedSettingsArtifact = class extends Error {
|
|
13
|
+
name = "InvalidPrevalidatedSettingsArtifact";
|
|
14
|
+
};
|
|
15
|
+
function cloneJson(value) {
|
|
16
|
+
return structuredClone(value);
|
|
17
|
+
}
|
|
18
|
+
function freezeRecursively(value, original) {
|
|
19
|
+
const pending = [original, value];
|
|
20
|
+
while (pending.length > 0) {
|
|
21
|
+
const current = pending.pop();
|
|
22
|
+
const source = pending.pop();
|
|
23
|
+
if (current === void 0 || source === void 0 || current === source || Object.isFrozen(current))
|
|
24
|
+
continue;
|
|
25
|
+
for (const key of Reflect.ownKeys(current)) {
|
|
26
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(current, key);
|
|
27
|
+
if (descriptor === void 0 || !("value" in descriptor)) continue;
|
|
28
|
+
const child = descriptor.value;
|
|
29
|
+
if (Object.isFrozen(child)) continue;
|
|
30
|
+
const sourceDescriptor = Reflect.getOwnPropertyDescriptor(source, key);
|
|
31
|
+
if (sourceDescriptor === void 0 || !("value" in sourceDescriptor)) continue;
|
|
32
|
+
const originalChild = sourceDescriptor.value;
|
|
33
|
+
if (child === originalChild) continue;
|
|
34
|
+
pending.push(...[originalChild, child]);
|
|
35
|
+
}
|
|
36
|
+
Object.freeze(current);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function normalizedSchemaId(input) {
|
|
40
|
+
return input.schemaId ?? `urn:pi-extension-settings:${input.id}`;
|
|
41
|
+
}
|
|
42
|
+
function fingerprintPayload(input, defaultSettings, exampleSettings) {
|
|
43
|
+
return {
|
|
44
|
+
id: input.id,
|
|
45
|
+
title: input.title,
|
|
46
|
+
description: input.description,
|
|
47
|
+
schemaId: normalizedSchemaId(input),
|
|
48
|
+
schema: input.schema,
|
|
49
|
+
inputExampleSettings: input.exampleSettings,
|
|
50
|
+
defaultSettings,
|
|
51
|
+
exampleSettings
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function prevalidatedExtensionSettingsFingerprint(input, defaultSettings, exampleSettings) {
|
|
55
|
+
const serialized = JSON.stringify(fingerprintPayload(input, defaultSettings, exampleSettings));
|
|
56
|
+
return `json-sha256-v1:${createHash("sha256").update(serialized).digest("hex")}`;
|
|
57
|
+
}
|
|
58
|
+
function semanticFingerprint(input, defaultSettings, exampleSettings) {
|
|
59
|
+
return `typebox-value-hash-v1:${Value.Hash(
|
|
60
|
+
fingerprintPayload(input, defaultSettings, exampleSettings)
|
|
61
|
+
)}`;
|
|
62
|
+
}
|
|
63
|
+
function createPrevalidatedExtensionSettingsArtifact(definition) {
|
|
64
|
+
const input = definition.exampleSettings === void 0 ? {
|
|
65
|
+
id: definition.id,
|
|
66
|
+
title: definition.title,
|
|
67
|
+
description: definition.description,
|
|
68
|
+
schemaId: definition.schemaId,
|
|
69
|
+
schema: definition.schema
|
|
70
|
+
} : {
|
|
71
|
+
id: definition.id,
|
|
72
|
+
title: definition.title,
|
|
73
|
+
description: definition.description,
|
|
74
|
+
schemaId: definition.schemaId,
|
|
75
|
+
schema: definition.schema,
|
|
76
|
+
exampleSettings: definition.exampleSettings
|
|
77
|
+
};
|
|
78
|
+
const defaultSettings = cloneJson(definition.defaultSettings);
|
|
79
|
+
const exampleSettings = definition.exampleSettings === void 0 ? void 0 : cloneJson(definition.exampleSettings);
|
|
80
|
+
const fingerprint = prevalidatedExtensionSettingsFingerprint(
|
|
81
|
+
input,
|
|
82
|
+
defaultSettings,
|
|
83
|
+
exampleSettings
|
|
84
|
+
);
|
|
85
|
+
const semantic = semanticFingerprint(input, defaultSettings, exampleSettings);
|
|
86
|
+
return exampleSettings === void 0 ? {
|
|
87
|
+
formatVersion: PREVALIDATION_FORMAT_VERSION,
|
|
88
|
+
fingerprint,
|
|
89
|
+
semanticFingerprint: semantic,
|
|
90
|
+
defaultSettings
|
|
91
|
+
} : {
|
|
92
|
+
formatVersion: PREVALIDATION_FORMAT_VERSION,
|
|
93
|
+
fingerprint,
|
|
94
|
+
semanticFingerprint: semantic,
|
|
95
|
+
defaultSettings,
|
|
96
|
+
exampleSettings
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function hasPlainObjectPrototype(value) {
|
|
100
|
+
try {
|
|
101
|
+
const prototype = Reflect.getPrototypeOf(value);
|
|
102
|
+
return prototype === Object.prototype || prototype === null;
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function definePrevalidatedExtensionSettings(input, artifact) {
|
|
108
|
+
if (artifact.formatVersion !== PREVALIDATION_FORMAT_VERSION) {
|
|
109
|
+
throw new InvalidPrevalidatedSettingsArtifact(
|
|
110
|
+
`unsupported prevalidation format version: ${String(artifact.formatVersion)}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (!hasPlainObjectPrototype(artifact.defaultSettings)) {
|
|
114
|
+
throw new InvalidPrevalidatedSettingsArtifact(
|
|
115
|
+
"prevalidated defaultSettings must be a JSON object"
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
if (artifact.exampleSettings !== void 0 && !hasPlainObjectPrototype(artifact.exampleSettings)) {
|
|
119
|
+
throw new InvalidPrevalidatedSettingsArtifact(
|
|
120
|
+
"prevalidated exampleSettings must be a JSON object"
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
const expectedFingerprint = prevalidatedExtensionSettingsFingerprint(
|
|
124
|
+
input,
|
|
125
|
+
artifact.defaultSettings,
|
|
126
|
+
artifact.exampleSettings
|
|
127
|
+
);
|
|
128
|
+
if (artifact.fingerprint !== expectedFingerprint) {
|
|
129
|
+
throw new InvalidPrevalidatedSettingsArtifact(
|
|
130
|
+
"prevalidated settings artifact is stale; run pi-extension-settings generate"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
const schema = Value.Clone(input.schema);
|
|
134
|
+
const defaultSettings = cloneJson(artifact.defaultSettings);
|
|
135
|
+
const exampleSettings = artifact.exampleSettings === void 0 ? void 0 : cloneJson(artifact.exampleSettings);
|
|
136
|
+
freezeRecursively(schema, input.schema);
|
|
137
|
+
freezeRecursively(defaultSettings, artifact.defaultSettings);
|
|
138
|
+
if (exampleSettings !== void 0 && artifact.exampleSettings !== void 0) {
|
|
139
|
+
freezeRecursively(exampleSettings, artifact.exampleSettings);
|
|
140
|
+
}
|
|
141
|
+
return Object.freeze({
|
|
142
|
+
[extensionSettingsDefinitionMarker]: true,
|
|
143
|
+
id: input.id,
|
|
144
|
+
title: input.title,
|
|
145
|
+
description: input.description,
|
|
146
|
+
schemaId: normalizedSchemaId(input),
|
|
147
|
+
schema,
|
|
148
|
+
defaultSettings,
|
|
149
|
+
exampleSettings
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
InvalidPrevalidatedSettingsArtifact,
|
|
154
|
+
createPrevalidatedExtensionSettingsArtifact,
|
|
155
|
+
definePrevalidatedExtensionSettings,
|
|
156
|
+
prevalidatedExtensionSettingsFingerprint
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=runtime.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/runtime.ts", "../src/definition-marker.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\n\nimport type { TObject } from \"typebox\";\nimport { Value } from \"typebox/value\";\n\nimport type {\n ExtensionSettingsDefinition,\n ExtensionSettingsDefinitionInput,\n} from \"./definition.ts\";\nimport { extensionSettingsDefinitionMarker as definitionMarker } from \"./definition-marker.ts\";\nimport type { JsonObject } from \"./json-value.ts\";\n\nconst PREVALIDATION_FORMAT_VERSION = 1 as const;\n\ntype SettingsDefinitionFingerprintInput = {\n readonly id: string;\n readonly title: string;\n readonly description: string;\n readonly schemaId?: string;\n readonly schema: TObject;\n readonly exampleSettings?: unknown;\n};\n\ntype SettingsFingerprintPayload = {\n readonly id: string;\n readonly title: string;\n readonly description: string;\n readonly schemaId: string;\n readonly schema: TObject;\n readonly inputExampleSettings: unknown;\n readonly defaultSettings: JsonObject;\n readonly exampleSettings: JsonObject | undefined;\n};\n\n/** Generated, authoring-validated values used by the startup-only definition fast path. */\nexport type PrevalidatedExtensionSettingsArtifact = {\n readonly formatVersion: typeof PREVALIDATION_FORMAT_VERSION;\n /** Fast runtime proof over the complete JSON-visible definition contract. */\n readonly fingerprint: string;\n /** Authoring-only fingerprint checked by `check`; codec function text can change in Pi. */\n readonly semanticFingerprint: string;\n readonly defaultSettings: JsonObject;\n readonly exampleSettings?: JsonObject;\n};\n\nexport class InvalidPrevalidatedSettingsArtifact extends Error {\n override readonly name = \"InvalidPrevalidatedSettingsArtifact\";\n}\n\nfunction cloneJson<Value extends JsonObject>(value: Value): Value {\n return structuredClone(value);\n}\n\nfunction freezeRecursively<Value extends object>(value: Value, original: Value): void {\n const pending: object[] = [original, value];\n while (pending.length > 0) {\n const current = pending.pop();\n const source = pending.pop();\n if (\n current === undefined ||\n source === undefined ||\n current === source ||\n Object.isFrozen(current)\n )\n continue;\n for (const key of Reflect.ownKeys(current)) {\n const descriptor = Reflect.getOwnPropertyDescriptor(current, key);\n if (descriptor === undefined || !(\"value\" in descriptor)) continue;\n const child: unknown = descriptor.value;\n if (Object.isFrozen(child)) continue;\n const sourceDescriptor = Reflect.getOwnPropertyDescriptor(source, key);\n if (sourceDescriptor === undefined || !(\"value\" in sourceDescriptor)) continue;\n const originalChild: unknown = sourceDescriptor.value;\n // TypeBox retains codec functions and other atomic values by identity. Only descend\n // into values that were copied; never mutate those caller-owned references.\n if (child === originalChild) continue;\n // SAFETY: Object.isFrozen false proves child is an object/function. Both clone\n // operations preserve primitives, so its distinct data-property source is an object\n // too. Ownership, codec, array and shared-reference tests cover this correspondence.\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion -- SAFETY: the clone/source correspondence proves both worklist values are objects.\n pending.push(...([originalChild, child] as [object, object]));\n }\n Object.freeze(current);\n }\n}\n\nfunction normalizedSchemaId(input: SettingsDefinitionFingerprintInput): string {\n return input.schemaId ?? `urn:pi-extension-settings:${input.id}`;\n}\n\nfunction fingerprintPayload(\n input: SettingsDefinitionFingerprintInput,\n defaultSettings: JsonObject,\n exampleSettings: JsonObject | undefined,\n): SettingsFingerprintPayload {\n return {\n id: input.id,\n title: input.title,\n description: input.description,\n schemaId: normalizedSchemaId(input),\n schema: input.schema,\n inputExampleSettings: input.exampleSettings,\n defaultSettings,\n exampleSettings,\n };\n}\n\n/** Computes the inexpensive runtime proof stored beside a prevalidated definition. */\nexport function prevalidatedExtensionSettingsFingerprint(\n input: SettingsDefinitionFingerprintInput,\n defaultSettings: JsonObject,\n exampleSettings: JsonObject | undefined,\n): string {\n const serialized = JSON.stringify(fingerprintPayload(input, defaultSettings, exampleSettings));\n return `json-sha256-v1:${createHash(\"sha256\").update(serialized).digest(\"hex\")}`;\n}\n\nfunction semanticFingerprint(\n input: SettingsDefinitionFingerprintInput,\n defaultSettings: JsonObject,\n exampleSettings: JsonObject | undefined,\n): string {\n return `typebox-value-hash-v1:${Value.Hash(\n fingerprintPayload(input, defaultSettings, exampleSettings),\n )}`;\n}\n\n/** Creates the generated artifact payload from a fully authoring-validated definition. */\nexport function createPrevalidatedExtensionSettingsArtifact<Schema extends TObject>(\n definition: ExtensionSettingsDefinition<Schema>,\n): PrevalidatedExtensionSettingsArtifact {\n const input: SettingsDefinitionFingerprintInput =\n definition.exampleSettings === undefined\n ? {\n id: definition.id,\n title: definition.title,\n description: definition.description,\n schemaId: definition.schemaId,\n schema: definition.schema,\n }\n : {\n id: definition.id,\n title: definition.title,\n description: definition.description,\n schemaId: definition.schemaId,\n schema: definition.schema,\n exampleSettings: definition.exampleSettings,\n };\n const defaultSettings = cloneJson(definition.defaultSettings);\n const exampleSettings =\n definition.exampleSettings === undefined\n ? undefined\n : cloneJson(definition.exampleSettings);\n const fingerprint = prevalidatedExtensionSettingsFingerprint(\n input,\n defaultSettings,\n exampleSettings,\n );\n const semantic = semanticFingerprint(input, defaultSettings, exampleSettings);\n return exampleSettings === undefined\n ? {\n formatVersion: PREVALIDATION_FORMAT_VERSION,\n fingerprint,\n semanticFingerprint: semantic,\n defaultSettings,\n }\n : {\n formatVersion: PREVALIDATION_FORMAT_VERSION,\n fingerprint,\n semanticFingerprint: semantic,\n defaultSettings,\n exampleSettings,\n };\n}\n\nfunction hasPlainObjectPrototype(value: JsonObject): boolean {\n try {\n const prototype = Reflect.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n } catch {\n return false;\n }\n}\n\n/**\n * Hydrates a settings definition from a checked-in authoring-validated artifact.\n *\n * This startup path deliberately omits schema documentation/default/example validation. Generation\n * performs those exhaustive checks. Runtime fingerprints reject JSON-visible drift before any\n * settings files are loaded. Codec function text is checked only by the authoring `check` command:\n * Pi and bundlers transform functions without changing their behavior.\n */\nexport function definePrevalidatedExtensionSettings<const Schema extends TObject>(\n input: ExtensionSettingsDefinitionInput<Schema>,\n artifact: PrevalidatedExtensionSettingsArtifact,\n): ExtensionSettingsDefinition<Schema> {\n if (artifact.formatVersion !== PREVALIDATION_FORMAT_VERSION) {\n throw new InvalidPrevalidatedSettingsArtifact(\n `unsupported prevalidation format version: ${String(artifact.formatVersion)}`,\n );\n }\n if (!hasPlainObjectPrototype(artifact.defaultSettings)) {\n throw new InvalidPrevalidatedSettingsArtifact(\n \"prevalidated defaultSettings must be a JSON object\",\n );\n }\n if (\n artifact.exampleSettings !== undefined &&\n !hasPlainObjectPrototype(artifact.exampleSettings)\n ) {\n throw new InvalidPrevalidatedSettingsArtifact(\n \"prevalidated exampleSettings must be a JSON object\",\n );\n }\n\n const expectedFingerprint = prevalidatedExtensionSettingsFingerprint(\n input,\n artifact.defaultSettings,\n artifact.exampleSettings,\n );\n if (artifact.fingerprint !== expectedFingerprint) {\n throw new InvalidPrevalidatedSettingsArtifact(\n \"prevalidated settings artifact is stale; run pi-extension-settings generate\",\n );\n }\n\n const schema = Value.Clone(input.schema);\n const defaultSettings = cloneJson(artifact.defaultSettings);\n const exampleSettings =\n artifact.exampleSettings === undefined ? undefined : cloneJson(artifact.exampleSettings);\n freezeRecursively(schema, input.schema);\n freezeRecursively(defaultSettings, artifact.defaultSettings);\n if (exampleSettings !== undefined && artifact.exampleSettings !== undefined) {\n freezeRecursively(exampleSettings, artifact.exampleSettings);\n }\n\n return Object.freeze({\n [definitionMarker]: true as const,\n id: input.id,\n title: input.title,\n description: input.description,\n schemaId: normalizedSchemaId(input),\n schema,\n defaultSettings,\n exampleSettings,\n });\n}\n", "export const extensionSettingsDefinitionMarker = Symbol.for(\n \"@zigai/pi-extension-settings/definition\",\n);\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,kBAAkB;AAG3B,SAAS,aAAa;;;ACHf,IAAM,oCAAoC,uBAAO;AAAA,EACpD;AACJ;;;ADUA,IAAM,+BAA+B;AAiC9B,IAAM,sCAAN,cAAkD,MAAM;AAAA,EACzC,OAAO;AAC7B;AAEA,SAAS,UAAoC,OAAqB;AAC9D,SAAO,gBAAgB,KAAK;AAChC;AAEA,SAAS,kBAAwC,OAAc,UAAuB;AAClF,QAAM,UAAoB,CAAC,UAAU,KAAK;AAC1C,SAAO,QAAQ,SAAS,GAAG;AACvB,UAAM,UAAU,QAAQ,IAAI;AAC5B,UAAM,SAAS,QAAQ,IAAI;AAC3B,QACI,YAAY,UACZ,WAAW,UACX,YAAY,UACZ,OAAO,SAAS,OAAO;AAEvB;AACJ,eAAW,OAAO,QAAQ,QAAQ,OAAO,GAAG;AACxC,YAAM,a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A,EACJ;AAEA,QAAM,SAAS,MAAM,MAAM,MAAM,MAAM;AACvC,QAAM,kBAAkB,UAAU,SAAS,eAAe;AAC1D,QAAM,kBACF,SAAS,oBAAoB,SAAY,SAAY,UAAU,SAAS,eAAe;AAC3F,oBAAkB,QAAQ,MAAM,MAAM;AACtC,oBAAkB,iBAAiB,SAAS,eAAe;AAC3D,MAAI,oBAAoB,UAAa,SAAS,oBAAoB,QAAW;AACzE,sBAAkB,iBAAiB,SAAS,eAAe;AAAA,EAC/D;AAEA,SAAO,OAAO,OAAO;AAAA,IACjB,CAAC,iCAAgB,GAAG;AAAA,IACpB,IAAI,MAAM;AAAA,IACV,OAAO,MAAM;AAAA,IACb,aAAa,MAAM;AAAA,IACnB,UAAU,mBAAmB,KAAK;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,EACJ,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TSchema } from "typebox";
|
|
2
|
+
import { type JsonObject } from "./json-value.ts";
|
|
3
|
+
export declare const JSON_SCHEMA_DIALECT = "https://json-schema.org/draft/2020-12/schema";
|
|
4
|
+
export type SchemaDocumentInput = {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly description: string;
|
|
8
|
+
readonly schemaId: string;
|
|
9
|
+
readonly schema: TSchema;
|
|
10
|
+
};
|
|
11
|
+
export declare function hasReservedSchemaProperty(schema: TSchema): boolean;
|
|
12
|
+
export declare function findUndocumentedSettings(schema: TSchema): readonly string[];
|
|
13
|
+
export declare function findNonStrictObjectSchemas(schema: TSchema): readonly string[];
|
|
14
|
+
export declare function createSettingsFileSchema(input: SchemaDocumentInput): JsonObject;
|
|
15
|
+
export declare function createSettingsDocument(id: string, settings: JsonObject, schemaReference?: string): JsonObject;
|
|
16
|
+
export declare function createDefaultSettingsDocument(input: SchemaDocumentInput & {
|
|
17
|
+
readonly defaultSettings: JsonObject;
|
|
18
|
+
}): JsonObject;
|
|
19
|
+
//# sourceMappingURL=schema-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-document.d.ts","sourceRoot":"","sources":["../src/schema-document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAKH,KAAK,UAAU,EAGlB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,mBAAmB,iDAAiD,CAAC;AAElF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC5B,CAAC;AA8FF,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAGlE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAwB3E;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAY7E;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,mBAAmB,GAAG,UAAU,CAkC/E;AAED,wBAAgB,sBAAsB,CAClC,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,UAAU,EACpB,eAAe,SAAgC,GAChD,UAAU,CAQZ;AAED,wBAAgB,6BAA6B,CACzC,KAAK,EAAE,mBAAmB,GAAG;IAAE,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAA;CAAE,GACtE,UAAU,CAEZ"}
|