@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,345 @@
|
|
|
1
|
+
const TRAILING_PUNCTUATION = new Set([".", ",", ";", ":", "!", "?", ")", "}", "]"]);
|
|
2
|
+
|
|
3
|
+
export type ChainDefinition = {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly trigger: string;
|
|
6
|
+
readonly separator?: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ParsedChain = {
|
|
10
|
+
readonly sourceId: string;
|
|
11
|
+
readonly trigger: string;
|
|
12
|
+
readonly start: number;
|
|
13
|
+
readonly end: number;
|
|
14
|
+
readonly segments: readonly string[];
|
|
15
|
+
readonly complete: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ChainSegmentSpan = {
|
|
19
|
+
readonly index: number;
|
|
20
|
+
readonly start: number;
|
|
21
|
+
readonly end: number;
|
|
22
|
+
readonly contentStart: number;
|
|
23
|
+
readonly contentEnd: number;
|
|
24
|
+
readonly value: string;
|
|
25
|
+
readonly quoted: boolean;
|
|
26
|
+
readonly complete: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ActiveChainSegment = {
|
|
30
|
+
readonly chain: ParsedChain;
|
|
31
|
+
readonly separator: string;
|
|
32
|
+
readonly index: number;
|
|
33
|
+
readonly query: string;
|
|
34
|
+
readonly path: readonly string[];
|
|
35
|
+
readonly start: number;
|
|
36
|
+
readonly end: number;
|
|
37
|
+
readonly ownedEnd: number;
|
|
38
|
+
readonly span: ChainSegmentSpan;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type ParsedChainWithSpans = {
|
|
42
|
+
readonly chain: ParsedChain;
|
|
43
|
+
readonly separator: string;
|
|
44
|
+
readonly spans: readonly ChainSegmentSpan[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function separatorOf(definition: ChainDefinition): string {
|
|
48
|
+
return definition.separator ?? ":";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function assertDefinitions(definitions: readonly ChainDefinition[]): void {
|
|
52
|
+
const triggers = new Set<string>();
|
|
53
|
+
for (const definition of definitions) {
|
|
54
|
+
if (definition.id.length === 0) throw new Error("Mention source id must not be empty.");
|
|
55
|
+
if (definition.trigger.length === 0) throw new Error("Mention trigger must not be empty.");
|
|
56
|
+
|
|
57
|
+
if (separatorOf(definition).length === 0) {
|
|
58
|
+
throw new Error(`Mention separator for ${definition.id} must not be empty.`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (triggers.has(definition.trigger)) {
|
|
62
|
+
throw new Error(`Duplicate mention trigger: ${definition.trigger}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
triggers.add(definition.trigger);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isTriggerBoundary(text: string, start: number): boolean {
|
|
70
|
+
if (start <= 0) return true;
|
|
71
|
+
|
|
72
|
+
const previous = text.at(start - 1);
|
|
73
|
+
if (previous === undefined) return true;
|
|
74
|
+
return !/[\p{L}\p{N}_\\]/u.test(previous);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function decodeEscapes(value: string): string {
|
|
78
|
+
let decoded = "";
|
|
79
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
80
|
+
const character = value.at(index);
|
|
81
|
+
if (character === "\\" && index + 1 < value.length) {
|
|
82
|
+
decoded += value[index + 1];
|
|
83
|
+
index += 1;
|
|
84
|
+
} else if (character !== undefined) {
|
|
85
|
+
decoded += character;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return decoded;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function parseChainAt(
|
|
93
|
+
text: string,
|
|
94
|
+
start: number,
|
|
95
|
+
definition: ChainDefinition,
|
|
96
|
+
): ParsedChainWithSpans {
|
|
97
|
+
const separator = separatorOf(definition);
|
|
98
|
+
const bodyStart = start + definition.trigger.length;
|
|
99
|
+
const spans: ChainSegmentSpan[] = [];
|
|
100
|
+
const segments: string[] = [];
|
|
101
|
+
let cursor = bodyStart;
|
|
102
|
+
let expectsSegment = true;
|
|
103
|
+
let syntaxComplete = true;
|
|
104
|
+
|
|
105
|
+
while (cursor < text.length) {
|
|
106
|
+
const first = text.at(cursor);
|
|
107
|
+
if (first === undefined || /\s/u.test(first)) break;
|
|
108
|
+
|
|
109
|
+
const segmentStart = cursor;
|
|
110
|
+
let contentStart = cursor;
|
|
111
|
+
let contentEnd = cursor;
|
|
112
|
+
let segmentEnd = cursor;
|
|
113
|
+
let value = "";
|
|
114
|
+
let quoted = false;
|
|
115
|
+
let segmentComplete = true;
|
|
116
|
+
|
|
117
|
+
if (first === '"') {
|
|
118
|
+
quoted = true;
|
|
119
|
+
contentStart = cursor + 1;
|
|
120
|
+
cursor += 1;
|
|
121
|
+
|
|
122
|
+
let closed = false;
|
|
123
|
+
while (cursor < text.length) {
|
|
124
|
+
const character = text.at(cursor);
|
|
125
|
+
if (character === "\\" && cursor + 1 < text.length) {
|
|
126
|
+
const escaped = text.at(cursor + 1);
|
|
127
|
+
if (escaped !== undefined) value += escaped;
|
|
128
|
+
cursor += 2;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (character === '"') {
|
|
133
|
+
contentEnd = cursor;
|
|
134
|
+
cursor += 1;
|
|
135
|
+
closed = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (character === undefined || character === "\n" || character === "\r") break;
|
|
140
|
+
|
|
141
|
+
value += character;
|
|
142
|
+
cursor += 1;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!closed) {
|
|
146
|
+
contentEnd = cursor;
|
|
147
|
+
segmentComplete = false;
|
|
148
|
+
syntaxComplete = false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
segmentEnd = cursor;
|
|
152
|
+
} else {
|
|
153
|
+
while (cursor < text.length) {
|
|
154
|
+
const character = text.at(cursor);
|
|
155
|
+
if (character === undefined || /\s/u.test(character)) break;
|
|
156
|
+
if (text.startsWith(separator, cursor)) break;
|
|
157
|
+
|
|
158
|
+
if (character === "\\" && cursor + 1 < text.length) {
|
|
159
|
+
cursor += 2;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
cursor += 1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
segmentEnd = cursor;
|
|
167
|
+
contentEnd = cursor;
|
|
168
|
+
|
|
169
|
+
let raw = text.slice(contentStart, contentEnd);
|
|
170
|
+
while (raw.length > 0) {
|
|
171
|
+
const last = raw.at(-1);
|
|
172
|
+
let precedingBackslashes = 0;
|
|
173
|
+
for (let index = raw.length - 2; index >= 0 && raw[index] === "\\"; index -= 1) {
|
|
174
|
+
precedingBackslashes += 1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const escaped = precedingBackslashes % 2 === 1;
|
|
178
|
+
if (last === undefined || escaped || !TRAILING_PUNCTUATION.has(last)) break;
|
|
179
|
+
|
|
180
|
+
raw = raw.slice(0, -1);
|
|
181
|
+
cursor -= 1;
|
|
182
|
+
segmentEnd -= 1;
|
|
183
|
+
contentEnd -= 1;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
value = decodeEscapes(raw);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (segmentEnd === segmentStart && !quoted) break;
|
|
190
|
+
|
|
191
|
+
spans.push({
|
|
192
|
+
index: spans.length,
|
|
193
|
+
start: segmentStart,
|
|
194
|
+
end: segmentEnd,
|
|
195
|
+
contentStart,
|
|
196
|
+
contentEnd,
|
|
197
|
+
value,
|
|
198
|
+
quoted,
|
|
199
|
+
complete: segmentComplete,
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
segments.push(value);
|
|
203
|
+
expectsSegment = false;
|
|
204
|
+
|
|
205
|
+
if (!segmentComplete || !text.startsWith(separator, cursor)) break;
|
|
206
|
+
|
|
207
|
+
cursor += separator.length;
|
|
208
|
+
expectsSegment = true;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const end = cursor;
|
|
212
|
+
const complete = segments.length > 0 && !expectsSegment && syntaxComplete;
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
chain: {
|
|
216
|
+
sourceId: definition.id,
|
|
217
|
+
trigger: definition.trigger,
|
|
218
|
+
start,
|
|
219
|
+
end,
|
|
220
|
+
segments,
|
|
221
|
+
complete,
|
|
222
|
+
},
|
|
223
|
+
separator,
|
|
224
|
+
spans,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function parseMentionsWithSpans(
|
|
229
|
+
text: string,
|
|
230
|
+
definitions: readonly ChainDefinition[],
|
|
231
|
+
): readonly ParsedChainWithSpans[] {
|
|
232
|
+
assertDefinitions(definitions);
|
|
233
|
+
|
|
234
|
+
const ordered = [...definitions].sort(
|
|
235
|
+
(left, right) => right.trigger.length - left.trigger.length,
|
|
236
|
+
);
|
|
237
|
+
const parsed: ParsedChainWithSpans[] = [];
|
|
238
|
+
|
|
239
|
+
for (let index = 0; index < text.length; ) {
|
|
240
|
+
let definition: ChainDefinition | undefined;
|
|
241
|
+
for (const candidate of ordered) {
|
|
242
|
+
if (text.startsWith(candidate.trigger, index) && isTriggerBoundary(text, index)) {
|
|
243
|
+
definition = candidate;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (definition === undefined) {
|
|
249
|
+
index += 1;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const mention = parseChainAt(text, index, definition);
|
|
254
|
+
parsed.push(mention);
|
|
255
|
+
index = Math.max(index + definition.trigger.length, mention.chain.end);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return parsed;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Parses registered mention chains without resolving their provider-owned segment values. */
|
|
262
|
+
export function parseMentions(
|
|
263
|
+
text: string,
|
|
264
|
+
definitions: readonly ChainDefinition[],
|
|
265
|
+
): readonly ParsedChain[] {
|
|
266
|
+
return parseMentionsWithSpans(text, definitions).map((parsed) => parsed.chain);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function queryThroughCursor(text: string, span: ChainSegmentSpan, cursor: number): string {
|
|
270
|
+
const through = Math.min(Math.max(cursor, span.contentStart), span.contentEnd);
|
|
271
|
+
return decodeEscapes(text.slice(span.contentStart, through));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Finds the segment edited at an absolute cursor and the chain suffix that completion owns. */
|
|
275
|
+
export function activeChainSegment(
|
|
276
|
+
text: string,
|
|
277
|
+
definitions: readonly ChainDefinition[],
|
|
278
|
+
cursor: number,
|
|
279
|
+
): ActiveChainSegment | undefined {
|
|
280
|
+
for (const parsed of parseMentionsWithSpans(text, definitions)) {
|
|
281
|
+
const bodyStart = parsed.chain.start + parsed.chain.trigger.length;
|
|
282
|
+
if (cursor < bodyStart || cursor > parsed.chain.end) continue;
|
|
283
|
+
|
|
284
|
+
for (const span of parsed.spans) {
|
|
285
|
+
if (cursor < span.start || cursor > span.end) continue;
|
|
286
|
+
return {
|
|
287
|
+
chain: parsed.chain,
|
|
288
|
+
separator: parsed.separator,
|
|
289
|
+
index: span.index,
|
|
290
|
+
query: queryThroughCursor(text, span, cursor),
|
|
291
|
+
path: parsed.chain.segments.slice(0, span.index),
|
|
292
|
+
start: span.start,
|
|
293
|
+
end: span.end,
|
|
294
|
+
ownedEnd: parsed.chain.end,
|
|
295
|
+
span,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const index = parsed.spans.length;
|
|
300
|
+
const emptySpan: ChainSegmentSpan = {
|
|
301
|
+
index,
|
|
302
|
+
start: cursor,
|
|
303
|
+
end: cursor,
|
|
304
|
+
contentStart: cursor,
|
|
305
|
+
contentEnd: cursor,
|
|
306
|
+
value: "",
|
|
307
|
+
quoted: false,
|
|
308
|
+
complete: false,
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
return {
|
|
312
|
+
chain: parsed.chain,
|
|
313
|
+
separator: parsed.separator,
|
|
314
|
+
index,
|
|
315
|
+
query: "",
|
|
316
|
+
path: parsed.chain.segments,
|
|
317
|
+
start: cursor,
|
|
318
|
+
end: cursor,
|
|
319
|
+
ownedEnd: parsed.chain.end,
|
|
320
|
+
span: emptySpan,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return undefined;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function formatSegment(segment: string, separator: string): string {
|
|
328
|
+
if (
|
|
329
|
+
segment.length > 0 &&
|
|
330
|
+
!segment.includes(separator) &&
|
|
331
|
+
!/[\s"\\]/u.test(segment) &&
|
|
332
|
+
!TRAILING_PUNCTUATION.has(segment[segment.length - 1] ?? "")
|
|
333
|
+
) {
|
|
334
|
+
return segment;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
return `"${segment.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Formats independently quoted chain segments using the same grammar as parseMentions. */
|
|
341
|
+
export function formatChain(segments: readonly string[], trigger: string, separator = ":"): string {
|
|
342
|
+
if (trigger.length === 0) throw new Error("Mention trigger must not be empty.");
|
|
343
|
+
if (separator.length === 0) throw new Error("Mention separator must not be empty.");
|
|
344
|
+
return `${trigger}${segments.map((segment) => formatSegment(segment, separator)).join(separator)}`;
|
|
345
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import { Value } from "typebox/value";
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
discoveryResponseSchema,
|
|
7
|
+
resolutionSchema,
|
|
8
|
+
type Candidate,
|
|
9
|
+
type DiscoveryResponse,
|
|
10
|
+
type Provider,
|
|
11
|
+
type Resolution,
|
|
12
|
+
} from "./source-contract.ts";
|
|
13
|
+
|
|
14
|
+
export const COMMAND_PROVIDER_PROTOCOL_VERSION = 1 as const;
|
|
15
|
+
const DEFAULT_MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
16
|
+
const DEFAULT_TIMEOUT_MS = 5_000;
|
|
17
|
+
|
|
18
|
+
export type CommandProcessOptions = {
|
|
19
|
+
readonly command: string;
|
|
20
|
+
readonly args: readonly string[];
|
|
21
|
+
readonly cwd: string;
|
|
22
|
+
readonly timeoutMs?: number;
|
|
23
|
+
readonly maxOutputBytes?: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type CommandProviderOptions = CommandProcessOptions & {
|
|
27
|
+
readonly filtering?: "local" | "provider";
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type CommandDiscoveryRequestV1 = {
|
|
31
|
+
readonly version: typeof COMMAND_PROVIDER_PROTOCOL_VERSION;
|
|
32
|
+
readonly method: "discover";
|
|
33
|
+
readonly sourceId: string;
|
|
34
|
+
readonly cwd: string;
|
|
35
|
+
readonly trusted: boolean;
|
|
36
|
+
readonly query: string;
|
|
37
|
+
readonly path: readonly Candidate[];
|
|
38
|
+
readonly limit: number;
|
|
39
|
+
readonly cursor?: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type CommandResolveRequestV1 = {
|
|
43
|
+
readonly version: typeof COMMAND_PROVIDER_PROTOCOL_VERSION;
|
|
44
|
+
readonly method: "resolve";
|
|
45
|
+
readonly sourceId: string;
|
|
46
|
+
readonly cwd: string;
|
|
47
|
+
readonly trusted: boolean;
|
|
48
|
+
readonly segments: readonly string[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type CommandRequestV1 = CommandDiscoveryRequestV1 | CommandResolveRequestV1;
|
|
52
|
+
|
|
53
|
+
export type CommandDiscoveryResponseV1 = {
|
|
54
|
+
readonly version: typeof COMMAND_PROVIDER_PROTOCOL_VERSION;
|
|
55
|
+
readonly method: "discover";
|
|
56
|
+
readonly result: DiscoveryResponse;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type CommandResolveResponseV1 = {
|
|
60
|
+
readonly version: typeof COMMAND_PROVIDER_PROTOCOL_VERSION;
|
|
61
|
+
readonly method: "resolve";
|
|
62
|
+
readonly result: Resolution;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export type CommandResponseV1 = CommandDiscoveryResponseV1 | CommandResolveResponseV1;
|
|
66
|
+
|
|
67
|
+
const commandDiscoveryResponseSchema = Type.Object(
|
|
68
|
+
{
|
|
69
|
+
version: Type.Literal(COMMAND_PROVIDER_PROTOCOL_VERSION),
|
|
70
|
+
method: Type.Literal("discover"),
|
|
71
|
+
result: discoveryResponseSchema,
|
|
72
|
+
},
|
|
73
|
+
{ additionalProperties: false },
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const commandResolveResponseSchema = Type.Object(
|
|
77
|
+
{
|
|
78
|
+
version: Type.Literal(COMMAND_PROVIDER_PROTOCOL_VERSION),
|
|
79
|
+
method: Type.Literal("resolve"),
|
|
80
|
+
result: resolutionSchema,
|
|
81
|
+
},
|
|
82
|
+
{ additionalProperties: false },
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
function validateProcessOptions(options: CommandProcessOptions): void {
|
|
86
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
87
|
+
const maxOutputBytes = options.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
|
|
88
|
+
|
|
89
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
90
|
+
throw new Error("timeoutMs must be positive");
|
|
91
|
+
|
|
92
|
+
if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes <= 0) {
|
|
93
|
+
throw new Error("maxOutputBytes must be a positive integer");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function killProcessTree(child: ReturnType<typeof spawn>): void {
|
|
98
|
+
const pid = child.pid;
|
|
99
|
+
if (pid !== undefined && process.platform !== "win32") {
|
|
100
|
+
try {
|
|
101
|
+
process.kill(-pid, "SIGKILL");
|
|
102
|
+
return;
|
|
103
|
+
} catch {
|
|
104
|
+
// The process may have exited between the event and termination attempt.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
child.kill("SIGKILL");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Executes a JSON-producing command without a shell. An undefined request closes stdin without
|
|
113
|
+
* writing bytes, which is the explicit adapter for commands that only return a JSON array.
|
|
114
|
+
*/
|
|
115
|
+
/* oxlint-disable antislop/no-unknown-returns, typescript/no-redundant-type-constituents -- The requested low-level JSON adapter intentionally leaves parsing to its caller. */
|
|
116
|
+
export async function executeJsonCommand(
|
|
117
|
+
options: CommandProcessOptions,
|
|
118
|
+
request: unknown | undefined,
|
|
119
|
+
signal: AbortSignal,
|
|
120
|
+
): Promise<unknown> {
|
|
121
|
+
validateProcessOptions(options);
|
|
122
|
+
signal.throwIfAborted();
|
|
123
|
+
let input: string | undefined;
|
|
124
|
+
if (request !== undefined) {
|
|
125
|
+
try {
|
|
126
|
+
// JSON.stringify returns undefined for unsupported top-level values.
|
|
127
|
+
const stringify: (...args: Parameters<typeof JSON.stringify>) => string | undefined =
|
|
128
|
+
JSON.stringify;
|
|
129
|
+
input = stringify(request);
|
|
130
|
+
} catch {
|
|
131
|
+
return Promise.reject(new Error("command request must be JSON serializable"));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (input === undefined) {
|
|
135
|
+
return Promise.reject(new Error("command request must be JSON serializable"));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const child = spawn(options.command, [...options.args], {
|
|
140
|
+
cwd: options.cwd,
|
|
141
|
+
detached: process.platform !== "win32",
|
|
142
|
+
shell: false,
|
|
143
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
return new Promise<unknown>((resolve, reject) => {
|
|
147
|
+
const stdout: Buffer[] = [];
|
|
148
|
+
const maxOutputBytes = options.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;
|
|
149
|
+
let outputBytes = 0;
|
|
150
|
+
let failure: Error | undefined;
|
|
151
|
+
let settled = false;
|
|
152
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
153
|
+
let abortListener: (() => void) | undefined;
|
|
154
|
+
|
|
155
|
+
const finishFailure = (cause: Error): void => {
|
|
156
|
+
if (settled) return;
|
|
157
|
+
|
|
158
|
+
settled = true;
|
|
159
|
+
clearTimeout(timeout);
|
|
160
|
+
|
|
161
|
+
if (abortListener !== undefined) signal.removeEventListener("abort", abortListener);
|
|
162
|
+
killProcessTree(child);
|
|
163
|
+
reject(cause);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
abortListener = (): void => {
|
|
167
|
+
let cause: Error = new DOMException("The operation was aborted", "AbortError");
|
|
168
|
+
if (signal.reason instanceof Error) cause = signal.reason;
|
|
169
|
+
finishFailure(cause);
|
|
170
|
+
};
|
|
171
|
+
timeout = setTimeout(
|
|
172
|
+
() => finishFailure(new Error("command timed out")),
|
|
173
|
+
options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
signal.addEventListener("abort", abortListener, { once: true });
|
|
177
|
+
child.once("error", () => {
|
|
178
|
+
finishFailure(new Error("command could not be started"));
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
child.stdin.once("error", () => {
|
|
182
|
+
if (!settled) failure = new Error("command stdin failed");
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
child.stdout.on("data", (chunk: Buffer) => {
|
|
186
|
+
outputBytes += chunk.byteLength;
|
|
187
|
+
if (outputBytes > maxOutputBytes) {
|
|
188
|
+
failure = new Error("command output exceeded maxOutputBytes");
|
|
189
|
+
killProcessTree(child);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
stdout.push(chunk);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
child.stderr.on("data", (chunk: Buffer) => {
|
|
197
|
+
outputBytes += chunk.byteLength;
|
|
198
|
+
if (outputBytes > maxOutputBytes) {
|
|
199
|
+
failure = new Error("command output exceeded maxOutputBytes");
|
|
200
|
+
killProcessTree(child);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
child.once("close", (code, closeSignal) => {
|
|
205
|
+
if (settled) return;
|
|
206
|
+
|
|
207
|
+
settled = true;
|
|
208
|
+
clearTimeout(timeout);
|
|
209
|
+
signal.removeEventListener("abort", abortListener);
|
|
210
|
+
|
|
211
|
+
if (failure !== undefined) {
|
|
212
|
+
reject(failure);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (code !== 0 || closeSignal !== null) {
|
|
217
|
+
reject(new Error("command failed"));
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
try {
|
|
222
|
+
resolve(JSON.parse(Buffer.concat(stdout).toString("utf8")));
|
|
223
|
+
} catch {
|
|
224
|
+
reject(new Error("command stdout must contain one JSON value"));
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
if (input === undefined) child.stdin.end();
|
|
229
|
+
else child.stdin.end(`${input}\n`);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/* oxlint-enable antislop/no-unknown-returns, typescript/no-redundant-type-constituents */
|
|
233
|
+
|
|
234
|
+
/** Adapts the explicit version-1 stdin/stdout protocol to the shared provider contract. */
|
|
235
|
+
export function createCommandProvider(options: CommandProviderOptions): Provider {
|
|
236
|
+
validateProcessOptions(options);
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
filtering: options.filtering ?? "provider",
|
|
240
|
+
async discover(request) {
|
|
241
|
+
let commandRequest: CommandDiscoveryRequestV1;
|
|
242
|
+
if (request.cursor === undefined) {
|
|
243
|
+
commandRequest = {
|
|
244
|
+
version: COMMAND_PROVIDER_PROTOCOL_VERSION,
|
|
245
|
+
method: "discover",
|
|
246
|
+
sourceId: request.sourceId,
|
|
247
|
+
cwd: request.cwd,
|
|
248
|
+
trusted: request.trusted,
|
|
249
|
+
query: request.query,
|
|
250
|
+
path: request.path,
|
|
251
|
+
limit: request.limit,
|
|
252
|
+
};
|
|
253
|
+
} else {
|
|
254
|
+
commandRequest = {
|
|
255
|
+
version: COMMAND_PROVIDER_PROTOCOL_VERSION,
|
|
256
|
+
method: "discover",
|
|
257
|
+
sourceId: request.sourceId,
|
|
258
|
+
cwd: request.cwd,
|
|
259
|
+
trusted: request.trusted,
|
|
260
|
+
query: request.query,
|
|
261
|
+
path: request.path,
|
|
262
|
+
limit: request.limit,
|
|
263
|
+
cursor: request.cursor,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const response = await executeJsonCommand(options, commandRequest, request.signal);
|
|
268
|
+
try {
|
|
269
|
+
return Value.Parse(commandDiscoveryResponseSchema, response).result;
|
|
270
|
+
} catch {
|
|
271
|
+
throw new Error("command returned an invalid protocol v1 response");
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
async resolve(request) {
|
|
275
|
+
const commandRequest: CommandResolveRequestV1 = {
|
|
276
|
+
version: COMMAND_PROVIDER_PROTOCOL_VERSION,
|
|
277
|
+
method: "resolve",
|
|
278
|
+
sourceId: request.sourceId,
|
|
279
|
+
cwd: request.cwd,
|
|
280
|
+
trusted: request.trusted,
|
|
281
|
+
segments: request.segments,
|
|
282
|
+
};
|
|
283
|
+
const response = await executeJsonCommand(options, commandRequest, request.signal);
|
|
284
|
+
try {
|
|
285
|
+
return Value.Parse(commandResolveResponseSchema, response).result;
|
|
286
|
+
} catch {
|
|
287
|
+
throw new Error("command returned an invalid protocol v1 response");
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { Value } from "typebox/value";
|
|
3
|
+
import { createCommandProvider, executeJsonCommand } from "./command-provider.ts";
|
|
4
|
+
import { createListProvider } from "./list-provider.ts";
|
|
5
|
+
import {
|
|
6
|
+
mentionItemSchema,
|
|
7
|
+
type ConfiguredMention,
|
|
8
|
+
type ConfiguredMentionItem,
|
|
9
|
+
} from "./settings-input.ts";
|
|
10
|
+
import type { Candidate, DiscoveryRequest, Provider } from "./source-contract.ts";
|
|
11
|
+
|
|
12
|
+
const itemsSchema = Type.Array(mentionItemSchema, { maxItems: 10000 });
|
|
13
|
+
|
|
14
|
+
function candidateOf(item: ConfiguredMentionItem): Candidate {
|
|
15
|
+
return {
|
|
16
|
+
id: item.id ?? item.name,
|
|
17
|
+
label: item.name,
|
|
18
|
+
segment: item.segment ?? item.name,
|
|
19
|
+
description: item.description,
|
|
20
|
+
searchText: item.searchText,
|
|
21
|
+
insertionText: item.insertionText,
|
|
22
|
+
selectable: item.selectable ?? item.navigable !== true,
|
|
23
|
+
navigable: item.navigable ?? false,
|
|
24
|
+
replacement: item.replacement,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function children(
|
|
29
|
+
items: readonly ConfiguredMentionItem[],
|
|
30
|
+
request: DiscoveryRequest,
|
|
31
|
+
): readonly Candidate[] {
|
|
32
|
+
const ids = request.path.map((candidate) => candidate.id);
|
|
33
|
+
|
|
34
|
+
return items
|
|
35
|
+
.filter((item) => {
|
|
36
|
+
const parent = item.parentPath ?? [];
|
|
37
|
+
|
|
38
|
+
return parent.length === ids.length && parent.every((id, index) => id === ids[index]);
|
|
39
|
+
})
|
|
40
|
+
.map(candidateOf);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Settings and commands adapt to the same contract; cache policy belongs to the source controller. */
|
|
44
|
+
export function createConfiguredProvider(mention: ConfiguredMention, cwd: string): Provider {
|
|
45
|
+
const source = mention.source;
|
|
46
|
+
if (source.type === "static")
|
|
47
|
+
return createListProvider(async (request) => children(source.items, request));
|
|
48
|
+
|
|
49
|
+
const options = {
|
|
50
|
+
command: source.command,
|
|
51
|
+
args: source.args,
|
|
52
|
+
cwd,
|
|
53
|
+
timeoutMs: source.timeoutMs,
|
|
54
|
+
maxOutputBytes: source.maxOutputBytes,
|
|
55
|
+
};
|
|
56
|
+
if (source.mode === "protocol")
|
|
57
|
+
return createCommandProvider({ ...options, filtering: source.filtering ?? "provider" });
|
|
58
|
+
|
|
59
|
+
return createListProvider(async (request) => {
|
|
60
|
+
const raw = await executeJsonCommand(options, undefined, request.signal);
|
|
61
|
+
if (!Value.Check(itemsSchema, raw))
|
|
62
|
+
throw new Error("Mention array command returned invalid candidates.");
|
|
63
|
+
|
|
64
|
+
return children(raw, request);
|
|
65
|
+
});
|
|
66
|
+
}
|