@greppleai/grip 0.1.4 → 0.1.6
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 +47 -0
- package/README.md +2 -2
- package/dist/bun/cli.d.ts.map +1 -1
- package/dist/bun/cli.js.map +1 -1
- package/dist/bun/embedded-assets.d.ts.map +1 -1
- package/dist/bun/embedded-assets.js.map +1 -1
- package/dist/bun/register-bedrock.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
- package/dist/bun/restore-sandbox-env.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts.map +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/initial-message.d.ts +1 -1
- package/dist/cli/initial-message.d.ts.map +1 -1
- package/dist/cli/initial-message.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +27 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +117 -152
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-guidance.d.ts.map +1 -1
- package/dist/core/auth-guidance.js.map +1 -1
- package/dist/core/auth-storage.d.ts +4 -0
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +6 -11
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +19 -23
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -1
- package/dist/core/compaction/compression-detection-ledger.js.map +1 -1
- package/dist/core/compaction/compression-detector.d.ts +1 -0
- package/dist/core/compaction/compression-detector.d.ts.map +1 -1
- package/dist/core/compaction/compression-detector.js +10 -21
- package/dist/core/compaction/compression-detector.js.map +1 -1
- package/dist/core/compaction/compression-economics.d.ts.map +1 -1
- package/dist/core/compaction/compression-economics.js.map +1 -1
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/event-bus.d.ts.map +1 -1
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js.map +1 -1
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
- package/dist/core/export-html/ansi-to-html.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +18 -30
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/wrapper.d.ts.map +1 -1
- package/dist/core/extensions/wrapper.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +15 -16
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/grip-agent.d.ts.map +1 -1
- package/dist/core/grip-agent.js +11 -23
- package/dist/core/grip-agent.js.map +1 -1
- package/dist/core/grip-manifest.d.ts.map +1 -1
- package/dist/core/grip-manifest.js.map +1 -1
- package/dist/core/hooks/aggregate.d.ts.map +1 -1
- package/dist/core/hooks/aggregate.js.map +1 -1
- package/dist/core/hooks/config.d.ts.map +1 -1
- package/dist/core/hooks/config.js.map +1 -1
- package/dist/core/hooks/executor.d.ts.map +1 -1
- package/dist/core/hooks/executor.js.map +1 -1
- package/dist/core/hooks/index.d.ts.map +1 -1
- package/dist/core/hooks/index.js.map +1 -1
- package/dist/core/hooks/matcher.d.ts.map +1 -1
- package/dist/core/hooks/matcher.js.map +1 -1
- package/dist/core/hooks/trust-store.d.ts.map +1 -1
- package/dist/core/hooks/trust-store.js +0 -3
- package/dist/core/hooks/trust-store.js.map +1 -1
- package/dist/core/hooks/types.d.ts.map +1 -1
- package/dist/core/hooks/types.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/instruction-resource-loader.d.ts.map +1 -1
- package/dist/core/instruction-resource-loader.js +0 -3
- package/dist/core/instruction-resource-loader.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +0 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/lsp/abort.d.ts.map +1 -1
- package/dist/core/lsp/abort.js.map +1 -1
- package/dist/core/lsp/client.d.ts.map +1 -1
- package/dist/core/lsp/client.js +8 -22
- package/dist/core/lsp/client.js.map +1 -1
- package/dist/core/lsp/config-loader.d.ts.map +1 -1
- package/dist/core/lsp/config-loader.js.map +1 -1
- package/dist/core/lsp/config.d.ts.map +1 -1
- package/dist/core/lsp/config.js.map +1 -1
- package/dist/core/lsp/diagnostics.d.ts.map +1 -1
- package/dist/core/lsp/diagnostics.js.map +1 -1
- package/dist/core/lsp/file-sync.d.ts.map +1 -1
- package/dist/core/lsp/file-sync.js +7 -9
- package/dist/core/lsp/file-sync.js.map +1 -1
- package/dist/core/lsp/integration.d.ts.map +1 -1
- package/dist/core/lsp/integration.js.map +1 -1
- package/dist/core/lsp/language-map.d.ts.map +1 -1
- package/dist/core/lsp/language-map.js +2 -7
- package/dist/core/lsp/language-map.js.map +1 -1
- package/dist/core/lsp/manager.d.ts.map +1 -1
- package/dist/core/lsp/manager.js +18 -29
- package/dist/core/lsp/manager.js.map +1 -1
- package/dist/core/lsp/navigation.d.ts.map +1 -1
- package/dist/core/lsp/navigation.js.map +1 -1
- package/dist/core/lsp/portable-path.d.ts.map +1 -1
- package/dist/core/lsp/portable-path.js.map +1 -1
- package/dist/core/lsp/refactor.d.ts.map +1 -1
- package/dist/core/lsp/refactor.js.map +1 -1
- package/dist/core/lsp/transport.d.ts.map +1 -1
- package/dist/core/lsp/transport.js.map +1 -1
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +5 -7
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +0 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/contract.js +4 -2
- package/dist/core/remote-workspace-protocol/contract.js.map +1 -1
- package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/guest-shared-client.js +1 -5
- package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -1
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +5 -10
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -1
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +2 -9
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -1
- package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -1
- package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -1
- package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/session.js +27 -65
- package/dist/core/remote-workspace-protocol/session.js.map +1 -1
- package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -1
- package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +0 -48
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rules.d.ts.map +1 -1
- package/dist/core/rules.js.map +1 -1
- package/dist/core/sandbox/command.d.ts.map +1 -1
- package/dist/core/sandbox/command.js.map +1 -1
- package/dist/core/sandbox/config.d.ts.map +1 -1
- package/dist/core/sandbox/config.js.map +1 -1
- package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -1
- package/dist/core/sandbox/lima-guest-binary.js.map +1 -1
- package/dist/core/sandbox/lima.d.ts +2 -0
- package/dist/core/sandbox/lima.d.ts.map +1 -1
- package/dist/core/sandbox/lima.js +9 -15
- package/dist/core/sandbox/lima.js.map +1 -1
- package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -1
- package/dist/core/sandbox/shared-lima-roots.js.map +1 -1
- package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -1
- package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -1
- package/dist/core/session/constants.d.ts.map +1 -1
- package/dist/core/session/context-metadata.d.ts.map +1 -1
- package/dist/core/session/context-metadata.js.map +1 -1
- package/dist/core/session/context.d.ts.map +1 -1
- package/dist/core/session/context.js.map +1 -1
- package/dist/core/session/ids.d.ts.map +1 -1
- package/dist/core/session/ids.js.map +1 -1
- package/dist/core/session/in-memory-session-manager.d.ts.map +1 -1
- package/dist/core/session/in-memory-session-manager.js +0 -1
- package/dist/core/session/in-memory-session-manager.js.map +1 -1
- package/dist/core/session/in-memory-session.d.ts.map +1 -1
- package/dist/core/session/in-memory-session.js.map +1 -1
- package/dist/core/session/jsonl-errors.d.ts.map +1 -1
- package/dist/core/session/jsonl-errors.js +0 -11
- package/dist/core/session/jsonl-errors.js.map +1 -1
- package/dist/core/session/jsonl-helpers.d.ts.map +1 -1
- package/dist/core/session/jsonl-helpers.js.map +1 -1
- package/dist/core/session/local-session-manager.d.ts.map +1 -1
- package/dist/core/session/local-session-manager.js +4 -6
- package/dist/core/session/local-session-manager.js.map +1 -1
- package/dist/core/session/local-session.d.ts.map +1 -1
- package/dist/core/session/local-session.js.map +1 -1
- package/dist/core/session/migrations.d.ts.map +1 -1
- package/dist/core/session/migrations.js.map +1 -1
- package/dist/core/session/remote-session-client.d.ts.map +1 -1
- package/dist/core/session/remote-session-client.js +0 -6
- package/dist/core/session/remote-session-client.js.map +1 -1
- package/dist/core/session/remote-session-manager.d.ts.map +1 -1
- package/dist/core/session/remote-session-manager.js +0 -3
- package/dist/core/session/remote-session-manager.js.map +1 -1
- package/dist/core/session/remote-session.d.ts.map +1 -1
- package/dist/core/session/remote-session.js +0 -1
- package/dist/core/session/remote-session.js.map +1 -1
- package/dist/core/session/session-manager.d.ts.map +1 -1
- package/dist/core/session/session.d.ts.map +1 -1
- package/dist/core/session/session.js +1 -5
- package/dist/core/session/session.js.map +1 -1
- package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -1
- package/dist/core/session/stores/in-memory-session-store.js +7 -6
- package/dist/core/session/stores/in-memory-session-store.js.map +1 -1
- package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/session/stores/jsonl-session-store.js +6 -14
- package/dist/core/session/stores/jsonl-session-store.js.map +1 -1
- package/dist/core/session/stores/remote-session-store.d.ts.map +1 -1
- package/dist/core/session/stores/remote-session-store.js +3 -8
- package/dist/core/session/stores/remote-session-store.js.map +1 -1
- package/dist/core/session/stores/session-store.d.ts.map +1 -1
- package/dist/core/session/types.d.ts.map +1 -1
- package/dist/core/session/usage-ledger.d.ts.map +1 -1
- package/dist/core/session/usage-ledger.js.map +1 -1
- package/dist/core/session-cwd.d.ts.map +1 -1
- package/dist/core/session-cwd.js +0 -1
- package/dist/core/session-cwd.js.map +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +9 -17
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/telemetry.d.ts.map +1 -1
- package/dist/core/telemetry.js.map +1 -1
- package/dist/core/timings.d.ts.map +1 -1
- package/dist/core/timings.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +8 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/compress-context.d.ts.map +1 -1
- package/dist/core/tools/compress-context.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/hash-store.d.ts.map +1 -1
- package/dist/core/tools/hash-store.js.map +1 -1
- package/dist/core/tools/hashline/apply.d.ts.map +1 -1
- package/dist/core/tools/hashline/apply.js.map +1 -1
- package/dist/core/tools/hashline/hash.d.ts.map +1 -1
- package/dist/core/tools/hashline/hash.js.map +1 -1
- package/dist/core/tools/hashline/parse.d.ts.map +1 -1
- package/dist/core/tools/hashline/parse.js.map +1 -1
- package/dist/core/tools/hashline/resolve.d.ts.map +1 -1
- package/dist/core/tools/hashline/resolve.js.map +1 -1
- package/dist/core/tools/hashline-utils.d.ts.map +1 -1
- package/dist/core/tools/hashline-utils.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/operations.d.ts +5 -0
- package/dist/core/tools/operations.d.ts.map +1 -1
- package/dist/core/tools/operations.js +26 -24
- package/dist/core/tools/operations.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +12 -18
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/path-utils.d.ts.map +1 -1
- package/dist/core/tools/path-utils.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/replace-diff.d.ts.map +1 -1
- package/dist/core/tools/replace-diff.js.map +1 -1
- package/dist/core/tools/replace-normalize.d.ts.map +1 -1
- package/dist/core/tools/replace-normalize.js.map +1 -1
- package/dist/core/tools/replace-render.d.ts +1 -1
- package/dist/core/tools/replace-render.d.ts.map +1 -1
- package/dist/core/tools/replace-render.js.map +1 -1
- package/dist/core/tools/runtime.d.ts.map +1 -1
- package/dist/core/tools/runtime.js.map +1 -1
- package/dist/core/tools/session-history.d.ts.map +1 -1
- package/dist/core/tools/session-history.js.map +1 -1
- package/dist/core/tools/subagent-agents.d.ts.map +1 -1
- package/dist/core/tools/subagent-agents.js.map +1 -1
- package/dist/core/tools/subagent.d.ts.map +1 -1
- package/dist/core/tools/subagent.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/core/tools/websearch.d.ts.map +1 -1
- package/dist/core/tools/websearch.js.map +1 -1
- package/dist/core/tools/workspace-tool-host.d.ts +1 -0
- package/dist/core/tools/workspace-tool-host.d.ts.map +1 -1
- package/dist/core/tools/workspace-tool-host.js +36 -22
- package/dist/core/tools/workspace-tool-host.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +0 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workspace-identity.d.ts.map +1 -1
- package/dist/daemon/activity-budget.d.ts.map +1 -1
- package/dist/daemon/activity-budget.js +2 -3
- package/dist/daemon/activity-budget.js.map +1 -1
- package/dist/daemon/command.d.ts.map +1 -1
- package/dist/daemon/command.js.map +1 -1
- package/dist/daemon/config.d.ts +2 -0
- package/dist/daemon/config.d.ts.map +1 -1
- package/dist/daemon/config.js +4 -0
- package/dist/daemon/config.js.map +1 -1
- package/dist/daemon/help.d.ts.map +1 -1
- package/dist/daemon/help.js +4 -3
- package/dist/daemon/help.js.map +1 -1
- package/dist/daemon/lsp-config.d.ts.map +1 -1
- package/dist/daemon/lsp-config.js.map +1 -1
- package/dist/daemon/outbound-budget.d.ts.map +1 -1
- package/dist/daemon/outbound-budget.js +2 -4
- package/dist/daemon/outbound-budget.js.map +1 -1
- package/dist/daemon/security.d.ts.map +1 -1
- package/dist/daemon/security.js.map +1 -1
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/shared-connection.d.ts.map +1 -1
- package/dist/daemon/shared-connection.js +10 -15
- package/dist/daemon/shared-connection.js.map +1 -1
- package/dist/daemon/shared-revision.d.ts.map +1 -1
- package/dist/daemon/shared-revision.js +2 -1
- package/dist/daemon/shared-revision.js.map +1 -1
- package/dist/daemon/shared-roots.d.ts.map +1 -1
- package/dist/daemon/shared-roots.js +0 -1
- package/dist/daemon/shared-roots.js.map +1 -1
- package/dist/daemon/workspace-runtime.d.ts +2 -0
- package/dist/daemon/workspace-runtime.d.ts.map +1 -1
- package/dist/daemon/workspace-runtime.js +43 -15
- package/dist/daemon/workspace-runtime.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +21 -17
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -9
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +0 -3
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +1 -3
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +6 -16
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +0 -5
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +1 -8
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +1 -6
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/diff.d.ts.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js +0 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +1 -7
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +2 -8
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +1 -9
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -3
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/hook-execution.js +2 -5
- package/dist/modes/interactive/components/hook-execution.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -9
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/message-card.d.ts.map +1 -1
- package/dist/modes/interactive/components/message-card.js +0 -1
- package/dist/modes/interactive/components/message-card.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +26 -18
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +223 -210
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +3 -12
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +9 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +33 -58
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +0 -4
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js +0 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/theme-selector.js +0 -2
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +0 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -24
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +18 -34
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +3 -6
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +0 -4
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +14 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +223 -137
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +0 -7
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +10 -11
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js.map +1 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard-native.d.ts.map +1 -1
- package/dist/utils/clipboard-native.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/deprecation.d.ts.map +1 -1
- package/dist/utils/deprecation.js.map +1 -1
- package/dist/utils/directory-completions.d.ts.map +1 -1
- package/dist/utils/directory-completions.js.map +1 -1
- package/dist/utils/exif-orientation.d.ts.map +1 -1
- package/dist/utils/exif-orientation.js.map +1 -1
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/fs-watch.d.ts.map +1 -1
- package/dist/utils/fs-watch.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/grip-user-agent.d.ts.map +1 -1
- package/dist/utils/grip-user-agent.js +1 -1
- package/dist/utils/grip-user-agent.js.map +1 -1
- package/dist/utils/html.d.ts.map +1 -1
- package/dist/utils/html.js.map +1 -1
- package/dist/utils/image-convert.d.ts.map +1 -1
- package/dist/utils/image-convert.js.map +1 -1
- package/dist/utils/image-process.d.ts.map +1 -1
- package/dist/utils/image-process.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/image-resize-worker.d.ts.map +1 -1
- package/dist/utils/image-resize-worker.js.map +1 -1
- package/dist/utils/image-resize.d.ts.map +1 -1
- package/dist/utils/image-resize.js.map +1 -1
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js.map +1 -1
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/photon.d.ts.map +1 -1
- package/dist/utils/photon.js +10 -5
- package/dist/utils/photon.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts.map +1 -1
- package/dist/utils/sleep.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +1 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js.map +1 -1
- package/dist/utils/windows-self-update.d.ts.map +1 -1
- package/dist/utils/windows-self-update.js.map +1 -1
- package/docs/keybindings.md +3 -1
- package/docs/providers.md +3 -1
- package/docs/sandbox.md +7 -1
- package/docs/sessions.md +1 -1
- package/docs/usage.md +39 -2
- package/examples/extensions/custom-provider-anthropic/package.json +2 -2
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +601 -833
- package/package.json +20 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GA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AED,OAAO;YACN,KAAK,EAAE,aAAa;YACpB,eAAe,EAAE,2BAA2B,aAAa,IAAI,YAAY,KAAK,MAAM,YAAY,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,EAAE,GAAG;SAC7I,CAAC;IACH,CAAC;IAED,sBAAsB;IACtB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC;AAAA,CACxD","sourcesContent":["/**\n * Model resolution, scoping, and initial selection\n */\n\nimport type { ThinkingLevel } from \"@greppleai/grip-agent-core\";\nimport type { Api, KnownProvider, Model } from \"@greppleai/grip-ai\";\nimport chalk from \"chalk\";\nimport { minimatch } from \"minimatch\";\nimport { isValidThinkingLevel } from \"../cli/args.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\n\n/** Default model IDs for each known provider */\nexport const defaultModelPerProvider: Record<KnownProvider, string> = {\n\t\"amazon-bedrock\": \"us.anthropic.claude-opus-4-6-v1\",\n\tanthropic: \"claude-opus-4-7\",\n\topenai: \"gpt-5.4\",\n\t\"azure-openai-responses\": \"gpt-5.4\",\n\t\"openai-codex\": \"gpt-6-astra\",\n\tdeepseek: \"deepseek-v4-pro\",\n\tgoogle: \"gemini-3.1-pro-preview\",\n\t\"google-vertex\": \"gemini-3.1-pro-preview\",\n\t\"github-copilot\": \"gpt-5.4\",\n\topenrouter: \"moonshotai/kimi-k2.6\",\n\t\"vercel-ai-gateway\": \"zai/glm-5.1\",\n\txai: \"grok-4.20-0309-reasoning\",\n\tgroq: \"openai/gpt-oss-120b\",\n\tcerebras: \"zai-glm-4.7\",\n\tzai: \"glm-5.1\",\n\tmistral: \"devstral-medium-latest\",\n\tminimax: \"MiniMax-M2.7\",\n\t\"minimax-cn\": \"MiniMax-M2.7\",\n\tmoonshotai: \"kimi-k2.6\",\n\t\"moonshotai-cn\": \"kimi-k2.6\",\n\thuggingface: \"moonshotai/Kimi-K2.6\",\n\tfireworks: \"accounts/fireworks/models/kimi-k2p6\",\n\ttogether: \"moonshotai/Kimi-K2.6\",\n\topencode: \"kimi-k2.6\",\n\t\"opencode-go\": \"kimi-k2.6\",\n\t\"kimi-coding\": \"kimi-for-coding\",\n\t\"cloudflare-workers-ai\": \"@cf/moonshotai/kimi-k2.6\",\n\t\"cloudflare-ai-gateway\": \"workers-ai/@cf/moonshotai/kimi-k2.6\",\n\txiaomi: \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-cn\": \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-ams\": \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-sgp\": \"mimo-v2.5-pro\",\n};\n\nexport interface ScopedModel {\n\tmodel: Model<Api>;\n\t/** Thinking level if explicitly specified in pattern (e.g., \"model:high\"), undefined otherwise */\n\tthinkingLevel?: ThinkingLevel;\n}\n\n/**\n * Helper to check if a model ID looks like an alias (no date suffix)\n * Dates are typically in format: -20241022 or -20250929\n */\nfunction isAlias(id: string): boolean {\n\t// Check if ID ends with -latest\n\tif (id.endsWith(\"-latest\")) return true;\n\n\t// Check if ID ends with a date pattern (-YYYYMMDD)\n\tconst datePattern = /-\\d{8}$/;\n\treturn !datePattern.test(id);\n}\n\n/**\n * Find an exact model reference match.\n * Supports either a bare model id or a canonical provider/modelId reference.\n * When matching by bare id, ambiguous matches across providers are rejected.\n */\nexport function findExactModelReferenceMatch(\n\tmodelReference: string,\n\tavailableModels: Model<Api>[],\n): Model<Api> | undefined {\n\tconst trimmedReference = modelReference.trim();\n\tif (!trimmedReference) {\n\t\treturn undefined;\n\t}\n\n\tconst normalizedReference = trimmedReference.toLowerCase();\n\n\tconst canonicalMatches = availableModels.filter(\n\t\t(model) => `${model.provider}/${model.id}`.toLowerCase() === normalizedReference,\n\t);\n\tif (canonicalMatches.length === 1) {\n\t\treturn canonicalMatches[0];\n\t}\n\tif (canonicalMatches.length > 1) {\n\t\treturn undefined;\n\t}\n\n\tconst slashIndex = trimmedReference.indexOf(\"/\");\n\tif (slashIndex !== -1) {\n\t\tconst provider = trimmedReference.substring(0, slashIndex).trim();\n\t\tconst modelId = trimmedReference.substring(slashIndex + 1).trim();\n\t\tif (provider && modelId) {\n\t\t\tconst providerMatches = availableModels.filter(\n\t\t\t\t(model) =>\n\t\t\t\t\tmodel.provider.toLowerCase() === provider.toLowerCase() &&\n\t\t\t\t\tmodel.id.toLowerCase() === modelId.toLowerCase(),\n\t\t\t);\n\t\t\tif (providerMatches.length === 1) {\n\t\t\t\treturn providerMatches[0];\n\t\t\t}\n\t\t\tif (providerMatches.length > 1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst idMatches = availableModels.filter((model) => model.id.toLowerCase() === normalizedReference);\n\treturn idMatches.length === 1 ? idMatches[0] : undefined;\n}\n\n/**\n * Try to match a pattern to a model from the available models list.\n * Returns the matched model or undefined if no match found.\n */\nfunction tryMatchModel(modelPattern: string, availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst exactMatch = findExactModelReferenceMatch(modelPattern, availableModels);\n\tif (exactMatch) {\n\t\treturn exactMatch;\n\t}\n\n\t// No exact match - fall back to partial matching\n\tconst matches = availableModels.filter(\n\t\t(m) =>\n\t\t\tm.id.toLowerCase().includes(modelPattern.toLowerCase()) ||\n\t\t\tm.name?.toLowerCase().includes(modelPattern.toLowerCase()),\n\t);\n\n\tif (matches.length === 0) {\n\t\treturn undefined;\n\t}\n\n\t// Separate into aliases and dated versions\n\tconst aliases = matches.filter((m) => isAlias(m.id));\n\tconst datedVersions = matches.filter((m) => !isAlias(m.id));\n\n\tif (aliases.length > 0) {\n\t\t// Prefer alias - if multiple aliases, pick the one that sorts highest\n\t\taliases.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn aliases[0];\n\t} else {\n\t\t// No alias found, pick latest dated version\n\t\tdatedVersions.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn datedVersions[0];\n\t}\n}\n\ninterface ParseModelPatternOptions {\n\tallowInvalidThinkingLevelFallback?: boolean;\n}\n\nexport interface ParsedModelResult {\n\tmodel: Model<Api> | undefined;\n\t/** Thinking level if explicitly specified in pattern, undefined otherwise */\n\tthinkingLevel?: ThinkingLevel;\n\twarning: string | undefined;\n}\n\nfunction buildFallbackModel(provider: string, modelId: string, availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst providerModels = availableModels.filter((m) => m.provider === provider);\n\tif (providerModels.length === 0) return undefined;\n\n\tconst defaultId = defaultModelPerProvider[provider as KnownProvider];\n\tconst baseModel = defaultId\n\t\t? (providerModels.find((m) => m.id === defaultId) ?? providerModels[0])\n\t\t: providerModels[0];\n\n\treturn {\n\t\t...baseModel,\n\t\tid: modelId,\n\t\tname: modelId,\n\t};\n}\n\n/**\n * Parse a pattern to extract model and thinking level.\n * Handles models with colons in their IDs (e.g., OpenRouter's :exacto suffix).\n *\n * Algorithm:\n * 1. Try to match full pattern as a model\n * 2. If found, return it with \"off\" thinking level\n * 3. If not found and has colons, split on last colon:\n * - If suffix is valid thinking level, use it and recurse on prefix\n * - If suffix is invalid, warn and recurse on prefix with \"off\"\n *\n * @internal Exported for testing\n */\nexport function parseModelPattern(\n\tpattern: string,\n\tavailableModels: Model<Api>[],\n\toptions?: ParseModelPatternOptions,\n): ParsedModelResult {\n\t// Try exact match first\n\tconst exactMatch = tryMatchModel(pattern, availableModels);\n\tif (exactMatch) {\n\t\treturn { model: exactMatch, thinkingLevel: undefined, warning: undefined };\n\t}\n\n\t// No match - try splitting on last colon if present\n\tconst lastColonIndex = pattern.lastIndexOf(\":\");\n\tif (lastColonIndex === -1) {\n\t\t// No colons, pattern simply doesn't match any model\n\t\treturn { model: undefined, thinkingLevel: undefined, warning: undefined };\n\t}\n\n\tconst prefix = pattern.substring(0, lastColonIndex);\n\tconst suffix = pattern.substring(lastColonIndex + 1);\n\n\tif (isValidThinkingLevel(suffix)) {\n\t\t// Valid thinking level - recurse on prefix and use this level\n\t\tconst result = parseModelPattern(prefix, availableModels, options);\n\t\tif (result.model) {\n\t\t\t// Only use this thinking level if no warning from inner recursion\n\t\t\treturn {\n\t\t\t\tmodel: result.model,\n\t\t\t\tthinkingLevel: result.warning ? undefined : suffix,\n\t\t\t\twarning: result.warning,\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t} else {\n\t\t// Invalid suffix\n\t\tconst allowFallback = options?.allowInvalidThinkingLevelFallback ?? true;\n\t\tif (!allowFallback) {\n\t\t\t// In strict mode (CLI --model parsing), treat it as part of the model id and fail.\n\t\t\t// This avoids accidentally resolving to a different model.\n\t\t\treturn { model: undefined, thinkingLevel: undefined, warning: undefined };\n\t\t}\n\n\t\t// Scope mode: recurse on prefix and warn\n\t\tconst result = parseModelPattern(prefix, availableModels, options);\n\t\tif (result.model) {\n\t\t\treturn {\n\t\t\t\tmodel: result.model,\n\t\t\t\tthinkingLevel: undefined,\n\t\t\t\twarning: `Invalid thinking level \"${suffix}\" in pattern \"${pattern}\". Using default instead.`,\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t}\n}\n\ninterface GlobModelPattern {\n\tpattern: string;\n\tthinkingLevel?: ThinkingLevel;\n}\n\ninterface ModelScopePatternResolution {\n\tmodels: ScopedModel[];\n\twarnings: string[];\n}\n\nfunction parseGlobModelPattern(pattern: string): GlobModelPattern {\n\tconst colonIndex = pattern.lastIndexOf(\":\");\n\tif (colonIndex === -1) return { pattern };\n\tconst suffix = pattern.substring(colonIndex + 1);\n\treturn isValidThinkingLevel(suffix)\n\t\t? { pattern: pattern.substring(0, colonIndex), thinkingLevel: suffix }\n\t\t: { pattern };\n}\n\nfunction resolveGlobModelScopePattern(pattern: string, availableModels: Model<Api>[]): ModelScopePatternResolution {\n\tconst glob = parseGlobModelPattern(pattern);\n\tconst matchingModels = availableModels.filter((model) => {\n\t\tconst fullId = `${model.provider}/${model.id}`;\n\t\treturn minimatch(fullId, glob.pattern, { nocase: true }) || minimatch(model.id, glob.pattern, { nocase: true });\n\t});\n\tif (matchingModels.length === 0) {\n\t\treturn { models: [], warnings: [`Warning: No models match pattern \"${pattern}\"`] };\n\t}\n\treturn {\n\t\tmodels: matchingModels.map((model) => ({ model, thinkingLevel: glob.thinkingLevel })),\n\t\twarnings: [],\n\t};\n}\n\nfunction resolveLiteralModelScopePattern(pattern: string, availableModels: Model<Api>[]): ModelScopePatternResolution {\n\tconst { model, thinkingLevel, warning } = parseModelPattern(pattern, availableModels);\n\tconst warnings = warning ? [`Warning: ${warning}`] : [];\n\tif (!model) warnings.push(`Warning: No models match pattern \"${pattern}\"`);\n\treturn { models: model ? [{ model, thinkingLevel }] : [], warnings };\n}\n\ntype ModelIndex = Map<string, Map<string, Model<Api>>>;\n\nfunction addModelToIndex(index: ModelIndex, model: Model<Api>): boolean {\n\tlet providerModels = index.get(model.provider);\n\tif (!providerModels) {\n\t\tproviderModels = new Map();\n\t\tindex.set(model.provider, providerModels);\n\t}\n\tif (providerModels.has(model.id)) return false;\n\tproviderModels.set(model.id, model);\n\treturn true;\n}\n\nfunction createModelIndex(models: Iterable<Model<Api>>): ModelIndex {\n\tconst index: ModelIndex = new Map();\n\tfor (const model of models) addModelToIndex(index, model);\n\treturn index;\n}\n\nfunction appendUniqueScopedModels(target: ScopedModel[], candidates: ScopedModel[]): void {\n\tconst modelIndex = createModelIndex(target.map((scopedModel) => scopedModel.model));\n\tfor (const candidate of candidates) {\n\t\tif (addModelToIndex(modelIndex, candidate.model)) target.push(candidate);\n\t}\n}\n/**\n * Resolve model patterns to actual Model objects with optional thinking levels\n * Format: \"pattern:level\" where :level is optional\n * For each pattern, finds all matching models and picks the best version:\n * 1. Prefer alias (e.g., claude-sonnet-4-5) over dated versions (claude-sonnet-4-5-20250929)\n * 2. If no alias, pick the latest dated version\n *\n * Supports models with colons in their IDs (e.g., OpenRouter's model:exacto).\n * The algorithm tries to match the full pattern first, then progressively\n * strips colon-suffixes to find a match.\n */\nexport async function resolveModelScope(patterns: string[], modelRegistry: ModelRegistry): Promise<ScopedModel[]> {\n\tconst availableModels = await modelRegistry.getAvailable();\n\tconst scopedModels: ScopedModel[] = [];\n\tfor (const pattern of patterns) {\n\t\tconst resolution =\n\t\t\tpattern.includes(\"*\") || pattern.includes(\"?\") || pattern.includes(\"[\")\n\t\t\t\t? resolveGlobModelScopePattern(pattern, availableModels)\n\t\t\t\t: resolveLiteralModelScopePattern(pattern, availableModels);\n\t\tfor (const warning of resolution.warnings) console.warn(chalk.yellow(warning));\n\t\tappendUniqueScopedModels(scopedModels, resolution.models);\n\t}\n\treturn scopedModels;\n}\n\ninterface ResolveCliModelOptions {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tmodelRegistry: ModelRegistry;\n}\n\nexport interface ResolveCliModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel?: ThinkingLevel;\n\twarning: string | undefined;\n\t/**\n\t * Error message suitable for CLI display.\n\t * When set, model will be undefined.\n\t */\n\terror: string | undefined;\n}\n\ninterface CliModelReference {\n\tprovider: string | undefined;\n\tpattern: string;\n\tinferredProvider: boolean;\n}\n\ntype CliModelReferenceResolution =\n\t| { reference: CliModelReference; error?: never }\n\t| { reference?: never; error: string };\n\nfunction createProviderMap(availableModels: Model<Api>[]): Map<string, string> {\n\tconst providerMap = new Map<string, string>();\n\tfor (const model of availableModels) providerMap.set(model.provider.toLowerCase(), model.provider);\n\treturn providerMap;\n}\n\nfunction resolveCliModelReference(\n\tcliProvider: string | undefined,\n\tcliModel: string,\n\tproviderMap: Map<string, string>,\n): CliModelReferenceResolution {\n\tlet provider = cliProvider ? providerMap.get(cliProvider.toLowerCase()) : undefined;\n\tif (cliProvider && !provider) {\n\t\treturn { error: `Unknown provider \"${cliProvider}\". Use --list-models to see available providers/models.` };\n\t}\n\tlet pattern = cliModel;\n\tlet inferredProvider = false;\n\tif (!provider) {\n\t\tconst slashIndex = cliModel.indexOf(\"/\");\n\t\tconst maybeProvider = slashIndex === -1 ? undefined : cliModel.substring(0, slashIndex);\n\t\tconst canonical = maybeProvider ? providerMap.get(maybeProvider.toLowerCase()) : undefined;\n\t\tif (canonical) {\n\t\t\tprovider = canonical;\n\t\t\tpattern = cliModel.substring(slashIndex + 1);\n\t\t\tinferredProvider = true;\n\t\t}\n\t}\n\tif (cliProvider && provider) {\n\t\tconst prefix = `${provider}/`;\n\t\tif (cliModel.toLowerCase().startsWith(prefix.toLowerCase())) pattern = cliModel.substring(prefix.length);\n\t}\n\treturn { reference: { provider, pattern, inferredProvider } };\n}\n\nfunction findExactCliInputModel(cliModel: string, availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst lower = cliModel.toLowerCase();\n\treturn availableModels.find(\n\t\t(model) => model.id.toLowerCase() === lower || `${model.provider}/${model.id}`.toLowerCase() === lower,\n\t);\n}\n\nfunction resolveInferredProviderFallback(\n\tcliModel: string,\n\tavailableModels: Model<Api>[],\n): ResolveCliModelResult | undefined {\n\tconst exact = findExactCliInputModel(cliModel, availableModels);\n\tif (exact) return { model: exact, warning: undefined, thinkingLevel: undefined, error: undefined };\n\tconst fallback = parseModelPattern(cliModel, availableModels, {\n\t\tallowInvalidThinkingLevelFallback: false,\n\t});\n\tif (!fallback.model) return undefined;\n\treturn {\n\t\tmodel: fallback.model,\n\t\tthinkingLevel: fallback.thinkingLevel,\n\t\twarning: fallback.warning,\n\t\terror: undefined,\n\t};\n}\n\nfunction resolveCustomProviderModel(\n\tprovider: string,\n\tpattern: string,\n\twarning: string | undefined,\n\tavailableModels: Model<Api>[],\n): ResolveCliModelResult | undefined {\n\tconst fallbackModel = buildFallbackModel(provider, pattern, availableModels);\n\tif (!fallbackModel) return undefined;\n\tconst fallbackWarning = warning\n\t\t? `${warning} Model \"${pattern}\" not found for provider \"${provider}\". Using custom model id.`\n\t\t: `Model \"${pattern}\" not found for provider \"${provider}\". Using custom model id.`;\n\treturn { model: fallbackModel, thinkingLevel: undefined, warning: fallbackWarning, error: undefined };\n}\n\n/**\n * Resolve a single model from CLI flags.\n *\n * Supports:\n * - --provider <provider> --model <pattern>\n * - --model <provider>/<pattern>\n * - Fuzzy matching (same rules as model scoping: exact id, then partial id/name)\n *\n * Note: This does not apply the thinking level by itself, but it may *parse* and\n * return a thinking level from \"<pattern>:<thinking>\" so the caller can apply it.\n */\nexport function resolveCliModel(options: ResolveCliModelOptions): ResolveCliModelResult {\n\tconst { cliProvider, cliModel, modelRegistry } = options;\n\tif (!cliModel) return { model: undefined, warning: undefined, error: undefined };\n\n\t// Important: use *all* models here, not just models with pre-configured auth.\n\t// This allows \"--api-key\" to be used for first-time setup.\n\tconst availableModels = modelRegistry.getAll();\n\tif (availableModels.length === 0) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: \"No models available. Check your installation or add models to models.json.\",\n\t\t};\n\t}\n\n\tconst referenceResolution = resolveCliModelReference(cliProvider, cliModel, createProviderMap(availableModels));\n\tif (\"error\" in referenceResolution) {\n\t\treturn { model: undefined, warning: undefined, error: referenceResolution.error };\n\t}\n\tconst { provider, pattern, inferredProvider } = referenceResolution.reference;\n\n\t// Without provider inference, model IDs containing slashes remain eligible for exact matching.\n\tif (!provider) {\n\t\tconst exact = findExactCliInputModel(cliModel, availableModels);\n\t\tif (exact) return { model: exact, warning: undefined, thinkingLevel: undefined, error: undefined };\n\t}\n\n\tconst candidates = provider ? availableModels.filter((model) => model.provider === provider) : availableModels;\n\tconst { model, thinkingLevel, warning } = parseModelPattern(pattern, candidates, {\n\t\tallowInvalidThinkingLevelFallback: false,\n\t});\n\tif (model) return { model, thinkingLevel, warning, error: undefined };\n\n\t// A slash prefix can name either a provider or part of a raw model ID. Retry the full input after provider matching fails.\n\tif (inferredProvider) {\n\t\tconst fallback = resolveInferredProviderFallback(cliModel, availableModels);\n\t\tif (fallback) return fallback;\n\t}\n\n\tif (provider) {\n\t\tconst fallback = resolveCustomProviderModel(provider, pattern, warning, availableModels);\n\t\tif (fallback) return fallback;\n\t}\n\n\tconst display = provider ? `${provider}/${pattern}` : cliModel;\n\treturn {\n\t\tmodel: undefined,\n\t\tthinkingLevel: undefined,\n\t\twarning,\n\t\terror: `Model \"${display}\" not found. Use --list-models to see available models.`,\n\t};\n}\n\nfunction findPreferredAvailableModel(availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst modelIndex = createModelIndex(availableModels);\n\tfor (const provider of Object.keys(defaultModelPerProvider) as KnownProvider[]) {\n\t\tconst match = modelIndex.get(provider)?.get(defaultModelPerProvider[provider]);\n\t\tif (match) return match;\n\t}\n\treturn availableModels[0];\n}\n\ninterface FindInitialModelOptions {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tscopedModels: ScopedModel[];\n\tisContinuing: boolean;\n\tdefaultProvider?: string;\n\tdefaultModelId?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelRegistry: ModelRegistry;\n}\n\nexport interface InitialModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel: ThinkingLevel;\n\tfallbackMessage: string | undefined;\n}\n\nfunction resolveInitialCliSelection(\n\tcliProvider: string | undefined,\n\tcliModel: string | undefined,\n\tmodelRegistry: ModelRegistry,\n): InitialModelResult | undefined {\n\tif (!cliProvider || !cliModel) return undefined;\n\tconst resolved = resolveCliModel({ cliProvider, cliModel, modelRegistry });\n\tif (resolved.error) {\n\t\tconsole.error(chalk.red(resolved.error));\n\t\tprocess.exit(1);\n\t}\n\treturn resolved.model\n\t\t? { model: resolved.model, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined }\n\t\t: undefined;\n}\n\n/**\n * Find the initial model to use based on priority:\n * 1. CLI args (provider + model)\n * 2. First model from scoped models (if not continuing/resuming)\n * 3. Restored from session (if continuing/resuming)\n * 4. Saved default from settings\n * 5. First available model with valid API key\n */\nexport async function findInitialModel(options: FindInitialModelOptions): Promise<InitialModelResult> {\n\tconst {\n\t\tcliProvider,\n\t\tcliModel,\n\t\tscopedModels,\n\t\tisContinuing,\n\t\tdefaultProvider,\n\t\tdefaultModelId,\n\t\tdefaultThinkingLevel,\n\t\tmodelRegistry,\n\t} = options;\n\n\t// 1. CLI args take priority\n\tconst cliSelection = resolveInitialCliSelection(cliProvider, cliModel, modelRegistry);\n\tif (cliSelection) return cliSelection;\n\n\t// 2. Use first model from scoped models (skip if continuing/resuming)\n\tif (scopedModels.length > 0 && !isContinuing) {\n\t\treturn {\n\t\t\tmodel: scopedModels[0].model,\n\t\t\tthinkingLevel: scopedModels[0].thinkingLevel ?? defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\t// 3. Try saved default from settings if auth is configured.\n\tif (defaultProvider && defaultModelId) {\n\t\tconst found = modelRegistry.find(defaultProvider, defaultModelId);\n\t\tif (found && modelRegistry.hasConfiguredAuth(found)) {\n\t\t\treturn {\n\t\t\t\tmodel: found,\n\t\t\t\tthinkingLevel: defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\t// 4. Try first available model with valid API key\n\tconst availableModels = await modelRegistry.getAvailable();\n\n\tconst preferredModel = findPreferredAvailableModel(availableModels);\n\tif (preferredModel) {\n\t\treturn { model: preferredModel, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n\t}\n\n\t// 5. No model found\n\treturn { model: undefined, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n}\n\ninterface RestoreModelResult {\n\tmodel: Model<Api> | undefined;\n\tfallbackMessage: string | undefined;\n}\n\n/**\n * Restore model from session, with fallback to available models\n */\nexport async function restoreModelFromSession(\n\tsavedProvider: string,\n\tsavedModelId: string,\n\tcurrentModel: Model<Api> | undefined,\n\tshouldPrintMessages: boolean,\n\tmodelRegistry: ModelRegistry,\n): Promise<RestoreModelResult> {\n\tconst restoredModel = modelRegistry.find(savedProvider, savedModelId);\n\t// Check if restored model exists and still has auth configured\n\tconst hasConfiguredAuth = restoredModel ? modelRegistry.hasConfiguredAuth(restoredModel) : false;\n\n\tif (restoredModel && hasConfiguredAuth) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Restored model: ${savedProvider}/${savedModelId}`));\n\t\t}\n\t\treturn { model: restoredModel, fallbackMessage: undefined };\n\t}\n\n\t// Model not found or no API key - fall back\n\tconst reason = !restoredModel ? \"model no longer exists\" : \"no auth configured\";\n\n\tif (shouldPrintMessages) {\n\t\tconsole.error(chalk.yellow(`Warning: Could not restore model ${savedProvider}/${savedModelId} (${reason}).`));\n\t}\n\n\t// If we already have a model, use it as fallback\n\tif (currentModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${currentModel.provider}/${currentModel.id}`));\n\t\t}\n\t\treturn {\n\t\t\tmodel: currentModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${currentModel.provider}/${currentModel.id}.`,\n\t\t};\n\t}\n\n\t// Try to find any available model\n\tconst availableModels = await modelRegistry.getAvailable();\n\n\tconst fallbackModel = findPreferredAvailableModel(availableModels);\n\tif (fallbackModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${fallbackModel.provider}/${fallbackModel.id}`));\n\t\t}\n\n\t\treturn {\n\t\t\tmodel: fallbackModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackModel.provider}/${fallbackModel.id}.`,\n\t\t};\n\t}\n\n\t// No models available\n\treturn { model: undefined, fallbackMessage: undefined };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-resolver.js","sourceRoot":"","sources":["../../src/core/model-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,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kingLevel } from \"@greppleai/grip-agent-core\";\nimport type { Api, KnownProvider, Model } from \"@greppleai/grip-ai\";\nimport chalk from \"chalk\";\nimport { minimatch } from \"minimatch\";\nimport { isValidThinkingLevel } from \"../cli/args.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\n\n/** Default model IDs for each known provider */\nexport const defaultModelPerProvider: Record<KnownProvider, string> = {\n\t\"amazon-bedrock\": \"us.anthropic.claude-opus-4-6-v1\",\n\tanthropic: \"claude-opus-4-7\",\n\topenai: \"gpt-5.4\",\n\t\"azure-openai-responses\": \"gpt-5.4\",\n\t\"openai-codex\": \"gpt-6-astra\",\n\tdeepseek: \"deepseek-v4-pro\",\n\tgoogle: \"gemini-3.1-pro-preview\",\n\t\"google-vertex\": \"gemini-3.1-pro-preview\",\n\t\"github-copilot\": \"gpt-5.4\",\n\topenrouter: \"moonshotai/kimi-k2.6\",\n\t\"vercel-ai-gateway\": \"zai/glm-5.1\",\n\txai: \"grok-4.20-0309-reasoning\",\n\tgroq: \"openai/gpt-oss-120b\",\n\tcerebras: \"zai-glm-4.7\",\n\tzai: \"glm-5.1\",\n\tmistral: \"devstral-medium-latest\",\n\tminimax: \"MiniMax-M2.7\",\n\t\"minimax-cn\": \"MiniMax-M2.7\",\n\tmoonshotai: \"kimi-k2.6\",\n\t\"moonshotai-cn\": \"kimi-k2.6\",\n\thuggingface: \"moonshotai/Kimi-K2.6\",\n\tfireworks: \"accounts/fireworks/models/kimi-k2p6\",\n\ttogether: \"moonshotai/Kimi-K2.6\",\n\topencode: \"kimi-k2.6\",\n\t\"opencode-go\": \"kimi-k2.6\",\n\t\"kimi-coding\": \"kimi-for-coding\",\n\t\"cloudflare-workers-ai\": \"@cf/moonshotai/kimi-k2.6\",\n\t\"cloudflare-ai-gateway\": \"workers-ai/@cf/moonshotai/kimi-k2.6\",\n\txiaomi: \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-cn\": \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-ams\": \"mimo-v2.5-pro\",\n\t\"xiaomi-token-plan-sgp\": \"mimo-v2.5-pro\",\n};\n\nexport interface ScopedModel {\n\tmodel: Model<Api>;\n\t/** Thinking level if explicitly specified in pattern (e.g., \"model:high\"), undefined otherwise */\n\tthinkingLevel?: ThinkingLevel;\n}\n\n/**\n * Helper to check if a model ID looks like an alias (no date suffix)\n * Dates are typically in format: -20241022 or -20250929\n */\nfunction isAlias(id: string): boolean {\n\t// Check if ID ends with -latest\n\tif (id.endsWith(\"-latest\")) return true;\n\n\t// Check if ID ends with a date pattern (-YYYYMMDD)\n\tconst datePattern = /-\\d{8}$/;\n\treturn !datePattern.test(id);\n}\n\n/**\n * Find an exact model reference match.\n * Supports either a bare model id or a canonical provider/modelId reference.\n * When matching by bare id, ambiguous matches across providers are rejected.\n */\nexport function findExactModelReferenceMatch(\n\tmodelReference: string,\n\tavailableModels: Model<Api>[],\n): Model<Api> | undefined {\n\tconst trimmedReference = modelReference.trim();\n\tif (!trimmedReference) {\n\t\treturn undefined;\n\t}\n\n\tconst normalizedReference = trimmedReference.toLowerCase();\n\n\tconst canonicalMatches = availableModels.filter(\n\t\t(model) => `${model.provider}/${model.id}`.toLowerCase() === normalizedReference,\n\t);\n\tif (canonicalMatches.length === 1) {\n\t\treturn canonicalMatches[0];\n\t}\n\tif (canonicalMatches.length > 1) {\n\t\treturn undefined;\n\t}\n\n\tconst slashIndex = trimmedReference.indexOf(\"/\");\n\tif (slashIndex !== -1) {\n\t\tconst provider = trimmedReference.substring(0, slashIndex).trim();\n\t\tconst modelId = trimmedReference.substring(slashIndex + 1).trim();\n\t\tif (provider && modelId) {\n\t\t\tconst providerMatches = availableModels.filter(\n\t\t\t\t(model) =>\n\t\t\t\t\tmodel.provider.toLowerCase() === provider.toLowerCase() &&\n\t\t\t\t\tmodel.id.toLowerCase() === modelId.toLowerCase(),\n\t\t\t);\n\t\t\tif (providerMatches.length === 1) {\n\t\t\t\treturn providerMatches[0];\n\t\t\t}\n\t\t\tif (providerMatches.length > 1) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst idMatches = availableModels.filter((model) => model.id.toLowerCase() === normalizedReference);\n\treturn idMatches.length === 1 ? idMatches[0] : undefined;\n}\n\n/**\n * Try to match a pattern to a model from the available models list.\n * Returns the matched model or undefined if no match found.\n */\nfunction tryMatchModel(modelPattern: string, availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst exactMatch = findExactModelReferenceMatch(modelPattern, availableModels);\n\tif (exactMatch) {\n\t\treturn exactMatch;\n\t}\n\n\t// No exact match - fall back to partial matching\n\tconst matches = availableModels.filter(\n\t\t(m) =>\n\t\t\tm.id.toLowerCase().includes(modelPattern.toLowerCase()) ||\n\t\t\tm.name?.toLowerCase().includes(modelPattern.toLowerCase()),\n\t);\n\n\tif (matches.length === 0) {\n\t\treturn undefined;\n\t}\n\n\t// Separate into aliases and dated versions\n\tconst aliases = matches.filter((m) => isAlias(m.id));\n\tconst datedVersions = matches.filter((m) => !isAlias(m.id));\n\n\tif (aliases.length > 0) {\n\t\t// Prefer alias - if multiple aliases, pick the one that sorts highest\n\t\taliases.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn aliases[0];\n\t} else {\n\t\t// No alias found, pick latest dated version\n\t\tdatedVersions.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn datedVersions[0];\n\t}\n}\n\ninterface ParseModelPatternOptions {\n\tallowInvalidThinkingLevelFallback?: boolean;\n}\n\nexport interface ParsedModelResult {\n\tmodel: Model<Api> | undefined;\n\t/** Thinking level if explicitly specified in pattern, undefined otherwise */\n\tthinkingLevel?: ThinkingLevel;\n\twarning: string | undefined;\n}\n\nfunction buildFallbackModel(provider: string, modelId: string, availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst providerModels = availableModels.filter((m) => m.provider === provider);\n\tif (providerModels.length === 0) return undefined;\n\n\tconst defaultId = defaultModelPerProvider[provider as KnownProvider];\n\tconst baseModel = defaultId\n\t\t? (providerModels.find((m) => m.id === defaultId) ?? providerModels[0])\n\t\t: providerModels[0];\n\n\treturn {\n\t\t...baseModel,\n\t\tid: modelId,\n\t\tname: modelId,\n\t};\n}\n\n/**\n * Parse a pattern to extract model and thinking level.\n * Handles models with colons in their IDs (e.g., OpenRouter's :exacto suffix).\n *\n * Algorithm:\n * 1. Try to match full pattern as a model\n * 2. If found, return it with \"off\" thinking level\n * 3. If not found and has colons, split on last colon:\n * - If suffix is valid thinking level, use it and recurse on prefix\n * - If suffix is invalid, warn and recurse on prefix with \"off\"\n *\n * @internal Exported for testing\n */\nexport function parseModelPattern(\n\tpattern: string,\n\tavailableModels: Model<Api>[],\n\toptions?: ParseModelPatternOptions,\n): ParsedModelResult {\n\t// Try exact match first\n\tconst exactMatch = tryMatchModel(pattern, availableModels);\n\tif (exactMatch) {\n\t\treturn { model: exactMatch, thinkingLevel: undefined, warning: undefined };\n\t}\n\n\t// No match - try splitting on last colon if present\n\tconst lastColonIndex = pattern.lastIndexOf(\":\");\n\tif (lastColonIndex === -1) {\n\t\t// No colons, pattern simply doesn't match any model\n\t\treturn { model: undefined, thinkingLevel: undefined, warning: undefined };\n\t}\n\n\tconst prefix = pattern.substring(0, lastColonIndex);\n\tconst suffix = pattern.substring(lastColonIndex + 1);\n\n\tif (isValidThinkingLevel(suffix)) {\n\t\t// Valid thinking level - recurse on prefix and use this level\n\t\tconst result = parseModelPattern(prefix, availableModels, options);\n\t\tif (result.model) {\n\t\t\t// Only use this thinking level if no warning from inner recursion\n\t\t\treturn {\n\t\t\t\tmodel: result.model,\n\t\t\t\tthinkingLevel: result.warning ? undefined : suffix,\n\t\t\t\twarning: result.warning,\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t} else {\n\t\t// Invalid suffix\n\t\tconst allowFallback = options?.allowInvalidThinkingLevelFallback ?? true;\n\t\tif (!allowFallback) {\n\t\t\t// In strict mode (CLI --model parsing), treat it as part of the model id and fail.\n\t\t\t// This avoids accidentally resolving to a different model.\n\t\t\treturn { model: undefined, thinkingLevel: undefined, warning: undefined };\n\t\t}\n\n\t\t// Scope mode: recurse on prefix and warn\n\t\tconst result = parseModelPattern(prefix, availableModels, options);\n\t\tif (result.model) {\n\t\t\treturn {\n\t\t\t\tmodel: result.model,\n\t\t\t\tthinkingLevel: undefined,\n\t\t\t\twarning: `Invalid thinking level \"${suffix}\" in pattern \"${pattern}\". Using default instead.`,\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t}\n}\n\ninterface GlobModelPattern {\n\tpattern: string;\n\tthinkingLevel?: ThinkingLevel;\n}\n\ninterface ModelScopePatternResolution {\n\tmodels: ScopedModel[];\n\twarnings: string[];\n}\n\nfunction parseGlobModelPattern(pattern: string): GlobModelPattern {\n\tconst colonIndex = pattern.lastIndexOf(\":\");\n\tif (colonIndex === -1) return { pattern };\n\tconst suffix = pattern.substring(colonIndex + 1);\n\treturn isValidThinkingLevel(suffix)\n\t\t? { pattern: pattern.substring(0, colonIndex), thinkingLevel: suffix }\n\t\t: { pattern };\n}\n\nfunction resolveGlobModelScopePattern(pattern: string, availableModels: Model<Api>[]): ModelScopePatternResolution {\n\tconst glob = parseGlobModelPattern(pattern);\n\tconst matchingModels = availableModels.filter((model) => {\n\t\tconst fullId = `${model.provider}/${model.id}`;\n\t\treturn minimatch(fullId, glob.pattern, { nocase: true }) || minimatch(model.id, glob.pattern, { nocase: true });\n\t});\n\tif (matchingModels.length === 0) {\n\t\treturn { models: [], warnings: [`Warning: No models match pattern \"${pattern}\"`] };\n\t}\n\treturn {\n\t\tmodels: matchingModels.map((model) => ({ model, thinkingLevel: glob.thinkingLevel })),\n\t\twarnings: [],\n\t};\n}\n\nfunction resolveLiteralModelScopePattern(pattern: string, availableModels: Model<Api>[]): ModelScopePatternResolution {\n\tconst { model, thinkingLevel, warning } = parseModelPattern(pattern, availableModels);\n\tconst warnings = warning ? [`Warning: ${warning}`] : [];\n\tif (!model) warnings.push(`Warning: No models match pattern \"${pattern}\"`);\n\treturn { models: model ? [{ model, thinkingLevel }] : [], warnings };\n}\n\ntype ModelIndex = Map<string, Map<string, Model<Api>>>;\n\nfunction addModelToIndex(index: ModelIndex, model: Model<Api>): boolean {\n\tlet providerModels = index.get(model.provider);\n\tif (!providerModels) {\n\t\tproviderModels = new Map();\n\t\tindex.set(model.provider, providerModels);\n\t}\n\tif (providerModels.has(model.id)) return false;\n\tproviderModels.set(model.id, model);\n\treturn true;\n}\n\nfunction createModelIndex(models: Iterable<Model<Api>>): ModelIndex {\n\tconst index: ModelIndex = new Map();\n\tfor (const model of models) addModelToIndex(index, model);\n\treturn index;\n}\n\nfunction appendUniqueScopedModels(target: ScopedModel[], candidates: ScopedModel[]): void {\n\tconst modelIndex = createModelIndex(target.map((scopedModel) => scopedModel.model));\n\tfor (const candidate of candidates) {\n\t\tif (addModelToIndex(modelIndex, candidate.model)) target.push(candidate);\n\t}\n}\n/**\n * Resolve model patterns to actual Model objects with optional thinking levels\n * Format: \"pattern:level\" where :level is optional\n * For each pattern, finds all matching models and picks the best version:\n * 1. Prefer alias (e.g., claude-sonnet-4-5) over dated versions (claude-sonnet-4-5-20250929)\n * 2. If no alias, pick the latest dated version\n *\n * Supports models with colons in their IDs (e.g., OpenRouter's model:exacto).\n * The algorithm tries to match the full pattern first, then progressively\n * strips colon-suffixes to find a match.\n */\nexport async function resolveModelScope(patterns: string[], modelRegistry: ModelRegistry): Promise<ScopedModel[]> {\n\tconst availableModels = await modelRegistry.getAvailable();\n\tconst scopedModels: ScopedModel[] = [];\n\tfor (const pattern of patterns) {\n\t\tconst resolution =\n\t\t\tpattern.includes(\"*\") || pattern.includes(\"?\") || pattern.includes(\"[\")\n\t\t\t\t? resolveGlobModelScopePattern(pattern, availableModels)\n\t\t\t\t: resolveLiteralModelScopePattern(pattern, availableModels);\n\t\tfor (const warning of resolution.warnings) console.warn(chalk.yellow(warning));\n\t\tappendUniqueScopedModels(scopedModels, resolution.models);\n\t}\n\treturn scopedModels;\n}\n\ninterface ResolveCliModelOptions {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tmodelRegistry: ModelRegistry;\n}\n\nexport interface ResolveCliModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel?: ThinkingLevel;\n\twarning: string | undefined;\n\t/**\n\t * Error message suitable for CLI display.\n\t * When set, model will be undefined.\n\t */\n\terror: string | undefined;\n}\n\ninterface CliModelReference {\n\tprovider: string | undefined;\n\tpattern: string;\n\tinferredProvider: boolean;\n}\n\ntype CliModelReferenceResolution =\n\t| { reference: CliModelReference; error?: never }\n\t| { reference?: never; error: string };\n\nfunction createProviderMap(availableModels: Model<Api>[]): Map<string, string> {\n\tconst providerMap = new Map<string, string>();\n\tfor (const model of availableModels) providerMap.set(model.provider.toLowerCase(), model.provider);\n\treturn providerMap;\n}\n\nfunction resolveCliModelReference(\n\tcliProvider: string | undefined,\n\tcliModel: string,\n\tproviderMap: Map<string, string>,\n): CliModelReferenceResolution {\n\tlet provider = cliProvider ? providerMap.get(cliProvider.toLowerCase()) : undefined;\n\tif (cliProvider && !provider) {\n\t\treturn { error: `Unknown provider \"${cliProvider}\". Use --list-models to see available providers/models.` };\n\t}\n\tlet pattern = cliModel;\n\tlet inferredProvider = false;\n\tif (!provider) {\n\t\tconst slashIndex = cliModel.indexOf(\"/\");\n\t\tconst maybeProvider = slashIndex === -1 ? undefined : cliModel.substring(0, slashIndex);\n\t\tconst canonical = maybeProvider ? providerMap.get(maybeProvider.toLowerCase()) : undefined;\n\t\tif (canonical) {\n\t\t\tprovider = canonical;\n\t\t\tpattern = cliModel.substring(slashIndex + 1);\n\t\t\tinferredProvider = true;\n\t\t}\n\t}\n\tif (cliProvider && provider) {\n\t\tconst prefix = `${provider}/`;\n\t\tif (cliModel.toLowerCase().startsWith(prefix.toLowerCase())) pattern = cliModel.substring(prefix.length);\n\t}\n\treturn { reference: { provider, pattern, inferredProvider } };\n}\n\nfunction findExactCliInputModel(cliModel: string, availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst lower = cliModel.toLowerCase();\n\treturn availableModels.find(\n\t\t(model) => model.id.toLowerCase() === lower || `${model.provider}/${model.id}`.toLowerCase() === lower,\n\t);\n}\n\nfunction resolveInferredProviderFallback(\n\tcliModel: string,\n\tavailableModels: Model<Api>[],\n): ResolveCliModelResult | undefined {\n\tconst exact = findExactCliInputModel(cliModel, availableModels);\n\tif (exact) return { model: exact, warning: undefined, thinkingLevel: undefined, error: undefined };\n\tconst fallback = parseModelPattern(cliModel, availableModels, {\n\t\tallowInvalidThinkingLevelFallback: false,\n\t});\n\tif (!fallback.model) return undefined;\n\treturn {\n\t\tmodel: fallback.model,\n\t\tthinkingLevel: fallback.thinkingLevel,\n\t\twarning: fallback.warning,\n\t\terror: undefined,\n\t};\n}\n\nfunction resolveCustomProviderModel(\n\tprovider: string,\n\tpattern: string,\n\twarning: string | undefined,\n\tavailableModels: Model<Api>[],\n): ResolveCliModelResult | undefined {\n\tconst fallbackModel = buildFallbackModel(provider, pattern, availableModels);\n\tif (!fallbackModel) return undefined;\n\tconst fallbackWarning = warning\n\t\t? `${warning} Model \"${pattern}\" not found for provider \"${provider}\". Using custom model id.`\n\t\t: `Model \"${pattern}\" not found for provider \"${provider}\". Using custom model id.`;\n\treturn { model: fallbackModel, thinkingLevel: undefined, warning: fallbackWarning, error: undefined };\n}\n\n/**\n * Resolve a single model from CLI flags.\n *\n * Supports:\n * - --provider <provider> --model <pattern>\n * - --model <provider>/<pattern>\n * - Fuzzy matching (same rules as model scoping: exact id, then partial id/name)\n *\n * Note: This does not apply the thinking level by itself, but it may *parse* and\n * return a thinking level from \"<pattern>:<thinking>\" so the caller can apply it.\n */\nexport function resolveCliModel(options: ResolveCliModelOptions): ResolveCliModelResult {\n\tconst { cliProvider, cliModel, modelRegistry } = options;\n\tif (!cliModel) return { model: undefined, warning: undefined, error: undefined };\n\n\t// Important: use *all* models here, not just models with pre-configured auth.\n\t// This allows \"--api-key\" to be used for first-time setup.\n\tconst availableModels = modelRegistry.getAll();\n\tif (availableModels.length === 0) {\n\t\treturn {\n\t\t\tmodel: undefined,\n\t\t\twarning: undefined,\n\t\t\terror: \"No models available. Check your installation or add models to models.json.\",\n\t\t};\n\t}\n\n\tconst referenceResolution = resolveCliModelReference(cliProvider, cliModel, createProviderMap(availableModels));\n\tif (\"error\" in referenceResolution) {\n\t\treturn { model: undefined, warning: undefined, error: referenceResolution.error };\n\t}\n\tconst { provider, pattern, inferredProvider } = referenceResolution.reference;\n\n\t// Without provider inference, model IDs containing slashes remain eligible for exact matching.\n\tif (!provider) {\n\t\tconst exact = findExactCliInputModel(cliModel, availableModels);\n\t\tif (exact) return { model: exact, warning: undefined, thinkingLevel: undefined, error: undefined };\n\t}\n\n\tconst candidates = provider ? availableModels.filter((model) => model.provider === provider) : availableModels;\n\tconst { model, thinkingLevel, warning } = parseModelPattern(pattern, candidates, {\n\t\tallowInvalidThinkingLevelFallback: false,\n\t});\n\tif (model) return { model, thinkingLevel, warning, error: undefined };\n\n\t// A slash prefix can name either a provider or part of a raw model ID. Retry the full input after provider matching fails.\n\tif (inferredProvider) {\n\t\tconst fallback = resolveInferredProviderFallback(cliModel, availableModels);\n\t\tif (fallback) return fallback;\n\t}\n\n\tif (provider) {\n\t\tconst fallback = resolveCustomProviderModel(provider, pattern, warning, availableModels);\n\t\tif (fallback) return fallback;\n\t}\n\n\tconst display = provider ? `${provider}/${pattern}` : cliModel;\n\treturn {\n\t\tmodel: undefined,\n\t\tthinkingLevel: undefined,\n\t\twarning,\n\t\terror: `Model \"${display}\" not found. Use --list-models to see available models.`,\n\t};\n}\n\nfunction findPreferredAvailableModel(availableModels: Model<Api>[]): Model<Api> | undefined {\n\tconst modelIndex = createModelIndex(availableModels);\n\tfor (const provider of Object.keys(defaultModelPerProvider) as KnownProvider[]) {\n\t\tconst match = modelIndex.get(provider)?.get(defaultModelPerProvider[provider]);\n\t\tif (match) return match;\n\t}\n\treturn availableModels[0];\n}\n\ninterface FindInitialModelOptions {\n\tcliProvider?: string;\n\tcliModel?: string;\n\tscopedModels: ScopedModel[];\n\tisContinuing: boolean;\n\tdefaultProvider?: string;\n\tdefaultModelId?: string;\n\tdefaultThinkingLevel?: ThinkingLevel;\n\tmodelRegistry: ModelRegistry;\n}\n\nexport interface InitialModelResult {\n\tmodel: Model<Api> | undefined;\n\tthinkingLevel: ThinkingLevel;\n\tfallbackMessage: string | undefined;\n}\n\nfunction resolveInitialCliSelection(\n\tcliProvider: string | undefined,\n\tcliModel: string | undefined,\n\tmodelRegistry: ModelRegistry,\n): InitialModelResult | undefined {\n\tif (!cliProvider || !cliModel) return undefined;\n\tconst resolved = resolveCliModel({ cliProvider, cliModel, modelRegistry });\n\tif (resolved.error) {\n\t\tconsole.error(chalk.red(resolved.error));\n\t\tprocess.exit(1);\n\t}\n\treturn resolved.model\n\t\t? { model: resolved.model, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined }\n\t\t: undefined;\n}\n\n/**\n * Find the initial model to use based on priority:\n * 1. CLI args (provider + model)\n * 2. First model from scoped models (if not continuing/resuming)\n * 3. Restored from session (if continuing/resuming)\n * 4. Saved default from settings\n * 5. First available model with valid API key\n */\nexport async function findInitialModel(options: FindInitialModelOptions): Promise<InitialModelResult> {\n\tconst {\n\t\tcliProvider,\n\t\tcliModel,\n\t\tscopedModels,\n\t\tisContinuing,\n\t\tdefaultProvider,\n\t\tdefaultModelId,\n\t\tdefaultThinkingLevel,\n\t\tmodelRegistry,\n\t} = options;\n\n\t// 1. CLI args take priority\n\tconst cliSelection = resolveInitialCliSelection(cliProvider, cliModel, modelRegistry);\n\tif (cliSelection) return cliSelection;\n\n\t// 2. Use first model from scoped models (skip if continuing/resuming)\n\tif (scopedModels.length > 0 && !isContinuing) {\n\t\treturn {\n\t\t\tmodel: scopedModels[0].model,\n\t\t\tthinkingLevel: scopedModels[0].thinkingLevel ?? defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\tfallbackMessage: undefined,\n\t\t};\n\t}\n\n\t// 3. Try saved default from settings if auth is configured.\n\tif (defaultProvider && defaultModelId) {\n\t\tconst found = modelRegistry.find(defaultProvider, defaultModelId);\n\t\tif (found && modelRegistry.hasConfiguredAuth(found)) {\n\t\t\treturn {\n\t\t\t\tmodel: found,\n\t\t\t\tthinkingLevel: defaultThinkingLevel ?? DEFAULT_THINKING_LEVEL,\n\t\t\t\tfallbackMessage: undefined,\n\t\t\t};\n\t\t}\n\t}\n\n\t// 4. Try first available model with valid API key\n\tconst availableModels = await modelRegistry.getAvailable();\n\n\tconst preferredModel = findPreferredAvailableModel(availableModels);\n\tif (preferredModel) {\n\t\treturn { model: preferredModel, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n\t}\n\n\t// 5. No model found\n\treturn { model: undefined, thinkingLevel: DEFAULT_THINKING_LEVEL, fallbackMessage: undefined };\n}\n\ninterface RestoreModelResult {\n\tmodel: Model<Api> | undefined;\n\tfallbackMessage: string | undefined;\n}\n\n/**\n * Restore model from session, with fallback to available models\n */\nexport async function restoreModelFromSession(\n\tsavedProvider: string,\n\tsavedModelId: string,\n\tcurrentModel: Model<Api> | undefined,\n\tshouldPrintMessages: boolean,\n\tmodelRegistry: ModelRegistry,\n): Promise<RestoreModelResult> {\n\tconst restoredModel = modelRegistry.find(savedProvider, savedModelId);\n\t// Check if restored model exists and still has auth configured\n\tconst hasConfiguredAuth = restoredModel ? modelRegistry.hasConfiguredAuth(restoredModel) : false;\n\n\tif (restoredModel && hasConfiguredAuth) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Restored model: ${savedProvider}/${savedModelId}`));\n\t\t}\n\t\treturn { model: restoredModel, fallbackMessage: undefined };\n\t}\n\n\t// Model not found or no API key - fall back\n\tconst reason = !restoredModel ? \"model no longer exists\" : \"no auth configured\";\n\n\tif (shouldPrintMessages) {\n\t\tconsole.error(chalk.yellow(`Warning: Could not restore model ${savedProvider}/${savedModelId} (${reason}).`));\n\t}\n\n\t// If we already have a model, use it as fallback\n\tif (currentModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${currentModel.provider}/${currentModel.id}`));\n\t\t}\n\t\treturn {\n\t\t\tmodel: currentModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${currentModel.provider}/${currentModel.id}.`,\n\t\t};\n\t}\n\n\t// Try to find any available model\n\tconst availableModels = await modelRegistry.getAvailable();\n\n\tconst fallbackModel = findPreferredAvailableModel(availableModels);\n\tif (fallbackModel) {\n\t\tif (shouldPrintMessages) {\n\t\t\tconsole.log(chalk.dim(`Falling back to: ${fallbackModel.provider}/${fallbackModel.id}`));\n\t\t}\n\n\t\treturn {\n\t\t\tmodel: fallbackModel,\n\t\t\tfallbackMessage: `Could not restore model ${savedProvider}/${savedModelId} (${reason}). Using ${fallbackModel.provider}/${fallbackModel.id}.`,\n\t\t};\n\t}\n\n\t// No models available\n\treturn { model: undefined, fallbackMessage: undefined };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-guard.d.ts","sourceRoot":"","sources":["../../src/core/output-guard.ts"],"names":[],"mappings":"AA+CA,wBAAgB,cAAc,IAAI,IAAI,CAyBrC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAOpC;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQjD;AAED,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlE;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAGpD"
|
|
1
|
+
{"version":3,"file":"output-guard.d.ts","sourceRoot":"","sources":["../../src/core/output-guard.ts"],"names":[],"mappings":"AA+CA,wBAAgB,cAAc,IAAI,IAAI,CAyBrC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAOpC;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQjD;AAED,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlE;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAGpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-guard.js","sourceRoot":"","sources":["../../src/core/output-guard.ts"],"names":[],"mappings":"AASA,IAAI,mBAAoD,CAAC;AAEzD,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,IAAI,kBAAkB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;AAE1D,SAAS,iBAAiB
|
|
1
|
+
{"version":3,"file":"output-guard.js","sourceRoot":"","sources":["../../src/core/output-guard.ts"],"names":[],"mappings":"AASA,IAAI,mBAAoD,CAAC;AAEzD,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,IAAI,kBAAkB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;AAE1D,SAAS,iBAAiB;IACzB,IAAI,mBAAmB,EAAE,CAAC;QACzB,OAAO,mBAAmB,CAAC,cAAc,CAAC;IAC3C,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAmB,CAAC;AACpE,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,EAAE,CAAC;QACb,IAAI,CAAC;YACJ,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC3C,IAAI,CAAC;oBACJ,iBAAiB,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;wBACnC,IAAI,KAAK;4BAAE,MAAM,CAAC,KAAK,CAAC,CAAC;;4BACpB,OAAO,EAAE,CAAC;oBAChB,CAAC,CAAC,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAA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teCallback = (error?: Error | null) => void;\ntype RawOutputWrite = (chunk: string, callback?: RawOutputWriteCallback) => boolean;\n\ninterface StdoutTakeoverState {\n\trawStdoutWrite: RawOutputWrite;\n\trawStderrWrite: RawOutputWrite;\n\toriginalStdoutWrite: typeof process.stdout.write;\n}\n\nlet stdoutTakeoverState: StdoutTakeoverState | undefined;\n\nconst RAW_STDOUT_RETRY_DELAY_MS = 10;\n\nlet rawStdoutWriteTail: Promise<void> = Promise.resolve();\n\nfunction getRawStdoutWrite(): RawOutputWrite {\n\tif (stdoutTakeoverState) {\n\t\treturn stdoutTakeoverState.rawStdoutWrite;\n\t}\n\treturn process.stdout.write.bind(process.stdout) as RawOutputWrite;\n}\n\nasync function writeRawStdoutChunk(text: string): Promise<void> {\n\twhile (true) {\n\t\ttry {\n\t\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\t\ttry {\n\t\t\t\t\tgetRawStdoutWrite()(text, (error) => {\n\t\t\t\t\t\tif (error) reject(error);\n\t\t\t\t\t\telse resolve();\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error instanceof Error ? error : new Error(String(error)));\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn;\n\t\t} catch (error) {\n\t\t\tconst writeError = error instanceof Error ? error : new Error(String(error));\n\t\t\tconst code = (writeError as Error & { code?: unknown }).code;\n\t\t\tif (code !== \"ENOBUFS\" && code !== \"EAGAIN\" && code !== \"EWOULDBLOCK\") {\n\t\t\t\tthrow writeError;\n\t\t\t}\n\t\t\tawait new Promise<void>((resolve) => setTimeout(resolve, RAW_STDOUT_RETRY_DELAY_MS));\n\t\t}\n\t}\n}\n\nexport function takeOverStdout(): void {\n\tif (stdoutTakeoverState) {\n\t\treturn;\n\t}\n\n\tconst rawStdoutWrite = process.stdout.write.bind(process.stdout) as RawOutputWrite;\n\tconst rawStderrWrite = process.stderr.write.bind(process.stderr) as RawOutputWrite;\n\tconst originalStdoutWrite = process.stdout.write;\n\n\tprocess.stdout.write = ((\n\t\tchunk: string | Uint8Array,\n\t\tencodingOrCallback?: BufferEncoding | ((error?: Error | null) => void),\n\t\tcallback?: (error?: Error | null) => void,\n\t): boolean => {\n\t\tif (typeof encodingOrCallback === \"function\") {\n\t\t\treturn rawStderrWrite(String(chunk), encodingOrCallback);\n\t\t}\n\t\treturn rawStderrWrite(String(chunk), callback);\n\t}) as typeof process.stdout.write;\n\n\tstdoutTakeoverState = {\n\t\trawStdoutWrite,\n\t\trawStderrWrite,\n\t\toriginalStdoutWrite,\n\t};\n}\n\nexport function restoreStdout(): void {\n\tif (!stdoutTakeoverState) {\n\t\treturn;\n\t}\n\n\tprocess.stdout.write = stdoutTakeoverState.originalStdoutWrite;\n\tstdoutTakeoverState = undefined;\n}\n\nexport function isStdoutTakenOver(): boolean {\n\treturn stdoutTakeoverState !== undefined;\n}\n\nexport function writeRawStdout(text: string): void {\n\tif (text.length === 0) {\n\t\treturn;\n\t}\n\trawStdoutWriteTail = rawStdoutWriteTail.then(() => writeRawStdoutChunk(text));\n\tvoid rawStdoutWriteTail.catch(() => {\n\t\tprocess.exit(1);\n\t});\n}\n\nexport async function waitForRawStdoutBackpressure(): Promise<void> {\n\twhile (true) {\n\t\tconst tail = rawStdoutWriteTail;\n\t\tawait tail;\n\t\tif (tail === rawStdoutWriteTail) {\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nexport async function flushRawStdout(): Promise<void> {\n\tawait waitForRawStdoutBackpressure();\n\tawait writeRawStdoutChunk(\"\");\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/core/package-manager.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAMjE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IAQ5C,OAAO,CAAC,+BAA+B;IAqBvC,OAAO,CAAC,mCAAmC;IAW3C,OAAO,CAAC,gCAAgC;IAWxC,OAAO,CAAC,iCAAiC;IAmBzC,OAAO,CAAC,uBAAuB;IAgD/B,OAAO,CAAC,uBAAuB;IAsB/B,OAAO,CAAC,kBAAkB;IA0B1B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,+BAA+B;IAkBvC,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,0BAA0B;IAyNlC,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,iBAAiB;IAwCzB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;CActB","sourcesContent":["import type { ChildProcess, ChildProcessByStdio } from \"node:child_process\";\nimport { createHash } from \"node:crypto\";\nimport {\n\ttype Dirent,\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trealpathSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { homedir, tmpdir } from \"node:os\";\n\nfunction getEnv(): NodeJS.ProcessEnv {\n\tif (process.platform !== \"linux\" || Object.keys(process.env).length > 0) {\n\t\treturn process.env;\n\t}\n\ttry {\n\t\tconst data = readFileSync(\"/proc/self/environ\", \"utf-8\");\n\t\tconst env: NodeJS.ProcessEnv = {};\n\t\tfor (const entry of data.split(\"\\0\")) {\n\t\t\tconst idx = entry.indexOf(\"=\");\n\t\t\tif (idx > 0) {\n\t\t\t\tenv[entry.slice(0, idx)] = entry.slice(idx + 1);\n\t\t\t}\n\t\t}\n\t\treturn env;\n\t} catch {\n\t\treturn process.env;\n\t}\n}\n\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport type { Readable } from \"node:stream\";\nimport { globSync } from \"glob\";\nimport ignore from \"ignore\";\nimport { minimatch } from \"minimatch\";\nimport { CONFIG_DIR_NAME } from \"../config.ts\";\nimport { spawnProcess, spawnProcessSync } from \"../utils/child-process.ts\";\nimport { type GitSource, isSafeGitInstallPath, parseGitUrl } from \"../utils/git.ts\";\nimport { canonicalizePath, isLocalPath, markPathIgnoredByCloudSync, resolvePath } from \"../utils/paths.ts\";\nimport { type GripManifest, readGripManifest } from \"./grip-manifest.ts\";\nimport { isStdoutTakenOver } from \"./output-guard.ts\";\nimport type { PackageSource, Settings, SettingsManager } from \"./settings-manager.ts\";\nimport type { SourceOrigin, SourceScope } from \"./source-info.ts\";\nimport type { WorkspaceIdentity } from \"./workspace-identity.ts\";\n\nconst NETWORK_TIMEOUT_MS = 10000;\nconst UPDATE_CHECK_CONCURRENCY = 4;\nconst GIT_UPDATE_CONCURRENCY = 4;\n\nexport type InstalledSourceScope = Exclude<SourceScope, \"temporary\">;\nexport type ProgressEventType = \"start\" | \"progress\" | \"complete\" | \"error\";\nexport type PackageUpdateType = \"npm\" | \"git\";\n\nfunction isOfflineModeEnabled(): boolean {\n\tconst value = process.env.GRIP_OFFLINE;\n\tif (!value) return false;\n\treturn value === \"1\" || value.toLowerCase() === \"true\" || value.toLowerCase() === \"yes\";\n}\n\n// grip-ignore noNearIdenticalDataStructures: Package paths require fully resolved scope and origin, while synthetic source options may omit them to request source-info defaults.\nexport interface PathMetadata {\n\tsource: string;\n\tscope: SourceScope;\n\torigin: SourceOrigin;\n\tbaseDir?: string;\n\tworkspace?: WorkspaceIdentity;\n}\n\nexport interface ResolvedResource {\n\tpath: string;\n\tenabled: boolean;\n\tmetadata: PathMetadata;\n}\n\nexport interface ResolvedPaths {\n\textensions: ResolvedResource[];\n\tskills: ResolvedResource[];\n\trules: ResolvedResource[];\n\tprompts: ResolvedResource[];\n\tthemes: ResolvedResource[];\n}\n\nexport type MissingSourceAction = \"install\" | \"skip\" | \"error\";\n\nexport type ProgressAction = \"install\" | \"remove\" | \"update\" | \"clone\" | \"pull\";\n\nexport interface ProgressEvent {\n\ttype: ProgressEventType;\n\taction: ProgressAction;\n\tsource: string;\n\tmessage?: string;\n}\n\nexport type ProgressCallback = (event: ProgressEvent) => void;\n\nexport interface PackageUpdate {\n\tsource: string;\n\tdisplayName: string;\n\ttype: PackageUpdateType;\n\tscope: InstalledSourceScope;\n}\n\nexport interface ConfiguredPackage {\n\tsource: string;\n\tscope: InstalledSourceScope;\n\tfiltered: boolean;\n\tinstalledPath?: string;\n}\n\nexport interface PackageScopeOptions {\n\tlocal?: boolean;\n}\n\nexport interface ExtensionSourceResolutionOptions extends PackageScopeOptions {\n\ttemporary?: boolean;\n}\n\nexport interface PackageManager {\n\tresolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths>;\n\tinstall(source: string, options?: PackageScopeOptions): Promise<void>;\n\tinstallAndPersist(source: string, options?: PackageScopeOptions): Promise<void>;\n\tremove(source: string, options?: PackageScopeOptions): Promise<void>;\n\tremoveAndPersist(source: string, options?: PackageScopeOptions): Promise<boolean>;\n\tupdate(source?: string): Promise<void>;\n\tlistConfiguredPackages(): ConfiguredPackage[];\n\tresolveExtensionSources(sources: string[], options?: ExtensionSourceResolutionOptions): Promise<ResolvedPaths>;\n\taddSourceToSettings(source: string, options?: PackageScopeOptions): boolean;\n\tremoveSourceFromSettings(source: string, options?: PackageScopeOptions): boolean;\n\tsetProgressCallback(callback: ProgressCallback | undefined): void;\n\tgetInstalledPath(source: string, scope: InstalledSourceScope): string | undefined;\n}\n\ninterface PackageManagerOptions {\n\tcwd: string;\n\tagentDir: string;\n\tsettingsManager: SettingsManager;\n}\ntype NpmSource = {\n\ttype: \"npm\";\n\tspec: string;\n\tname: string;\n\tpinned: boolean;\n};\n\ntype LocalSource = {\n\ttype: \"local\";\n\tpath: string;\n};\n\ntype ParsedSource = NpmSource | GitSource | LocalSource;\ninterface ConfiguredUpdateSource {\n\tsource: string;\n\tscope: InstalledSourceScope;\n}\n\ninterface NpmUpdateTarget extends ConfiguredUpdateSource {\n\tparsed: NpmSource;\n}\n\ninterface GitUpdateTarget extends ConfiguredUpdateSource {\n\tparsed: GitSource;\n}\n\ninterface PackageUpdateCandidates {\n\tnpm: NpmUpdateTarget[];\n\tgit: GitUpdateTarget[];\n}\n\ninterface ScopedPackageSource {\n\tpkg: PackageSource;\n\tscope: SourceScope;\n}\n\ninterface InstalledPackageSource extends ScopedPackageSource {\n\tscope: InstalledSourceScope;\n}\n\ninterface ManagedPackageResolutionContext {\n\tsource: string;\n\tscope: SourceScope;\n\taccumulator: ResourceAccumulator;\n\tfilter: PackageFilter | undefined;\n\tmetadata: PathMetadata;\n\tonMissing: ((source: string) => Promise<MissingSourceAction>) | undefined;\n}\n\ninterface AccumulatedResource {\n\tmetadata: PathMetadata;\n\tenabled: boolean;\n}\n\ntype ResourceMap = Map<string, AccumulatedResource>;\n\ninterface ResourceAccumulator {\n\textensions: ResourceMap;\n\tskills: ResourceMap;\n\trules: ResourceMap;\n\tprompts: ResourceMap;\n\tthemes: ResourceMap;\n}\n\n// grip-ignore noNearIdenticalDataStructures: This private checkout plan is mirrored only by a test facade for private-method verification and must not become a published API.\ninterface GitCheckoutTarget {\n\tref: string;\n\thead: string;\n\tfetchArgs: string[];\n}\n\n// grip-ignore noNearIdenticalDataStructures: Parsed npm identity/version data and LSP client metadata have unrelated validation and ownership.\ninterface ParsedNpmSpec {\n\tname: string;\n\tversion?: string;\n}\n\n// grip-ignore noNearIdenticalDataStructures: Package-manager invocations and RPC client startup commands evolve under separate configuration and process lifecycles.\ninterface PackageManagerCommand {\n\tcommand: string;\n\targs: string[];\n}\n\ninterface ManifestFileCollection {\n\tallFiles: string[];\n\tenabledByManifest: Set<string>;\n}\n\ninterface PnpmGlobalDependencyMetadata {\n\tpath?: string;\n}\n\ninterface CommandWorkingDirectoryOptions {\n\tcwd?: string;\n}\n\ninterface CommandEnvironmentOptions extends CommandWorkingDirectoryOptions {\n\tenv?: Record<string, string>;\n}\n\ninterface CommandCaptureOptions extends CommandEnvironmentOptions {\n\ttimeoutMs?: number;\n}\n\n/**\n * Compute a numeric precedence rank for a resource based on its metadata.\n * Lower rank = higher precedence. Used to sort resolved resources so that\n * name-collision resolution (\"first wins\") produces the correct outcome.\n *\n * Precedence (highest to lowest):\n * 0 project + settings entry (source: \"local\", scope: \"project\")\n * 1 project + auto-discovered (source: \"auto\", scope: \"project\")\n * 2 user + settings entry (source: \"local\", scope: \"user\")\n * 3 user + auto-discovered (source: \"auto\", scope: \"user\")\n * 4 package resource (origin: \"package\")\n */\nfunction resourcePrecedenceRank(m: PathMetadata): number {\n\tif (m.origin === \"package\") return 4;\n\tconst scopeBase = m.scope === \"project\" ? 0 : 2;\n\treturn scopeBase + (m.source === \"local\" ? 0 : 1);\n}\n\ntype PackageFilter = Omit<Exclude<PackageSource, string>, \"source\">;\n\ntype ResourceType = \"extensions\" | \"skills\" | \"rules\" | \"prompts\" | \"themes\";\n\nconst RESOURCE_TYPES: ResourceType[] = [\"extensions\", \"skills\", \"rules\", \"prompts\", \"themes\"];\n\nconst FILE_PATTERNS: Record<ResourceType, RegExp> = {\n\textensions: /\\.(ts|js)$/,\n\tskills: /\\.md$/,\n\trules: /\\.md$/,\n\tprompts: /\\.md$/,\n\tthemes: /\\.json$/,\n};\n\nconst IGNORE_FILE_NAMES = new Set([\".gitignore\", \".ignore\", \".fdignore\"]);\n\nfunction toPosixPath(p: string): string {\n\treturn p.split(sep).join(\"/\");\n}\n\nfunction isPathWithin(root: string, candidate: string): boolean {\n\tconst rel = relative(root, candidate);\n\treturn rel === \"\" || (rel !== \"..\" && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === \"object\" && error !== null && \"code\" in error && (error as { code?: unknown }).code === \"ENOENT\"\n\t);\n}\n\nfunction getHomeDir(): string {\n\treturn process.env.HOME || homedir();\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\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\n\tif (pattern.startsWith(\"/\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction addIgnoreRules(ig: ignore.Ignore, dir: string, rootDir: string): void {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = join(dir, filename);\n\t\tif (!existsSync(ignorePath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) {\n\t\t\t\tig.add(patterns);\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\nfunction isPattern(s: string): boolean {\n\treturn s.startsWith(\"!\") || s.startsWith(\"+\") || s.startsWith(\"-\") || s.includes(\"*\") || s.includes(\"?\");\n}\n\nfunction isOverridePattern(s: string): boolean {\n\treturn s.startsWith(\"!\") || s.startsWith(\"+\") || s.startsWith(\"-\");\n}\n\nfunction hasGlobPattern(s: string): boolean {\n\treturn s.includes(\"*\") || s.includes(\"?\");\n}\ninterface PatternPartition {\n\tplain: string[];\n\tpatterns: string[];\n}\n\ninterface FileCollectionContext {\n\tfilePattern: RegExp;\n\tskipNodeModules: boolean;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tvisited: Set<string>;\n}\n\nfunction splitPatterns(entries: string[]): PatternPartition {\n\tconst plain: string[] = [];\n\tconst patterns: string[] = [];\n\tfor (const entry of entries) {\n\t\tif (isPattern(entry)) {\n\t\t\tpatterns.push(entry);\n\t\t} else {\n\t\t\tplain.push(entry);\n\t\t}\n\t}\n\treturn { plain, patterns };\n}\nfunction collectFileEntry(dir: string, entry: Dirent, context: FileCollectionContext): string[] {\n\tif (entry.name.startsWith(\".\")) return [];\n\tif (context.skipNodeModules && entry.name === \"node_modules\") return [];\n\n\tconst fullPath = join(dir, entry.name);\n\tlet isDirectory = entry.isDirectory();\n\tlet isFile = entry.isFile();\n\tif (entry.isSymbolicLink()) {\n\t\ttry {\n\t\t\tconst stats = statSync(fullPath);\n\t\t\tisDirectory = stats.isDirectory();\n\t\t\tisFile = stats.isFile();\n\t\t} catch {\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tconst relPath = toPosixPath(relative(context.rootDir, fullPath));\n\tconst ignorePath = isDirectory ? `${relPath}/` : relPath;\n\tif (context.ignoreMatcher.ignores(ignorePath)) return [];\n\tif (isDirectory) {\n\t\treturn collectFiles(\n\t\t\tfullPath,\n\t\t\tcontext.filePattern,\n\t\t\tcontext.skipNodeModules,\n\t\t\tcontext.ignoreMatcher,\n\t\t\tcontext.rootDir,\n\t\t\tcontext.visited,\n\t\t);\n\t}\n\treturn isFile && context.filePattern.test(entry.name) ? [fullPath] : [];\n}\n\nfunction collectFiles(\n\tdir: string,\n\tfilePattern: RegExp,\n\tskipNodeModules = true,\n\tignoreMatcher?: ignore.Ignore,\n\trootDir?: string,\n\tvisited = new Set<string>(),\n): string[] {\n\tconst files: string[] = [];\n\tif (!existsSync(dir)) return files;\n\tlet canonicalDir: string;\n\ttry {\n\t\tcanonicalDir = realpathSync(dir);\n\t} catch {\n\t\treturn files;\n\t}\n\tif (visited.has(canonicalDir)) return files;\n\tvisited.add(canonicalDir);\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\tconst context: FileCollectionContext = {\n\t\tfilePattern,\n\t\tskipNodeModules,\n\t\tignoreMatcher: ig,\n\t\trootDir: root,\n\t\tvisited,\n\t};\n\ttry {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of entries) files.push(...collectFileEntry(dir, entry, context));\n\t} catch {\n\t\t// Ignore errors\n\t}\n\n\treturn files;\n}\n\ntype InstructionDiscoveryMode = \"grip\" | \"agents\";\ntype InstructionEntryFileName = \"SKILL.md\" | \"RULES.md\";\n\ninterface DirectoryEntryKind {\n\tisDirectory: boolean;\n\tisFile: boolean;\n}\n\ninterface InstructionCollectionContext {\n\tentryFileName: InstructionEntryFileName;\n\tmode: InstructionDiscoveryMode;\n\tignoreMatcher: ignore.Ignore;\n\trootDir: string;\n\tvisited: Set<string>;\n}\n\nfunction resolveDirectoryEntryKind(fullPath: string, entry: Dirent): DirectoryEntryKind | undefined {\n\tif (!entry.isSymbolicLink()) {\n\t\treturn { isDirectory: entry.isDirectory(), isFile: entry.isFile() };\n\t}\n\ttry {\n\t\tconst stats = statSync(fullPath);\n\t\treturn { isDirectory: stats.isDirectory(), isFile: stats.isFile() };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction findDirectInstructionFile(\n\tdir: string,\n\tdirectoryEntries: Dirent[],\n\tcontext: InstructionCollectionContext,\n): string | undefined {\n\tfor (const entry of directoryEntries) {\n\t\tif (entry.name !== context.entryFileName) continue;\n\t\tconst fullPath = join(dir, entry.name);\n\t\tconst kind = resolveDirectoryEntryKind(fullPath, entry);\n\t\tconst relPath = toPosixPath(relative(context.rootDir, fullPath));\n\t\tif (kind?.isFile && !context.ignoreMatcher.ignores(relPath)) return fullPath;\n\t}\n\treturn undefined;\n}\n\nfunction collectInstructionDirectoryEntries(\n\tdir: string,\n\tdirectoryEntries: Dirent[],\n\tcontext: InstructionCollectionContext,\n\tentries: string[],\n): void {\n\tfor (const entry of directoryEntries) {\n\t\tif (entry.name.startsWith(\".\")) continue;\n\t\tif (entry.name === \"node_modules\") continue;\n\t\tconst fullPath = join(dir, entry.name);\n\t\tconst kind = resolveDirectoryEntryKind(fullPath, entry);\n\t\tif (!kind) continue;\n\t\tconst relPath = toPosixPath(relative(context.rootDir, fullPath));\n\t\tif (\n\t\t\tcontext.mode === \"grip\" &&\n\t\t\tdir === context.rootDir &&\n\t\t\tkind.isFile &&\n\t\t\tentry.name.endsWith(\".md\") &&\n\t\t\t!context.ignoreMatcher.ignores(relPath)\n\t\t) {\n\t\t\tentries.push(fullPath);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!kind.isDirectory || context.ignoreMatcher.ignores(`${relPath}/`)) continue;\n\t\tentries.push(...collectInstructionEntries(fullPath, context));\n\t}\n}\n\nfunction collectInstructionEntries(dir: string, context: InstructionCollectionContext): string[] {\n\tconst entries: string[] = [];\n\tif (!existsSync(dir)) return entries;\n\tlet canonicalDir: string;\n\ttry {\n\t\tcanonicalDir = realpathSync(dir);\n\t} catch {\n\t\treturn entries;\n\t}\n\tif (context.visited.has(canonicalDir)) return entries;\n\tcontext.visited.add(canonicalDir);\n\taddIgnoreRules(context.ignoreMatcher, dir, context.rootDir);\n\ttry {\n\t\tconst directoryEntries = readdirSync(dir, { withFileTypes: true });\n\t\tconst directFile = findDirectInstructionFile(dir, directoryEntries, context);\n\t\tif (directFile) return [directFile];\n\t\tcollectInstructionDirectoryEntries(dir, directoryEntries, context, entries);\n\t} catch {\n\t\t// Ignore errors\n\t}\n\treturn entries;\n}\n\nfunction collectSkillEntries(\n\tdir: string,\n\tmode: InstructionDiscoveryMode,\n\tignoreMatcher?: ignore.Ignore,\n\trootDir?: string,\n\tvisited = new Set<string>(),\n): string[] {\n\treturn collectInstructionEntries(dir, {\n\t\tentryFileName: \"SKILL.md\",\n\t\tmode,\n\t\tignoreMatcher: ignoreMatcher ?? ignore(),\n\t\trootDir: rootDir ?? dir,\n\t\tvisited,\n\t});\n}\n\nfunction collectAutoSkillEntries(dir: string, mode: InstructionDiscoveryMode): string[] {\n\treturn collectSkillEntries(dir, mode);\n}\n\nfunction collectRuleEntries(\n\tdir: string,\n\tmode: InstructionDiscoveryMode,\n\tignoreMatcher?: ignore.Ignore,\n\trootDir?: string,\n\tvisited = new Set<string>(),\n): string[] {\n\treturn collectInstructionEntries(dir, {\n\t\tentryFileName: \"RULES.md\",\n\t\tmode,\n\t\tignoreMatcher: ignoreMatcher ?? ignore(),\n\t\trootDir: rootDir ?? dir,\n\t\tvisited,\n\t});\n}\n\nfunction collectAutoRuleEntries(dir: string, mode: InstructionDiscoveryMode): string[] {\n\treturn collectRuleEntries(dir, mode);\n}\n\nfunction findGitRepoRoot(startDir: string): string | null {\n\tlet dir = resolve(startDir);\n\twhile (true) {\n\t\tif (existsSync(join(dir, \".git\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) {\n\t\t\treturn null;\n\t\t}\n\t\tdir = parent;\n\t}\n}\n\nfunction collectAncestorAgentsSkillDirs(startDir: string): string[] {\n\tconst skillDirs: string[] = [];\n\tconst resolvedStartDir = resolve(startDir);\n\tconst gitRepoRoot = findGitRepoRoot(resolvedStartDir);\n\n\tlet dir = resolvedStartDir;\n\twhile (true) {\n\t\tskillDirs.push(join(dir, \".agents\", \"skills\"));\n\t\tif (gitRepoRoot && dir === gitRepoRoot) {\n\t\t\tbreak;\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) {\n\t\t\tbreak;\n\t\t}\n\t\tdir = parent;\n\t}\n\n\treturn skillDirs;\n}\n\nfunction collectAncestorAgentsRuleDirs(startDir: string): string[] {\n\tconst ruleDirs: string[] = [];\n\tconst resolvedStartDir = resolve(startDir);\n\tconst gitRepoRoot = findGitRepoRoot(resolvedStartDir);\n\n\tlet dir = resolvedStartDir;\n\twhile (true) {\n\t\truleDirs.push(join(dir, \".agents\", \"rules\"));\n\t\tif (gitRepoRoot && dir === gitRepoRoot) {\n\t\t\tbreak;\n\t\t}\n\t\tconst parent = dirname(dir);\n\t\tif (parent === dir) {\n\t\t\tbreak;\n\t\t}\n\t\tdir = parent;\n\t}\n\n\treturn ruleDirs;\n}\n\nfunction collectAutoPromptEntries(dir: string): string[] {\n\tconst entries: string[] = [];\n\tif (!existsSync(dir)) return entries;\n\n\tconst ig = ignore();\n\taddIgnoreRules(ig, dir, dir);\n\n\ttry {\n\t\tconst dirEntries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name.startsWith(\".\")) continue;\n\t\t\tif (entry.name === \"node_modules\") continue;\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst kind = resolveDirectoryEntryKind(fullPath, entry);\n\t\t\tif (!kind) continue;\n\t\t\tconst relPath = toPosixPath(relative(dir, fullPath));\n\t\t\tif (ig.ignores(relPath)) continue;\n\t\t\tif (kind.isFile && entry.name.endsWith(\".md\")) entries.push(fullPath);\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\n\treturn entries;\n}\n\nfunction collectAutoThemeEntries(dir: string): string[] {\n\tconst entries: string[] = [];\n\tif (!existsSync(dir)) return entries;\n\n\tconst ig = ignore();\n\taddIgnoreRules(ig, dir, dir);\n\n\ttry {\n\t\tconst dirEntries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of dirEntries) {\n\t\t\tif (entry.name.startsWith(\".\")) continue;\n\t\t\tif (entry.name === \"node_modules\") continue;\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\t\t\tconst kind = resolveDirectoryEntryKind(fullPath, entry);\n\t\t\tif (!kind) continue;\n\t\t\tconst relPath = toPosixPath(relative(dir, fullPath));\n\t\t\tif (ig.ignores(relPath)) continue;\n\t\t\tif (kind.isFile && entry.name.endsWith(\".json\")) entries.push(fullPath);\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\n\treturn entries;\n}\n\nfunction resolveExtensionEntries(dir: string): string[] | null {\n\tconst packageJsonPath = join(dir, \"package.json\");\n\tif (existsSync(packageJsonPath)) {\n\t\tconst manifest = readGripManifest(packageJsonPath);\n\t\tif (manifest?.extensions?.length) {\n\t\t\tconst entries: string[] = [];\n\t\t\tfor (const extPath of manifest.extensions) {\n\t\t\t\tconst resolvedExtPath = resolve(dir, extPath);\n\t\t\t\tif (existsSync(resolvedExtPath)) {\n\t\t\t\t\tentries.push(resolvedExtPath);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (entries.length > 0) {\n\t\t\t\treturn entries;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst indexTs = join(dir, \"index.ts\");\n\tconst indexJs = join(dir, \"index.ts\");\n\tif (existsSync(indexTs)) {\n\t\treturn [indexTs];\n\t}\n\tif (existsSync(indexJs)) {\n\t\treturn [indexJs];\n\t}\n\n\treturn null;\n}\n\nfunction collectAutoExtensionDirectoryEntry(dir: string, entry: Dirent, ignoreMatcher: ignore.Ignore): string[] {\n\tif (entry.name.startsWith(\".\")) return [];\n\tif (entry.name === \"node_modules\") return [];\n\tconst fullPath = join(dir, entry.name);\n\tconst kind = resolveDirectoryEntryKind(fullPath, entry);\n\tif (!kind) return [];\n\tconst relPath = toPosixPath(relative(dir, fullPath));\n\tconst ignorePath = kind.isDirectory ? `${relPath}/` : relPath;\n\tif (ignoreMatcher.ignores(ignorePath)) return [];\n\tif (kind.isFile) return entry.name.endsWith(\".ts\") ? [fullPath] : [];\n\tif (!kind.isDirectory) return [];\n\treturn resolveExtensionEntries(fullPath) ?? [];\n}\n\nfunction collectAutoExtensionEntries(dir: string): string[] {\n\tif (!existsSync(dir)) return [];\n\t// An explicit package manifest or index takes precedence over child discovery.\n\tconst rootEntries = resolveExtensionEntries(dir);\n\tif (rootEntries) return rootEntries;\n\n\tconst entries: string[] = [];\n\tconst ignoreMatcher = ignore();\n\taddIgnoreRules(ignoreMatcher, dir, dir);\n\ttry {\n\t\tconst directoryEntries = readdirSync(dir, { withFileTypes: true });\n\t\tfor (const entry of directoryEntries) {\n\t\t\tentries.push(...collectAutoExtensionDirectoryEntry(dir, entry, ignoreMatcher));\n\t\t}\n\t} catch {\n\t\t// Ignore errors\n\t}\n\treturn entries;\n}\n\n/**\n * Collect resource files from a directory based on resource type.\n * Extensions use smart discovery (index.ts in subdirs), others use recursive collection.\n */\nfunction collectResourceFiles(dir: string, resourceType: ResourceType): string[] {\n\tif (resourceType === \"skills\") {\n\t\treturn collectSkillEntries(dir, \"grip\");\n\t}\n\tif (resourceType === \"rules\") {\n\t\treturn collectRuleEntries(dir, \"grip\");\n\t}\n\tif (resourceType === \"extensions\") {\n\t\treturn collectAutoExtensionEntries(dir);\n\t}\n\treturn collectFiles(dir, FILE_PATTERNS[resourceType]);\n}\n\nfunction matchesAnyPattern(filePath: string, patterns: string[], baseDir: string): boolean {\n\tconst rel = toPosixPath(relative(baseDir, filePath));\n\tconst name = basename(filePath);\n\tconst filePathPosix = toPosixPath(filePath);\n\tconst isDirectoryResourceFile = name === \"SKILL.md\" || name === \"RULES.md\";\n\tconst parentDir = isDirectoryResourceFile ? dirname(filePath) : undefined;\n\tconst parentRel = isDirectoryResourceFile ? toPosixPath(relative(baseDir, parentDir!)) : undefined;\n\tconst parentName = isDirectoryResourceFile ? basename(parentDir!) : undefined;\n\tconst parentDirPosix = isDirectoryResourceFile ? toPosixPath(parentDir!) : undefined;\n\n\treturn patterns.some((pattern) => {\n\t\tconst normalizedPattern = toPosixPath(pattern);\n\t\tif (\n\t\t\tminimatch(rel, normalizedPattern) ||\n\t\t\tminimatch(name, normalizedPattern) ||\n\t\t\tminimatch(filePathPosix, normalizedPattern)\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!isDirectoryResourceFile) return false;\n\t\treturn (\n\t\t\tminimatch(parentRel!, normalizedPattern) ||\n\t\t\tminimatch(parentName!, normalizedPattern) ||\n\t\t\tminimatch(parentDirPosix!, normalizedPattern)\n\t\t);\n\t});\n}\n\nfunction normalizeExactPattern(pattern: string): string {\n\tconst normalized = pattern.startsWith(\"./\") || pattern.startsWith(\".\\\\\") ? pattern.slice(2) : pattern;\n\treturn toPosixPath(normalized);\n}\n\nfunction matchesAnyExactPattern(filePath: string, patterns: string[], baseDir: string): boolean {\n\tif (patterns.length === 0) return false;\n\tconst rel = toPosixPath(relative(baseDir, filePath));\n\tconst name = basename(filePath);\n\tconst filePathPosix = toPosixPath(filePath);\n\tconst isDirectoryResourceFile = name === \"SKILL.md\" || name === \"RULES.md\";\n\tconst parentDir = isDirectoryResourceFile ? dirname(filePath) : undefined;\n\tconst parentRel = isDirectoryResourceFile ? toPosixPath(relative(baseDir, parentDir!)) : undefined;\n\tconst parentDirPosix = isDirectoryResourceFile ? toPosixPath(parentDir!) : undefined;\n\n\treturn patterns.some((pattern) => {\n\t\tconst normalized = normalizeExactPattern(pattern);\n\t\tif (normalized === rel || normalized === filePathPosix) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!isDirectoryResourceFile) return false;\n\t\treturn normalized === parentRel || normalized === parentDirPosix;\n\t});\n}\n\nfunction getOverridePatterns(entries: string[]): string[] {\n\treturn entries.filter((pattern) => pattern.startsWith(\"!\") || pattern.startsWith(\"+\") || pattern.startsWith(\"-\"));\n}\n\nfunction isEnabledByOverrides(filePath: string, patterns: string[], baseDir: string): boolean {\n\tconst overrides = getOverridePatterns(patterns);\n\tconst excludes = overrides.filter((pattern) => pattern.startsWith(\"!\")).map((pattern) => pattern.slice(1));\n\tconst forceIncludes = overrides.filter((pattern) => pattern.startsWith(\"+\")).map((pattern) => pattern.slice(1));\n\tconst forceExcludes = overrides.filter((pattern) => pattern.startsWith(\"-\")).map((pattern) => pattern.slice(1));\n\n\tlet enabled = true;\n\tif (excludes.length > 0 && matchesAnyPattern(filePath, excludes, baseDir)) {\n\t\tenabled = false;\n\t}\n\tif (forceIncludes.length > 0 && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {\n\t\tenabled = true;\n\t}\n\tif (forceExcludes.length > 0 && matchesAnyExactPattern(filePath, forceExcludes, baseDir)) {\n\t\tenabled = false;\n\t}\n\treturn enabled;\n}\n\n/**\n * Apply patterns to paths and return a Set of enabled paths.\n * Pattern types:\n * - Plain patterns: include matching paths\n * - `!pattern`: exclude matching paths\n * - `+path`: force-include exact path (overrides exclusions)\n * - `-path`: force-exclude exact path (overrides force-includes)\n */\ninterface PackagePatternGroups {\n\tincludes: string[];\n\texcludes: string[];\n\tforceIncludes: string[];\n\tforceExcludes: string[];\n}\n\nfunction groupPackagePatterns(patterns: string[]): PackagePatternGroups {\n\tconst groups: PackagePatternGroups = { includes: [], excludes: [], forceIncludes: [], forceExcludes: [] };\n\tfor (const pattern of patterns) {\n\t\tif (pattern.startsWith(\"+\")) {\n\t\t\tgroups.forceIncludes.push(pattern.slice(1));\n\t\t} else if (pattern.startsWith(\"-\")) {\n\t\t\tgroups.forceExcludes.push(pattern.slice(1));\n\t\t} else if (pattern.startsWith(\"!\")) {\n\t\t\tgroups.excludes.push(pattern.slice(1));\n\t\t} else {\n\t\t\tgroups.includes.push(pattern);\n\t\t}\n\t}\n\treturn groups;\n}\n\nfunction applyPatterns(allPaths: string[], patterns: string[], baseDir: string): Set<string> {\n\tconst { includes, excludes, forceIncludes, forceExcludes } = groupPackagePatterns(patterns);\n\n\t// Step 1: Apply includes (or all if no includes)\n\tlet result: string[];\n\tif (includes.length === 0) {\n\t\tresult = [...allPaths];\n\t} else {\n\t\tresult = allPaths.filter((filePath) => matchesAnyPattern(filePath, includes, baseDir));\n\t}\n\n\t// Step 2: Apply excludes\n\tif (excludes.length > 0) {\n\t\tresult = result.filter((filePath) => !matchesAnyPattern(filePath, excludes, baseDir));\n\t}\n\n\t// Step 3: Force-include (add back from allPaths, overriding exclusions)\n\tif (forceIncludes.length > 0) {\n\t\tconst includedPaths = new Set(result);\n\t\tfor (const filePath of allPaths) {\n\t\t\tif (!includedPaths.has(filePath) && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {\n\t\t\t\tincludedPaths.add(filePath);\n\t\t\t\tresult.push(filePath);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Step 4: Force-exclude (remove even if included or force-included)\n\tif (forceExcludes.length > 0) {\n\t\tresult = result.filter((filePath) => !matchesAnyExactPattern(filePath, forceExcludes, baseDir));\n\t}\n\n\treturn new Set(result);\n}\n\nexport class DefaultPackageManager implements PackageManager {\n\tprivate cwd: string;\n\tprivate agentDir: string;\n\tprivate settingsManager: SettingsManager;\n\tprivate globalNpmRoot: string | undefined;\n\tprivate globalNpmRootCommandKey: string | undefined;\n\tprivate progressCallback: ProgressCallback | undefined;\n\n\tconstructor(options: PackageManagerOptions) {\n\t\tthis.cwd = resolvePath(options.cwd);\n\t\tthis.agentDir = resolvePath(options.agentDir);\n\t\tthis.settingsManager = options.settingsManager;\n\t}\n\n\tsetProgressCallback(callback: ProgressCallback | undefined): void {\n\t\tthis.progressCallback = callback;\n\t}\n\n\taddSourceToSettings(source: string, options?: PackageScopeOptions): boolean {\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tconst currentSettings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\t\tconst currentPackages = currentSettings.packages ?? [];\n\t\tconst normalizedSource = this.normalizePackageSourceForSettings(source, scope);\n\t\tconst matchIndex = currentPackages.findIndex((existing) => this.packageSourcesMatch(existing, source, scope));\n\t\tif (matchIndex !== -1) {\n\t\t\tconst existing = currentPackages[matchIndex];\n\t\t\tif (this.getPackageSourceString(existing) === normalizedSource) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst nextPackages = [...currentPackages];\n\t\t\tnextPackages[matchIndex] =\n\t\t\t\ttypeof existing === \"string\" ? normalizedSource : { ...existing, source: normalizedSource };\n\t\t\tif (scope === \"project\") {\n\t\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t\t} else {\n\t\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\tconst nextPackages = [...currentPackages, normalizedSource];\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t}\n\t\treturn true;\n\t}\n\n\tremoveSourceFromSettings(source: string, options?: PackageScopeOptions): boolean {\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tconst currentSettings =\n\t\t\tscope === \"project\" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();\n\t\tconst currentPackages = currentSettings.packages ?? [];\n\t\tconst nextPackages = currentPackages.filter((existing) => !this.packageSourcesMatch(existing, source, scope));\n\t\tconst changed = nextPackages.length !== currentPackages.length;\n\t\tif (!changed) {\n\t\t\treturn false;\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\tthis.settingsManager.setProjectPackages(nextPackages);\n\t\t} else {\n\t\t\tthis.settingsManager.setPackages(nextPackages);\n\t\t}\n\t\treturn true;\n\t}\n\n\tgetInstalledPath(source: string, scope: InstalledSourceScope): string | undefined {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") {\n\t\t\tconst path = this.getNpmInstallPath(parsed, scope);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\tconst path = this.getGitInstallPath(parsed, scope);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\tif (parsed.type === \"local\") {\n\t\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\t\tconst path = this.resolvePathFromBase(parsed.path, baseDir);\n\t\t\treturn existsSync(path) ? path : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate emitProgress(event: ProgressEvent): void {\n\t\tthis.progressCallback?.(event);\n\t}\n\n\tprivate async withProgress(\n\t\taction: ProgressAction,\n\t\tsource: string,\n\t\tmessage: string,\n\t\toperation: () => Promise<void>,\n\t): Promise<void> {\n\t\tthis.emitProgress({ type: \"start\", action, source, message });\n\t\ttry {\n\t\t\tawait operation();\n\t\t\tthis.emitProgress({ type: \"complete\", action, source });\n\t\t} catch (error) {\n\t\t\tconst errorMessage = error instanceof Error ? error.message : String(error);\n\t\t\tthis.emitProgress({ type: \"error\", action, source, message: errorMessage });\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync resolve(onMissing?: (source: string) => Promise<MissingSourceAction>): Promise<ResolvedPaths> {\n\t\tconst accumulator = this.createAccumulator();\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\n\t\t// Collect all packages with scope (project first so cwd resources win collisions)\n\t\tconst allPackages: ScopedPackageSource[] = [];\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"project\" });\n\t\t}\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"user\" });\n\t\t}\n\n\t\t// Dedupe: project scope wins over global for same package identity\n\t\tconst packageSources = this.dedupePackages(allPackages);\n\t\tawait this.resolvePackageSources(packageSources, accumulator, onMissing);\n\n\t\tconst globalBaseDir = this.agentDir;\n\t\tconst projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);\n\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tconst target = this.getTargetMap(accumulator, resourceType);\n\t\t\tconst globalEntries = (globalSettings[resourceType] ?? []) as string[];\n\t\t\tconst projectEntries = (projectSettings[resourceType] ?? []) as string[];\n\t\t\tthis.resolveLocalEntries(\n\t\t\t\tprojectEntries,\n\t\t\t\tresourceType,\n\t\t\t\ttarget,\n\t\t\t\t{\n\t\t\t\t\tsource: \"local\",\n\t\t\t\t\tscope: \"project\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t},\n\t\t\t\tprojectBaseDir,\n\t\t\t);\n\t\t\tthis.resolveLocalEntries(\n\t\t\t\tglobalEntries,\n\t\t\t\tresourceType,\n\t\t\t\ttarget,\n\t\t\t\t{\n\t\t\t\t\tsource: \"local\",\n\t\t\t\t\tscope: \"user\",\n\t\t\t\t\torigin: \"top-level\",\n\t\t\t\t},\n\t\t\t\tglobalBaseDir,\n\t\t\t);\n\t\t}\n\n\t\tthis.addAutoDiscoveredResources(accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir);\n\n\t\treturn this.toResolvedPaths(accumulator);\n\t}\n\n\tasync resolveExtensionSources(\n\t\tsources: string[],\n\t\toptions?: ExtensionSourceResolutionOptions,\n\t): Promise<ResolvedPaths> {\n\t\tconst accumulator = this.createAccumulator();\n\t\tconst scope: SourceScope = options?.temporary ? \"temporary\" : options?.local ? \"project\" : \"user\";\n\t\tconst packageSources = sources.map((source) => ({ pkg: source as PackageSource, scope }));\n\t\tawait this.resolvePackageSources(packageSources, accumulator);\n\t\treturn this.toResolvedPaths(accumulator);\n\t}\n\n\tlistConfiguredPackages(): ConfiguredPackage[] {\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst configuredPackages: ConfiguredPackage[] = [];\n\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconfiguredPackages.push({\n\t\t\t\tsource,\n\t\t\t\tscope: \"user\",\n\t\t\t\tfiltered: typeof pkg === \"object\",\n\t\t\t\tinstalledPath: this.getInstalledPath(source, \"user\"),\n\t\t\t});\n\t\t}\n\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconfiguredPackages.push({\n\t\t\t\tsource,\n\t\t\t\tscope: \"project\",\n\t\t\t\tfiltered: typeof pkg === \"object\",\n\t\t\t\tinstalledPath: this.getInstalledPath(source, \"project\"),\n\t\t\t});\n\t\t}\n\n\t\treturn configuredPackages;\n\t}\n\n\tasync install(source: string, options?: PackageScopeOptions): Promise<void> {\n\t\tconst parsed = this.parseSource(source);\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tawait this.withProgress(\"install\", source, `Installing ${source}...`, async () => {\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.installNpm(parsed, scope, false);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tawait this.installGit(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\tconst resolved = this.resolvePath(parsed.path);\n\t\t\t\tif (!existsSync(resolved)) {\n\t\t\t\t\tthrow new Error(`Path does not exist: ${resolved}`);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(`Unsupported install source: ${source}`);\n\t\t});\n\t}\n\n\tasync installAndPersist(source: string, options?: PackageScopeOptions): Promise<void> {\n\t\tawait this.install(source, options);\n\t\tthis.addSourceToSettings(source, options);\n\t}\n\n\tasync remove(source: string, options?: PackageScopeOptions): Promise<void> {\n\t\tconst parsed = this.parseSource(source);\n\t\tconst scope: SourceScope = options?.local ? \"project\" : \"user\";\n\t\tawait this.withProgress(\"remove\", source, `Removing ${source}...`, async () => {\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.uninstallNpm(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") {\n\t\t\t\tawait this.removeGit(parsed, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(`Unsupported remove source: ${source}`);\n\t\t});\n\t}\n\n\tasync removeAndPersist(source: string, options?: PackageScopeOptions): Promise<boolean> {\n\t\tawait this.remove(source, options);\n\t\treturn this.removeSourceFromSettings(source, options);\n\t}\n\n\tprivate collectConfiguredUpdateSources(\n\t\tpackages: PackageSource[],\n\t\tscope: InstalledSourceScope,\n\t\tidentity: string | undefined,\n\t): ConfiguredUpdateSource[] {\n\t\tconst sources: ConfiguredUpdateSource[] = [];\n\t\tfor (const pkg of packages) {\n\t\t\tconst packageSource = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tif (identity && this.getPackageIdentity(packageSource, scope) !== identity) continue;\n\t\t\tsources.push({ source: packageSource, scope });\n\t\t}\n\t\treturn sources;\n\t}\n\n\tasync update(source?: string): Promise<void> {\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst globalPackages = globalSettings.packages ?? [];\n\t\tconst projectPackages = projectSettings.packages ?? [];\n\t\tconst identity = source ? this.getPackageIdentity(source) : undefined;\n\t\tconst updateSources = [\n\t\t\t...this.collectConfiguredUpdateSources(globalPackages, \"user\", identity),\n\t\t\t...this.collectConfiguredUpdateSources(projectPackages, \"project\", identity),\n\t\t];\n\n\t\tif (source && updateSources.length === 0) {\n\t\t\tthrow new Error(this.buildNoMatchingPackageMessage(source, [...globalPackages, ...projectPackages]));\n\t\t}\n\t\tawait this.updateConfiguredSources(updateSources);\n\t}\n\n\tprivate classifyConfiguredUpdateSources(sources: ConfiguredUpdateSource[]): PackageUpdateCandidates {\n\t\tconst candidates: PackageUpdateCandidates = { npm: [], git: [] };\n\t\tfor (const entry of sources) {\n\t\t\tconst parsed = this.parseSource(entry.source);\n\t\t\t// Pinned npm versions are fixed. Pinned git refs are configured checkout targets,\n\t\t\t// so include them to reconcile an existing clone when the configured ref changes.\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tif (!parsed.pinned) candidates.npm.push({ ...entry, parsed });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (parsed.type === \"git\") candidates.git.push({ ...entry, parsed });\n\t\t}\n\t\treturn candidates;\n\t}\n\n\tprivate async updateConfiguredSources(sources: ConfiguredUpdateSource[]): Promise<void> {\n\t\tif (isOfflineModeEnabled() || sources.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst candidates = this.classifyConfiguredUpdateSources(sources);\n\n\t\tconst npmCheckTasks = candidates.npm.map((entry) => async () => ({\n\t\t\tentry,\n\t\t\tshouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),\n\t\t}));\n\t\tconst npmCheckResults = await this.runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);\n\t\tconst userNpmUpdates: NpmUpdateTarget[] = [];\n\t\tconst projectNpmUpdates: NpmUpdateTarget[] = [];\n\t\tfor (const result of npmCheckResults) {\n\t\t\tif (!result.shouldUpdate) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (result.entry.scope === \"user\") {\n\t\t\t\tuserNpmUpdates.push(result.entry);\n\t\t\t} else {\n\t\t\t\tprojectNpmUpdates.push(result.entry);\n\t\t\t}\n\t\t}\n\n\t\tconst tasks: Promise<void>[] = [];\n\t\tif (userNpmUpdates.length > 0) {\n\t\t\ttasks.push(this.updateNpmBatch(userNpmUpdates, \"user\"));\n\t\t}\n\t\tif (projectNpmUpdates.length > 0) {\n\t\t\ttasks.push(this.updateNpmBatch(projectNpmUpdates, \"project\"));\n\t\t}\n\t\tif (candidates.git.length > 0) {\n\t\t\tconst gitTasks = candidates.git.map(\n\t\t\t\t(entry) => async () =>\n\t\t\t\t\tthis.withProgress(\"update\", entry.source, `Updating ${entry.source}...`, async () => {\n\t\t\t\t\t\tawait this.updateGit(entry.parsed, entry.scope);\n\t\t\t\t\t}),\n\t\t\t);\n\t\t\ttasks.push(this.runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => {}));\n\t\t}\n\n\t\tawait Promise.all(tasks);\n\t}\n\n\tprivate async shouldUpdateNpmSource(source: NpmSource, scope: InstalledSourceScope): Promise<boolean> {\n\t\tconst installedPath = this.getManagedNpmInstallPath(source, scope);\n\t\tconst installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;\n\t\tif (!installedVersion) {\n\t\t\treturn true;\n\t\t}\n\n\t\ttry {\n\t\t\tconst latestVersion = await this.getLatestNpmVersion(source.name);\n\t\t\treturn latestVersion !== installedVersion;\n\t\t} catch {\n\t\t\t// Preserve existing update behavior when version lookup fails.\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tprivate async updateNpmBatch(sources: NpmUpdateTarget[], scope: InstalledSourceScope): Promise<void> {\n\t\tif (sources.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;\n\t\tconst message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;\n\t\tconst specs = sources.map((entry) => `${entry.parsed.name}@latest`);\n\n\t\tawait this.withProgress(\"update\", sourceLabel, message, async () => {\n\t\t\tawait this.installNpmBatch(specs, scope);\n\t\t});\n\t}\n\n\tprivate async installNpmBatch(specs: string[], scope: InstalledSourceScope): Promise<void> {\n\t\tconst installRoot = this.getNpmInstallRoot(scope, false);\n\t\tthis.ensureNpmProject(installRoot);\n\t\tawait this.runNpmCommand(this.getNpmInstallArgs(specs, installRoot));\n\t}\n\tprivate async getAvailableNpmUpdate(\n\t\tsource: string,\n\t\tparsed: NpmSource,\n\t\tscope: InstalledSourceScope,\n\t): Promise<PackageUpdate | undefined> {\n\t\tconst installedPath = this.getNpmInstallPath(parsed, scope);\n\t\tif (!existsSync(installedPath)) return undefined;\n\t\tif (!(await this.npmHasAvailableUpdate(parsed, installedPath))) return undefined;\n\t\treturn { source, displayName: parsed.name, type: \"npm\", scope };\n\t}\n\n\tprivate async getAvailableGitUpdate(\n\t\tsource: string,\n\t\tparsed: GitSource,\n\t\tscope: InstalledSourceScope,\n\t): Promise<PackageUpdate | undefined> {\n\t\tconst installedPath = this.getGitInstallPath(parsed, scope);\n\t\tif (!existsSync(installedPath)) return undefined;\n\t\tif (!(await this.gitHasAvailableUpdate(installedPath))) return undefined;\n\t\treturn { source, displayName: `${parsed.host}/${parsed.path}`, type: \"git\", scope };\n\t}\n\n\tasync checkForAvailableUpdates(): Promise<PackageUpdate[]> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst globalSettings = this.settingsManager.getGlobalSettings();\n\t\tconst projectSettings = this.settingsManager.getProjectSettings();\n\t\tconst allPackages: ScopedPackageSource[] = [];\n\t\tfor (const pkg of projectSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"project\" });\n\t\t}\n\t\tfor (const pkg of globalSettings.packages ?? []) {\n\t\t\tallPackages.push({ pkg, scope: \"user\" });\n\t\t}\n\n\t\tconst packageSources = this.dedupePackages(allPackages);\n\t\tconst checks = packageSources\n\t\t\t.filter((entry): entry is InstalledPackageSource => entry.scope !== \"temporary\")\n\t\t\t.map((entry) => async (): Promise<PackageUpdate | undefined> => {\n\t\t\t\tconst source = typeof entry.pkg === \"string\" ? entry.pkg : entry.pkg.source;\n\t\t\t\tconst parsed = this.parseSource(source);\n\t\t\t\tif (parsed.type === \"local\" || parsed.pinned) return undefined;\n\t\t\t\tif (parsed.type === \"npm\") return this.getAvailableNpmUpdate(source, parsed, entry.scope);\n\t\t\t\treturn this.getAvailableGitUpdate(source, parsed, entry.scope);\n\t\t\t});\n\n\t\tconst results = await this.runWithConcurrency(checks, UPDATE_CHECK_CONCURRENCY);\n\t\treturn results.filter((result): result is PackageUpdate => result !== undefined);\n\t}\n\n\tprivate async resolvePackageSources(\n\t\tsources: ScopedPackageSource[],\n\t\taccumulator: ResourceAccumulator,\n\t\tonMissing?: (source: string) => Promise<MissingSourceAction>,\n\t): Promise<void> {\n\t\tfor (const { pkg, scope } of sources) {\n\t\t\tconst source = typeof pkg === \"string\" ? pkg : pkg.source;\n\t\t\tconst filter = typeof pkg === \"object\" ? pkg : undefined;\n\t\t\tconst parsed = this.parseSource(source);\n\t\t\tconst metadata: PathMetadata = { source, scope, origin: \"package\" };\n\n\t\t\tif (parsed.type === \"local\") {\n\t\t\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\t\t\tthis.resolveLocalExtensionSource(parsed, accumulator, filter, metadata, baseDir);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst context: ManagedPackageResolutionContext = {\n\t\t\t\tsource,\n\t\t\t\tscope,\n\t\t\t\taccumulator,\n\t\t\t\tfilter,\n\t\t\t\tmetadata,\n\t\t\t\tonMissing,\n\t\t\t};\n\t\t\tif (parsed.type === \"npm\") {\n\t\t\t\tawait this.resolveNpmPackageSource(parsed, context);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait this.resolveGitPackageSource(parsed, context);\n\t\t}\n\t}\n\n\tprivate async installMissingPackageSource(\n\t\tparsed: NpmSource | GitSource,\n\t\tcontext: ManagedPackageResolutionContext,\n\t): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) return false;\n\t\tif (!context.onMissing) {\n\t\t\tawait this.installParsedSource(parsed, context.scope);\n\t\t\treturn true;\n\t\t}\n\n\t\tconst action = await context.onMissing(context.source);\n\t\tif (action === \"skip\") return false;\n\t\tif (action === \"error\") throw new Error(`Missing source: ${context.source}`);\n\t\tawait this.installParsedSource(parsed, context.scope);\n\t\treturn true;\n\t}\n\n\tprivate async resolveNpmPackageSource(source: NpmSource, context: ManagedPackageResolutionContext): Promise<void> {\n\t\tlet installedPath = this.getNpmInstallPath(source, context.scope);\n\t\tconst needsInstall =\n\t\t\t!existsSync(installedPath) ||\n\t\t\t(source.pinned && !(await this.installedNpmMatchesPinnedVersion(source, installedPath)));\n\t\tif (needsInstall) {\n\t\t\tconst installed = await this.installMissingPackageSource(source, context);\n\t\t\tif (!installed) return;\n\t\t\tinstalledPath = this.getNpmInstallPath(source, context.scope);\n\t\t}\n\t\tcontext.metadata.baseDir = installedPath;\n\t\tthis.collectPackageResources(installedPath, context.accumulator, context.filter, context.metadata);\n\t}\n\n\tprivate async resolveGitPackageSource(source: GitSource, context: ManagedPackageResolutionContext): Promise<void> {\n\t\tconst installedPath = this.getGitInstallPath(source, context.scope);\n\t\tif (!existsSync(installedPath)) {\n\t\t\tconst installed = await this.installMissingPackageSource(source, context);\n\t\t\tif (!installed) return;\n\t\t} else if (context.scope === \"temporary\" && !source.pinned && !isOfflineModeEnabled()) {\n\t\t\tawait this.refreshTemporaryGitSource(source, context.source);\n\t\t}\n\t\tcontext.metadata.baseDir = installedPath;\n\t\tthis.collectManagedGitPackageResources(installedPath, context.accumulator, context.filter, context.metadata);\n\t}\n\n\tprivate resolveLocalExtensionSource(\n\t\tsource: LocalSource,\n\t\taccumulator: ResourceAccumulator,\n\t\tfilter: PackageFilter | undefined,\n\t\tmetadata: PathMetadata,\n\t\tbaseDir: string,\n\t): void {\n\t\tconst resolved = this.resolvePathFromBase(source.path, baseDir);\n\t\tif (!existsSync(resolved)) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst stats = statSync(resolved);\n\t\t\tif (stats.isFile()) {\n\t\t\t\tmetadata.baseDir = dirname(resolved);\n\t\t\t\tthis.addResource(accumulator.extensions, resolved, metadata, true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tmetadata.baseDir = resolved;\n\t\t\t\tconst resources = this.collectPackageResources(resolved, accumulator, filter, metadata);\n\t\t\t\tif (!resources) {\n\t\t\t\t\tthis.addResource(accumulator.extensions, resolved, metadata, true);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate async installParsedSource(parsed: ParsedSource, scope: SourceScope): Promise<void> {\n\t\tif (parsed.type === \"npm\") {\n\t\t\tawait this.installNpm(parsed, scope, scope === \"temporary\");\n\t\t\treturn;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\tawait this.installGit(parsed, scope);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tprivate getPackageSourceString(pkg: PackageSource): string {\n\t\treturn typeof pkg === \"string\" ? pkg : pkg.source;\n\t}\n\n\tprivate getSourceMatchKeyForInput(source: string): string {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") {\n\t\t\treturn `npm:${parsed.name}`;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\treturn `git:${parsed.host}/${parsed.path}`;\n\t\t}\n\t\treturn `local:${this.resolvePath(parsed.path)}`;\n\t}\n\n\tprivate getSourceMatchKeyForSettings(source: string, scope: SourceScope): string {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") {\n\t\t\treturn `npm:${parsed.name}`;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\treturn `git:${parsed.host}/${parsed.path}`;\n\t\t}\n\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\treturn `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;\n\t}\n\n\tprivate buildNoMatchingPackageMessage(source: string, configuredPackages: PackageSource[]): string {\n\t\tconst suggestion = this.findSuggestedConfiguredSource(source, configuredPackages);\n\t\tif (!suggestion) {\n\t\t\treturn `No matching package found for ${source}`;\n\t\t}\n\t\treturn `No matching package found for ${source}. Did you mean ${suggestion}?`;\n\t}\n\tprivate getConfiguredSourceAliases(source: string): string[] {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") return [parsed.name, parsed.spec];\n\t\tif (parsed.type !== \"git\") return [];\n\t\tconst shorthand = `${parsed.host}/${parsed.path}`;\n\t\treturn parsed.ref ? [shorthand, `${shorthand}@${parsed.ref}`] : [shorthand];\n\t}\n\n\tprivate findSuggestedConfiguredSource(source: string, configuredPackages: PackageSource[]): string | undefined {\n\t\tconst trimmedSource = source.trim();\n\t\tconst suggestions = new Set<string>();\n\n\t\tfor (const pkg of configuredPackages) {\n\t\t\tconst sourceStr = this.getPackageSourceString(pkg);\n\t\t\tif (this.getConfiguredSourceAliases(sourceStr).includes(trimmedSource)) suggestions.add(sourceStr);\n\t\t}\n\n\t\treturn suggestions.values().next().value;\n\t}\n\n\tprivate packageSourcesMatch(existing: PackageSource, inputSource: string, scope: SourceScope): boolean {\n\t\tconst left = this.getSourceMatchKeyForSettings(this.getPackageSourceString(existing), scope);\n\t\tconst right = this.getSourceMatchKeyForInput(inputSource);\n\t\treturn left === right;\n\t}\n\n\tprivate normalizePackageSourceForSettings(source: string, scope: SourceScope): string {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type !== \"local\") {\n\t\t\treturn source;\n\t\t}\n\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\tconst resolved = this.resolvePath(parsed.path);\n\t\tconst rel = relative(baseDir, resolved);\n\t\treturn rel || \".\";\n\t}\n\n\tprivate parseSource(source: string): ParsedSource {\n\t\tif (source.startsWith(\"npm:\")) {\n\t\t\tconst spec = source.slice(\"npm:\".length).trim();\n\t\t\tconst { name, version } = this.parseNpmSpec(spec);\n\t\t\treturn {\n\t\t\t\ttype: \"npm\",\n\t\t\t\tspec,\n\t\t\t\tname,\n\t\t\t\tpinned: Boolean(version),\n\t\t\t};\n\t\t}\n\n\t\tif (isLocalPath(source)) {\n\t\t\treturn { type: \"local\", path: source };\n\t\t}\n\n\t\t// Try parsing as git URL\n\t\tconst gitParsed = parseGitUrl(source);\n\t\tif (gitParsed) {\n\t\t\treturn gitParsed;\n\t\t}\n\t\tif (!isLocalPath(source)) {\n\t\t\tthrow new Error(`Unsafe or invalid Git package source: ${source}`);\n\t\t}\n\n\t\treturn { type: \"local\", path: source };\n\t}\n\n\tprivate async installedNpmMatchesPinnedVersion(source: NpmSource, installedPath: string): Promise<boolean> {\n\t\tconst installedVersion = this.getInstalledNpmVersion(installedPath);\n\t\tif (!installedVersion) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst { version: pinnedVersion } = this.parseNpmSpec(source.spec);\n\t\tif (!pinnedVersion) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn installedVersion === pinnedVersion;\n\t}\n\n\tprivate async npmHasAvailableUpdate(source: NpmSource, installedPath: string): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst installedVersion = this.getInstalledNpmVersion(installedPath);\n\t\tif (!installedVersion) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst latestVersion = await this.getLatestNpmVersion(source.name);\n\t\t\treturn latestVersion !== installedVersion;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate getInstalledNpmVersion(installedPath: string): string | undefined {\n\t\tconst packageJsonPath = join(installedPath, \"package.json\");\n\t\tif (!existsSync(packageJsonPath)) return undefined;\n\t\ttry {\n\t\t\tconst content = readFileSync(packageJsonPath, \"utf-8\");\n\t\t\tconst pkg = JSON.parse(content) as { version?: string };\n\t\t\treturn pkg.version;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate async getLatestNpmVersion(packageName: string): Promise<string> {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst stdout = await this.runCommandCapture(\n\t\t\tnpmCommand.command,\n\t\t\t[...npmCommand.args, \"view\", packageName, \"version\", \"--json\"],\n\t\t\t{ cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS },\n\t\t);\n\t\tconst raw = stdout.trim();\n\t\tif (!raw) throw new Error(\"Empty response from npm view\");\n\t\treturn JSON.parse(raw);\n\t}\n\n\tprivate async gitHasAvailableUpdate(installedPath: string): Promise<boolean> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn false;\n\t\t}\n\n\t\ttry {\n\t\t\tconst localHead = await this.runCommandCapture(\"git\", [\"rev-parse\", \"HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst remoteHead = await this.getRemoteGitHead(installedPath);\n\t\t\treturn localHead.trim() !== remoteHead.trim();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate async getRemoteGitHead(installedPath: string): Promise<string> {\n\t\tconst upstreamRef = await this.getGitUpstreamRef(installedPath);\n\t\tif (upstreamRef) {\n\t\t\tconst remoteHead = await this.runGitRemoteCommand(installedPath, [\"ls-remote\", \"origin\", upstreamRef]);\n\t\t\tconst match = remoteHead.match(/^([0-9a-f]{40})\\s+/m);\n\t\t\tif (match?.[1]) {\n\t\t\t\treturn match[1];\n\t\t\t}\n\t\t}\n\n\t\tconst remoteHead = await this.runGitRemoteCommand(installedPath, [\"ls-remote\", \"origin\", \"HEAD\"]);\n\t\tconst match = remoteHead.match(/^([0-9a-f]{40})\\s+HEAD$/m);\n\t\tif (!match?.[1]) {\n\t\t\tthrow new Error(\"Failed to determine remote HEAD\");\n\t\t}\n\t\treturn match[1];\n\t}\n\n\tprivate async getLocalGitUpdateTarget(installedPath: string): Promise<GitCheckoutTarget> {\n\t\ttry {\n\t\t\tconst upstream = await this.runCommandCapture(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst trimmedUpstream = upstream.trim();\n\t\t\tif (!trimmedUpstream.startsWith(\"origin/\")) {\n\t\t\t\tthrow new Error(`Unsupported upstream remote: ${trimmedUpstream}`);\n\t\t\t}\n\t\t\tconst branch = trimmedUpstream.slice(\"origin/\".length);\n\t\t\tif (!branch) {\n\t\t\t\tthrow new Error(\"Missing upstream branch name\");\n\t\t\t}\n\t\t\tconst head = await this.runCommandCapture(\"git\", [\"rev-parse\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tref: \"@{upstream}\",\n\t\t\t\thead,\n\t\t\t\tfetchArgs: [\n\t\t\t\t\t\"fetch\",\n\t\t\t\t\t\"--prune\",\n\t\t\t\t\t\"--no-tags\",\n\t\t\t\t\t\"origin\",\n\t\t\t\t\t`+refs/heads/${branch}:refs/remotes/origin/${branch}`,\n\t\t\t\t],\n\t\t\t};\n\t\t} catch {\n\t\t\tawait this.runCommand(\"git\", [\"remote\", \"set-head\", \"origin\", \"-a\"], { cwd: installedPath }).catch(() => {});\n\t\t\tconst head = await this.runCommandCapture(\"git\", [\"rev-parse\", \"origin/HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst originHeadRef = await this.runCommandCapture(\"git\", [\"symbolic-ref\", \"refs/remotes/origin/HEAD\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t}).catch(() => \"\");\n\t\t\tconst branch = originHeadRef.trim().replace(/^refs\\/remotes\\/origin\\//, \"\");\n\t\t\tif (branch) {\n\t\t\t\treturn {\n\t\t\t\t\tref: \"origin/HEAD\",\n\t\t\t\t\thead,\n\t\t\t\t\tfetchArgs: [\n\t\t\t\t\t\t\"fetch\",\n\t\t\t\t\t\t\"--prune\",\n\t\t\t\t\t\t\"--no-tags\",\n\t\t\t\t\t\t\"origin\",\n\t\t\t\t\t\t`+refs/heads/${branch}:refs/remotes/origin/${branch}`,\n\t\t\t\t\t],\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tref: \"origin/HEAD\",\n\t\t\t\thead,\n\t\t\t\tfetchArgs: [\"fetch\", \"--prune\", \"--no-tags\", \"origin\", \"+HEAD:refs/remotes/origin/HEAD\"],\n\t\t\t};\n\t\t}\n\t}\n\n\tprivate async getGitUpstreamRef(installedPath: string): Promise<string | undefined> {\n\t\ttry {\n\t\t\tconst upstream = await this.runCommandCapture(\"git\", [\"rev-parse\", \"--abbrev-ref\", \"@{upstream}\"], {\n\t\t\t\tcwd: installedPath,\n\t\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\t});\n\t\t\tconst trimmed = upstream.trim();\n\t\t\tif (!trimmed.startsWith(\"origin/\")) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst branch = trimmed.slice(\"origin/\".length);\n\t\t\treturn branch ? `refs/heads/${branch}` : undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate runGitRemoteCommand(installedPath: string, args: string[]): Promise<string> {\n\t\treturn this.runCommandCapture(\"git\", args, {\n\t\t\tcwd: installedPath,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t\tenv: {\n\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t},\n\t\t});\n\t}\n\n\tprivate async runWithConcurrency<T>(tasks: Array<() => Promise<T>>, limit: number): Promise<T[]> {\n\t\tif (tasks.length === 0) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst results: T[] = new Array(tasks.length);\n\t\tlet nextIndex = 0;\n\t\tconst workerCount = Math.max(1, Math.min(limit, tasks.length));\n\n\t\tconst worker = async () => {\n\t\t\twhile (true) {\n\t\t\t\tconst index = nextIndex;\n\t\t\t\tnextIndex += 1;\n\t\t\t\tif (index >= tasks.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tresults[index] = await tasks[index]();\n\t\t\t}\n\t\t};\n\n\t\tawait Promise.all(Array.from({ length: workerCount }, () => worker()));\n\t\treturn results;\n\t}\n\n\t/**\n\t * Get a unique identity for a package, ignoring version/ref.\n\t * Used to detect when the same package is in both global and project settings.\n\t * For git packages, uses normalized host/path to ensure SSH and HTTPS URLs\n\t * for the same repository are treated as identical.\n\t */\n\tprivate getPackageIdentity(source: string, scope?: SourceScope): string {\n\t\tconst parsed = this.parseSource(source);\n\t\tif (parsed.type === \"npm\") {\n\t\t\treturn `npm:${parsed.name}`;\n\t\t}\n\t\tif (parsed.type === \"git\") {\n\t\t\t// Use host/path for identity to normalize SSH and HTTPS\n\t\t\treturn `git:${parsed.host}/${parsed.path}`;\n\t\t}\n\t\tif (scope) {\n\t\t\tconst baseDir = this.getBaseDirForScope(scope);\n\t\t\treturn `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;\n\t\t}\n\t\treturn `local:${this.resolvePath(parsed.path)}`;\n\t}\n\n\t/**\n\t * Dedupe packages: if same package identity appears in both global and project,\n\t * keep only the project one (project wins).\n\t */\n\tprivate dedupePackages(packages: ScopedPackageSource[]): ScopedPackageSource[] {\n\t\tconst seen = new Map<string, ScopedPackageSource>();\n\n\t\tfor (const entry of packages) {\n\t\t\tconst sourceStr = typeof entry.pkg === \"string\" ? entry.pkg : entry.pkg.source;\n\t\t\tconst identity = this.getPackageIdentity(sourceStr, entry.scope);\n\n\t\t\tconst existing = seen.get(identity);\n\t\t\tif (!existing) {\n\t\t\t\tseen.set(identity, entry);\n\t\t\t} else if (entry.scope === \"project\" && existing.scope === \"user\") {\n\t\t\t\t// Project wins over user\n\t\t\t\tseen.set(identity, entry);\n\t\t\t}\n\t\t\t// If existing is project and new is global, keep existing (project)\n\t\t\t// If both are same scope, keep first one\n\t\t}\n\n\t\treturn Array.from(seen.values());\n\t}\n\n\tprivate parseNpmSpec(spec: string): ParsedNpmSpec {\n\t\tconst match = spec.match(/^(@?[^@]+(?:\\/[^@]+)?)(?:@(.+))?$/);\n\t\tif (!match) {\n\t\t\treturn { name: spec };\n\t\t}\n\t\tconst name = match[1] ?? spec;\n\t\tconst version = match[2];\n\t\treturn { name, version };\n\t}\n\n\tprivate getNpmCommand(): PackageManagerCommand {\n\t\tconst configuredCommand = this.settingsManager.getNpmCommand();\n\t\tif (!configuredCommand || configuredCommand.length === 0) {\n\t\t\treturn { command: \"npm\", args: [] };\n\t\t}\n\t\tconst [command, ...args] = configuredCommand;\n\t\tif (!command) {\n\t\t\tthrow new Error(\"Invalid npmCommand: first array entry must be a non-empty command\");\n\t\t}\n\t\treturn { command, args };\n\t}\n\n\tprivate getPackageManagerName(): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst commandParts = [npmCommand.command, ...npmCommand.args];\n\t\tconst separatorIndex = commandParts.lastIndexOf(\"--\");\n\t\tconst packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;\n\t\treturn packageManagerCommand ? basename(packageManagerCommand).replace(/\\.(cmd|exe)$/i, \"\") : \"\";\n\t}\n\n\tprivate async runNpmCommand(args: string[], options?: CommandWorkingDirectoryOptions): Promise<void> {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tawait this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);\n\t}\n\n\tprivate getGitDependencyInstallArgs(): string[] {\n\t\tconst configuredCommand = this.settingsManager.getNpmCommand();\n\t\tif (configuredCommand && configuredCommand.length > 0) {\n\t\t\treturn [\"install\"];\n\t\t}\n\t\treturn [\"install\", \"--omit=dev\"];\n\t}\n\n\tprivate runNpmCommandSync(args: string[]): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\treturn this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);\n\t}\n\n\tprivate getNpmInstallArgs(specs: string[], installRoot: string): string[] {\n\t\tconst packageManagerName = this.getPackageManagerName();\n\t\t// Extension packages run inside grip and resolve grip APIs through loader aliases/virtual modules.\n\t\t// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and\n\t\t// equivalent bun/pnpm settings) so package managers do not install or solve host-provided\n\t\t// @greppleai/grip-* peers. Stale auto-installed grip peers can otherwise block updates.\n\t\tif (packageManagerName === \"bun\") {\n\t\t\treturn [\"install\", ...specs, \"--cwd\", installRoot, \"--omit=peer\"];\n\t\t}\n\t\tif (packageManagerName === \"pnpm\") {\n\t\t\treturn [\n\t\t\t\t\"install\",\n\t\t\t\t...specs,\n\t\t\t\t\"--prefix\",\n\t\t\t\tinstallRoot,\n\t\t\t\t\"--config.auto-install-peers=false\",\n\t\t\t\t\"--config.strict-peer-dependencies=false\",\n\t\t\t\t\"--config.strict-dep-builds=false\",\n\t\t\t];\n\t\t}\n\t\treturn [\"install\", ...specs, \"--prefix\", installRoot, \"--legacy-peer-deps\"];\n\t}\n\n\tprivate async installNpm(source: NpmSource, scope: SourceScope, temporary: boolean): Promise<void> {\n\t\tconst installRoot = this.getNpmInstallRoot(scope, temporary);\n\t\tthis.ensureNpmProject(installRoot);\n\t\tawait this.runNpmCommand(this.getNpmInstallArgs([source.spec], installRoot));\n\t}\n\n\tprivate async uninstallNpm(source: NpmSource, scope: SourceScope): Promise<void> {\n\t\tconst installRoot = this.getNpmInstallRoot(scope, false);\n\t\tif (!existsSync(installRoot)) {\n\t\t\treturn;\n\t\t}\n\t\tif (this.getPackageManagerName() === \"bun\") {\n\t\t\tawait this.runNpmCommand([\"uninstall\", source.name, \"--cwd\", installRoot]);\n\t\t\treturn;\n\t\t}\n\t\tawait this.runNpmCommand([\"uninstall\", source.name, \"--prefix\", installRoot]);\n\t}\n\n\tprivate async installGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (existsSync(targetDir)) {\n\t\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\t\tif (source.ref) {\n\t\t\t\tawait this.ensureGitRef(targetDir, [\"fetch\", \"origin\", source.ref], \"FETCH_HEAD\", source, scope);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst target = await this.getLocalGitUpdateTarget(targetDir);\n\t\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\t\tawait this.ensureGitRef(targetDir, target.fetchArgs, target.ref, source, scope);\n\t\t\treturn;\n\t\t}\n\t\tconst gitRoot = this.getGitInstallRoot(scope);\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tif (gitRoot) {\n\t\t\tthis.ensureGitIgnore(gitRoot, true);\n\t\t}\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tmkdirSync(dirname(targetDir), { recursive: true });\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\n\t\tawait this.runCommand(\"git\", [\"clone\", source.repo, targetDir]);\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tif (source.ref) {\n\t\t\tawait this.runCommand(\"git\", [\"checkout\", source.ref], { cwd: targetDir });\n\t\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\t}\n\t\tconst packageJsonPath = join(targetDir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tthis.assertConfinedResourcePath(packageJsonPath, targetDir);\n\t\t\tawait this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });\n\t\t}\n\t}\n\n\tprivate async updateGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (!existsSync(targetDir)) {\n\t\t\tawait this.installGit(source, scope);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tif (source.ref) {\n\t\t\tawait this.ensureGitRef(targetDir, [\"fetch\", \"origin\", source.ref], \"FETCH_HEAD\", source, scope);\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = await this.getLocalGitUpdateTarget(targetDir);\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tawait this.ensureGitRef(targetDir, target.fetchArgs, target.ref, source, scope);\n\t}\n\n\tprivate async ensureGitRef(\n\t\ttargetDir: string,\n\t\tfetchArgs: string[],\n\t\tref: string,\n\t\tsource: GitSource,\n\t\tscope: SourceScope,\n\t): Promise<void> {\n\t\t// Fetch only the ref we will reset to, avoiding unrelated branch/tag noise.\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tawait this.runCommand(\"git\", fetchArgs, { cwd: targetDir });\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\n\t\tconst localHead = await this.runCommandCapture(\"git\", [\"rev-parse\", \"HEAD\"], {\n\t\t\tcwd: targetDir,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t});\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tconst commitRef = `${ref}^{commit}`;\n\t\tconst targetHead = await this.runCommandCapture(\"git\", [\"rev-parse\", commitRef], {\n\t\t\tcwd: targetDir,\n\t\t\ttimeoutMs: NETWORK_TIMEOUT_MS,\n\t\t});\n\t\tif (localHead.trim() === targetHead.trim()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tawait this.runCommand(\"git\", [\"reset\", \"--hard\", commitRef], { cwd: targetDir });\n\n\t\t// Clean untracked files (extensions should be pristine)\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\tawait this.runCommand(\"git\", [\"clean\", \"-fdx\"], { cwd: targetDir });\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\n\t\tconst packageJsonPath = join(targetDir, \"package.json\");\n\t\tif (existsSync(packageJsonPath)) {\n\t\t\tthis.assertConfinedResourcePath(packageJsonPath, targetDir);\n\t\t\tawait this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });\n\t\t}\n\t}\n\n\tprivate async refreshTemporaryGitSource(source: GitSource, sourceStr: string): Promise<void> {\n\t\tif (isOfflineModeEnabled()) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tawait this.withProgress(\"pull\", sourceStr, `Refreshing ${sourceStr}...`, async () => {\n\t\t\t\tawait this.updateGit(source, \"temporary\");\n\t\t\t});\n\t\t} catch {\n\t\t\t// Keep cached temporary checkout if refresh fails.\n\t\t}\n\t}\n\n\tprivate async removeGit(source: GitSource, scope: SourceScope): Promise<void> {\n\t\tconst targetDir = this.getGitInstallPath(source, scope);\n\t\tif (!existsSync(targetDir)) return;\n\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\trmSync(targetDir, { recursive: true, force: true });\n\t\tthis.pruneEmptyGitParents(targetDir, this.getGitInstallRoot(scope), source, scope);\n\t}\n\n\tprivate isSafeGitParentForPruning(\n\t\tcurrent: string,\n\t\ttargetDir: string,\n\t\tsource: GitSource,\n\t\tscope: SourceScope,\n\t): boolean {\n\t\ttry {\n\t\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\t\treturn !existsSync(current) || !lstatSync(current).isSymbolicLink();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate pruneEmptyGitParents(\n\t\ttargetDir: string,\n\t\tinstallRoot: string | undefined,\n\t\tsource: GitSource,\n\t\tscope: SourceScope,\n\t): void {\n\t\tif (!installRoot) return;\n\t\tconst resolvedRoot = resolve(installRoot);\n\t\tlet current = dirname(resolve(targetDir));\n\t\twhile (current !== resolvedRoot && isPathWithin(resolvedRoot, current)) {\n\t\t\tif (!this.isSafeGitParentForPruning(current, targetDir, source, scope)) break;\n\t\t\tif (!existsSync(current)) {\n\t\t\t\tcurrent = dirname(current);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst entries = readdirSync(current);\n\t\t\tif (entries.length > 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tthis.assertGitTarget(source, scope, targetDir);\n\t\t\t\tthis.resolveManagedPath(resolvedRoot, relative(resolvedRoot, current));\n\t\t\t\tif (lstatSync(current).isSymbolicLink()) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\trmSync(current, { recursive: true, force: true });\n\t\t\t} catch {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcurrent = dirname(current);\n\t\t}\n\t}\n\n\tprivate ensureNpmProject(installRoot: string): void {\n\t\tif (!existsSync(installRoot)) {\n\t\t\tmkdirSync(installRoot, { recursive: true });\n\t\t}\n\t\tmarkPathIgnoredByCloudSync(installRoot);\n\t\tthis.ensureGitIgnore(installRoot);\n\t\tconst packageJsonPath = join(installRoot, \"package.json\");\n\t\tif (!existsSync(packageJsonPath)) {\n\t\t\tconst pkgJson = { name: \"grip-extensions\", private: true };\n\t\t\twriteFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), \"utf-8\");\n\t\t}\n\t}\n\n\tprivate ensureGitIgnore(dir: string, managedGitRoot = false): void {\n\t\tif (!existsSync(dir)) {\n\t\t\tmkdirSync(dir, { recursive: true });\n\t\t}\n\t\tconst ignorePath = join(dir, \".gitignore\");\n\t\tif (!managedGitRoot) {\n\t\t\tif (!existsSync(ignorePath)) {\n\t\t\t\twriteFileSync(ignorePath, \"*\\n!.gitignore\\n\", \"utf-8\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst stats = lstatSync(ignorePath);\n\t\t\tif (stats.isSymbolicLink()) {\n\t\t\t\tthrow new Error(`Refusing symbolic link in managed Git metadata path: ${ignorePath}`);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!isMissingPathError(error)) throw error;\n\t\t\twriteFileSync(ignorePath, \"*\\n!.gitignore\\n\", \"utf-8\");\n\t\t}\n\t}\n\n\tprivate getNpmInstallRoot(scope: SourceScope, temporary: boolean): string {\n\t\tif (temporary) {\n\t\t\treturn this.getTemporaryDir(\"npm\");\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn join(this.cwd, CONFIG_DIR_NAME, \"npm\");\n\t\t}\n\t\treturn join(this.agentDir, \"npm\");\n\t}\n\n\tprivate getGlobalNpmRoot(): string {\n\t\tconst npmCommand = this.getNpmCommand();\n\t\tconst commandKey = [npmCommand.command, ...npmCommand.args].join(\"\\0\");\n\t\tif (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {\n\t\t\treturn this.globalNpmRoot;\n\t\t}\n\t\tif (this.getPackageManagerName() === \"bun\") {\n\t\t\tconst binDir = this.runNpmCommandSync([\"pm\", \"bin\", \"-g\"]).trim();\n\t\t\tthis.globalNpmRoot = join(dirname(binDir), \"install\", \"global\", \"node_modules\");\n\t\t} else {\n\t\t\tthis.globalNpmRoot = this.runNpmCommandSync([\"root\", \"-g\"]).trim();\n\t\t}\n\t\tthis.globalNpmRootCommandKey = commandKey;\n\t\treturn this.globalNpmRoot;\n\t}\n\n\tprivate getPnpmGlobalPackagePath(packageName: string): string | undefined {\n\t\tif (this.getPackageManagerName() !== \"pnpm\") {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst output = this.runNpmCommandSync([\"list\", \"-g\", \"--depth\", \"0\", \"--json\"]);\n\t\tconst entries = JSON.parse(output) as Array<{ dependencies?: Record<string, PnpmGlobalDependencyMetadata> }>;\n\t\tfor (const entry of entries) {\n\t\t\tconst path = entry.dependencies?.[packageName]?.path;\n\t\t\tif (path) return path;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate getManagedNpmInstallPath(source: NpmSource, scope: SourceScope): string {\n\t\tif (scope === \"temporary\") {\n\t\t\treturn join(this.getTemporaryDir(\"npm\"), \"node_modules\", source.name);\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn join(this.cwd, CONFIG_DIR_NAME, \"npm\", \"node_modules\", source.name);\n\t\t}\n\t\treturn join(this.agentDir, \"npm\", \"node_modules\", source.name);\n\t}\n\n\tprivate getLegacyGlobalNpmInstallPath(source: NpmSource): string | undefined {\n\t\ttry {\n\t\t\treturn this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate getNpmInstallPath(source: NpmSource, scope: SourceScope): string {\n\t\tconst managedPath = this.getManagedNpmInstallPath(source, scope);\n\t\tif (scope !== \"user\" || existsSync(managedPath)) {\n\t\t\treturn managedPath;\n\t\t}\n\t\tconst legacyPath = this.getLegacyGlobalNpmInstallPath(source);\n\t\treturn legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;\n\t}\n\n\tprivate getGitInstallPath(source: GitSource, scope: SourceScope): string {\n\t\tif (!isSafeGitInstallPath(source)) {\n\t\t\tthrow new Error(`Refusing unsafe Git package path: ${source.host}/${source.path}`);\n\t\t}\n\n\t\tlet targetDir: string;\n\t\tif (scope === \"temporary\") {\n\t\t\ttargetDir = this.getTemporaryDir(`git-${source.host}`, source.path);\n\t\t} else {\n\t\t\tconst installRoot = this.getGitInstallRoot(scope);\n\t\t\tif (!installRoot) {\n\t\t\t\tthrow new Error(\"Missing Git install root\");\n\t\t\t}\n\t\t\ttargetDir = this.resolveManagedPath(installRoot, source.host, source.path);\n\t\t}\n\n\t\tthis.assertManagedGitPath(source, scope, targetDir);\n\t\treturn targetDir;\n\t}\n\n\tprivate getGitInstallRoot(scope: SourceScope): string | undefined {\n\t\tif (scope === \"temporary\") {\n\t\t\treturn undefined;\n\t\t}\n\t\tif (scope === \"project\") {\n\t\t\treturn join(this.cwd, CONFIG_DIR_NAME, \"git\");\n\t\t}\n\t\treturn join(this.agentDir, \"git\");\n\t}\n\n\tprivate getGitConfinementRoot(scope: SourceScope): string {\n\t\treturn scope === \"temporary\" ? join(tmpdir(), \"grip-extensions\") : (this.getGitInstallRoot(scope) ?? \"\");\n\t}\n\n\tprivate getGitScopeAnchor(scope: SourceScope): string {\n\t\tif (scope === \"temporary\") return tmpdir();\n\t\treturn scope === \"project\" ? this.cwd : this.agentDir;\n\t}\n\n\tprivate getTemporaryDir(prefix: string, suffix?: string): string {\n\t\tconst root = this.resolveManagedPath(join(tmpdir(), \"grip-extensions\"), prefix);\n\t\tconst hash = createHash(\"sha256\")\n\t\t\t.update(`${prefix}-${suffix ?? \"\"}`)\n\t\t\t.digest(\"hex\")\n\t\t\t.slice(0, 8);\n\t\treturn this.resolveManagedPath(root, hash, suffix ?? \"\");\n\t}\n\n\tprivate resolveManagedPath(root: string, ...parts: string[]): string {\n\t\tconst resolvedRoot = resolve(root);\n\t\tconst resolvedPath = resolve(resolvedRoot, ...parts);\n\t\tif (!isPathWithin(resolvedRoot, resolvedPath)) {\n\t\t\tthrow new Error(`Refusing to use path outside package install root: ${resolvedPath}`);\n\t\t}\n\t\treturn resolvedPath;\n\t}\n\n\tprivate canonicalizeProspectivePath(path: string): string {\n\t\tlet current = resolve(path);\n\t\tconst missingParts: string[] = [];\n\t\twhile (true) {\n\t\t\ttry {\n\t\t\t\tlstatSync(current);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isMissingPathError(error)) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst parent = dirname(current);\n\t\t\t\tif (parent === current) {\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tmissingParts.unshift(basename(current));\n\t\t\t\tcurrent = parent;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn resolve(realpathSync(current), ...missingParts);\n\t\t}\n\t}\n\n\tprivate assertManagedGitPath(source: GitSource, scope: SourceScope, targetDir: string): void {\n\t\tif (!isSafeGitInstallPath(source)) {\n\t\t\tthrow new Error(`Refusing unsafe Git package path: ${source.host}/${source.path}`);\n\t\t}\n\n\t\tconst anchor = resolve(this.getGitScopeAnchor(scope));\n\t\tconst root = resolve(this.getGitConfinementRoot(scope));\n\t\tconst target = resolve(targetDir);\n\t\tif (!isPathWithin(anchor, root) || !isPathWithin(root, target)) {\n\t\t\tthrow new Error(`Refusing to use path outside package install root: ${target}`);\n\t\t}\n\n\t\tlet canonicalAnchor: string;\n\t\tlet canonicalRoot: string;\n\t\ttry {\n\t\t\tcanonicalAnchor = this.canonicalizeProspectivePath(anchor);\n\t\t\tcanonicalRoot = this.canonicalizeProspectivePath(root);\n\t\t} catch {\n\t\t\tthrow new Error(`Refusing unsafe Git package install root: ${root}`);\n\t\t}\n\t\tif (!isPathWithin(canonicalAnchor, canonicalRoot)) {\n\t\t\tthrow new Error(`Refusing Git package install root outside its trusted anchor: ${root}`);\n\t\t}\n\n\t\tconst relativeTarget = relative(root, target);\n\t\tlet current = canonicalRoot;\n\t\tfor (const component of relativeTarget.split(sep).filter(Boolean)) {\n\t\t\tcurrent = join(current, component);\n\t\t\ttry {\n\t\t\t\tconst stats = lstatSync(current);\n\t\t\t\tif (stats.isSymbolicLink()) {\n\t\t\t\t\tthrow new Error(`Refusing symbolic link in Git package path: ${current}`);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isMissingPathError(error)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate assertGitTarget(source: GitSource, scope: SourceScope, targetDir: string): void {\n\t\tconst expected = this.getGitInstallPath(source, scope);\n\t\tif (expected !== resolve(targetDir)) {\n\t\t\tthrow new Error(`Refusing unexpected Git package path: ${targetDir}`);\n\t\t}\n\t}\n\n\tprivate getBaseDirForScope(scope: SourceScope): string {\n\t\tif (scope === \"project\") {\n\t\t\treturn join(this.cwd, CONFIG_DIR_NAME);\n\t\t}\n\t\tif (scope === \"user\") {\n\t\t\treturn this.agentDir;\n\t\t}\n\t\treturn this.cwd;\n\t}\n\n\tprivate resolvePath(input: string): string {\n\t\treturn resolvePath(input, this.cwd, { homeDir: getHomeDir(), trim: true });\n\t}\n\n\tprivate resolvePathFromBase(input: string, baseDir: string): string {\n\t\treturn resolvePath(input, baseDir, { homeDir: getHomeDir(), trim: true });\n\t}\n\n\tprivate assertConfinedResourcePath(candidate: string, packageRoot: string): void {\n\t\tlet canonicalRoot: string;\n\t\tlet canonicalCandidate: string;\n\t\ttry {\n\t\t\tcanonicalRoot = realpathSync(packageRoot);\n\t\t\tcanonicalCandidate = realpathSync(candidate);\n\t\t} catch {\n\t\t\tthrow new Error(`Refusing unreadable or broken managed Git package resource: ${candidate}`);\n\t\t}\n\t\tif (!isPathWithin(canonicalRoot, canonicalCandidate)) {\n\t\t\tthrow new Error(`Refusing managed Git package resource outside checkout: ${candidate}`);\n\t\t}\n\t}\n\n\tprivate validateConfinedResourceTree(candidate: string, packageRoot: string, visited = new Set<string>()): void {\n\t\tlstatSync(candidate);\n\t\tthis.assertConfinedResourcePath(candidate, packageRoot);\n\t\tconst canonicalCandidate = realpathSync(candidate);\n\t\tconst stats = statSync(candidate);\n\t\tif (!stats.isDirectory() || visited.has(canonicalCandidate)) return;\n\t\tvisited.add(canonicalCandidate);\n\t\tfor (const entry of readdirSync(candidate, { withFileTypes: true })) {\n\t\t\tif (entry.name === \"node_modules\") continue;\n\t\t\tif (entry.name.startsWith(\".\") && !IGNORE_FILE_NAMES.has(entry.name)) continue;\n\t\t\tthis.validateConfinedResourceTree(join(candidate, entry.name), packageRoot, visited);\n\t\t}\n\t}\n\n\tprivate validateOptionalConfinedResourcePath(candidate: string, packageRoot: string): void {\n\t\ttry {\n\t\t\tlstatSync(candidate);\n\t\t\tthis.assertConfinedResourcePath(candidate, packageRoot);\n\t\t} catch (error) {\n\t\t\tif (!isMissingPathError(error)) throw error;\n\t\t}\n\t}\n\n\tprivate validateOptionalConfinedResourceTree(candidate: string, packageRoot: string): void {\n\t\ttry {\n\t\t\tthis.validateConfinedResourceTree(candidate, packageRoot);\n\t\t} catch (error) {\n\t\t\tif (!isMissingPathError(error)) throw error;\n\t\t}\n\t}\n\n\tprivate validateManagedGitManifestEntry(entry: string, packageRoot: string): void {\n\t\tif (entry.includes(\"\\\\\") || /^[a-z]:/i.test(entry)) {\n\t\t\tthrow new Error(`Refusing unsafe managed Git package resource entry: ${entry}`);\n\t\t}\n\t\tthis.resolveManagedPath(packageRoot, entry);\n\t\tconst entryParts = entry.split(\"/\");\n\t\tconst firstGlobPart = entryParts.findIndex((part) => hasGlobPattern(part));\n\t\tconst scanEntry = firstGlobPart < 0 ? entry : entryParts.slice(0, firstGlobPart).join(\"/\") || \".\";\n\t\tthis.validateOptionalConfinedResourceTree(resolve(packageRoot, scanEntry), packageRoot);\n\t\tif (firstGlobPart < 0) return;\n\t\tfor (const match of globSync(entry, {\n\t\t\tcwd: packageRoot,\n\t\t\tabsolute: true,\n\t\t\tdot: false,\n\t\t\tfollow: false,\n\t\t\tnodir: false,\n\t\t})) {\n\t\t\tthis.validateConfinedResourceTree(resolve(match), packageRoot);\n\t\t}\n\t}\n\n\tprivate validateManagedGitManifestResources(manifest: GripManifest, packageRoot: string): void {\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tconst entries = manifest[resourceType as keyof GripManifest];\n\t\t\tif (!Array.isArray(entries)) continue;\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (typeof entry !== \"string\" || isOverridePattern(entry)) continue;\n\t\t\t\tthis.validateManagedGitManifestEntry(entry, packageRoot);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate validateManagedGitResourceInputs(packageRoot: string): void {\n\t\tthis.assertConfinedResourcePath(packageRoot, packageRoot);\n\t\tconst packageJsonPath = join(packageRoot, \"package.json\");\n\t\tthis.validateOptionalConfinedResourcePath(packageJsonPath, packageRoot);\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tthis.validateOptionalConfinedResourceTree(join(packageRoot, resourceType), packageRoot);\n\t\t}\n\t\tconst manifest = readGripManifest(packageJsonPath);\n\t\tif (manifest) this.validateManagedGitManifestResources(manifest, packageRoot);\n\t}\n\n\tprivate collectManagedGitPackageResources(\n\t\tpackageRoot: string,\n\t\taccumulator: ResourceAccumulator,\n\t\tfilter: PackageFilter | undefined,\n\t\tmetadata: PathMetadata,\n\t): void {\n\t\tthis.validateManagedGitResourceInputs(packageRoot);\n\t\tconst packageAccumulator = this.createAccumulator();\n\t\tthis.collectPackageResources(packageRoot, packageAccumulator, filter, metadata);\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tconst sourceMap = this.getTargetMap(packageAccumulator, resourceType);\n\t\t\tconst targetMap = this.getTargetMap(accumulator, resourceType);\n\t\t\tfor (const [path, value] of sourceMap) {\n\t\t\t\tthis.assertConfinedResourcePath(path, packageRoot);\n\t\t\t\tthis.addResource(targetMap, path, value.metadata, value.enabled);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate collectPackageResources(\n\t\tpackageRoot: string,\n\t\taccumulator: ResourceAccumulator,\n\t\tfilter: PackageFilter | undefined,\n\t\tmetadata: PathMetadata,\n\t): boolean {\n\t\tif (filter) {\n\t\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\t\tconst patterns = filter[resourceType as keyof PackageFilter];\n\t\t\t\tconst target = this.getTargetMap(accumulator, resourceType);\n\t\t\t\tif (patterns !== undefined) {\n\t\t\t\t\tthis.applyPackageFilter(packageRoot, patterns, resourceType, target, metadata);\n\t\t\t\t} else {\n\t\t\t\t\tthis.collectDefaultResources(packageRoot, resourceType, target, metadata);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tconst manifest = readGripManifest(join(packageRoot, \"package.json\"));\n\t\tif (manifest) {\n\t\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\t\tconst entries = manifest[resourceType as keyof GripManifest];\n\t\t\t\tthis.addManifestEntries(\n\t\t\t\t\tentries,\n\t\t\t\t\tpackageRoot,\n\t\t\t\t\tresourceType,\n\t\t\t\t\tthis.getTargetMap(accumulator, resourceType),\n\t\t\t\t\tmetadata,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\n\t\tlet hasAnyDir = false;\n\t\tfor (const resourceType of RESOURCE_TYPES) {\n\t\t\tconst dir = join(packageRoot, resourceType);\n\t\t\tif (!existsSync(dir)) continue;\n\t\t\t// Collect all files from the directory (all enabled by default)\n\t\t\tconst files = collectResourceFiles(dir, resourceType);\n\t\t\tfor (const f of files) {\n\t\t\t\tthis.addResource(this.getTargetMap(accumulator, resourceType), f, metadata, true);\n\t\t\t}\n\t\t\thasAnyDir = true;\n\t\t}\n\t\treturn hasAnyDir;\n\t}\n\n\tprivate collectDefaultResources(\n\t\tpackageRoot: string,\n\t\tresourceType: ResourceType,\n\t\ttarget: ResourceMap,\n\t\tmetadata: PathMetadata,\n\t): void {\n\t\tconst manifest = readGripManifest(join(packageRoot, \"package.json\"));\n\t\tconst entries = manifest?.[resourceType as keyof GripManifest];\n\t\tif (entries) {\n\t\t\tthis.addManifestEntries(entries, packageRoot, resourceType, target, metadata);\n\t\t\treturn;\n\t\t}\n\t\tconst dir = join(packageRoot, resourceType);\n\t\tif (existsSync(dir)) {\n\t\t\t// Collect all files from the directory (all enabled by default)\n\t\t\tconst files = collectResourceFiles(dir, resourceType);\n\t\t\tfor (const f of files) {\n\t\t\t\tthis.addResource(target, f, metadata, true);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate applyPackageFilter(\n\t\tpackageRoot: string,\n\t\tuserPatterns: string[],\n\t\tresourceType: ResourceType,\n\t\ttarget: ResourceMap,\n\t\tmetadata: PathMetadata,\n\t): void {\n\t\tconst { allFiles } = this.collectManifestFiles(packageRoot, resourceType);\n\n\t\tif (userPatterns.length === 0) {\n\t\t\t// Empty array explicitly disables all resources of this type\n\t\t\tfor (const f of allFiles) {\n\t\t\t\tthis.addResource(target, f, metadata, false);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Apply user patterns\n\t\tconst enabledByUser = applyPatterns(allFiles, userPatterns, packageRoot);\n\n\t\tfor (const f of allFiles) {\n\t\t\tconst enabled = enabledByUser.has(f);\n\t\t\tthis.addResource(target, f, metadata, enabled);\n\t\t}\n\t}\n\n\t/**\n\t * Collect all files from a package for a resource type, applying manifest patterns.\n\t * Returns { allFiles, enabledByManifest } where enabledByManifest is the set of files\n\t * that pass the manifest's own patterns.\n\t */\n\tprivate collectManifestFiles(packageRoot: string, resourceType: ResourceType): ManifestFileCollection {\n\t\tconst manifest = readGripManifest(join(packageRoot, \"package.json\"));\n\t\tconst entries = manifest?.[resourceType as keyof GripManifest];\n\t\tif (entries && entries.length > 0) {\n\t\t\tconst allFiles = this.collectFilesFromManifestEntries(entries, packageRoot, resourceType);\n\t\t\tconst manifestPatterns = entries.filter(isOverridePattern);\n\t\t\tconst enabledByManifest =\n\t\t\t\tmanifestPatterns.length > 0 ? applyPatterns(allFiles, manifestPatterns, packageRoot) : new Set(allFiles);\n\t\t\treturn { allFiles: Array.from(enabledByManifest), enabledByManifest };\n\t\t}\n\n\t\tconst conventionDir = join(packageRoot, resourceType);\n\t\tif (!existsSync(conventionDir)) {\n\t\t\treturn { allFiles: [], enabledByManifest: new Set() };\n\t\t}\n\t\tconst allFiles = collectResourceFiles(conventionDir, resourceType);\n\t\treturn { allFiles, enabledByManifest: new Set(allFiles) };\n\t}\n\n\tprivate addManifestEntries(\n\t\tentries: string[] | undefined,\n\t\troot: string,\n\t\tresourceType: ResourceType,\n\t\ttarget: ResourceMap,\n\t\tmetadata: PathMetadata,\n\t): void {\n\t\tif (!entries) return;\n\n\t\tconst allFiles = this.collectFilesFromManifestEntries(entries, root, resourceType);\n\t\tconst patterns = entries.filter(isOverridePattern);\n\t\tconst enabledPaths = applyPatterns(allFiles, patterns, root);\n\n\t\tfor (const f of allFiles) {\n\t\t\tif (enabledPaths.has(f)) {\n\t\t\t\tthis.addResource(target, f, metadata, true);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate collectFilesFromManifestEntries(entries: string[], root: string, resourceType: ResourceType): string[] {\n\t\tconst sourceEntries = entries.filter((entry) => !isOverridePattern(entry));\n\t\tconst resolved = sourceEntries.flatMap((entry) => {\n\t\t\tif (!hasGlobPattern(entry)) {\n\t\t\t\treturn [resolve(root, entry)];\n\t\t\t}\n\n\t\t\treturn globSync(entry, {\n\t\t\t\tcwd: root,\n\t\t\t\tabsolute: true,\n\t\t\t\tdot: false,\n\t\t\t\tfollow: false,\n\t\t\t\tnodir: false,\n\t\t\t}).map((match) => resolve(match));\n\t\t});\n\t\treturn this.collectFilesFromPaths(resolved, resourceType);\n\t}\n\n\tprivate resolveLocalEntries(\n\t\tentries: string[],\n\t\tresourceType: ResourceType,\n\t\ttarget: ResourceMap,\n\t\tmetadata: PathMetadata,\n\t\tbaseDir: string,\n\t): void {\n\t\tif (entries.length === 0) return;\n\n\t\t// Collect all files from plain entries (non-pattern entries)\n\t\tconst { plain, patterns } = splitPatterns(entries);\n\t\tconst resolvedPlain = plain.map((p) => this.resolvePathFromBase(p, baseDir));\n\t\tconst allFiles = this.collectFilesFromPaths(resolvedPlain, resourceType);\n\n\t\t// Determine which files are enabled based on patterns\n\t\tconst enabledPaths = applyPatterns(allFiles, patterns, baseDir);\n\n\t\t// Add all files with their enabled state\n\t\tfor (const f of allFiles) {\n\t\t\tthis.addResource(target, f, metadata, enabledPaths.has(f));\n\t\t}\n\t}\n\n\tprivate addAutoDiscoveredResources(\n\t\taccumulator: ResourceAccumulator,\n\t\tglobalSettings: Settings,\n\t\tprojectSettings: Settings,\n\t\tglobalBaseDir: string,\n\t\tprojectBaseDir: string,\n\t): void {\n\t\tconst userMetadata: PathMetadata = {\n\t\t\tsource: \"auto\",\n\t\t\tscope: \"user\",\n\t\t\torigin: \"top-level\",\n\t\t\tbaseDir: globalBaseDir,\n\t\t};\n\t\tconst projectMetadata: PathMetadata = {\n\t\t\tsource: \"auto\",\n\t\t\tscope: \"project\",\n\t\t\torigin: \"top-level\",\n\t\t\tbaseDir: projectBaseDir,\n\t\t};\n\n\t\tconst userOverrides = {\n\t\t\textensions: (globalSettings.extensions ?? []) as string[],\n\t\t\tskills: (globalSettings.skills ?? []) as string[],\n\t\t\trules: (globalSettings.rules ?? []) as string[],\n\t\t\tprompts: (globalSettings.prompts ?? []) as string[],\n\t\t\tthemes: (globalSettings.themes ?? []) as string[],\n\t\t};\n\t\tconst projectOverrides = {\n\t\t\textensions: (projectSettings.extensions ?? []) as string[],\n\t\t\tskills: (projectSettings.skills ?? []) as string[],\n\t\t\trules: (projectSettings.rules ?? []) as string[],\n\t\t\tprompts: (projectSettings.prompts ?? []) as string[],\n\t\t\tthemes: (projectSettings.themes ?? []) as string[],\n\t\t};\n\n\t\tconst userDirs = {\n\t\t\textensions: join(globalBaseDir, \"extensions\"),\n\t\t\tskills: join(globalBaseDir, \"skills\"),\n\t\t\trules: join(globalBaseDir, \"rules\"),\n\t\t\tprompts: join(globalBaseDir, \"prompts\"),\n\t\t\tthemes: join(globalBaseDir, \"themes\"),\n\t\t};\n\t\tconst projectDirs = {\n\t\t\textensions: join(projectBaseDir, \"extensions\"),\n\t\t\tskills: join(projectBaseDir, \"skills\"),\n\t\t\trules: join(projectBaseDir, \"rules\"),\n\t\t\tprompts: join(projectBaseDir, \"prompts\"),\n\t\t\tthemes: join(projectBaseDir, \"themes\"),\n\t\t};\n\t\tconst userAgentsSkillsDir = join(getHomeDir(), \".agents\", \"skills\");\n\t\tconst userAgentsRulesDir = join(getHomeDir(), \".agents\", \"rules\");\n\t\tconst projectAgentsSkillDirs = collectAncestorAgentsSkillDirs(this.cwd).filter(\n\t\t\t(dir) => resolve(dir) !== resolve(userAgentsSkillsDir),\n\t\t);\n\t\tconst projectAgentsRuleDirs = collectAncestorAgentsRuleDirs(this.cwd).filter(\n\t\t\t(dir) => resolve(dir) !== resolve(userAgentsRulesDir),\n\t\t);\n\n\t\tconst addResources = (\n\t\t\tresourceType: ResourceType,\n\t\t\tpaths: string[],\n\t\t\tmetadata: PathMetadata,\n\t\t\toverrides: string[],\n\t\t\tbaseDir: string,\n\t\t) => {\n\t\t\tconst target = this.getTargetMap(accumulator, resourceType);\n\t\t\tfor (const path of paths) {\n\t\t\t\tconst enabled = isEnabledByOverrides(path, overrides, baseDir);\n\t\t\t\tthis.addResource(target, path, metadata, enabled);\n\t\t\t}\n\t\t};\n\n\t\t// Project extensions from .grip/\n\t\taddResources(\n\t\t\t\"extensions\",\n\t\t\tcollectAutoExtensionEntries(projectDirs.extensions),\n\t\t\tprojectMetadata,\n\t\t\tprojectOverrides.extensions,\n\t\t\tprojectBaseDir,\n\t\t);\n\n\t\t// Project skills from .grip/\n\t\taddResources(\n\t\t\t\"skills\",\n\t\t\tcollectAutoSkillEntries(projectDirs.skills, \"grip\"),\n\t\t\tprojectMetadata,\n\t\t\tprojectOverrides.skills,\n\t\t\tprojectBaseDir,\n\t\t);\n\n\t\t// Project rules from .grip/\n\t\taddResources(\n\t\t\t\"rules\",\n\t\t\tcollectAutoRuleEntries(projectDirs.rules, \"grip\"),\n\t\t\tprojectMetadata,\n\t\t\tprojectOverrides.rules,\n\t\t\tprojectBaseDir,\n\t\t);\n\n\t\t// Project skills from .agents/ (each with its own baseDir)\n\t\tfor (const agentsSkillsDir of projectAgentsSkillDirs) {\n\t\t\tconst agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory\n\t\t\tconst agentsMetadata: PathMetadata = {\n\t\t\t\t...projectMetadata,\n\t\t\t\tbaseDir: agentsBaseDir,\n\t\t\t};\n\t\t\taddResources(\n\t\t\t\t\"skills\",\n\t\t\t\tcollectAutoSkillEntries(agentsSkillsDir, \"agents\"),\n\t\t\t\tagentsMetadata,\n\t\t\t\tprojectOverrides.skills,\n\t\t\t\tagentsBaseDir,\n\t\t\t);\n\t\t}\n\n\t\t// Project rules from .agents/ (each with its own baseDir)\n\t\tfor (const agentsRulesDir of projectAgentsRuleDirs) {\n\t\t\tconst agentsBaseDir = dirname(agentsRulesDir); // the .agents directory\n\t\t\tconst agentsMetadata: PathMetadata = {\n\t\t\t\t...projectMetadata,\n\t\t\t\tbaseDir: agentsBaseDir,\n\t\t\t};\n\t\t\taddResources(\n\t\t\t\t\"rules\",\n\t\t\t\tcollectAutoRuleEntries(agentsRulesDir, \"agents\"),\n\t\t\t\tagentsMetadata,\n\t\t\t\tprojectOverrides.rules,\n\t\t\t\tagentsBaseDir,\n\t\t\t);\n\t\t}\n\n\t\taddResources(\n\t\t\t\"prompts\",\n\t\t\tcollectAutoPromptEntries(projectDirs.prompts),\n\t\t\tprojectMetadata,\n\t\t\tprojectOverrides.prompts,\n\t\t\tprojectBaseDir,\n\t\t);\n\t\taddResources(\n\t\t\t\"themes\",\n\t\t\tcollectAutoThemeEntries(projectDirs.themes),\n\t\t\tprojectMetadata,\n\t\t\tprojectOverrides.themes,\n\t\t\tprojectBaseDir,\n\t\t);\n\n\t\t// User extensions from ~/.grip/agent/\n\t\taddResources(\n\t\t\t\"extensions\",\n\t\t\tcollectAutoExtensionEntries(userDirs.extensions),\n\t\t\tuserMetadata,\n\t\t\tuserOverrides.extensions,\n\t\t\tglobalBaseDir,\n\t\t);\n\n\t\t// User skills from ~/.grip/agent/\n\t\taddResources(\n\t\t\t\"skills\",\n\t\t\tcollectAutoSkillEntries(userDirs.skills, \"grip\"),\n\t\t\tuserMetadata,\n\t\t\tuserOverrides.skills,\n\t\t\tglobalBaseDir,\n\t\t);\n\n\t\t// User rules from ~/.grip/agent/\n\t\taddResources(\n\t\t\t\"rules\",\n\t\t\tcollectAutoRuleEntries(userDirs.rules, \"grip\"),\n\t\t\tuserMetadata,\n\t\t\tuserOverrides.rules,\n\t\t\tglobalBaseDir,\n\t\t);\n\n\t\t// User skills from ~/.agents/ (with its own baseDir)\n\t\tconst userAgentsBaseDir = dirname(userAgentsSkillsDir);\n\t\tconst userAgentsMetadata: PathMetadata = {\n\t\t\t...userMetadata,\n\t\t\tbaseDir: userAgentsBaseDir,\n\t\t};\n\t\taddResources(\n\t\t\t\"skills\",\n\t\t\tcollectAutoSkillEntries(userAgentsSkillsDir, \"agents\"),\n\t\t\tuserAgentsMetadata,\n\t\t\tuserOverrides.skills,\n\t\t\tuserAgentsBaseDir,\n\t\t);\n\n\t\t// User rules from ~/.agents/ (with its own baseDir)\n\t\tconst userAgentsRulesBaseDir = dirname(userAgentsRulesDir);\n\t\tconst userAgentsRulesMetadata: PathMetadata = {\n\t\t\t...userMetadata,\n\t\t\tbaseDir: userAgentsRulesBaseDir,\n\t\t};\n\t\taddResources(\n\t\t\t\"rules\",\n\t\t\tcollectAutoRuleEntries(userAgentsRulesDir, \"agents\"),\n\t\t\tuserAgentsRulesMetadata,\n\t\t\tuserOverrides.rules,\n\t\t\tuserAgentsRulesBaseDir,\n\t\t);\n\n\t\taddResources(\n\t\t\t\"prompts\",\n\t\t\tcollectAutoPromptEntries(userDirs.prompts),\n\t\t\tuserMetadata,\n\t\t\tuserOverrides.prompts,\n\t\t\tglobalBaseDir,\n\t\t);\n\t\taddResources(\n\t\t\t\"themes\",\n\t\t\tcollectAutoThemeEntries(userDirs.themes),\n\t\t\tuserMetadata,\n\t\t\tuserOverrides.themes,\n\t\t\tglobalBaseDir,\n\t\t);\n\t}\n\n\tprivate collectFilesFromPaths(paths: string[], resourceType: ResourceType): string[] {\n\t\tconst files: string[] = [];\n\t\tfor (const p of paths) {\n\t\t\tif (!existsSync(p)) continue;\n\n\t\t\ttry {\n\t\t\t\tconst stats = statSync(p);\n\t\t\t\tif (stats.isFile()) {\n\t\t\t\t\tfiles.push(p);\n\t\t\t\t} else if (stats.isDirectory()) {\n\t\t\t\t\tfiles.push(...collectResourceFiles(p, resourceType));\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Ignore errors\n\t\t\t}\n\t\t}\n\t\treturn files;\n\t}\n\n\tprivate getTargetMap(accumulator: ResourceAccumulator, resourceType: ResourceType): ResourceMap {\n\t\tswitch (resourceType) {\n\t\t\tcase \"extensions\":\n\t\t\t\treturn accumulator.extensions;\n\t\t\tcase \"skills\":\n\t\t\t\treturn accumulator.skills;\n\t\t\tcase \"rules\":\n\t\t\t\treturn accumulator.rules;\n\t\t\tcase \"prompts\":\n\t\t\t\treturn accumulator.prompts;\n\t\t\tcase \"themes\":\n\t\t\t\treturn accumulator.themes;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unknown resource type: ${resourceType}`);\n\t\t}\n\t}\n\n\tprivate addResource(map: ResourceMap, path: string, metadata: PathMetadata, enabled: boolean): void {\n\t\tif (!path) return;\n\t\tif (!map.has(path)) {\n\t\t\tmap.set(path, { metadata, enabled });\n\t\t}\n\t}\n\n\tprivate createAccumulator(): ResourceAccumulator {\n\t\treturn {\n\t\t\textensions: new Map(),\n\t\t\tskills: new Map(),\n\t\t\trules: new Map(),\n\t\t\tprompts: new Map(),\n\t\t\tthemes: new Map(),\n\t\t};\n\t}\n\n\tprivate toResolvedPaths(accumulator: ResourceAccumulator): ResolvedPaths {\n\t\tconst mapToResolved = (entries: ResourceMap): ResolvedResource[] => {\n\t\t\tconst resolved = Array.from(entries.entries()).map(([path, { metadata, enabled }]) => ({\n\t\t\t\tpath,\n\t\t\t\tenabled,\n\t\t\t\tmetadata,\n\t\t\t}));\n\t\t\tresolved.sort((a, b) => resourcePrecedenceRank(a.metadata) - resourcePrecedenceRank(b.metadata));\n\n\t\t\tconst seen = new Set<string>();\n\t\t\treturn resolved.filter((entry) => {\n\t\t\t\tconst canonicalPath = canonicalizePath(entry.path);\n\t\t\t\tif (seen.has(canonicalPath)) return false;\n\t\t\t\tseen.add(canonicalPath);\n\t\t\t\treturn true;\n\t\t\t});\n\t\t};\n\n\t\treturn {\n\t\t\textensions: mapToResolved(accumulator.extensions),\n\t\t\tskills: mapToResolved(accumulator.skills),\n\t\t\trules: mapToResolved(accumulator.rules),\n\t\t\tprompts: mapToResolved(accumulator.prompts),\n\t\t\tthemes: mapToResolved(accumulator.themes),\n\t\t};\n\t}\n\n\tprivate spawnCommand(command: string, args: string[], options?: CommandWorkingDirectoryOptions): ChildProcess {\n\t\tconst env = getEnv();\n\t\treturn spawnProcess(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tstdio: isStdoutTakenOver() ? [\"ignore\", 2, 2] : \"inherit\",\n\t\t\tenv,\n\t\t});\n\t}\n\n\tprivate spawnCaptureCommand(\n\t\tcommand: string,\n\t\targs: string[],\n\t\toptions?: CommandEnvironmentOptions,\n\t): ChildProcessByStdio<null, Readable, Readable> {\n\t\tconst baseEnv = getEnv();\n\t\tconst env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;\n\t\treturn spawnProcess(command, args, {\n\t\t\tcwd: options?.cwd,\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tenv,\n\t\t});\n\t}\n\n\tprivate runCommandCapture(command: string, args: string[], options?: CommandCaptureOptions): Promise<string> {\n\t\treturn new Promise((resolvePromise, reject) => {\n\t\t\tconst child = this.spawnCaptureCommand(command, args, options);\n\t\t\tlet stdout = \"\";\n\t\t\tlet stderr = \"\";\n\t\t\tlet timedOut = false;\n\t\t\tconst timeout =\n\t\t\t\ttypeof options?.timeoutMs === \"number\"\n\t\t\t\t\t? setTimeout(() => {\n\t\t\t\t\t\t\ttimedOut = true;\n\t\t\t\t\t\t\tchild.kill();\n\t\t\t\t\t\t}, options.timeoutMs)\n\t\t\t\t\t: undefined;\n\n\t\t\tchild.stdout?.on(\"data\", (data) => {\n\t\t\t\tstdout += data.toString();\n\t\t\t});\n\t\t\tchild.stderr?.on(\"data\", (data) => {\n\t\t\t\tstderr += data.toString();\n\t\t\t});\n\t\t\tchild.once(\"error\", (error) => {\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.once(\"close\", (code, signal) => {\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\tif (timedOut) {\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} timed out after ${options?.timeoutMs}ms`));\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolvePromise(stdout.trim());\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst exitStatus = code === null ? `signal ${signal ?? \"unknown\"}` : `code ${code}`;\n\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed with ${exitStatus}: ${stderr || stdout}`));\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate runCommand(command: string, args: string[], options?: CommandWorkingDirectoryOptions): Promise<void> {\n\t\treturn new Promise((resolvePromise, reject) => {\n\t\t\tconst child = this.spawnCommand(command, args, options);\n\t\t\tchild.on(\"error\", reject);\n\t\t\tchild.on(\"exit\", (code) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolvePromise();\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${command} ${args.join(\" \")} failed with code ${code}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate runCommandSync(command: string, args: string[]): string {\n\t\tconst env = getEnv();\n\t\tconst result = spawnProcessSync(command, args, {\n\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\tencoding: \"utf-8\",\n\t\t\tenv,\n\t\t});\n\t\tif (result.error || result.status !== 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to run ${command} ${args.join(\" \")}: ${result.error?.message || result.stderr || result.stdout}`,\n\t\t\t);\n\t\t}\n\t\treturn (result.stdout || result.stderr || \"\").trim();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../src/core/package-manager.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAA2B,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAMjE,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAC5E,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,KAAK,CAAC;AAS9C,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,KAAK,EAAE,gBAAgB,EAAE,CAAC;IAC1B,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAE/D,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;A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AO,CAAC,eAAe;IASvB,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,oBAAoB;IA0C5B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,4BAA4B;IAcpC,OAAO,CAAC,oCAAoC;IAS5C,OAAO,CAAC,oCAAoC;IAQ5C,OAAO,CAAC,+BAA+B;IAqBvC,OAAO,CAAC,mCAAmC;IAW3C,OAAO,CAAC,gCAAgC;IAWxC,OAAO,CAAC,iCAAiC;IAmBzC,OAAO,CAAC,uBAAuB;IAgD/B,OAAO,CAAC,uBAAuB;IAsB/B,OAAO,CAAC,kBAAkB;IA0B1B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,kBAAkB;IAoB1B,OAAO,CAAC,+BAA+B;IAkBvC,OAAO,CAAC,mBAAmB;IAuB3B,OAAO,CAAC,0BAA0B;IAyNlC,OAAO,CAAC,qBAAqB;IAmB7B,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,iBAAiB;IAwCzB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;CActB"}
|
|
@@ -608,12 +608,6 @@ function applyPatterns(allPaths, patterns, baseDir) {
|
|
|
608
608
|
return new Set(result);
|
|
609
609
|
}
|
|
610
610
|
export class DefaultPackageManager {
|
|
611
|
-
cwd;
|
|
612
|
-
agentDir;
|
|
613
|
-
settingsManager;
|
|
614
|
-
globalNpmRoot;
|
|
615
|
-
globalNpmRootCommandKey;
|
|
616
|
-
progressCallback;
|
|
617
611
|
constructor(options) {
|
|
618
612
|
this.cwd = resolvePath(options.cwd);
|
|
619
613
|
this.agentDir = resolvePath(options.agentDir);
|