@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,596 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AutocompleteItem,
|
|
3
|
+
type AutocompleteProvider,
|
|
4
|
+
fuzzyFilter,
|
|
5
|
+
} from "@earendil-works/pi-tui";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
activeChainSegment,
|
|
9
|
+
formatChain,
|
|
10
|
+
isTriggerBoundary,
|
|
11
|
+
type ActiveChainSegment,
|
|
12
|
+
} from "./chain-syntax.ts";
|
|
13
|
+
import type { Candidate, Resolution } from "./source-contract.ts";
|
|
14
|
+
|
|
15
|
+
export type ChainCompletionSource = {
|
|
16
|
+
readonly id: string;
|
|
17
|
+
readonly trigger: string;
|
|
18
|
+
readonly separator?: string;
|
|
19
|
+
readonly completionSuffix: string;
|
|
20
|
+
readonly filtering: "local" | "provider";
|
|
21
|
+
|
|
22
|
+
discover(request: {
|
|
23
|
+
readonly query: string;
|
|
24
|
+
readonly path: readonly Candidate[];
|
|
25
|
+
readonly cursor?: string;
|
|
26
|
+
readonly signal?: AbortSignal;
|
|
27
|
+
}): Promise<{ readonly items: readonly Candidate[]; readonly nextCursor?: string }>;
|
|
28
|
+
|
|
29
|
+
resolve(segments: readonly string[], signal?: AbortSignal): Promise<Resolution>;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export type ChainSelection = {
|
|
33
|
+
readonly sourceId: string;
|
|
34
|
+
readonly start: number;
|
|
35
|
+
readonly end: number;
|
|
36
|
+
readonly text: string;
|
|
37
|
+
readonly path: readonly Candidate[];
|
|
38
|
+
readonly editorText: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ChainAutocompleteOptions = {
|
|
42
|
+
readonly current: AutocompleteProvider;
|
|
43
|
+
readonly sources: readonly ChainCompletionSource[];
|
|
44
|
+
readonly onSelection?: (selection: ChainSelection) => void;
|
|
45
|
+
|
|
46
|
+
readonly resolveSelected?: (
|
|
47
|
+
sourceId: string,
|
|
48
|
+
segments: readonly string[],
|
|
49
|
+
start: number,
|
|
50
|
+
) => readonly Candidate[] | undefined;
|
|
51
|
+
|
|
52
|
+
readonly onState?: (sourceId: string, status: "ready" | "unresolved" | "failed") => void;
|
|
53
|
+
readonly onContinue?: () => void;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const MAX_CONTINUATION_PATHS = 64;
|
|
57
|
+
|
|
58
|
+
export type ChainAutocompleteProvider = AutocompleteProvider & {
|
|
59
|
+
reconcile(text: string): void;
|
|
60
|
+
dispose(): void;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type ContinuationPath = {
|
|
64
|
+
readonly sourceId: string;
|
|
65
|
+
readonly start: number;
|
|
66
|
+
readonly end: number;
|
|
67
|
+
readonly text: string;
|
|
68
|
+
readonly path: readonly Candidate[];
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const MAX_PAGE_SCOPES = 32;
|
|
72
|
+
const MAX_PAGES_PER_SCOPE = 10;
|
|
73
|
+
const MAX_RETAINED_CANDIDATES = 1_000;
|
|
74
|
+
const MAX_LOCAL_SUGGESTIONS = 100;
|
|
75
|
+
|
|
76
|
+
type CompletionAction =
|
|
77
|
+
| {
|
|
78
|
+
readonly kind: "navigate";
|
|
79
|
+
readonly source: ChainCompletionSource;
|
|
80
|
+
readonly active: ActiveChainSegment;
|
|
81
|
+
readonly path: readonly Candidate[];
|
|
82
|
+
readonly candidate: Candidate;
|
|
83
|
+
}
|
|
84
|
+
| {
|
|
85
|
+
readonly kind: "select";
|
|
86
|
+
readonly source: ChainCompletionSource;
|
|
87
|
+
readonly active: ActiveChainSegment;
|
|
88
|
+
readonly path: readonly Candidate[];
|
|
89
|
+
}
|
|
90
|
+
| {
|
|
91
|
+
readonly kind: "more";
|
|
92
|
+
readonly source: ChainCompletionSource;
|
|
93
|
+
readonly active: ActiveChainSegment;
|
|
94
|
+
readonly key: string;
|
|
95
|
+
readonly cursor: string;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type PageState = {
|
|
99
|
+
readonly items: readonly Candidate[];
|
|
100
|
+
readonly pageCount: number;
|
|
101
|
+
readonly requestedCursors: ReadonlySet<string>;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
function absoluteCursor(lines: readonly string[], cursorLine: number, cursorCol: number): number {
|
|
105
|
+
let offset = 0;
|
|
106
|
+
for (let index = 0; index < cursorLine; index += 1) {
|
|
107
|
+
offset += (lines[index]?.length ?? 0) + 1;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return offset + cursorCol;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function cursorPosition(text: string, offset: number) {
|
|
114
|
+
const before = text.slice(0, offset).split("\n");
|
|
115
|
+
return { line: before.length - 1, col: before[before.length - 1]?.length ?? 0 };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function definitionsFor(sources: readonly ChainCompletionSource[]) {
|
|
119
|
+
return sources.map((source) => ({
|
|
120
|
+
id: source.id,
|
|
121
|
+
trigger: source.trigger,
|
|
122
|
+
separator: source.separator,
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function sourceFor(
|
|
127
|
+
sources: readonly ChainCompletionSource[],
|
|
128
|
+
sourceId: string,
|
|
129
|
+
): ChainCompletionSource | undefined {
|
|
130
|
+
return sources.find((source) => source.id === sourceId);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function itemFor(candidate: Candidate): AutocompleteItem {
|
|
134
|
+
const item: AutocompleteItem = { value: candidate.segment, label: candidate.label };
|
|
135
|
+
if (candidate.description !== undefined) item.description = candidate.description;
|
|
136
|
+
|
|
137
|
+
return item;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function occurrenceKey(sourceId: string, start: number): string {
|
|
141
|
+
return `${sourceId}\u0000${start}`;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function pathMatchesSegments(path: readonly Candidate[], segments: readonly string[]): boolean {
|
|
145
|
+
return (
|
|
146
|
+
path.length === segments.length &&
|
|
147
|
+
path.every((candidate, index) => candidate.segment === segments[index])
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function pageKey(
|
|
152
|
+
source: ChainCompletionSource,
|
|
153
|
+
active: ActiveChainSegment,
|
|
154
|
+
path: readonly Candidate[],
|
|
155
|
+
): string {
|
|
156
|
+
return JSON.stringify([
|
|
157
|
+
source.id,
|
|
158
|
+
active.index,
|
|
159
|
+
active.query,
|
|
160
|
+
path.map((candidate) => candidate.id),
|
|
161
|
+
]);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function retainPageState(states: Map<string, PageState>, key: string, state: PageState): void {
|
|
165
|
+
states.delete(key);
|
|
166
|
+
states.set(key, state);
|
|
167
|
+
|
|
168
|
+
while (states.size > MAX_PAGE_SCOPES) {
|
|
169
|
+
const oldest = states.keys().next().value;
|
|
170
|
+
if (oldest === undefined) break;
|
|
171
|
+
|
|
172
|
+
states.delete(oldest);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function completionSuffixFor(textAfterMention: string, suffix: string) {
|
|
177
|
+
if (suffix.length === 0) return { text: "", consume: 0 };
|
|
178
|
+
if (textAfterMention.startsWith(suffix)) return { text: suffix, consume: suffix.length };
|
|
179
|
+
|
|
180
|
+
if (/^\s/u.test(suffix) && /^\s/u.test(textAfterMention)) {
|
|
181
|
+
const existingWhitespace = /^\s/u.exec(textAfterMention)?.[0] ?? "";
|
|
182
|
+
return { text: suffix, consume: existingWhitespace.length };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return { text: suffix, consume: 0 };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function replaceOwnedSuffix(
|
|
189
|
+
lines: string[],
|
|
190
|
+
action: CompletionAction,
|
|
191
|
+
replacement: string,
|
|
192
|
+
consumeAfter = 0,
|
|
193
|
+
) {
|
|
194
|
+
const text = lines.join("\n");
|
|
195
|
+
const start = action.active.chain.start;
|
|
196
|
+
const before = text.slice(0, start);
|
|
197
|
+
const after = text.slice(action.active.ownedEnd + consumeAfter);
|
|
198
|
+
const updated = `${before}${replacement}${after}`;
|
|
199
|
+
const cursorOffset = before.length + replacement.length;
|
|
200
|
+
const cursor = cursorPosition(updated, cursorOffset);
|
|
201
|
+
const mentionStart = start;
|
|
202
|
+
const mentionEnd = cursorOffset;
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
lines: updated.split("\n"),
|
|
206
|
+
cursorLine: cursor.line,
|
|
207
|
+
cursorCol: cursor.col,
|
|
208
|
+
start: mentionStart,
|
|
209
|
+
end: mentionEnd,
|
|
210
|
+
text: updated.slice(mentionStart, mentionEnd),
|
|
211
|
+
editorText: updated,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Creates a chain-aware provider while retaining the caller-owned mutable sources array by reference. */
|
|
216
|
+
export function createChainAutocompleteProvider(
|
|
217
|
+
options: ChainAutocompleteOptions,
|
|
218
|
+
): ChainAutocompleteProvider {
|
|
219
|
+
let actions = new WeakMap<AutocompleteItem, CompletionAction>();
|
|
220
|
+
let activeRequest: AbortController | undefined;
|
|
221
|
+
let requestGeneration = 0;
|
|
222
|
+
let pendingPage: { readonly key: string; readonly cursor: string } | undefined;
|
|
223
|
+
const pageStates = new Map<string, PageState>();
|
|
224
|
+
const continuationPaths = new Map<string, ContinuationPath>();
|
|
225
|
+
let composedTriggerCharacters: string[] = [];
|
|
226
|
+
let previousText = "";
|
|
227
|
+
const reconcile = (text: string): void => {
|
|
228
|
+
if (text === previousText) return;
|
|
229
|
+
|
|
230
|
+
activeRequest?.abort();
|
|
231
|
+
requestGeneration += 1;
|
|
232
|
+
|
|
233
|
+
let prefix = 0;
|
|
234
|
+
while (
|
|
235
|
+
prefix < text.length &&
|
|
236
|
+
prefix < previousText.length &&
|
|
237
|
+
text[prefix] === previousText[prefix]
|
|
238
|
+
)
|
|
239
|
+
prefix += 1;
|
|
240
|
+
|
|
241
|
+
let suffix = 0;
|
|
242
|
+
while (
|
|
243
|
+
suffix < text.length - prefix &&
|
|
244
|
+
suffix < previousText.length - prefix &&
|
|
245
|
+
text[text.length - 1 - suffix] === previousText[previousText.length - 1 - suffix]
|
|
246
|
+
)
|
|
247
|
+
suffix += 1;
|
|
248
|
+
|
|
249
|
+
const oldEnd = previousText.length - suffix;
|
|
250
|
+
const delta = text.length - previousText.length;
|
|
251
|
+
const retained: ContinuationPath[] = [];
|
|
252
|
+
for (const entry of continuationPaths.values()) {
|
|
253
|
+
let updated = entry;
|
|
254
|
+
|
|
255
|
+
if (entry.end <= prefix) {
|
|
256
|
+
const removed = previousText.slice(prefix, oldEnd);
|
|
257
|
+
const inserted = text.slice(prefix, text.length - suffix);
|
|
258
|
+
if (
|
|
259
|
+
entry.end === prefix &&
|
|
260
|
+
(removed.includes(entry.text) || inserted.includes(entry.text))
|
|
261
|
+
)
|
|
262
|
+
continue;
|
|
263
|
+
} else if (entry.start >= oldEnd)
|
|
264
|
+
updated = { ...entry, start: entry.start + delta, end: entry.end + delta };
|
|
265
|
+
else continue;
|
|
266
|
+
|
|
267
|
+
if (
|
|
268
|
+
!isTriggerBoundary(text, updated.start) ||
|
|
269
|
+
text.slice(updated.start, updated.end) !== updated.text
|
|
270
|
+
)
|
|
271
|
+
continue;
|
|
272
|
+
|
|
273
|
+
retained.push(updated);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
continuationPaths.clear();
|
|
277
|
+
|
|
278
|
+
for (const entry of retained)
|
|
279
|
+
continuationPaths.set(occurrenceKey(entry.sourceId, entry.start), entry);
|
|
280
|
+
|
|
281
|
+
previousText = text;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
const provider: ChainAutocompleteProvider = {
|
|
285
|
+
reconcile,
|
|
286
|
+
dispose() {
|
|
287
|
+
activeRequest?.abort();
|
|
288
|
+
requestGeneration += 1;
|
|
289
|
+
continuationPaths.clear();
|
|
290
|
+
pageStates.clear();
|
|
291
|
+
actions = new WeakMap();
|
|
292
|
+
},
|
|
293
|
+
get triggerCharacters() {
|
|
294
|
+
return [
|
|
295
|
+
...new Set([
|
|
296
|
+
...composedTriggerCharacters,
|
|
297
|
+
...options.sources.map((source) => Array.from(source.trigger)[0] ?? ""),
|
|
298
|
+
]),
|
|
299
|
+
].filter((character) => character.length > 0);
|
|
300
|
+
},
|
|
301
|
+
|
|
302
|
+
set triggerCharacters(characters: string[] | undefined) {
|
|
303
|
+
composedTriggerCharacters = characters ?? [];
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
async getSuggestions(lines, cursorLine, cursorCol, suggestionOptions) {
|
|
307
|
+
const text = lines.join("\n");
|
|
308
|
+
reconcile(text);
|
|
309
|
+
|
|
310
|
+
const cursor = absoluteCursor(lines, cursorLine, cursorCol);
|
|
311
|
+
const active = activeChainSegment(text, definitionsFor(options.sources), cursor);
|
|
312
|
+
if (active === undefined) {
|
|
313
|
+
return options.current.getSuggestions(
|
|
314
|
+
lines,
|
|
315
|
+
cursorLine,
|
|
316
|
+
cursorCol,
|
|
317
|
+
suggestionOptions,
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const source = sourceFor(options.sources, active.chain.sourceId);
|
|
322
|
+
if (source === undefined || suggestionOptions.signal.aborted) return null;
|
|
323
|
+
|
|
324
|
+
activeRequest?.abort();
|
|
325
|
+
|
|
326
|
+
const request = new AbortController();
|
|
327
|
+
let completionPrefix = active.query;
|
|
328
|
+
if (completionPrefix.startsWith("/")) completionPrefix = "";
|
|
329
|
+
activeRequest = request;
|
|
330
|
+
|
|
331
|
+
const generation = ++requestGeneration;
|
|
332
|
+
const abort = () => request.abort();
|
|
333
|
+
suggestionOptions.signal.addEventListener("abort", abort, { once: true });
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
let path: readonly Candidate[] = [];
|
|
337
|
+
if (active.path.length > 0) {
|
|
338
|
+
const occurrence = occurrenceKey(source.id, active.chain.start);
|
|
339
|
+
const continued = continuationPaths.get(occurrence);
|
|
340
|
+
if (
|
|
341
|
+
continued !== undefined &&
|
|
342
|
+
pathMatchesSegments(continued.path, active.path)
|
|
343
|
+
) {
|
|
344
|
+
path = continued.path;
|
|
345
|
+
} else {
|
|
346
|
+
continuationPaths.delete(occurrence);
|
|
347
|
+
|
|
348
|
+
const selected = options.resolveSelected?.(
|
|
349
|
+
source.id,
|
|
350
|
+
active.path,
|
|
351
|
+
active.chain.start,
|
|
352
|
+
);
|
|
353
|
+
if (selected !== undefined && pathMatchesSegments(selected, active.path)) {
|
|
354
|
+
path = selected;
|
|
355
|
+
} else {
|
|
356
|
+
const resolution = await source.resolve(active.path, request.signal);
|
|
357
|
+
|
|
358
|
+
if (request.signal.aborted || generation !== requestGeneration)
|
|
359
|
+
return null;
|
|
360
|
+
|
|
361
|
+
if (resolution.status === "unresolved") {
|
|
362
|
+
options.onState?.(source.id, "unresolved");
|
|
363
|
+
return { prefix: completionPrefix, items: [] };
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
path = resolution.path;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (request.signal.aborted || generation !== requestGeneration) return null;
|
|
372
|
+
|
|
373
|
+
const key = pageKey(source, active, path);
|
|
374
|
+
let cursorForRequest: string | undefined;
|
|
375
|
+
if (pendingPage?.key === key) cursorForRequest = pendingPage.cursor;
|
|
376
|
+
pendingPage = undefined;
|
|
377
|
+
|
|
378
|
+
const response = await source.discover({
|
|
379
|
+
query: active.query,
|
|
380
|
+
path,
|
|
381
|
+
cursor: cursorForRequest,
|
|
382
|
+
signal: request.signal,
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
request.signal.throwIfAborted();
|
|
386
|
+
if (generation !== requestGeneration) return null;
|
|
387
|
+
|
|
388
|
+
let existingPage: PageState | undefined;
|
|
389
|
+
if (cursorForRequest !== undefined) existingPage = pageStates.get(key);
|
|
390
|
+
|
|
391
|
+
const requestedCursors = new Set(existingPage?.requestedCursors);
|
|
392
|
+
if (cursorForRequest !== undefined) requestedCursors.add(cursorForRequest);
|
|
393
|
+
|
|
394
|
+
const retained: Candidate[] = [];
|
|
395
|
+
const retainedIds = new Set<string>();
|
|
396
|
+
let received = response.items.filter(
|
|
397
|
+
(candidate) => candidate.selectable || candidate.navigable,
|
|
398
|
+
);
|
|
399
|
+
if (source.filtering === "local" && active.query.length > 0) {
|
|
400
|
+
received = fuzzyFilter(
|
|
401
|
+
received,
|
|
402
|
+
active.query,
|
|
403
|
+
(candidate) =>
|
|
404
|
+
candidate.searchText ??
|
|
405
|
+
`${candidate.label} ${candidate.description ?? ""}`,
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
for (const candidate of existingPage?.items ?? []) {
|
|
410
|
+
if (retainedIds.has(candidate.id)) continue;
|
|
411
|
+
retainedIds.add(candidate.id);
|
|
412
|
+
retained.push(candidate);
|
|
413
|
+
|
|
414
|
+
if (retained.length === MAX_RETAINED_CANDIDATES) break;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (retained.length < MAX_RETAINED_CANDIDATES) {
|
|
418
|
+
for (const candidate of received) {
|
|
419
|
+
if (retainedIds.has(candidate.id)) continue;
|
|
420
|
+
retainedIds.add(candidate.id);
|
|
421
|
+
retained.push(candidate);
|
|
422
|
+
|
|
423
|
+
if (retained.length === MAX_RETAINED_CANDIDATES) break;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
let pageCount = 1;
|
|
428
|
+
if (cursorForRequest !== undefined) {
|
|
429
|
+
pageCount = (existingPage?.pageCount ?? 0) + 1;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
retainPageState(pageStates, key, {
|
|
433
|
+
items: retained,
|
|
434
|
+
pageCount,
|
|
435
|
+
requestedCursors,
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
let candidates = retained;
|
|
439
|
+
if (source.filtering === "local") {
|
|
440
|
+
candidates = candidates.slice(0, MAX_LOCAL_SUGGESTIONS);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
actions = new WeakMap();
|
|
444
|
+
|
|
445
|
+
const items: AutocompleteItem[] = [];
|
|
446
|
+
const parent = path.at(-1);
|
|
447
|
+
if (parent?.selectable === true && parent.navigable) {
|
|
448
|
+
const useParent: AutocompleteItem = {
|
|
449
|
+
value: parent.segment,
|
|
450
|
+
label: `Use ${parent.label}`,
|
|
451
|
+
description: "Use this target",
|
|
452
|
+
};
|
|
453
|
+
actions.set(useParent, { kind: "select", source, active, path });
|
|
454
|
+
items.push(useParent);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
for (const candidate of candidates) {
|
|
458
|
+
const item = itemFor(candidate);
|
|
459
|
+
if (candidate.navigable) {
|
|
460
|
+
actions.set(item, { kind: "navigate", source, active, path, candidate });
|
|
461
|
+
} else if (candidate.selectable) {
|
|
462
|
+
actions.set(item, {
|
|
463
|
+
kind: "select",
|
|
464
|
+
source,
|
|
465
|
+
active,
|
|
466
|
+
path: [...path, candidate],
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
items.push(item);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (
|
|
474
|
+
response.nextCursor !== undefined &&
|
|
475
|
+
pageCount < MAX_PAGES_PER_SCOPE &&
|
|
476
|
+
retained.length < MAX_RETAINED_CANDIDATES &&
|
|
477
|
+
!requestedCursors.has(response.nextCursor)
|
|
478
|
+
) {
|
|
479
|
+
const more: AutocompleteItem = {
|
|
480
|
+
value: "",
|
|
481
|
+
label: "More…",
|
|
482
|
+
description: "Load more results",
|
|
483
|
+
};
|
|
484
|
+
actions.set(more, {
|
|
485
|
+
kind: "more",
|
|
486
|
+
source,
|
|
487
|
+
active,
|
|
488
|
+
key,
|
|
489
|
+
cursor: response.nextCursor,
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
items.push(more);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
options.onState?.(source.id, "ready");
|
|
496
|
+
|
|
497
|
+
return { prefix: completionPrefix, items };
|
|
498
|
+
} catch {
|
|
499
|
+
if (request.signal.aborted) return null;
|
|
500
|
+
|
|
501
|
+
options.onState?.(source.id, "failed");
|
|
502
|
+
|
|
503
|
+
return { prefix: completionPrefix, items: [] };
|
|
504
|
+
} finally {
|
|
505
|
+
suggestionOptions.signal.removeEventListener("abort", abort);
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
|
|
510
|
+
const action = actions.get(item);
|
|
511
|
+
if (action === undefined) {
|
|
512
|
+
return options.current.applyCompletion(lines, cursorLine, cursorCol, item, prefix);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if (action.kind === "more") {
|
|
516
|
+
pendingPage = { key: action.key, cursor: action.cursor };
|
|
517
|
+
options.onContinue?.();
|
|
518
|
+
return { lines, cursorLine, cursorCol };
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const separator = action.source.separator ?? ":";
|
|
522
|
+
if (action.kind === "navigate") {
|
|
523
|
+
const replacement = `${formatChain(
|
|
524
|
+
[...action.path, action.candidate].map((candidate) => candidate.segment),
|
|
525
|
+
action.active.chain.trigger,
|
|
526
|
+
separator,
|
|
527
|
+
)}${separator}`;
|
|
528
|
+
const result = replaceOwnedSuffix(lines, action, replacement);
|
|
529
|
+
const continuedPath = [...action.path, action.candidate];
|
|
530
|
+
|
|
531
|
+
reconcile(result.editorText);
|
|
532
|
+
continuationPaths.set(occurrenceKey(action.source.id, result.start), {
|
|
533
|
+
sourceId: action.source.id,
|
|
534
|
+
start: result.start,
|
|
535
|
+
end: result.end,
|
|
536
|
+
text: result.text,
|
|
537
|
+
path: structuredClone(continuedPath),
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
if (continuationPaths.size > MAX_CONTINUATION_PATHS) {
|
|
541
|
+
const oldest = continuationPaths.keys().next().value;
|
|
542
|
+
if (oldest !== undefined) continuationPaths.delete(oldest);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
options.onContinue?.();
|
|
546
|
+
|
|
547
|
+
return {
|
|
548
|
+
lines: result.lines,
|
|
549
|
+
cursorLine: result.cursorLine,
|
|
550
|
+
cursorCol: result.cursorCol,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const segments = action.path.map((candidate) => candidate.segment);
|
|
555
|
+
let mention = formatChain(segments, action.active.chain.trigger, separator);
|
|
556
|
+
const target = action.path.at(-1);
|
|
557
|
+
if (target?.insertionText !== undefined) mention = target.insertionText;
|
|
558
|
+
|
|
559
|
+
const text = lines.join("\n");
|
|
560
|
+
const suffix = completionSuffixFor(
|
|
561
|
+
text.slice(action.active.ownedEnd),
|
|
562
|
+
action.source.completionSuffix,
|
|
563
|
+
);
|
|
564
|
+
const replacement = `${mention}${suffix.text}`;
|
|
565
|
+
const result = replaceOwnedSuffix(lines, action, replacement, suffix.consume);
|
|
566
|
+
continuationPaths.delete(occurrenceKey(action.source.id, result.start));
|
|
567
|
+
options.onSelection?.({
|
|
568
|
+
sourceId: action.source.id,
|
|
569
|
+
start: result.start,
|
|
570
|
+
end: result.end - suffix.text.length,
|
|
571
|
+
text: result.text.slice(0, result.text.length - suffix.text.length),
|
|
572
|
+
path: action.path,
|
|
573
|
+
editorText: result.editorText,
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
return {
|
|
577
|
+
lines: result.lines,
|
|
578
|
+
cursorLine: result.cursorLine,
|
|
579
|
+
cursorCol: result.cursorCol,
|
|
580
|
+
};
|
|
581
|
+
},
|
|
582
|
+
|
|
583
|
+
shouldTriggerFileCompletion(lines, cursorLine, cursorCol) {
|
|
584
|
+
const text = lines.join("\n");
|
|
585
|
+
const cursor = absoluteCursor(lines, cursorLine, cursorCol);
|
|
586
|
+
if (activeChainSegment(text, definitionsFor(options.sources), cursor) !== undefined)
|
|
587
|
+
return false;
|
|
588
|
+
|
|
589
|
+
return (
|
|
590
|
+
options.current.shouldTriggerFileCompletion?.(lines, cursorLine, cursorCol) ?? true
|
|
591
|
+
);
|
|
592
|
+
},
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
return provider;
|
|
596
|
+
}
|