@greppleai/grip 0.0.0-stage → 0.0.1
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 +22 -0
- package/README.md +725 -2
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +11 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +13 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +32 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +70 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +441 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +60 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +406 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +970 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +5176 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +150 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +557 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +26 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +99 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +83 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +220 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +65 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +550 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/compression-detection-ledger.d.ts +34 -0
- package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -0
- package/dist/core/compaction/compression-detection-ledger.js +52 -0
- package/dist/core/compaction/compression-detection-ledger.js.map +1 -0
- package/dist/core/compaction/compression-detector.d.ts +71 -0
- package/dist/core/compaction/compression-detector.d.ts.map +1 -0
- package/dist/core/compaction/compression-detector.js +407 -0
- package/dist/core/compaction/compression-detector.js.map +1 -0
- package/dist/core/compaction/compression-economics.d.ts +55 -0
- package/dist/core/compaction/compression-economics.d.ts.map +1 -0
- package/dist/core/compaction/compression-economics.js +151 -0
- package/dist/core/compaction/compression-economics.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +28 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +165 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +18 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +245 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +21 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +230 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +32 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +613 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +160 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +962 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1311 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +51 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +52 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +318 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/grip-agent.d.ts +240 -0
- package/dist/core/grip-agent.d.ts.map +1 -0
- package/dist/core/grip-agent.js +1243 -0
- package/dist/core/grip-agent.js.map +1 -0
- package/dist/core/grip-manifest.d.ts +9 -0
- package/dist/core/grip-manifest.d.ts.map +1 -0
- package/dist/core/grip-manifest.js +25 -0
- package/dist/core/grip-manifest.js.map +1 -0
- package/dist/core/hooks/aggregate.d.ts +5 -0
- package/dist/core/hooks/aggregate.d.ts.map +1 -0
- package/dist/core/hooks/aggregate.js +226 -0
- package/dist/core/hooks/aggregate.js.map +1 -0
- package/dist/core/hooks/config.d.ts +14 -0
- package/dist/core/hooks/config.d.ts.map +1 -0
- package/dist/core/hooks/config.js +372 -0
- package/dist/core/hooks/config.js.map +1 -0
- package/dist/core/hooks/executor.d.ts +12 -0
- package/dist/core/hooks/executor.d.ts.map +1 -0
- package/dist/core/hooks/executor.js +708 -0
- package/dist/core/hooks/executor.js.map +1 -0
- package/dist/core/hooks/index.d.ts +9 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +14 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/matcher.d.ts +10 -0
- package/dist/core/hooks/matcher.d.ts.map +1 -0
- package/dist/core/hooks/matcher.js +70 -0
- package/dist/core/hooks/matcher.js.map +1 -0
- package/dist/core/hooks/trust-store.d.ts +38 -0
- package/dist/core/hooks/trust-store.d.ts.map +1 -0
- package/dist/core/hooks/trust-store.js +167 -0
- package/dist/core/hooks/trust-store.js.map +1 -0
- package/dist/core/hooks/types.d.ts +234 -0
- package/dist/core/hooks/types.d.ts.map +1 -0
- package/dist/core/hooks/types.js +52 -0
- package/dist/core/hooks/types.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +21 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +82 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/instruction-resource-loader.d.ts +81 -0
- package/dist/core/instruction-resource-loader.d.ts.map +1 -0
- package/dist/core/instruction-resource-loader.js +574 -0
- package/dist/core/instruction-resource-loader.js.map +1 -0
- package/dist/core/keybindings.d.ts +399 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +299 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/lsp/abort.d.ts +3 -0
- package/dist/core/lsp/abort.d.ts.map +1 -0
- package/dist/core/lsp/abort.js +28 -0
- package/dist/core/lsp/abort.js.map +1 -0
- package/dist/core/lsp/client.d.ts +108 -0
- package/dist/core/lsp/client.d.ts.map +1 -0
- package/dist/core/lsp/client.js +586 -0
- package/dist/core/lsp/client.js.map +1 -0
- package/dist/core/lsp/config-loader.d.ts +44 -0
- package/dist/core/lsp/config-loader.d.ts.map +1 -0
- package/dist/core/lsp/config-loader.js +223 -0
- package/dist/core/lsp/config-loader.js.map +1 -0
- package/dist/core/lsp/config.d.ts +134 -0
- package/dist/core/lsp/config.d.ts.map +1 -0
- package/dist/core/lsp/config.js +682 -0
- package/dist/core/lsp/config.js.map +1 -0
- package/dist/core/lsp/diagnostics.d.ts +18 -0
- package/dist/core/lsp/diagnostics.d.ts.map +1 -0
- package/dist/core/lsp/diagnostics.js +311 -0
- package/dist/core/lsp/diagnostics.js.map +1 -0
- package/dist/core/lsp/file-sync.d.ts +58 -0
- package/dist/core/lsp/file-sync.d.ts.map +1 -0
- package/dist/core/lsp/file-sync.js +432 -0
- package/dist/core/lsp/file-sync.js.map +1 -0
- package/dist/core/lsp/integration.d.ts +62 -0
- package/dist/core/lsp/integration.d.ts.map +1 -0
- package/dist/core/lsp/integration.js +145 -0
- package/dist/core/lsp/integration.js.map +1 -0
- package/dist/core/lsp/language-map.d.ts +54 -0
- package/dist/core/lsp/language-map.d.ts.map +1 -0
- package/dist/core/lsp/language-map.js +300 -0
- package/dist/core/lsp/language-map.js.map +1 -0
- package/dist/core/lsp/manager.d.ts +120 -0
- package/dist/core/lsp/manager.d.ts.map +1 -0
- package/dist/core/lsp/manager.js +636 -0
- package/dist/core/lsp/manager.js.map +1 -0
- package/dist/core/lsp/navigation.d.ts +32 -0
- package/dist/core/lsp/navigation.d.ts.map +1 -0
- package/dist/core/lsp/navigation.js +327 -0
- package/dist/core/lsp/navigation.js.map +1 -0
- package/dist/core/lsp/portable-path.d.ts +18 -0
- package/dist/core/lsp/portable-path.d.ts.map +1 -0
- package/dist/core/lsp/portable-path.js +83 -0
- package/dist/core/lsp/portable-path.js.map +1 -0
- package/dist/core/lsp/refactor.d.ts +32 -0
- package/dist/core/lsp/refactor.d.ts.map +1 -0
- package/dist/core/lsp/refactor.js +519 -0
- package/dist/core/lsp/refactor.js.map +1 -0
- package/dist/core/lsp/transport.d.ts +39 -0
- package/dist/core/lsp/transport.d.ts.map +1 -0
- package/dist/core/lsp/transport.js +261 -0
- package/dist/core/lsp/transport.js.map +1 -0
- package/dist/core/messages.d.ts +34 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +140 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +148 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +812 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +115 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +498 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +209 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2341 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +57 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +353 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +33 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts +456 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.js +809 -0
- package/dist/core/remote-workspace-protocol/contract.js.map +1 -0
- package/dist/core/remote-workspace-protocol/session.d.ts +247 -0
- package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/session.js +1839 -0
- package/dist/core/remote-workspace-protocol/session.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +32 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +257 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +200 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +1209 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/rules.d.ts +40 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +57 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/sandbox/command.d.ts +27 -0
- package/dist/core/sandbox/command.d.ts.map +1 -0
- package/dist/core/sandbox/command.js +124 -0
- package/dist/core/sandbox/command.js.map +1 -0
- package/dist/core/sandbox/docker.d.ts +169 -0
- package/dist/core/sandbox/docker.d.ts.map +1 -0
- package/dist/core/sandbox/docker.js +633 -0
- package/dist/core/sandbox/docker.js.map +1 -0
- package/dist/core/sandbox/lima.d.ts +38 -0
- package/dist/core/sandbox/lima.d.ts.map +1 -0
- package/dist/core/sandbox/lima.js +324 -0
- package/dist/core/sandbox/lima.js.map +1 -0
- package/dist/core/session/constants.d.ts +2 -0
- package/dist/core/session/constants.d.ts.map +1 -0
- package/dist/core/session/constants.js +2 -0
- package/dist/core/session/constants.js.map +1 -0
- package/dist/core/session/context-metadata.d.ts +5 -0
- package/dist/core/session/context-metadata.d.ts.map +1 -0
- package/dist/core/session/context-metadata.js +55 -0
- package/dist/core/session/context-metadata.js.map +1 -0
- package/dist/core/session/context.d.ts +14 -0
- package/dist/core/session/context.d.ts.map +1 -0
- package/dist/core/session/context.js +117 -0
- package/dist/core/session/context.js.map +1 -0
- package/dist/core/session/ids.d.ts +9 -0
- package/dist/core/session/ids.d.ts.map +1 -0
- package/dist/core/session/ids.js +21 -0
- package/dist/core/session/ids.js.map +1 -0
- package/dist/core/session/in-memory-session-manager.d.ts +17 -0
- package/dist/core/session/in-memory-session-manager.d.ts.map +1 -0
- package/dist/core/session/in-memory-session-manager.js +40 -0
- package/dist/core/session/in-memory-session-manager.js.map +1 -0
- package/dist/core/session/in-memory-session.d.ts +7 -0
- package/dist/core/session/in-memory-session.d.ts.map +1 -0
- package/dist/core/session/in-memory-session.js +11 -0
- package/dist/core/session/in-memory-session.js.map +1 -0
- package/dist/core/session/jsonl-errors.d.ts +36 -0
- package/dist/core/session/jsonl-errors.d.ts.map +1 -0
- package/dist/core/session/jsonl-errors.js +49 -0
- package/dist/core/session/jsonl-errors.js.map +1 -0
- package/dist/core/session/jsonl-helpers.d.ts +20 -0
- package/dist/core/session/jsonl-helpers.d.ts.map +1 -0
- package/dist/core/session/jsonl-helpers.js +21 -0
- package/dist/core/session/jsonl-helpers.js.map +1 -0
- package/dist/core/session/local-session-manager.d.ts +30 -0
- package/dist/core/session/local-session-manager.d.ts.map +1 -0
- package/dist/core/session/local-session-manager.js +205 -0
- package/dist/core/session/local-session-manager.js.map +1 -0
- package/dist/core/session/local-session.d.ts +9 -0
- package/dist/core/session/local-session.d.ts.map +1 -0
- package/dist/core/session/local-session.js +15 -0
- package/dist/core/session/local-session.js.map +1 -0
- package/dist/core/session/migrations.d.ts +11 -0
- package/dist/core/session/migrations.d.ts.map +1 -0
- package/dist/core/session/migrations.js +78 -0
- package/dist/core/session/migrations.js.map +1 -0
- package/dist/core/session/remote-session-client.d.ts +83 -0
- package/dist/core/session/remote-session-client.d.ts.map +1 -0
- package/dist/core/session/remote-session-client.js +224 -0
- package/dist/core/session/remote-session-client.js.map +1 -0
- package/dist/core/session/remote-session-manager.d.ts +32 -0
- package/dist/core/session/remote-session-manager.d.ts.map +1 -0
- package/dist/core/session/remote-session-manager.js +124 -0
- package/dist/core/session/remote-session-manager.js.map +1 -0
- package/dist/core/session/remote-session.d.ts +20 -0
- package/dist/core/session/remote-session.d.ts.map +1 -0
- package/dist/core/session/remote-session.js +33 -0
- package/dist/core/session/remote-session.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +18 -0
- package/dist/core/session/session-manager.d.ts.map +1 -0
- package/dist/core/session/session-manager.js +2 -0
- package/dist/core/session/session-manager.js.map +1 -0
- package/dist/core/session/session.d.ts +140 -0
- package/dist/core/session/session.d.ts.map +1 -0
- package/dist/core/session/session.js +461 -0
- package/dist/core/session/session.js.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts +39 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.js +168 -0
- package/dist/core/session/stores/in-memory-session-store.js.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts +97 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.js +1140 -0
- package/dist/core/session/stores/jsonl-session-store.js.map +1 -0
- package/dist/core/session/stores/remote-session-store.d.ts +44 -0
- package/dist/core/session/stores/remote-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/remote-session-store.js +159 -0
- package/dist/core/session/stores/remote-session-store.js.map +1 -0
- package/dist/core/session/stores/session-store.d.ts +42 -0
- package/dist/core/session/stores/session-store.d.ts.map +1 -0
- package/dist/core/session/stores/session-store.js +2 -0
- package/dist/core/session/stores/session-store.js.map +1 -0
- package/dist/core/session/types.d.ts +141 -0
- package/dist/core/session/types.d.ts.map +1 -0
- package/dist/core/session/types.js +2 -0
- package/dist/core/session/types.js.map +1 -0
- package/dist/core/session/usage-ledger.d.ts +18 -0
- package/dist/core/session/usage-ledger.d.ts.map +1 -0
- package/dist/core/session/usage-ledger.js +68 -0
- package/dist/core/session/usage-ledger.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/settings-manager.d.ts +318 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +991 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +40 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +57 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +36 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +26 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +27 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +32 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +131 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +10 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +41 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +51 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +310 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/compress-context.d.ts +27 -0
- package/dist/core/tools/compress-context.d.ts.map +1 -0
- package/dist/core/tools/compress-context.js +142 -0
- package/dist/core/tools/compress-context.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +82 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +327 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +324 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +60 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +22 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +268 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +27 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +332 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/hash-store.d.ts +12 -0
- package/dist/core/tools/hash-store.d.ts.map +1 -0
- package/dist/core/tools/hash-store.js +48 -0
- package/dist/core/tools/hash-store.js.map +1 -0
- package/dist/core/tools/hashline/apply.d.ts +40 -0
- package/dist/core/tools/hashline/apply.d.ts.map +1 -0
- package/dist/core/tools/hashline/apply.js +261 -0
- package/dist/core/tools/hashline/apply.js.map +1 -0
- package/dist/core/tools/hashline/hash.d.ts +56 -0
- package/dist/core/tools/hashline/hash.d.ts.map +1 -0
- package/dist/core/tools/hashline/hash.js +196 -0
- package/dist/core/tools/hashline/hash.js.map +1 -0
- package/dist/core/tools/hashline/parse.d.ts +8 -0
- package/dist/core/tools/hashline/parse.d.ts.map +1 -0
- package/dist/core/tools/hashline/parse.js +41 -0
- package/dist/core/tools/hashline/parse.js.map +1 -0
- package/dist/core/tools/hashline/resolve.d.ts +51 -0
- package/dist/core/tools/hashline/resolve.d.ts.map +1 -0
- package/dist/core/tools/hashline/resolve.js +187 -0
- package/dist/core/tools/hashline/resolve.js.map +1 -0
- package/dist/core/tools/hashline-utils.d.ts +6 -0
- package/dist/core/tools/hashline-utils.d.ts.map +1 -0
- package/dist/core/tools/hashline-utils.js +23 -0
- package/dist/core/tools/hashline-utils.js.map +1 -0
- package/dist/core/tools/index.d.ts +36 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +141 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +21 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +156 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/operations.d.ts +201 -0
- package/dist/core/tools/operations.d.ts.map +1 -0
- package/dist/core/tools/operations.js +697 -0
- package/dist/core/tools/operations.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +54 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +32 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +318 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +33 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +61 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/replace-diff.d.ts +16 -0
- package/dist/core/tools/replace-diff.d.ts.map +1 -0
- package/dist/core/tools/replace-diff.js +117 -0
- package/dist/core/tools/replace-diff.js.map +1 -0
- package/dist/core/tools/replace-normalize.d.ts +2 -0
- package/dist/core/tools/replace-normalize.d.ts.map +1 -0
- package/dist/core/tools/replace-normalize.js +73 -0
- package/dist/core/tools/replace-normalize.js.map +1 -0
- package/dist/core/tools/replace-render.d.ts +51 -0
- package/dist/core/tools/replace-render.d.ts.map +1 -0
- package/dist/core/tools/replace-render.js +162 -0
- package/dist/core/tools/replace-render.js.map +1 -0
- package/dist/core/tools/runtime.d.ts +2 -0
- package/dist/core/tools/runtime.d.ts.map +1 -0
- package/dist/core/tools/runtime.js +6 -0
- package/dist/core/tools/runtime.js.map +1 -0
- package/dist/core/tools/session-history.d.ts +55 -0
- package/dist/core/tools/session-history.d.ts.map +1 -0
- package/dist/core/tools/session-history.js +649 -0
- package/dist/core/tools/session-history.js.map +1 -0
- package/dist/core/tools/subagent-agents.d.ts +29 -0
- package/dist/core/tools/subagent-agents.d.ts.map +1 -0
- package/dist/core/tools/subagent-agents.js +223 -0
- package/dist/core/tools/subagent-agents.js.map +1 -0
- package/dist/core/tools/subagent.d.ts +185 -0
- package/dist/core/tools/subagent.d.ts.map +1 -0
- package/dist/core/tools/subagent.js +1309 -0
- package/dist/core/tools/subagent.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +39 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/websearch.d.ts +33 -0
- package/dist/core/tools/websearch.d.ts.map +1 -0
- package/dist/core/tools/websearch.js +341 -0
- package/dist/core/tools/websearch.js.map +1 -0
- package/dist/core/tools/workspace-tool-host.d.ts +102 -0
- package/dist/core/tools/workspace-tool-host.d.ts.map +1 -0
- package/dist/core/tools/workspace-tool-host.js +348 -0
- package/dist/core/tools/workspace-tool-host.js.map +1 -0
- package/dist/core/tools/write.d.ts +16 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +204 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/workspace-identity.d.ts +7 -0
- package/dist/core/workspace-identity.d.ts.map +1 -0
- package/dist/core/workspace-identity.js +2 -0
- package/dist/core/workspace-identity.js.map +1 -0
- package/dist/daemon/command.d.ts +6 -0
- package/dist/daemon/command.d.ts.map +1 -0
- package/dist/daemon/command.js +58 -0
- package/dist/daemon/command.js.map +1 -0
- package/dist/daemon/config.d.ts +43 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +304 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/help.d.ts +2 -0
- package/dist/daemon/help.d.ts.map +1 -0
- package/dist/daemon/help.js +42 -0
- package/dist/daemon/help.js.map +1 -0
- package/dist/daemon/lsp-config.d.ts +4 -0
- package/dist/daemon/lsp-config.d.ts.map +1 -0
- package/dist/daemon/lsp-config.js +155 -0
- package/dist/daemon/lsp-config.js.map +1 -0
- package/dist/daemon/security.d.ts +19 -0
- package/dist/daemon/security.d.ts.map +1 -0
- package/dist/daemon/security.js +175 -0
- package/dist/daemon/security.js.map +1 -0
- package/dist/daemon/server.d.ts +20 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +400 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/workspace-runtime.d.ts +46 -0
- package/dist/daemon/workspace-runtime.d.ts.map +1 -0
- package/dist/daemon/workspace-runtime.js +673 -0
- package/dist/daemon/workspace-runtime.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +39 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +763 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +35 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +412 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +29 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +149 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +173 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +18 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +54 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +74 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +514 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +25 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +85 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +80 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +118 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +128 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +83 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +36 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +227 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/hook-execution.d.ts +19 -0
- package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/hook-execution.js +184 -0
- package/dist/modes/interactive/components/hook-execution.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +55 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +176 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts +4 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +14 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +228 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +52 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +296 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +165 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +50 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +300 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +144 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +108 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +835 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +81 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +455 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +39 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +50 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +51 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +67 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +306 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +127 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1098 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +114 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +16 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +49 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +557 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +5859 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +106 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1030 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/json-event.d.ts +28 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +12 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +29 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +142 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +321 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +755 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +963 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +652 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +488 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +25 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +23 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +74 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +15 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +88 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +13 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +248 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +4 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +171 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/directory-completions.d.ts +5 -0
- package/dist/utils/directory-completions.d.ts.map +1 -0
- package/dist/utils/directory-completions.js +64 -0
- package/dist/utils/directory-completions.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +6 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +166 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +27 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +237 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/grip-user-agent.d.ts +2 -0
- package/dist/utils/grip-user-agent.d.ts.map +1 -0
- package/dist/utils/grip-user-agent.js +5 -0
- package/dist/utils/grip-user-agent.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +43 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +133 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +19 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +81 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +110 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +87 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +22 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +125 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +28 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +188 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +125 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +5 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +329 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +14 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +91 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +408 -0
- package/docs/custom-provider.md +714 -0
- package/docs/daemon-architecture.md +399 -0
- package/docs/daemon.md +110 -0
- package/docs/development.md +72 -0
- package/docs/docs.json +164 -0
- package/docs/extensions.md +2745 -0
- package/docs/hooks.md +85 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +81 -0
- package/docs/json.md +89 -0
- package/docs/keybindings.md +230 -0
- package/docs/lsp.md +499 -0
- package/docs/migrating-to-grip.md +18 -0
- package/docs/models.md +496 -0
- package/docs/packages.md +228 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +251 -0
- package/docs/quickstart.md +167 -0
- package/docs/rpc.md +1492 -0
- package/docs/rules.md +117 -0
- package/docs/sandbox.md +181 -0
- package/docs/sdk.md +360 -0
- package/docs/session-format.md +414 -0
- package/docs/sessions.md +137 -0
- package/docs/settings.md +371 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +246 -0
- package/docs/terminal-setup.md +112 -0
- package/docs/termux.md +129 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +918 -0
- package/docs/usage.md +304 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +31 -0
- package/examples/daemon-docker/Dockerfile +43 -0
- package/examples/daemon-docker/README.md +45 -0
- package/examples/extensions/README.md +208 -0
- package/examples/extensions/auto-commit-on-exit.ts +46 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +145 -0
- package/examples/extensions/built-in-tool-renderer.ts +259 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +82 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +131 -0
- package/examples/extensions/custom-footer.ts +79 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +707 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +402 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +104 -0
- package/examples/extensions/dirty-repo-guard.ts +59 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/RULES.md +8 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +16 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +125 -0
- package/examples/extensions/github-issue-autocomplete.ts +191 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +104 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +194 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +428 -0
- package/examples/extensions/modal-editor.ts +86 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1374 -0
- package/examples/extensions/overlay-test.ts +171 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +346 -0
- package/examples/extensions/plan-mode/utils.ts +172 -0
- package/examples/extensions/preset.ts +426 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +29 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +125 -0
- package/examples/extensions/question.ts +294 -0
- package/examples/extensions/questionnaire.ts +459 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +320 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +381 -0
- package/examples/extensions/space-invaders.ts +597 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1083 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +186 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1091 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +306 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +141 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +200 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/remote-session-server/README.md +71 -0
- package/examples/remote-session-server/server.ts +353 -0
- package/examples/rpc-extension-ui.ts +642 -0
- package/examples/sandbox-docker/Dockerfile +274 -0
- package/examples/sandbox-docker/README.md +88 -0
- package/examples/sdk/01-minimal.ts +27 -0
- package/examples/sdk/02-custom-model.ts +54 -0
- package/examples/sdk/03-custom-prompt.ts +76 -0
- package/examples/sdk/04-skills.ts +60 -0
- package/examples/sdk/05-tools.ts +55 -0
- package/examples/sdk/06-extensions.ts +94 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +56 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +50 -0
- package/examples/sdk/10-settings.ts +58 -0
- package/examples/sdk/11-sessions.ts +54 -0
- package/examples/sdk/12-full-control.ts +79 -0
- package/examples/sdk/13-session-runtime.ts +49 -0
- package/examples/sdk/README.md +94 -0
- package/npm-shrinkwrap.json +1878 -0
- package/package.json +102 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instruction-resource-loader.d.ts","sourceRoot":"","sources":["../../src/core/instruction-resource-loader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAW9E,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAS1E,MAAM,WAAW,8BAA8B;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,sBAAsB,EAAE,OAAO,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,6BAA6B,CAAC,SAAS,SAAS,mBAAmB;IACnF,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,mCAAmC;IACnD,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;CACf;AA6BD,UAAU,sCAAsC;IAC/C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gCAAgC;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,8CAA+C,SAAQ,gCAAgC;IACvG,UAAU,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,+BAA+B;IAC/C,YAAY,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAChD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;CACrB;AA8FD,8BAAsB,yBAAyB,CAC9C,SAAS,SAAS,mBAAmB,EACrC,YAAY,SAAS,8BAA8B;IAEnD,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,YAAY,CAAS;IAE7B,YAAY,MAAM,EAAE,+BAA+B,EAIlD;IAED,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,GAAG,SAAS,CAAC;IAEvG,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,6BAA6B,CAAC,SAAS,CAAC,CAEpG;IAED,OAAO,CAAC,+BAA+B;IAqCvC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,gCAAgC,GAAG,6BAA6B,CAAC,SAAS,CAAC,CAuD3G;YAEa,6CAA6C;IA4C3D,UAAgB,2BAA2B,CAC1C,OAAO,EAAE,8CAA8C,GACrD,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC,CAqEnD;IAED,OAAO,CAAC,yBAAyB;IAcjC,OAAO,CAAC,cAAc;YAgBR,4BAA4B;IAsB1C,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,2BAA2B;IAkBnC,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,8BAA8B;IAItC,OAAO,CAAC,4BAA4B;YAgCtB,uBAAuB;YAWvB,8BAA8B;YAkB9B,gCAAgC;YA6BhC,iCAAiC;YAIjC,0CAA0C;IAkCxD,OAAO,CAAC,oBAAoB;YAQd,kCAAkC;IAmBhD,OAAO,CAAC,aAAa;IAoCrB,OAAO,CAAC,gBAAgB;CAYxB;AAED,wBAAgB,mCAAmC,CAClD,SAAS,EAAE,mBAAmB,EAAE,EAChC,OAAO,EAAE,sCAAsC,GAC7C,MAAM,CAeR","sourcesContent":["import { type Dirent, existsSync, readdirSync, readFileSync, type Stats, statSync } from \"node:fs\";\nimport { dirname, join, relative, resolve, sep } from \"node:path\";\nimport ignore from \"ignore\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.ts\";\nimport { parseFrontmatter } from \"../utils/frontmatter.ts\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\nimport type { ResourceCollision, ResourceDiagnostic } from \"./diagnostics.ts\";\nimport {\n\tdirnamePortablePath,\n\tjoinPortablePath,\n\tnormalizePortablePath,\n\ttype PortablePathFlavor,\n\tpathComparisonValue,\n\trelativePortablePath,\n\trelativeWithin,\n\tresolvePortablePath,\n} from \"./lsp/portable-path.ts\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.ts\";\nimport type { ToolFileStat, ToolOperations } from \"./tools/operations.ts\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype ConfiguredResourceSource = \"user\" | \"project\" | \"path\";\ntype ResourceSource = ConfiguredResourceSource | string;\n\nexport interface InstructionResourceFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\ttools?: string | string[];\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\nexport interface InstructionResource {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\ttools?: string[];\n\tcontent?: string;\n}\n\nexport interface InstructionResourceLoadResult<TResource extends InstructionResource> {\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\nexport interface InstructionResourceDirectoryOptions {\n\t/** Directory to scan for instruction resources. */\n\tdir: string;\n\t/** Source identifier for these instruction resources. */\n\tsource: string;\n}\ninterface LocalResourceTraversal<TResource extends InstructionResource> {\n\tentries: Dirent[];\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface BackendResourceTraversal<TResource extends InstructionResource> {\n\tentries: string[];\n\toperations: ToolOperations;\n\tdir: string;\n\tsource: string;\n\tincludeRootFiles: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tresources: TResource[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourceParseResult<TResource extends InstructionResource> {\n\tresource: TResource | null;\n\tdiagnostics: ResourceDiagnostic[];\n}\n\ninterface InstructionResourcePromptFormatOptions {\n\tintro: string[];\n\tcontainerTag: string;\n\titemTag: string;\n}\n\nexport interface InstructionResourceLoaderOptions {\n\tcwd: string;\n\tagentDir: string;\n\tresourcePaths: string[];\n\tincludeDefaults: boolean;\n}\n\nexport interface InstructionResourceLoaderWithOperationsOptions extends InstructionResourceLoaderOptions {\n\toperations: ToolOperations;\n}\n\nexport interface InstructionResourceLoaderConfig {\n\tresourceType: ResourceCollision[\"resourceType\"];\n\tdefaultDirectoryName: string;\n\trootFileName: string;\n}\n\nfunction toPosixPath(path: string): string {\n\treturn path.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction validateName(name: string): string[] {\n\tconst errors: string[] = [];\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(\"name must not start or end with a hyphen\");\n\t}\n\tif (name.includes(\"--\")) {\n\t\terrors.push(\"name must not contain consecutive hyphens\");\n\t}\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tif (!description || description.trim() === \"\") return [\"description is required\"];\n\tif (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\treturn [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];\n\t}\n\treturn [];\n}\n\nfunction normalizeFrontmatterTools(value: unknown): string[] {\n\tconst raw = Array.isArray(value) ? value : typeof value === \"string\" ? value.split(/[\\s,]+/) : [];\n\tconst tools: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const entry of raw) {\n\t\tif (typeof entry !== \"string\") continue;\n\t\tconst trimmed = entry.trim();\n\t\tif (trimmed.length > 0 && !seen.has(trimmed)) {\n\t\t\tseen.add(trimmed);\n\t\t\ttools.push(trimmed);\n\t\t}\n\t}\n\treturn tools;\n}\n\nfunction createResourceSourceInfo(filePath: string, baseDir: string, source: ResourceSource): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"user\", baseDir });\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", scope: \"project\", baseDir });\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, { source: \"local\", baseDir });\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\nfunction isUnderPath(target: string, root: string): boolean {\n\tconst normalizedRoot = resolve(root);\n\tif (target === normalizedRoot) return true;\n\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\treturn target.startsWith(prefix);\n}\n\nasync function backendPathExists(operations: ToolOperations, path: string): Promise<boolean> {\n\ttry {\n\t\tawait operations.access(path, \"exists\");\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport abstract class InstructionResourceLoader<\n\tTResource extends InstructionResource,\n\tTFrontmatter extends InstructionResourceFrontmatter,\n> {\n\tprivate resourceType: ResourceCollision[\"resourceType\"];\n\tprivate defaultDirectoryName: string;\n\tprivate rootFileName: string;\n\n\tconstructor(config: InstructionResourceLoaderConfig) {\n\t\tthis.resourceType = config.resourceType;\n\t\tthis.defaultDirectoryName = config.defaultDirectoryName;\n\t\tthis.rootFileName = config.rootFileName;\n\t}\n\n\tprotected abstract createResource(resource: InstructionResource, frontmatter: TFrontmatter): TResource;\n\n\tprotected loadResourcesFromDir(dir: string, source: string): InstructionResourceLoadResult<TResource> {\n\t\treturn this.loadResourcesFromDirInternal(dir, source, true);\n\t}\n\n\tprivate loadResourcesFromConfiguredPath(\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tif (stats.isDirectory()) return this.loadResourcesFromDirInternal(resolvedPath, source, true);\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{ type: \"warning\", message: `${this.resourceType} path is not a markdown file`, path: resolvedPath },\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = this.loadResourceFromFile(resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected loadResources(options: InstructionResourceLoaderOptions): InstructionResourceLoadResult<TResource> {\n\t\tconst resolvedCwd = resolvePath(options.cwd);\n\t\tconst resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst realPathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst realPath = canonicalizePath(resource.filePath);\n\t\t\t\tif (realPathSet.has(realPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\trealPathSet.add(realPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(join(resolvedAgentDir, this.defaultDirectoryName), \"user\", true),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tthis.loadResourcesFromDirInternal(\n\t\t\t\t\tresolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = join(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (isUnderPath(resolvedPath, userDir)) return \"user\";\n\t\t\t\tif (isUnderPath(resolvedPath, projectDir)) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });\n\t\t\taddResources(this.loadResourcesFromConfiguredPath(resolvedPath, getSource(resolvedPath)));\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate async loadResourcesFromConfiguredPathWithOperations(\n\t\toperations: ToolOperations,\n\t\tresolvedPath: string,\n\t\tsource: ConfiguredResourceSource,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tif (!(await backendPathExists(operations, resolvedPath))) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [{ type: \"warning\", message: `${this.resourceType} path does not exist`, path: resolvedPath }],\n\t\t\t};\n\t\t}\n\t\ttry {\n\t\t\tconst stats = await operations.stat(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\treturn this.loadResourcesFromDirInternalWithOperations(operations, resolvedPath, source, true);\n\t\t\t}\n\t\t\tif (!stats.isFile() || !resolvedPath.endsWith(\".md\")) {\n\t\t\t\treturn {\n\t\t\t\t\tresources: [],\n\t\t\t\t\tdiagnostics: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\t\tmessage: `${this.resourceType} path is not a markdown file`,\n\t\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(operations, resolvedPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tresources: [],\n\t\t\t\tdiagnostics: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,\n\t\t\t\t\t\tpath: resolvedPath,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t}\n\n\tprotected async loadResourcesWithOperations(\n\t\toptions: InstructionResourceLoaderWithOperationsOptions,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst backend = options.operations.getBackendInfo?.();\n\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\tconst resolvedCwd = resolvePortablePath(options.operations.cwd, options.cwd);\n\t\tconst resolvedAgentDir = normalizePortablePath(options.agentDir ?? getAgentDir(), pathFlavor);\n\t\tconst resourceMap = new Map<string, TResource>();\n\t\tconst pathSet = new Set<string>();\n\t\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\t\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\t\tconst addResources = (result: InstructionResourceLoadResult<TResource>): void => {\n\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\tfor (const resource of result.resources) {\n\t\t\t\tconst canonicalPath = pathComparisonValue(resource.filePath, pathFlavor);\n\t\t\t\tif (pathSet.has(canonicalPath)) continue;\n\t\t\t\tconst existing = resourceMap.get(resource.name);\n\t\t\t\tif (existing) {\n\t\t\t\t\tcollisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));\n\t\t\t\t} else {\n\t\t\t\t\tresourceMap.set(resource.name, resource);\n\t\t\t\t\tpathSet.add(canonicalPath);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (options.includeDefaults) {\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedAgentDir, this.defaultDirectoryName),\n\t\t\t\t\t\"user\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tjoinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName),\n\t\t\t\t\t\"project\",\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst userDir = joinPortablePath(resolvedAgentDir, this.defaultDirectoryName);\n\t\tconst projectDir = joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);\n\t\tconst getSource = (resolvedPath: string): ConfiguredResourceSource => {\n\t\t\tif (!options.includeDefaults) {\n\t\t\t\tif (relativeWithin(userDir, resolvedPath) !== undefined) return \"user\";\n\t\t\t\tif (relativeWithin(projectDir, resolvedPath) !== undefined) return \"project\";\n\t\t\t}\n\t\t\treturn \"path\";\n\t\t};\n\n\t\tfor (const rawPath of options.resourcePaths) {\n\t\t\tconst resolvedPath = resolvePortablePath(resolvedCwd, rawPath.trim());\n\t\t\taddResources(\n\t\t\t\tawait this.loadResourcesFromConfiguredPathWithOperations(\n\t\t\t\t\toptions.operations,\n\t\t\t\t\tresolvedPath,\n\t\t\t\t\tgetSource(resolvedPath),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tresources: Array.from(resourceMap.values()),\n\t\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t\t};\n\t}\n\n\tprivate createCollisionDiagnostic(resource: TResource, existing: TResource): ResourceDiagnostic {\n\t\treturn {\n\t\t\ttype: \"collision\",\n\t\t\tmessage: `name \"${resource.name}\" collision`,\n\t\t\tpath: resource.filePath,\n\t\t\tcollision: {\n\t\t\t\tresourceType: this.resourceType,\n\t\t\t\tname: resource.name,\n\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\tloserPath: resource.filePath,\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate addIgnoreRules(ig: ignore.Ignore, dir: string, rootDir: string): void {\n\t\tconst relativeDir = relative(rootDir, dir);\n\t\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = join(dir, filename);\n\t\t\tif (!existsSync(ignorePath)) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = readFileSync(ignorePath, \"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate async addIgnoreRulesWithOperations(\n\t\toperations: ToolOperations,\n\t\tig: ignore.Ignore,\n\t\tdir: string,\n\t\trootDir: string,\n\t): Promise<void> {\n\t\tconst relativeDir = relativePortablePath(rootDir, dir);\n\t\tconst prefix = relativeDir && relativeDir !== \".\" ? `${relativeDir.replace(/\\\\/g, \"/\")}/` : \"\";\n\t\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\t\tconst ignorePath = joinPortablePath(dir, filename);\n\t\t\tif (!(await backendPathExists(operations, ignorePath))) continue;\n\t\t\ttry {\n\t\t\t\tconst patterns = (await operations.readFile(ignorePath))\n\t\t\t\t\t.toString(\"utf-8\")\n\t\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\t\tif (patterns.length > 0) ig.add(patterns);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\tprivate getLocalResourceEntry(entry: Dirent, fullPath: string): Dirent | Stats | undefined {\n\t\tif (!entry.isSymbolicLink()) return entry;\n\t\ttry {\n\t\t\treturn statSync(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate loadRootResourceFromEntries(\n\t\tentries: Dirent[],\n\t\tdir: string,\n\t\tsource: string,\n\t\tignoreMatcher: ignore.Ignore,\n\t\trootDir: string,\n\t): InstructionResourceLoadResult<TResource> | undefined {\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== this.rootFileName) continue;\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\t\tif (!resourceEntry?.isFile() || ignoreMatcher.ignores(toPosixPath(relative(rootDir, fullPath)))) continue;\n\t\t\tconst result = this.loadResourceFromFile(fullPath, source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate loadNestedResourceEntry(entry: Dirent, context: LocalResourceTraversal<TResource>): void {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") return;\n\t\tconst fullPath = join(context.dir, entry.name);\n\t\tconst resourceEntry = this.getLocalResourceEntry(entry, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = toPosixPath(relative(context.rootDir, fullPath));\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = this.loadResourcesFromDirInternal(\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !entry.name.endsWith(\".md\")) return;\n\t\tconst result = this.loadResourceFromFile(fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate loadNestedResourcesFromEntries(context: LocalResourceTraversal<TResource>): void {\n\t\tfor (const entry of context.entries) this.loadNestedResourceEntry(entry, context);\n\t}\n\n\tprivate loadResourcesFromDirInternal(\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): InstructionResourceLoadResult<TResource> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!existsSync(dir)) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tthis.addIgnoreRules(ig, dir, root);\n\t\ttry {\n\t\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\t\t\tconst rootResource = this.loadRootResourceFromEntries(entries, dir, source, ig, root);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tthis.loadNestedResourcesFromEntries({\n\t\t\t\tentries,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t});\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate async getBackendResourceEntry(\n\t\toperations: ToolOperations,\n\t\tfullPath: string,\n\t): Promise<ToolFileStat | undefined> {\n\t\ttry {\n\t\t\treturn await operations.stat(fullPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async loadRootResourceWithOperations(\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<InstructionResourceLoadResult<TResource> | undefined> {\n\t\tfor (const name of context.entries) {\n\t\t\tif (name !== this.rootFileName) continue;\n\t\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\t\tif (\n\t\t\t\t!resourceEntry?.isFile() ||\n\t\t\t\tcontext.ignoreMatcher.ignores(relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\"))\n\t\t\t)\n\t\t\t\tcontinue;\n\t\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\t\treturn { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate async loadNestedResourceWithOperations(\n\t\tname: string,\n\t\tcontext: BackendResourceTraversal<TResource>,\n\t): Promise<void> {\n\t\tif (name.startsWith(\".\") || name === \"node_modules\") return;\n\t\tconst fullPath = joinPortablePath(context.dir, name);\n\t\tconst resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);\n\t\tif (!resourceEntry) return;\n\t\tconst relativePath = relativePortablePath(context.rootDir, fullPath).replace(/\\\\/g, \"/\");\n\t\tif (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath)) return;\n\t\tif (resourceEntry.isDirectory()) {\n\t\t\tconst nested = await this.loadResourcesFromDirInternalWithOperations(\n\t\t\t\tcontext.operations,\n\t\t\t\tfullPath,\n\t\t\t\tcontext.source,\n\t\t\t\tfalse,\n\t\t\t\tcontext.ignoreMatcher,\n\t\t\t\tcontext.rootDir,\n\t\t\t);\n\t\t\tcontext.resources.push(...nested.resources);\n\t\t\tcontext.diagnostics.push(...nested.diagnostics);\n\t\t\treturn;\n\t\t}\n\t\tif (!resourceEntry.isFile() || !context.includeRootFiles || !name.endsWith(\".md\")) return;\n\t\tconst result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);\n\t\tif (result.resource) context.resources.push(result.resource);\n\t\tcontext.diagnostics.push(...result.diagnostics);\n\t}\n\n\tprivate async loadNestedResourcesWithOperations(context: BackendResourceTraversal<TResource>): Promise<void> {\n\t\tfor (const name of context.entries) await this.loadNestedResourceWithOperations(name, context);\n\t}\n\n\tprivate async loadResourcesFromDirInternalWithOperations(\n\t\toperations: ToolOperations,\n\t\tdir: string,\n\t\tsource: string,\n\t\tincludeRootFiles: boolean,\n\t\tignoreMatcher?: ignore.Ignore,\n\t\trootDir?: string,\n\t): Promise<InstructionResourceLoadResult<TResource>> {\n\t\tconst resources: TResource[] = [];\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tif (!(await backendPathExists(operations, dir))) return { resources, diagnostics };\n\n\t\tconst root = rootDir ?? dir;\n\t\tconst ig = ignoreMatcher ?? ignore();\n\t\tawait this.addIgnoreRulesWithOperations(operations, ig, dir, root);\n\t\ttry {\n\t\t\tconst context: BackendResourceTraversal<TResource> = {\n\t\t\t\tentries: await operations.readdir(dir),\n\t\t\t\toperations,\n\t\t\t\tdir,\n\t\t\t\tsource,\n\t\t\t\tincludeRootFiles,\n\t\t\t\tignoreMatcher: ig,\n\t\t\t\trootDir: root,\n\t\t\t\tresources,\n\t\t\t\tdiagnostics,\n\t\t\t};\n\t\t\tconst rootResource = await this.loadRootResourceWithOperations(context);\n\t\t\tif (rootResource) return rootResource;\n\t\t\tawait this.loadNestedResourcesWithOperations(context);\n\t\t} catch {}\n\t\treturn { resources, diagnostics };\n\t}\n\n\tprivate loadResourceFromFile(filePath: string, source: string): InstructionResourceParseResult<TResource> {\n\t\ttry {\n\t\t\treturn this.parseResource(readFileSync(filePath, \"utf-8\"), filePath, source);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate async loadResourceFromFileWithOperations(\n\t\toperations: ToolOperations,\n\t\tfilePath: string,\n\t\tsource: string,\n\t): Promise<InstructionResourceParseResult<TResource>> {\n\t\ttry {\n\t\t\tconst backend = operations.getBackendInfo?.();\n\t\t\tconst pathFlavor = backend?.type === \"remote\" && backend.configured ? backend.workspace.pathFlavor : undefined;\n\t\t\treturn this.parseResource(\n\t\t\t\t(await operations.readFile(filePath)).toString(\"utf-8\"),\n\t\t\t\tfilePath,\n\t\t\t\tsource,\n\t\t\t\tpathFlavor,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\treturn this.createParseError(error, filePath);\n\t\t}\n\t}\n\n\tprivate parseResource(\n\t\trawContent: string,\n\t\tfilePath: string,\n\t\tsource: string,\n\t\tpathFlavor?: PortablePathFlavor,\n\t): InstructionResourceParseResult<TResource> {\n\t\tconst diagnostics: ResourceDiagnostic[] = [];\n\t\tconst { frontmatter } = parseFrontmatter<TFrontmatter>(rawContent);\n\t\tfor (const error of validateDescription(frontmatter.description)) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\t\tif (!frontmatter.name || frontmatter.name.trim() === \"\") {\n\t\t\tdiagnostics.push({ type: \"warning\", message: \"name is required\", path: filePath });\n\t\t}\n\t\tconst name = frontmatter.name;\n\t\tif (name) {\n\t\t\tfor (const error of validateName(name)) {\n\t\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t\t}\n\t\t}\n\t\tif (!name || !frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { resource: null, diagnostics };\n\t\t}\n\t\tconst baseDir = pathFlavor ? dirnamePortablePath(filePath, pathFlavor) : dirname(filePath);\n\t\tconst resource: InstructionResource = {\n\t\t\tname,\n\t\t\tdescription: frontmatter.description,\n\t\t\tfilePath,\n\t\t\tbaseDir,\n\t\t\tsourceInfo: createResourceSourceInfo(filePath, baseDir, source),\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\ttools: normalizeFrontmatterTools(frontmatter.tools),\n\t\t};\n\t\treturn { resource: this.createResource(resource, frontmatter), diagnostics };\n\t}\n\n\tprivate createParseError(error: unknown, filePath: string): InstructionResourceParseResult<TResource> {\n\t\treturn {\n\t\t\tresource: null,\n\t\t\tdiagnostics: [\n\t\t\t\t{\n\t\t\t\t\ttype: \"warning\",\n\t\t\t\t\tmessage: error instanceof Error ? error.message : `failed to parse ${this.resourceType} file`,\n\t\t\t\t\tpath: filePath,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t}\n}\n\nexport function formatInstructionResourcesForPrompt(\n\tresources: InstructionResource[],\n\toptions: InstructionResourcePromptFormatOptions,\n): string {\n\tconst visibleResources = resources.filter((resource) => !resource.disableModelInvocation);\n\tif (visibleResources.length === 0) return \"\";\n\n\tconst [firstIntroLine = \"\", ...remainingIntroLines] = options.intro;\n\tconst lines = [`\\n\\n${firstIntroLine}`, ...remainingIntroLines, \"\", `<${options.containerTag}>`];\n\tfor (const resource of visibleResources) {\n\t\tlines.push(` <${options.itemTag}>`);\n\t\tlines.push(` <name>${escapeXml(resource.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(resource.description)}</description>`);\n\t\tlines.push(` <location>${escapeXml(resource.filePath)}</location>`);\n\t\tlines.push(` </${options.itemTag}>`);\n\t}\n\tlines.push(`</${options.containerTag}>`);\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n"]}
|
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import ignore from "ignore";
|
|
4
|
+
import { CONFIG_DIR_NAME, getAgentDir } from "../config.js";
|
|
5
|
+
import { parseFrontmatter } from "../utils/frontmatter.js";
|
|
6
|
+
import { canonicalizePath, resolvePath } from "../utils/paths.js";
|
|
7
|
+
import { dirnamePortablePath, joinPortablePath, normalizePortablePath, pathComparisonValue, relativePortablePath, relativeWithin, resolvePortablePath, } from "./lsp/portable-path.js";
|
|
8
|
+
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
9
|
+
const MAX_NAME_LENGTH = 64;
|
|
10
|
+
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
11
|
+
const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
|
|
12
|
+
function toPosixPath(path) {
|
|
13
|
+
return path.split(sep).join("/");
|
|
14
|
+
}
|
|
15
|
+
function prefixIgnorePattern(line, prefix) {
|
|
16
|
+
const trimmed = line.trim();
|
|
17
|
+
if (!trimmed)
|
|
18
|
+
return null;
|
|
19
|
+
if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
|
|
20
|
+
return null;
|
|
21
|
+
let pattern = line;
|
|
22
|
+
let negated = false;
|
|
23
|
+
if (pattern.startsWith("!")) {
|
|
24
|
+
negated = true;
|
|
25
|
+
pattern = pattern.slice(1);
|
|
26
|
+
}
|
|
27
|
+
else if (pattern.startsWith("\\!")) {
|
|
28
|
+
pattern = pattern.slice(1);
|
|
29
|
+
}
|
|
30
|
+
if (pattern.startsWith("/"))
|
|
31
|
+
pattern = pattern.slice(1);
|
|
32
|
+
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
33
|
+
return negated ? `!${prefixed}` : prefixed;
|
|
34
|
+
}
|
|
35
|
+
function validateName(name) {
|
|
36
|
+
const errors = [];
|
|
37
|
+
if (name.length > MAX_NAME_LENGTH) {
|
|
38
|
+
errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);
|
|
39
|
+
}
|
|
40
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
41
|
+
errors.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)");
|
|
42
|
+
}
|
|
43
|
+
if (name.startsWith("-") || name.endsWith("-")) {
|
|
44
|
+
errors.push("name must not start or end with a hyphen");
|
|
45
|
+
}
|
|
46
|
+
if (name.includes("--")) {
|
|
47
|
+
errors.push("name must not contain consecutive hyphens");
|
|
48
|
+
}
|
|
49
|
+
return errors;
|
|
50
|
+
}
|
|
51
|
+
function validateDescription(description) {
|
|
52
|
+
if (!description || description.trim() === "")
|
|
53
|
+
return ["description is required"];
|
|
54
|
+
if (description.length > MAX_DESCRIPTION_LENGTH) {
|
|
55
|
+
return [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
function normalizeFrontmatterTools(value) {
|
|
60
|
+
const raw = Array.isArray(value) ? value : typeof value === "string" ? value.split(/[\s,]+/) : [];
|
|
61
|
+
const tools = [];
|
|
62
|
+
const seen = new Set();
|
|
63
|
+
for (const entry of raw) {
|
|
64
|
+
if (typeof entry !== "string")
|
|
65
|
+
continue;
|
|
66
|
+
const trimmed = entry.trim();
|
|
67
|
+
if (trimmed.length > 0 && !seen.has(trimmed)) {
|
|
68
|
+
seen.add(trimmed);
|
|
69
|
+
tools.push(trimmed);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return tools;
|
|
73
|
+
}
|
|
74
|
+
function createResourceSourceInfo(filePath, baseDir, source) {
|
|
75
|
+
switch (source) {
|
|
76
|
+
case "user":
|
|
77
|
+
return createSyntheticSourceInfo(filePath, { source: "local", scope: "user", baseDir });
|
|
78
|
+
case "project":
|
|
79
|
+
return createSyntheticSourceInfo(filePath, { source: "local", scope: "project", baseDir });
|
|
80
|
+
case "path":
|
|
81
|
+
return createSyntheticSourceInfo(filePath, { source: "local", baseDir });
|
|
82
|
+
default:
|
|
83
|
+
return createSyntheticSourceInfo(filePath, { source, baseDir });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isUnderPath(target, root) {
|
|
87
|
+
const normalizedRoot = resolve(root);
|
|
88
|
+
if (target === normalizedRoot)
|
|
89
|
+
return true;
|
|
90
|
+
const prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;
|
|
91
|
+
return target.startsWith(prefix);
|
|
92
|
+
}
|
|
93
|
+
async function backendPathExists(operations, path) {
|
|
94
|
+
try {
|
|
95
|
+
await operations.access(path, "exists");
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export class InstructionResourceLoader {
|
|
103
|
+
resourceType;
|
|
104
|
+
defaultDirectoryName;
|
|
105
|
+
rootFileName;
|
|
106
|
+
constructor(config) {
|
|
107
|
+
this.resourceType = config.resourceType;
|
|
108
|
+
this.defaultDirectoryName = config.defaultDirectoryName;
|
|
109
|
+
this.rootFileName = config.rootFileName;
|
|
110
|
+
}
|
|
111
|
+
loadResourcesFromDir(dir, source) {
|
|
112
|
+
return this.loadResourcesFromDirInternal(dir, source, true);
|
|
113
|
+
}
|
|
114
|
+
loadResourcesFromConfiguredPath(resolvedPath, source) {
|
|
115
|
+
if (!existsSync(resolvedPath)) {
|
|
116
|
+
return {
|
|
117
|
+
resources: [],
|
|
118
|
+
diagnostics: [{ type: "warning", message: `${this.resourceType} path does not exist`, path: resolvedPath }],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
const stats = statSync(resolvedPath);
|
|
123
|
+
if (stats.isDirectory())
|
|
124
|
+
return this.loadResourcesFromDirInternal(resolvedPath, source, true);
|
|
125
|
+
if (!stats.isFile() || !resolvedPath.endsWith(".md")) {
|
|
126
|
+
return {
|
|
127
|
+
resources: [],
|
|
128
|
+
diagnostics: [
|
|
129
|
+
{ type: "warning", message: `${this.resourceType} path is not a markdown file`, path: resolvedPath },
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const result = this.loadResourceFromFile(resolvedPath, source);
|
|
134
|
+
return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
return {
|
|
138
|
+
resources: [],
|
|
139
|
+
diagnostics: [
|
|
140
|
+
{
|
|
141
|
+
type: "warning",
|
|
142
|
+
message: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,
|
|
143
|
+
path: resolvedPath,
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
loadResources(options) {
|
|
150
|
+
const resolvedCwd = resolvePath(options.cwd);
|
|
151
|
+
const resolvedAgentDir = resolvePath(options.agentDir ?? getAgentDir());
|
|
152
|
+
const resourceMap = new Map();
|
|
153
|
+
const realPathSet = new Set();
|
|
154
|
+
const allDiagnostics = [];
|
|
155
|
+
const collisionDiagnostics = [];
|
|
156
|
+
const addResources = (result) => {
|
|
157
|
+
allDiagnostics.push(...result.diagnostics);
|
|
158
|
+
for (const resource of result.resources) {
|
|
159
|
+
const realPath = canonicalizePath(resource.filePath);
|
|
160
|
+
if (realPathSet.has(realPath))
|
|
161
|
+
continue;
|
|
162
|
+
const existing = resourceMap.get(resource.name);
|
|
163
|
+
if (existing) {
|
|
164
|
+
collisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
resourceMap.set(resource.name, resource);
|
|
168
|
+
realPathSet.add(realPath);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
if (options.includeDefaults) {
|
|
173
|
+
addResources(this.loadResourcesFromDirInternal(join(resolvedAgentDir, this.defaultDirectoryName), "user", true));
|
|
174
|
+
addResources(this.loadResourcesFromDirInternal(resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName), "project", true));
|
|
175
|
+
}
|
|
176
|
+
const userDir = join(resolvedAgentDir, this.defaultDirectoryName);
|
|
177
|
+
const projectDir = resolve(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);
|
|
178
|
+
const getSource = (resolvedPath) => {
|
|
179
|
+
if (!options.includeDefaults) {
|
|
180
|
+
if (isUnderPath(resolvedPath, userDir))
|
|
181
|
+
return "user";
|
|
182
|
+
if (isUnderPath(resolvedPath, projectDir))
|
|
183
|
+
return "project";
|
|
184
|
+
}
|
|
185
|
+
return "path";
|
|
186
|
+
};
|
|
187
|
+
for (const rawPath of options.resourcePaths) {
|
|
188
|
+
const resolvedPath = resolvePath(rawPath, resolvedCwd, { trim: true });
|
|
189
|
+
addResources(this.loadResourcesFromConfiguredPath(resolvedPath, getSource(resolvedPath)));
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
resources: Array.from(resourceMap.values()),
|
|
193
|
+
diagnostics: [...allDiagnostics, ...collisionDiagnostics],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
async loadResourcesFromConfiguredPathWithOperations(operations, resolvedPath, source) {
|
|
197
|
+
if (!(await backendPathExists(operations, resolvedPath))) {
|
|
198
|
+
return {
|
|
199
|
+
resources: [],
|
|
200
|
+
diagnostics: [{ type: "warning", message: `${this.resourceType} path does not exist`, path: resolvedPath }],
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
const stats = await operations.stat(resolvedPath);
|
|
205
|
+
if (stats.isDirectory()) {
|
|
206
|
+
return this.loadResourcesFromDirInternalWithOperations(operations, resolvedPath, source, true);
|
|
207
|
+
}
|
|
208
|
+
if (!stats.isFile() || !resolvedPath.endsWith(".md")) {
|
|
209
|
+
return {
|
|
210
|
+
resources: [],
|
|
211
|
+
diagnostics: [
|
|
212
|
+
{
|
|
213
|
+
type: "warning",
|
|
214
|
+
message: `${this.resourceType} path is not a markdown file`,
|
|
215
|
+
path: resolvedPath,
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const result = await this.loadResourceFromFileWithOperations(operations, resolvedPath, source);
|
|
221
|
+
return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
return {
|
|
225
|
+
resources: [],
|
|
226
|
+
diagnostics: [
|
|
227
|
+
{
|
|
228
|
+
type: "warning",
|
|
229
|
+
message: error instanceof Error ? error.message : `failed to read ${this.resourceType} path`,
|
|
230
|
+
path: resolvedPath,
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async loadResourcesWithOperations(options) {
|
|
237
|
+
const backend = options.operations.getBackendInfo?.();
|
|
238
|
+
const pathFlavor = backend?.type === "remote" && backend.configured ? backend.workspace.pathFlavor : undefined;
|
|
239
|
+
const resolvedCwd = resolvePortablePath(options.operations.cwd, options.cwd);
|
|
240
|
+
const resolvedAgentDir = normalizePortablePath(options.agentDir ?? getAgentDir(), pathFlavor);
|
|
241
|
+
const resourceMap = new Map();
|
|
242
|
+
const pathSet = new Set();
|
|
243
|
+
const allDiagnostics = [];
|
|
244
|
+
const collisionDiagnostics = [];
|
|
245
|
+
const addResources = (result) => {
|
|
246
|
+
allDiagnostics.push(...result.diagnostics);
|
|
247
|
+
for (const resource of result.resources) {
|
|
248
|
+
const canonicalPath = pathComparisonValue(resource.filePath, pathFlavor);
|
|
249
|
+
if (pathSet.has(canonicalPath))
|
|
250
|
+
continue;
|
|
251
|
+
const existing = resourceMap.get(resource.name);
|
|
252
|
+
if (existing) {
|
|
253
|
+
collisionDiagnostics.push(this.createCollisionDiagnostic(resource, existing));
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
resourceMap.set(resource.name, resource);
|
|
257
|
+
pathSet.add(canonicalPath);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
if (options.includeDefaults) {
|
|
262
|
+
addResources(await this.loadResourcesFromDirInternalWithOperations(options.operations, joinPortablePath(resolvedAgentDir, this.defaultDirectoryName), "user", true));
|
|
263
|
+
addResources(await this.loadResourcesFromDirInternalWithOperations(options.operations, joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName), "project", true));
|
|
264
|
+
}
|
|
265
|
+
const userDir = joinPortablePath(resolvedAgentDir, this.defaultDirectoryName);
|
|
266
|
+
const projectDir = joinPortablePath(resolvedCwd, CONFIG_DIR_NAME, this.defaultDirectoryName);
|
|
267
|
+
const getSource = (resolvedPath) => {
|
|
268
|
+
if (!options.includeDefaults) {
|
|
269
|
+
if (relativeWithin(userDir, resolvedPath) !== undefined)
|
|
270
|
+
return "user";
|
|
271
|
+
if (relativeWithin(projectDir, resolvedPath) !== undefined)
|
|
272
|
+
return "project";
|
|
273
|
+
}
|
|
274
|
+
return "path";
|
|
275
|
+
};
|
|
276
|
+
for (const rawPath of options.resourcePaths) {
|
|
277
|
+
const resolvedPath = resolvePortablePath(resolvedCwd, rawPath.trim());
|
|
278
|
+
addResources(await this.loadResourcesFromConfiguredPathWithOperations(options.operations, resolvedPath, getSource(resolvedPath)));
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
resources: Array.from(resourceMap.values()),
|
|
282
|
+
diagnostics: [...allDiagnostics, ...collisionDiagnostics],
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
createCollisionDiagnostic(resource, existing) {
|
|
286
|
+
return {
|
|
287
|
+
type: "collision",
|
|
288
|
+
message: `name "${resource.name}" collision`,
|
|
289
|
+
path: resource.filePath,
|
|
290
|
+
collision: {
|
|
291
|
+
resourceType: this.resourceType,
|
|
292
|
+
name: resource.name,
|
|
293
|
+
winnerPath: existing.filePath,
|
|
294
|
+
loserPath: resource.filePath,
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
addIgnoreRules(ig, dir, rootDir) {
|
|
299
|
+
const relativeDir = relative(rootDir, dir);
|
|
300
|
+
const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
|
|
301
|
+
for (const filename of IGNORE_FILE_NAMES) {
|
|
302
|
+
const ignorePath = join(dir, filename);
|
|
303
|
+
if (!existsSync(ignorePath))
|
|
304
|
+
continue;
|
|
305
|
+
try {
|
|
306
|
+
const patterns = readFileSync(ignorePath, "utf-8")
|
|
307
|
+
.split(/\r?\n/)
|
|
308
|
+
.map((line) => prefixIgnorePattern(line, prefix))
|
|
309
|
+
.filter((line) => Boolean(line));
|
|
310
|
+
if (patterns.length > 0)
|
|
311
|
+
ig.add(patterns);
|
|
312
|
+
}
|
|
313
|
+
catch { }
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
async addIgnoreRulesWithOperations(operations, ig, dir, rootDir) {
|
|
317
|
+
const relativeDir = relativePortablePath(rootDir, dir);
|
|
318
|
+
const prefix = relativeDir && relativeDir !== "." ? `${relativeDir.replace(/\\/g, "/")}/` : "";
|
|
319
|
+
for (const filename of IGNORE_FILE_NAMES) {
|
|
320
|
+
const ignorePath = joinPortablePath(dir, filename);
|
|
321
|
+
if (!(await backendPathExists(operations, ignorePath)))
|
|
322
|
+
continue;
|
|
323
|
+
try {
|
|
324
|
+
const patterns = (await operations.readFile(ignorePath))
|
|
325
|
+
.toString("utf-8")
|
|
326
|
+
.split(/\r?\n/)
|
|
327
|
+
.map((line) => prefixIgnorePattern(line, prefix))
|
|
328
|
+
.filter((line) => Boolean(line));
|
|
329
|
+
if (patterns.length > 0)
|
|
330
|
+
ig.add(patterns);
|
|
331
|
+
}
|
|
332
|
+
catch { }
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
getLocalResourceEntry(entry, fullPath) {
|
|
336
|
+
if (!entry.isSymbolicLink())
|
|
337
|
+
return entry;
|
|
338
|
+
try {
|
|
339
|
+
return statSync(fullPath);
|
|
340
|
+
}
|
|
341
|
+
catch {
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
loadRootResourceFromEntries(entries, dir, source, ignoreMatcher, rootDir) {
|
|
346
|
+
for (const entry of entries) {
|
|
347
|
+
if (entry.name !== this.rootFileName)
|
|
348
|
+
continue;
|
|
349
|
+
const fullPath = join(dir, entry.name);
|
|
350
|
+
const resourceEntry = this.getLocalResourceEntry(entry, fullPath);
|
|
351
|
+
if (!resourceEntry?.isFile() || ignoreMatcher.ignores(toPosixPath(relative(rootDir, fullPath))))
|
|
352
|
+
continue;
|
|
353
|
+
const result = this.loadResourceFromFile(fullPath, source);
|
|
354
|
+
return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
|
|
355
|
+
}
|
|
356
|
+
return undefined;
|
|
357
|
+
}
|
|
358
|
+
loadNestedResourceEntry(entry, context) {
|
|
359
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
360
|
+
return;
|
|
361
|
+
const fullPath = join(context.dir, entry.name);
|
|
362
|
+
const resourceEntry = this.getLocalResourceEntry(entry, fullPath);
|
|
363
|
+
if (!resourceEntry)
|
|
364
|
+
return;
|
|
365
|
+
const relativePath = toPosixPath(relative(context.rootDir, fullPath));
|
|
366
|
+
if (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath))
|
|
367
|
+
return;
|
|
368
|
+
if (resourceEntry.isDirectory()) {
|
|
369
|
+
const nested = this.loadResourcesFromDirInternal(fullPath, context.source, false, context.ignoreMatcher, context.rootDir);
|
|
370
|
+
context.resources.push(...nested.resources);
|
|
371
|
+
context.diagnostics.push(...nested.diagnostics);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (!resourceEntry.isFile() || !context.includeRootFiles || !entry.name.endsWith(".md"))
|
|
375
|
+
return;
|
|
376
|
+
const result = this.loadResourceFromFile(fullPath, context.source);
|
|
377
|
+
if (result.resource)
|
|
378
|
+
context.resources.push(result.resource);
|
|
379
|
+
context.diagnostics.push(...result.diagnostics);
|
|
380
|
+
}
|
|
381
|
+
loadNestedResourcesFromEntries(context) {
|
|
382
|
+
for (const entry of context.entries)
|
|
383
|
+
this.loadNestedResourceEntry(entry, context);
|
|
384
|
+
}
|
|
385
|
+
loadResourcesFromDirInternal(dir, source, includeRootFiles, ignoreMatcher, rootDir) {
|
|
386
|
+
const resources = [];
|
|
387
|
+
const diagnostics = [];
|
|
388
|
+
if (!existsSync(dir))
|
|
389
|
+
return { resources, diagnostics };
|
|
390
|
+
const root = rootDir ?? dir;
|
|
391
|
+
const ig = ignoreMatcher ?? ignore();
|
|
392
|
+
this.addIgnoreRules(ig, dir, root);
|
|
393
|
+
try {
|
|
394
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
395
|
+
const rootResource = this.loadRootResourceFromEntries(entries, dir, source, ig, root);
|
|
396
|
+
if (rootResource)
|
|
397
|
+
return rootResource;
|
|
398
|
+
this.loadNestedResourcesFromEntries({
|
|
399
|
+
entries,
|
|
400
|
+
dir,
|
|
401
|
+
source,
|
|
402
|
+
includeRootFiles,
|
|
403
|
+
ignoreMatcher: ig,
|
|
404
|
+
rootDir: root,
|
|
405
|
+
resources,
|
|
406
|
+
diagnostics,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
catch { }
|
|
410
|
+
return { resources, diagnostics };
|
|
411
|
+
}
|
|
412
|
+
async getBackendResourceEntry(operations, fullPath) {
|
|
413
|
+
try {
|
|
414
|
+
return await operations.stat(fullPath);
|
|
415
|
+
}
|
|
416
|
+
catch {
|
|
417
|
+
return undefined;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
async loadRootResourceWithOperations(context) {
|
|
421
|
+
for (const name of context.entries) {
|
|
422
|
+
if (name !== this.rootFileName)
|
|
423
|
+
continue;
|
|
424
|
+
const fullPath = joinPortablePath(context.dir, name);
|
|
425
|
+
const resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);
|
|
426
|
+
if (!resourceEntry?.isFile() ||
|
|
427
|
+
context.ignoreMatcher.ignores(relativePortablePath(context.rootDir, fullPath).replace(/\\/g, "/")))
|
|
428
|
+
continue;
|
|
429
|
+
const result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);
|
|
430
|
+
return { resources: result.resource ? [result.resource] : [], diagnostics: result.diagnostics };
|
|
431
|
+
}
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
async loadNestedResourceWithOperations(name, context) {
|
|
435
|
+
if (name.startsWith(".") || name === "node_modules")
|
|
436
|
+
return;
|
|
437
|
+
const fullPath = joinPortablePath(context.dir, name);
|
|
438
|
+
const resourceEntry = await this.getBackendResourceEntry(context.operations, fullPath);
|
|
439
|
+
if (!resourceEntry)
|
|
440
|
+
return;
|
|
441
|
+
const relativePath = relativePortablePath(context.rootDir, fullPath).replace(/\\/g, "/");
|
|
442
|
+
if (context.ignoreMatcher.ignores(resourceEntry.isDirectory() ? `${relativePath}/` : relativePath))
|
|
443
|
+
return;
|
|
444
|
+
if (resourceEntry.isDirectory()) {
|
|
445
|
+
const nested = await this.loadResourcesFromDirInternalWithOperations(context.operations, fullPath, context.source, false, context.ignoreMatcher, context.rootDir);
|
|
446
|
+
context.resources.push(...nested.resources);
|
|
447
|
+
context.diagnostics.push(...nested.diagnostics);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (!resourceEntry.isFile() || !context.includeRootFiles || !name.endsWith(".md"))
|
|
451
|
+
return;
|
|
452
|
+
const result = await this.loadResourceFromFileWithOperations(context.operations, fullPath, context.source);
|
|
453
|
+
if (result.resource)
|
|
454
|
+
context.resources.push(result.resource);
|
|
455
|
+
context.diagnostics.push(...result.diagnostics);
|
|
456
|
+
}
|
|
457
|
+
async loadNestedResourcesWithOperations(context) {
|
|
458
|
+
for (const name of context.entries)
|
|
459
|
+
await this.loadNestedResourceWithOperations(name, context);
|
|
460
|
+
}
|
|
461
|
+
async loadResourcesFromDirInternalWithOperations(operations, dir, source, includeRootFiles, ignoreMatcher, rootDir) {
|
|
462
|
+
const resources = [];
|
|
463
|
+
const diagnostics = [];
|
|
464
|
+
if (!(await backendPathExists(operations, dir)))
|
|
465
|
+
return { resources, diagnostics };
|
|
466
|
+
const root = rootDir ?? dir;
|
|
467
|
+
const ig = ignoreMatcher ?? ignore();
|
|
468
|
+
await this.addIgnoreRulesWithOperations(operations, ig, dir, root);
|
|
469
|
+
try {
|
|
470
|
+
const context = {
|
|
471
|
+
entries: await operations.readdir(dir),
|
|
472
|
+
operations,
|
|
473
|
+
dir,
|
|
474
|
+
source,
|
|
475
|
+
includeRootFiles,
|
|
476
|
+
ignoreMatcher: ig,
|
|
477
|
+
rootDir: root,
|
|
478
|
+
resources,
|
|
479
|
+
diagnostics,
|
|
480
|
+
};
|
|
481
|
+
const rootResource = await this.loadRootResourceWithOperations(context);
|
|
482
|
+
if (rootResource)
|
|
483
|
+
return rootResource;
|
|
484
|
+
await this.loadNestedResourcesWithOperations(context);
|
|
485
|
+
}
|
|
486
|
+
catch { }
|
|
487
|
+
return { resources, diagnostics };
|
|
488
|
+
}
|
|
489
|
+
loadResourceFromFile(filePath, source) {
|
|
490
|
+
try {
|
|
491
|
+
return this.parseResource(readFileSync(filePath, "utf-8"), filePath, source);
|
|
492
|
+
}
|
|
493
|
+
catch (error) {
|
|
494
|
+
return this.createParseError(error, filePath);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async loadResourceFromFileWithOperations(operations, filePath, source) {
|
|
498
|
+
try {
|
|
499
|
+
const backend = operations.getBackendInfo?.();
|
|
500
|
+
const pathFlavor = backend?.type === "remote" && backend.configured ? backend.workspace.pathFlavor : undefined;
|
|
501
|
+
return this.parseResource((await operations.readFile(filePath)).toString("utf-8"), filePath, source, pathFlavor);
|
|
502
|
+
}
|
|
503
|
+
catch (error) {
|
|
504
|
+
return this.createParseError(error, filePath);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
parseResource(rawContent, filePath, source, pathFlavor) {
|
|
508
|
+
const diagnostics = [];
|
|
509
|
+
const { frontmatter } = parseFrontmatter(rawContent);
|
|
510
|
+
for (const error of validateDescription(frontmatter.description)) {
|
|
511
|
+
diagnostics.push({ type: "warning", message: error, path: filePath });
|
|
512
|
+
}
|
|
513
|
+
if (!frontmatter.name || frontmatter.name.trim() === "") {
|
|
514
|
+
diagnostics.push({ type: "warning", message: "name is required", path: filePath });
|
|
515
|
+
}
|
|
516
|
+
const name = frontmatter.name;
|
|
517
|
+
if (name) {
|
|
518
|
+
for (const error of validateName(name)) {
|
|
519
|
+
diagnostics.push({ type: "warning", message: error, path: filePath });
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (!name || !frontmatter.description || frontmatter.description.trim() === "") {
|
|
523
|
+
return { resource: null, diagnostics };
|
|
524
|
+
}
|
|
525
|
+
const baseDir = pathFlavor ? dirnamePortablePath(filePath, pathFlavor) : dirname(filePath);
|
|
526
|
+
const resource = {
|
|
527
|
+
name,
|
|
528
|
+
description: frontmatter.description,
|
|
529
|
+
filePath,
|
|
530
|
+
baseDir,
|
|
531
|
+
sourceInfo: createResourceSourceInfo(filePath, baseDir, source),
|
|
532
|
+
disableModelInvocation: frontmatter["disable-model-invocation"] === true,
|
|
533
|
+
tools: normalizeFrontmatterTools(frontmatter.tools),
|
|
534
|
+
};
|
|
535
|
+
return { resource: this.createResource(resource, frontmatter), diagnostics };
|
|
536
|
+
}
|
|
537
|
+
createParseError(error, filePath) {
|
|
538
|
+
return {
|
|
539
|
+
resource: null,
|
|
540
|
+
diagnostics: [
|
|
541
|
+
{
|
|
542
|
+
type: "warning",
|
|
543
|
+
message: error instanceof Error ? error.message : `failed to parse ${this.resourceType} file`,
|
|
544
|
+
path: filePath,
|
|
545
|
+
},
|
|
546
|
+
],
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
export function formatInstructionResourcesForPrompt(resources, options) {
|
|
551
|
+
const visibleResources = resources.filter((resource) => !resource.disableModelInvocation);
|
|
552
|
+
if (visibleResources.length === 0)
|
|
553
|
+
return "";
|
|
554
|
+
const [firstIntroLine = "", ...remainingIntroLines] = options.intro;
|
|
555
|
+
const lines = [`\n\n${firstIntroLine}`, ...remainingIntroLines, "", `<${options.containerTag}>`];
|
|
556
|
+
for (const resource of visibleResources) {
|
|
557
|
+
lines.push(` <${options.itemTag}>`);
|
|
558
|
+
lines.push(` <name>${escapeXml(resource.name)}</name>`);
|
|
559
|
+
lines.push(` <description>${escapeXml(resource.description)}</description>`);
|
|
560
|
+
lines.push(` <location>${escapeXml(resource.filePath)}</location>`);
|
|
561
|
+
lines.push(` </${options.itemTag}>`);
|
|
562
|
+
}
|
|
563
|
+
lines.push(`</${options.containerTag}>`);
|
|
564
|
+
return lines.join("\n");
|
|
565
|
+
}
|
|
566
|
+
function escapeXml(value) {
|
|
567
|
+
return value
|
|
568
|
+
.replace(/&/g, "&")
|
|
569
|
+
.replace(/</g, "<")
|
|
570
|
+
.replace(/>/g, ">")
|
|
571
|
+
.replace(/"/g, """)
|
|
572
|
+
.replace(/'/g, "'");
|
|
573
|
+
}
|
|
574
|
+
//# sourceMappingURL=instruction-resource-loader.js.map
|