dal-code 1.0.23 → 1.0.25
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 +26 -0
- package/dal-docs/README.md +96 -0
- package/dal-docs/extensions.md +98 -0
- package/dal-docs/keybindings.md +40 -0
- package/dal-docs/packages.md +62 -0
- package/dal-docs/prompt-templates.md +42 -0
- package/dal-docs/settings.md +86 -0
- package/dal-docs/skills.md +65 -0
- package/dal-docs/themes.md +44 -0
- package/dist/cli/args.d.ts +56 -0
- package/dist/config.d.ts +63 -0
- package/dist/config.js +1 -1
- package/dist/core/agent-session-runtime.d.ts +74 -0
- package/dist/core/agent-session-services.d.ts +48 -0
- package/dist/core/agent-session.d.ts +409 -0
- package/dist/core/agent-session.js +6 -6
- package/dist/core/auth-storage.d.ts +56 -0
- package/dist/core/bash-executor.d.ts +13 -0
- package/dist/core/cache-warmer.d.ts +60 -0
- package/dist/core/compaction/branch-summarization.d.ts +43 -0
- package/dist/core/compaction/compaction.d.ts +62 -0
- package/dist/core/compaction/index.d.ts +3 -0
- package/dist/core/compaction/utils.d.ts +16 -0
- package/dist/core/diagnostics.d.ts +14 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/exec.d.ts +12 -0
- package/dist/core/extensions/index.d.ts +8 -0
- package/dist/core/extensions/loader.d.ts +13 -0
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/permission-surface.js +1 -1
- package/dist/core/extensions/runner.d.ts +165 -0
- package/dist/core/extensions/runner.js +1 -1
- package/dist/core/extensions/types.d.ts +1000 -0
- package/dist/core/extensions/wrapper.d.ts +5 -0
- package/dist/core/footer-data-provider.d.ts +46 -0
- package/dist/core/keybindings.d.ts +525 -0
- package/dist/core/keybindings.js +1 -1
- package/dist/core/messages.d.ts +50 -0
- package/dist/core/model-config.d.ts +1212 -0
- package/dist/core/model-registry.d.ts +41 -0
- package/dist/core/model-resolver.d.ts +67 -0
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-runtime.d.ts +101 -0
- package/dist/core/model-runtime.js +2 -2
- package/dist/core/package-manager.d.ts +213 -0
- package/dist/core/package-manager.js +2 -2
- package/dist/core/project-map.d.ts +18 -0
- package/dist/core/prompt-templates.d.ts +24 -0
- package/dist/core/provider-composer.d.ts +55 -0
- package/dist/core/remote-catalog-provider.js +1 -1
- package/dist/core/resolve-config-value.d.ts +11 -0
- package/dist/core/resource-loader.d.ts +220 -0
- package/dist/core/resource-loader.js +1 -1
- package/dist/core/sdk.d.ts +40 -0
- package/dist/core/session-manager.d.ts +208 -0
- package/dist/core/settings-manager.d.ts +348 -0
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/skills.d.ts +33 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/system-prompt.d.ts +39 -0
- package/dist/core/system-prompt.js +15 -11
- package/dist/core/tools/bash.d.ts +75 -0
- package/dist/core/tools/bash.js +14 -14
- package/dist/core/tools/edit-diff.d.ts +44 -0
- package/dist/core/tools/edit.d.ts +48 -0
- package/dist/core/tools/file-mutation-queue.d.ts +1 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/grep.d.ts +34 -0
- package/dist/core/tools/index.d.ts +42 -0
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/ls.d.ts +33 -0
- package/dist/core/tools/powershell.d.ts +17 -0
- package/dist/core/tools/read.d.ts +33 -0
- package/dist/core/tools/read.js +2 -2
- package/dist/core/tools/renderers/bash.d.ts +3 -0
- package/dist/core/tools/renderers/edit.d.ts +15 -0
- package/dist/core/tools/renderers/find.d.ts +2 -0
- package/dist/core/tools/renderers/grep.d.ts +2 -0
- package/dist/core/tools/renderers/index.d.ts +13 -0
- package/dist/core/tools/renderers/ls.d.ts +2 -0
- package/dist/core/tools/renderers/read.d.ts +3 -0
- package/dist/core/tools/renderers/read.js +8 -8
- package/dist/core/tools/renderers/write.d.ts +2 -0
- package/dist/core/tools/truncate.d.ts +27 -0
- package/dist/core/tools/write.d.ts +24 -0
- package/dist/core/trust-manager.d.ts +28 -0
- package/dist/core/trust-manager.js +2 -2
- package/dist/dal/child-env.d.ts +12 -0
- package/dist/dal/child-env.js +1 -0
- package/dist/dal/hooks/activity.d.ts +17 -0
- package/dist/dal/hooks/activity.js +1 -0
- package/dist/dal/hooks/config.d.ts +47 -0
- package/dist/dal/hooks/config.js +1 -0
- package/dist/dal/hooks/events.d.ts +43 -0
- package/dist/dal/hooks/events.js +4 -0
- package/dist/dal/hooks/extension.d.ts +3 -0
- package/dist/dal/hooks/extension.js +4 -0
- package/dist/dal/hooks/index.d.ts +5 -0
- package/dist/dal/hooks/index.js +1 -0
- package/dist/dal/hooks/runner.d.ts +57 -0
- package/dist/dal/hooks/runner.js +1 -0
- package/dist/dal/safety-net.js +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +1 -1
- package/dist/main.d.ts +9 -0
- package/dist/main.js +2 -2
- package/dist/modes/acp/acp-mode.d.ts +2 -0
- package/dist/modes/index.d.ts +7 -0
- package/dist/modes/interactive/components/armin.d.ts +30 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +26 -0
- package/dist/modes/interactive/components/assistant-message.js +2 -2
- package/dist/modes/interactive/components/bash-execution.d.ts +22 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +14 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +11 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +11 -0
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/modes/interactive/components/custom-message.d.ts +17 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +17 -0
- package/dist/modes/interactive/components/diff.d.ts +4 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +12 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +19 -0
- package/dist/modes/interactive/components/extension-input.d.ts +21 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +22 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +23 -0
- package/dist/modes/interactive/components/footer.d.ts +18 -0
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +9 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +27 -0
- package/dist/modes/interactive/components/model-selector.d.ts +81 -0
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/oauth-selector.d.ts +29 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +39 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +20 -0
- package/dist/modes/interactive/components/session-selector.d.ts +88 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +92 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +6 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +11 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +44 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +7 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +19 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +76 -0
- package/dist/modes/interactive/components/tool-execution.js +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +65 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +22 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +23 -0
- package/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode.d.ts +326 -0
- package/dist/modes/interactive/interactive-mode.js +48 -48
- package/dist/modes/interactive/theme/theme-json.d.ts +257 -0
- package/dist/modes/interactive/theme/theme.d.ts +106 -0
- package/dist/modes/interactive/tui-renderer.d.ts +18 -0
- package/dist/modes/json-event.d.ts +26 -0
- package/dist/modes/print-mode.d.ts +9 -0
- package/dist/modes/rpc/rpc-client.d.ts +119 -0
- package/dist/modes/rpc/rpc-client.js +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +3 -0
- package/dist/modes/rpc/rpc-types.d.ts +483 -0
- package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-bridge/src/ask-user.js +12 -0
- package/dist/node_modules/@dalcode/dal-bridge/src/client.js +1 -1
- package/dist/node_modules/@dalcode/dal-bridge/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-gateway/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-guard/package.json +5 -4
- package/dist/node_modules/@dalcode/dal-guard/src/hooks.js +1 -0
- package/dist/node_modules/@dalcode/dal-guard/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-lsp/src/client.js +3 -3
- package/dist/node_modules/@dalcode/dal-mcp/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-mcp/src/command-parser.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config-edit.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/config.d.ts +9 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/http-client.d.ts +16 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.d.ts +22 -0
- package/dist/node_modules/@dalcode/dal-mcp/src/stdio-client.js +2 -2
- package/dist/node_modules/@dalcode/dal-mcp/src/types.d.ts +30 -0
- package/dist/node_modules/@dalcode/dal-office/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/extract/csv.d.ts +3 -0
- package/dist/node_modules/@dalcode/dal-office/src/extract/csv.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/extract/ooxml.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/index.d.ts +11 -0
- package/dist/node_modules/@dalcode/dal-office/src/index.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/paths.d.ts +3 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/chart.js +1 -1
- package/dist/node_modules/@dalcode/dal-office/src/render/docx.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.d.ts +40 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/pptx.js +2 -2
- package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.d.ts +19 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/thumbnails.js +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/render/xlsx.d.ts +14 -0
- package/dist/node_modules/@dalcode/dal-office/src/scratchpad.d.ts +16 -0
- package/dist/node_modules/@dalcode/dal-office/src/themes.d.ts +13 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/docx-edit.js +10 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/edit-shared.js +1 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/pptx-edit.js +9 -0
- package/dist/node_modules/@dalcode/dal-office/src/tools/read-file.js +4 -2
- package/dist/node_modules/@dalcode/dal-office/src/tools/xlsx-edit.js +5 -0
- package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
- package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.js +2 -2
- package/dist/node_modules/@dalcode/dal-plugins/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-rewind/src/core.d.ts +61 -0
- package/dist/node_modules/@dalcode/dal-router/package.json +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/commands.js +6 -6
- package/dist/node_modules/@dalcode/dal-router/src/config.d.ts +50 -0
- package/dist/node_modules/@dalcode/dal-router/src/index.js +4 -4
- package/dist/node_modules/@dalcode/dal-router/src/jev.d.ts +51 -0
- package/dist/node_modules/@dalcode/dal-router/src/pool.d.ts +6 -0
- package/dist/node_modules/@dalcode/dal-router/src/router.d.ts +32 -0
- package/dist/node_modules/@dalcode/dal-router/src/runtime.d.ts +37 -0
- package/dist/node_modules/@dalcode/dal-router/src/runtime.js +1 -1
- package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-skills/src/discover.js +4 -4
- package/dist/node_modules/@dalcode/dal-skills/src/index.js +9 -9
- package/dist/node_modules/@dalcode/dal-subagent/package.json +5 -5
- package/dist/node_modules/@dalcode/dal-subagent/src/index.js +14 -8
- package/dist/node_modules/@dalcode/dal-subagent/src/process-runner.js +3 -3
- package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-tool-catalog/src/groups.js +1 -1
- package/dist/node_modules/@dalcode/dal-web/package.json +3 -3
- package/dist/node_modules/@dalcode/dal-workflow/package.json +2 -2
- package/dist/node_modules/@dalcode/dal-workflow/src/plan-mode.js +1 -1
- package/dist/node_modules/@dalcode/deepailab/package.json +3 -3
- package/dist/node_modules/@dalcode/deepailab/src/index.js +3 -3
- package/dist/node_modules/@dalcode/deepailab/src/model-defaults.js +1 -1
- package/dist/node_modules/@earendil-works/chord/dist/api.d.ts +21 -0
- package/dist/node_modules/@earendil-works/chord/dist/context/index.d.ts +12 -0
- package/dist/node_modules/@earendil-works/chord/dist/delta/index.d.ts +127 -0
- package/dist/node_modules/@earendil-works/chord/dist/index.d.ts +8 -0
- package/dist/node_modules/@earendil-works/chord/dist/json.d.ts +2 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/errors.d.ts +16 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/provider.d.ts +32 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/state-codec.d.ts +12 -0
- package/dist/node_modules/@earendil-works/chord/dist/services/wire.d.ts +59 -0
- package/dist/node_modules/@earendil-works/chord/dist/state/draft.d.ts +13 -0
- package/dist/node_modules/@earendil-works/chord/dist/types.d.ts +188 -0
- package/dist/node_modules/@earendil-works/chord/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +80 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +711 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +44 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +80 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/context.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/events.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/execution/effect-gate.d.ts +17 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/hooks.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +50 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/result.d.ts +132 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/harness.d.ts +56 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/lane.d.ts +94 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/reducer.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/runtime/types.d.ts +99 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/commit.d.ts +52 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork-policy.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/fork.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/index.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/index.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/repo.d.ts +33 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/storage.d.ts +37 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/types.d.ts +36 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory.d.ts +46 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/mutation-line.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +75 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/types.d.ts +473 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/values.d.ts +94 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/telemetry.d.ts +1495 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/bash.d.ts +26 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/edit.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/index.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/read.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/tool-context.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/tools/write.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +185 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/output-capture.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +22 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/truncate.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +27 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/proxy.d.ts +61 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/index.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/stream-fn.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +150 -0
- package/dist/node_modules/@earendil-works/pi-agent-core/package.json +4 -4
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/bedrock-converse-stream.lazy.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.d.ts +12 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-generative-ai.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-shared.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.d.ts +14 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/google-vertex.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/mistral-conversations.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.d.ts +30 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-codex-responses.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +24 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts +85 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.lazy.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/context.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/credential-store.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/helpers.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/resolve.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +127 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/cli.js +0 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat/extension-oauth-types.d.ts +34 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/compat.d.ts +47 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +829 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/images-models.d.ts +37 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/images.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/index.d.ts +38 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/legacy-api-aliases.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/model-catalog.d.ts +16 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models-store.d.ts +21 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.d.ts +97 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +84 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts +18 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/ant-ling.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/baseten.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cerebras.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-ai-gateway.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare-workers-ai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/azure-openai-responses.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openai.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode-go.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/radius.json +1 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/deepseek.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +100 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/fireworks.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/google.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/groq.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/huggingface.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/meta.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/minimax-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/minimax.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/mistral.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/nvidia.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/opencode.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan-individual.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/qwen-token-plan.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/radius.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/together.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/vercel-ai-gateway.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-ams.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi-token-plan-sgp.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/xiaomi.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/zai-coding-cn.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/providers/zai.models.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/session-resources.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/types.d.ts +502 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/assistant-message-frame.d.ts +63 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +19 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/json-parse.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts +16 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/text.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/transcript.d.ts +29 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/typebox-helpers.d.ts +5 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/uuid.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts +3 -0
- package/dist/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-client/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-coding-agent/LICENSE +21 -0
- package/dist/node_modules/@earendil-works/pi-coding-agent/index.d.ts +1 -0
- package/dist/node_modules/@earendil-works/pi-coding-agent/index.js +1 -0
- package/dist/node_modules/@earendil-works/pi-coding-agent/package.json +15 -0
- package/dist/node_modules/@earendil-works/pi-protocol/package.json +2 -2
- package/dist/node_modules/@earendil-works/pi-server/package.json +5 -5
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/package.json +3 -3
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/index.d.ts +200 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/memory.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/dist/noop.d.ts +2 -0
- package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/dist/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +55 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +20 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +151 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/h-stack.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +25 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +43 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +28 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +61 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/mouse-region.d.ts +10 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/scroll-view.d.ts +61 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +52 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +50 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +8 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/stack.d.ts +35 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +15 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/components/v-stack.d.ts +7 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +17 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +6 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/index.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +329 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +101 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/latex.d.ts +4 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/layout-node.d.ts +41 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/native-platform.d.ts +13 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +30 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-colors.d.ts +9 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +82 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +76 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-alt-screen.d.ts +138 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui-main-screen.d.ts +32 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +252 -0
- package/dist/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +38 -0
- package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/dist/package-manager-cli.js +32 -32
- package/dist/sdk/index.d.ts +14 -0
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/mcp.d.ts +8 -0
- package/dist/sdk/mcp.js +1 -0
- package/dist/sdk/office.d.ts +1 -0
- package/dist/sdk/office.js +1 -0
- package/dist/sdk/rewind.d.ts +1 -0
- package/dist/sdk/rewind.js +1 -0
- package/dist/sdk/router.d.ts +6 -0
- package/dist/sdk/router.js +1 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/image-convert.d.ts +5 -0
- package/dist/utils/image-resize-core.d.ts +16 -0
- package/dist/utils/image-resize.d.ts +4 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/shell.d.ts +20 -0
- package/dist/utils/shell.js +3 -3
- package/dist/utils/version-check.d.ts +20 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +22 -1
- package/dist/bun/register-bedrock.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/reducer.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl/errors.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js +0 -5
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/state.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/harness/session/testing/conformance.js +0 -1
- package/dist/node_modules/@earendil-works/pi-agent-core/dist/search/scanning.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/api/cloudflare-gateway-binding.js +0 -1
- package/dist/node_modules/@earendil-works/pi-ai/dist/utils/deferred-tools.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/session-handle.js +0 -1
- package/dist/node_modules/@earendil-works/pi-client/dist/state.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/cli.js +0 -16
- package/dist/node_modules/@earendil-works/pi-server/dist/config.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/handler.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/client.js +0 -2
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/protocol.js +0 -2
- package/dist/node_modules/@earendil-works/pi-server/dist/ipc/server.js +0 -3
- package/dist/node_modules/@earendil-works/pi-server/dist/protocol.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/radius.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/rpc-process.js +0 -4
- package/dist/node_modules/@earendil-works/pi-server/dist/serve.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/sessions.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/snapshots.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/storage.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/supervisor.js +0 -1
- package/dist/node_modules/@earendil-works/pi-server/dist/testing/service.js +0 -1
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/branch-cache.js +0 -7
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/search-backend.js +0 -36
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-entries.js +0 -25
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/branch-tips.js +0 -2
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/entries.js +0 -7
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/facts.js +0 -20
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/lanes.js +0 -26
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/records.js +0 -9
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-sequences.js +0 -1
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/session-stats.js +0 -10
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/sessions.js +0 -29
- package/dist/node_modules/@earendil-works/pi-session-backend-sqlite-node/dist/sqlite/storage/writer-leases.js +0 -14
- package/dist/server/create-harness.js +0 -1
- package/dist/utils/clipboard-native.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var gt=Object.defineProperty;var m=(c,t)=>gt(c,"name",{value:t,configurable:!0});import{createHash as dt}from"node:crypto";import{chmodSync as yt,existsSync as f,globSync as Pt,mkdirSync as D,readdirSync as F,readFileSync as T,rmSync as b,statSync as C,writeFileSync as z}from"node:fs";import{homedir as wt}from"node:os";function Y(){if(process.platform!=="linux"||Object.keys(process.env).length>0)return process.env;try{const c=T("/proc/self/environ","utf-8"),t={};for(const e of c.split("\0")){const s=e.indexOf("=");s>0&&(t[e.slice(0,s)]=e.slice(s+1))}return t}catch{return process.env}}m(Y,"getEnv");import{basename as x,dirname as k,join as h,relative as S,resolve as v,sep as W}from"node:path";import G from"ignore";import{minimatch as j}from"minimatch";import{gt as et,maxSatisfying as kt,rcompare as St,satisfies as vt,valid as Mt,validRange as Ct}from"semver";import{CONFIG_DIR_NAME as I,isOfficialExtensionsPackage as Nt}from"../config.js";import{spawnProcess as st,spawnProcessSync as Et}from"../utils/child-process.js";import{parseGitUrl as Ft}from"../utils/git.js";import{isOfflineModeEnabled as N}from"../utils/offline.js";import{canonicalizePath as bt,isLocalPath as jt,markPathIgnoredByCloudSync as xt,resolvePath as H}from"../utils/paths.js";import{stripBom as nt}from"../utils/text.js";import{isStdoutTakenOver as Gt}from"./output-guard.js";import{findNearestPiManifest as It,readPiManifest as U}from"./pi-manifest.js";const M=1e4,rt=4,$t=4,At=Symbol.for("dalcode.packageManager.npmArgsHook");function Rt(c){return Mt(c??"")!==null}m(Rt,"isExactNpmVersion");function Dt(c){return c?Ct(c)??void 0:void 0}m(Dt,"getNpmVersionRange");function it(c){return c.origin==="package"?4:(c.scope==="project"?0:2)+(c.source==="local"?0:1)}m(it,"resourcePrecedenceRank");const L=["extensions","skills","prompts","themes"],Tt={extensions:/\.(ts|js)$/,skills:/\.md$/,prompts:/\.md$/,themes:/\.json$/},Wt=[".gitignore",".ignore",".fdignore"];function y(c){return c.split(W).join("/")}m(y,"toPosixPath");function q(){return process.env.HOME||wt()}m(q,"getHomeDir");function Ht(c){const t=h(c,"tmp","extensions");return D(t,{recursive:!0,mode:448}),yt(t,448),t}m(Ht,"getExtensionTempFolder");function Ut(c,t){const e=c.trim();if(!e||e.startsWith("#")&&!e.startsWith("\\#"))return null;let s=c,n=!1;s.startsWith("!")?(n=!0,s=s.slice(1)):s.startsWith("\\!")&&(s=s.slice(1)),s.startsWith("/")&&(s=s.slice(1));const r=t?`${t}${s}`:s;return n?`!${r}`:r}m(Ut,"prefixIgnorePattern");function $(c,t,e){const s=S(e,t),n=s?`${y(s)}/`:"";for(const r of Wt){const i=h(t,r);if(f(i))try{const a=T(i,"utf-8").split(/\r?\n/).map(l=>Ut(l,n)).filter(l=>!!l);a.length>0&&c.add(a)}catch{}}}m($,"addIgnoreRules");function Lt(c){return c.startsWith("!")||c.startsWith("+")||c.startsWith("-")||c.includes("*")||c.includes("?")}m(Lt,"isPattern");function Q(c){return c.startsWith("!")||c.startsWith("+")||c.startsWith("-")}m(Q,"isOverridePattern");function Ot(c){return c.includes("*")||c.includes("?")}m(Ot,"hasGlobPattern");function _t(c,t){return Pt(c,{cwd:t}).map(e=>v(t,e)).filter(e=>S(t,e).split(W).every(s=>s===".."||!s.startsWith("."))).sort((e,s)=>e<s?-1:e>s?1:0)}m(_t,"expandPackageGlob");function Bt(c){const t=[],e=[];for(const s of c)Lt(s)?e.push(s):t.push(s);return{plain:t,patterns:e}}m(Bt,"splitPatterns");function ot(c,t,e=!0,s,n){const r=[];if(!f(c))return r;const i=n??c,o=s??G();$(o,c,i);try{const a=F(c,{withFileTypes:!0});for(const l of a){if(l.name.startsWith(".")||e&&l.name==="node_modules")continue;const p=h(c,l.name);let u=l.isDirectory(),g=l.isFile();if(l.isSymbolicLink())try{const w=C(p);u=w.isDirectory(),g=w.isFile()}catch{continue}const P=y(S(i,p)),d=u?`${P}/`:P;o.ignores(d)||(u?r.push(...ot(p,t,e,o,i)):g&&t.test(l.name)&&r.push(p))}}catch{}return r}m(ot,"collectFiles");function X(c,t,e,s){const n=[];if(!f(c))return n;const r=s??c,i=e??G();$(i,c,r);try{const o=F(c,{withFileTypes:!0});for(const a of o){if(a.name!=="SKILL.md")continue;const l=h(c,a.name);let p=a.isFile();if(a.isSymbolicLink())try{p=C(l).isFile()}catch{continue}const u=y(S(r,l));if(p&&!i.ignores(u))return n.push(l),n}for(const a of o){if(a.name.startsWith(".")||a.name==="node_modules")continue;const l=h(c,a.name);let p=a.isDirectory(),u=a.isFile();if(a.isSymbolicLink())try{const d=C(l);p=d.isDirectory(),u=d.isFile()}catch{continue}const g=y(S(r,l));if(u&&a.name.endsWith(".md")&&!i.ignores(g)&&(t==="pi"&&c===r||t==="agents"&&c!==r)){n.push(l);continue}p&&(i.ignores(`${g}/`)||n.push(...X(l,t,i,r)))}}catch{}return n}m(X,"collectSkillEntries");function O(c,t){return X(c,t)}m(O,"collectAutoSkillEntries");function Vt(c){let t=v(c);for(;;){if(f(h(t,".git")))return t;const e=k(t);if(e===t)return null;t=e}}m(Vt,"findGitRepoRoot");function Jt(c){const t=[],e=v(c),s=Vt(e);let n=e;for(;t.push(h(n,".agents","skills")),!(s&&n===s);){const r=k(n);if(r===n)break;n=r}return t}m(Jt,"collectAncestorAgentsSkillDirs");function at(c){const t=[];if(!f(c))return t;const e=G();$(e,c,c);try{const s=F(c,{withFileTypes:!0});for(const n of s){if(n.name.startsWith(".")||n.name==="node_modules")continue;const r=h(c,n.name);let i=n.isFile();if(n.isSymbolicLink())try{i=C(r).isFile()}catch{continue}const o=y(S(c,r));e.ignores(o)||i&&n.name.endsWith(".md")&&t.push(r)}}catch{}return t}m(at,"collectAutoPromptEntries");function ct(c){const t=[];if(!f(c))return t;const e=G();$(e,c,c);try{const s=F(c,{withFileTypes:!0});for(const n of s){if(n.name.startsWith(".")||n.name==="node_modules")continue;const r=h(c,n.name);let i=n.isFile();if(n.isSymbolicLink())try{i=C(r).isFile()}catch{continue}const o=y(S(c,r));e.ignores(o)||i&&n.name.endsWith(".json")&&t.push(r)}}catch{}return t}m(ct,"collectAutoThemeEntries");function lt(c){const t=h(c,"package.json");if(f(t)){const n=U(t);if(n?.extensions?.length){const r=[];for(const i of n.extensions){const o=v(c,i);f(o)&&r.push(o)}if(r.length>0)return r}}const e=h(c,"index.ts"),s=h(c,"index.js");return f(e)?[e]:f(s)?[s]:null}m(lt,"resolveExtensionEntries");function Z(c){const t=[];if(!f(c))return t;const e=lt(c);if(e)return e;const s=G();$(s,c,c);try{const n=F(c,{withFileTypes:!0});for(const r of n){if(r.name.startsWith(".")||r.name==="node_modules")continue;const i=h(c,r.name);let o=r.isDirectory(),a=r.isFile();if(r.isSymbolicLink())try{const u=C(i);o=u.isDirectory(),a=u.isFile()}catch{continue}const l=y(S(c,i)),p=o?`${l}/`:l;if(!s.ignores(p)){if(a&&(r.name.endsWith(".ts")||r.name.endsWith(".js")))t.push(i);else if(o){const u=lt(i);u&&t.push(...u)}}}}catch{}return t}m(Z,"collectAutoExtensionEntries");function _(c,t){return t==="skills"?X(c,"pi"):t==="extensions"?Z(c):ot(c,Tt[t])}m(_,"collectResourceFiles");function B(c,t,e){const s=y(S(e,c)),n=x(c),r=y(c),i=n==="SKILL.md",o=i?k(c):void 0,a=i?y(S(e,o)):void 0,l=i?x(o):void 0,p=i?y(o):void 0;return t.some(u=>{const g=y(u);return j(s,g)||j(n,g)||j(r,g)?!0:i?j(a,g)||j(l,g)||j(p,g):!1})}m(B,"matchesAnyPattern");function Kt(c){const t=c.startsWith("./")||c.startsWith(".\\")?c.slice(2):c;return y(t)}m(Kt,"normalizeExactPattern");function A(c,t,e){if(t.length===0)return!1;const s=y(S(e,c)),n=x(c),r=y(c),i=n==="SKILL.md",o=i?k(c):void 0,a=i?y(S(e,o)):void 0,l=i?y(o):void 0;return t.some(p=>{const u=Kt(p);return u===s||u===r?!0:i?u===a||u===l:!1})}m(A,"matchesAnyExactPattern");function zt(c){return c.filter(t=>t.startsWith("!")||t.startsWith("+")||t.startsWith("-"))}m(zt,"getOverridePatterns");function Yt(c,t,e){const s=zt(t),n=s.filter(a=>a.startsWith("!")).map(a=>a.slice(1)),r=s.filter(a=>a.startsWith("+")).map(a=>a.slice(1)),i=s.filter(a=>a.startsWith("-")).map(a=>a.slice(1));let o=!0;return n.length>0&&B(c,n,e)&&(o=!1),r.length>0&&A(c,r,e)&&(o=!0),i.length>0&&A(c,i,e)&&(o=!1),o}m(Yt,"isEnabledByOverrides");function V(c,t,e){const s=[],n=[],r=[],i=[];for(const a of t)a.startsWith("+")?r.push(a.slice(1)):a.startsWith("-")?i.push(a.slice(1)):a.startsWith("!")?n.push(a.slice(1)):s.push(a);let o;if(s.length===0?o=[...c]:o=c.filter(a=>B(a,s,e)),n.length>0&&(o=o.filter(a=>!B(a,n,e))),r.length>0)for(const a of c)!o.includes(a)&&A(a,r,e)&&o.push(a);return i.length>0&&(o=o.filter(a=>!A(a,i,e))),new Set(o)}m(V,"applyPatterns");function qt(c,t,e){const s=new Map;for(const n of t){const r=n.slice(n.startsWith("+")||n.startsWith("-")||n.startsWith("!")?1:0),i=!n.startsWith("-")&&!n.startsWith("!"),o=n.startsWith("+")||n.startsWith("-");for(const a of c)(o?A(a,[r],e):B(a,[r],e))&&s.set(a,i)}return s}m(qt,"applyAutoloadDisabledPatterns");class fe{static{m(this,"DefaultPackageManager")}cwd;agentDir;settingsManager;globalNpmRoot;globalNpmRootCommandKey;progressCallback;constructor(t){this.cwd=H(t.cwd),this.agentDir=H(t.agentDir),this.settingsManager=t.settingsManager}setProgressCallback(t){this.progressCallback=t}addSourceToSettings(t,e){const s=e?.local?"project":"user",r=(s==="project"?this.settingsManager.getProjectSettings():this.settingsManager.getGlobalSettings()).packages??[],i=this.normalizePackageSourceForSettings(t,s),o=m(p=>{const u=e?.resolvedCommit;return!u&&!p?i:typeof p=="string"||p===void 0?u?{source:i,resolvedCommit:u}:i:u?{...p,source:i,resolvedCommit:u}:{...p,source:i}},"toEntry"),a=r.findIndex(p=>this.packageSourcesMatch(p,t,s));if(a!==-1){const p=r[a];if(this.getPackageSourceString(p)===i&&!e?.resolvedCommit)return!1;const u=[...r];return u[a]=o(p),s==="project"?this.settingsManager.setProjectPackages(u):this.settingsManager.setPackages(u),!0}const l=[...r,o()];return s==="project"?this.settingsManager.setProjectPackages(l):this.settingsManager.setPackages(l),!0}removeSourceFromSettings(t,e){const s=e?.local?"project":"user",r=(s==="project"?this.settingsManager.getProjectSettings():this.settingsManager.getGlobalSettings()).packages??[],i=r.filter(a=>!this.packageSourcesMatch(a,t,s));return i.length!==r.length?(s==="project"?this.settingsManager.setProjectPackages(i):this.settingsManager.setPackages(i),!0):!1}getInstalledPath(t,e){const s=this.parseSource(t);if(s.type==="npm"){const n=this.getNpmInstallPath(s,e);return f(n)?n:void 0}if(s.type==="git"){const n=this.getGitInstallPath(s,e);return f(n)?n:void 0}if(s.type==="local"){const n=this.getBaseDirForScope(e),r=this.resolvePathFromBase(s.path,n);return f(r)?r:void 0}}readDeclaredPermissions(t){if(!t)return;const s=It(t)?.manifest.permissions;return s&&s.length>0?[...s]:void 0}async readGitHead(t){if(t)try{const s=(await this.runCommandCapture("git",["rev-parse","HEAD"],{cwd:t,timeoutMs:M})).trim();return/^[0-9a-f]{7,40}$/i.test(s)?s:void 0}catch{return}}getStoredResolvedCommit(t,e){const s=e==="project"?this.settingsManager.getProjectSettings().packages??[]:this.settingsManager.getGlobalSettings().packages??[];for(const n of s)if(typeof n!="string"&&this.packageSourcesMatch(n,t,e))return n.resolvedCommit}emitProgress(t){this.progressCallback?.(t)}async withProgress(t,e,s,n){this.emitProgress({type:"start",action:t,source:e,message:s});try{await n(),this.emitProgress({type:"complete",action:t,source:e})}catch(r){const i=r instanceof Error?r.message:String(r);throw this.emitProgress({type:"error",action:t,source:e,message:i}),r}}async resolve(t){const e=this.createAccumulator(),s=this.settingsManager.getGlobalSettings(),n=this.settingsManager.getProjectSettings(),r=[];for(const l of n.packages??[])r.push({pkg:l,scope:"project"});for(const l of s.packages??[])r.push({pkg:l,scope:"user"});const i=this.dedupePackages(r);await this.resolvePackageSources(i,e,t);const o=this.agentDir,a=h(this.cwd,I);for(const l of L){const p=this.getTargetMap(e,l),u=s[l]??[],g=n[l]??[];this.resolveLocalEntries(g,l,p,{source:"local",scope:"project",origin:"top-level"},a),this.resolveLocalEntries(u,l,p,{source:"local",scope:"user",origin:"top-level"},o)}return this.addAutoDiscoveredResources(e,s,n,o,a),this.toResolvedPaths(e)}async resolveExtensionSources(t,e){const s=this.createAccumulator(),n=e?.temporary?"temporary":e?.local?"project":"user",r=t.map(i=>({pkg:i,scope:n}));return await this.resolvePackageSources(r,s),this.toResolvedPaths(s)}listConfiguredPackages(){const t=this.settingsManager.getGlobalSettings(),e=this.settingsManager.getProjectSettings(),s=[];for(const n of t.packages??[]){const r=typeof n=="string"?n:n.source,i=this.getInstalledPath(r,"user");s.push({source:r,scope:"user",filtered:typeof n=="object",installedPath:i,resolvedCommit:typeof n=="object"?n.resolvedCommit:void 0,permissions:this.readDeclaredPermissions(i)})}for(const n of e.packages??[]){const r=typeof n=="string"?n:n.source,i=this.getInstalledPath(r,"project");s.push({source:r,scope:"project",filtered:typeof n=="object",installedPath:i,resolvedCommit:typeof n=="object"?n.resolvedCommit:void 0,permissions:this.readDeclaredPermissions(i)})}return s}async install(t,e){const s=this.parseSource(t),n=e?.local?"project":"user";this.assertProjectTrustedForScope(n),await this.withProgress("install",t,`Installing ${t}...`,async()=>{if(s.type==="npm"){await this.installNpm(s,n,!1);return}if(s.type==="git"){await this.installGit(s,n);return}if(s.type==="local"){const r=this.resolvePath(s.path);if(!f(r))throw new Error(`Path does not exist: ${r}`);return}throw new Error(`Unsupported install source: ${t}`)})}async installAndPersist(t,e){await this.install(t,e);const s=e?.local?"project":"user",n=this.getInstalledPath(t,s),r=await this.readGitHead(n);this.addSourceToSettings(t,{...e,resolvedCommit:r})}async remove(t,e){const s=this.parseSource(t),n=e?.local?"project":"user";this.assertProjectTrustedForScope(n),await this.withProgress("remove",t,`Removing ${t}...`,async()=>{if(s.type==="npm"){await this.uninstallNpm(s,n);return}if(s.type==="git"){await this.removeGit(s,n);return}if(s.type!=="local")throw new Error(`Unsupported remove source: ${t}`)})}async removeAndPersist(t,e){return await this.remove(t,e),this.removeSourceFromSettings(t,e)}async update(t,e){const s=e?.latest===!0,n=this.settingsManager.getGlobalSettings(),r=this.settingsManager.getProjectSettings(),i=t?this.getPackageIdentity(t):void 0;let o=!1;const a=[];for(const l of n.packages??[]){const p=typeof l=="string"?l:l.source;i&&this.getPackageIdentity(p,"user")!==i||(o=!0,a.push({source:p,scope:"user"}))}for(const l of r.packages??[]){const p=typeof l=="string"?l:l.source;i&&this.getPackageIdentity(p,"project")!==i||(o=!0,a.push({source:p,scope:"project"}))}if(t&&!o)throw new Error(this.buildNoMatchingPackageMessage(t,[...n.packages??[],...r.packages??[]]));await this.updateConfiguredSources(a,s)}async updateConfiguredSources(t,e=!1){if(N()||t.length===0)return;const s=[],n=[];for(const p of t){const u=this.parseSource(p.source);if(u.type==="npm")u.pinned||s.push({...p,parsed:u});else if(u.type==="git"){const g=this.getStoredResolvedCommit(p.source,p.scope);if(!u.ref&&g&&!e)continue;n.push({...p,parsed:u})}}const r=s.map(p=>async()=>({entry:p,shouldUpdate:await this.shouldUpdateNpmSource(p.parsed,p.scope)})),i=await this.runWithConcurrency(r,rt),o=[],a=[];for(const p of i)p.shouldUpdate&&(p.entry.scope==="user"?o.push(p.entry):a.push(p.entry));const l=[];if(o.length>0&&l.push(this.updateNpmBatch(o,"user")),a.length>0&&l.push(this.updateNpmBatch(a,"project")),n.length>0){const p=n.map(u=>async()=>this.withProgress("update",u.source,`Updating ${u.source}...`,async()=>{if(await this.updateGit(u.parsed,u.scope),!this.getStoredResolvedCommit(u.source,u.scope))return;const P=this.getInstalledPath(u.source,u.scope),d=await this.readGitHead(P);d&&this.addSourceToSettings(u.source,{local:u.scope==="project",resolvedCommit:d})}));l.push(this.runWithConcurrency(p,$t).then(()=>{}))}await Promise.all(l)}async shouldUpdateNpmSource(t,e){const s=this.getManagedNpmInstallPath(t,e),n=f(s)?this.getInstalledNpmVersion(s):void 0;if(!n)return!0;try{const r=await this.getLatestNpmVersion(t.version?t.spec:t.name,t.range);return et(r,n)}catch{return!0}}async updateNpmBatch(t,e){if(t.length===0)return;const s=t.length===1?t[0].source:`${e} npm packages`,n=t.length===1?`Updating ${t[0].source}...`:`Updating ${e} npm packages...`,r=t.map(i=>i.parsed.version?i.parsed.spec:`${i.parsed.name}@latest`);await this.withProgress("update",s,n,async()=>{await this.installNpmBatch(r,e)})}async installNpmBatch(t,e){const s=this.getNpmInstallRoot(e,!1);this.ensureNpmProject(s),await this.runNpmCommand(this.getNpmInstallArgs(t,s))}async checkForAvailableUpdates(){if(N())return[];const t=this.settingsManager.getGlobalSettings(),e=this.settingsManager.getProjectSettings(),s=[];for(const o of e.packages??[])s.push({pkg:o,scope:"project"});for(const o of t.packages??[])s.push({pkg:o,scope:"user"});const r=this.dedupePackages(s).filter(o=>o.scope!=="temporary").map(o=>async()=>{const a=typeof o.pkg=="string"?o.pkg:o.pkg.source,l=this.parseSource(a);if(l.type==="local"||l.pinned)return;if(l.type==="npm"){const g=this.getNpmInstallPath(l,o.scope);return!f(g)||!await this.npmHasAvailableUpdate(l,g)?void 0:{source:a,displayName:l.name,type:"npm",scope:o.scope}}const p=this.getGitInstallPath(l,o.scope);if(!(!f(p)||!await this.gitHasAvailableUpdate(p)))return{source:a,displayName:`${l.host}/${l.path}`,type:"git",scope:o.scope}});return(await this.runWithConcurrency(r,rt)).filter(o=>o!==void 0)}async resolvePackageSources(t,e,s){for(const{pkg:n,scope:r}of t){const i=typeof n=="string"?n:n.source,o=typeof n=="object"?n:void 0,a=this.findAutoloadDeltaBase(n,r,t),l=a?.source??i,p=a?.scope??r,u=this.parseSource(l),g={source:i,scope:r,origin:"package"};if(u.type==="local"){const d=this.getBaseDirForScope(p);this.resolveLocalExtensionSource(u,e,o,g,d);continue}const P=m(async()=>{if(N())return!1;if(!s)return await this.installParsedSource(u,p),!0;const d=await s(l);if(d==="skip")return!1;if(d==="error")throw new Error(`Missing source: ${l}`);return await this.installParsedSource(u,p),!0},"installMissing");if(u.type==="npm"){let d=this.getNpmInstallPath(u,p);if(!f(d)||!await this.installedNpmMatchesConfiguredVersion(u,d)){if(!await P())continue;d=this.getNpmInstallPath(u,p)}g.baseDir=d,this.collectPackageResources(d,e,o,g);continue}if(u.type==="git"){const d=this.getGitInstallPath(u,p);if(f(d))p==="temporary"&&!u.pinned&&!N()&&await this.refreshTemporaryGitSource(u,l);else if(!await P())continue;g.baseDir=d,this.collectPackageResources(d,e,o,g)}}}findAutoloadDeltaBase(t,e,s){if(e!=="project"||typeof t!="object"||t.autoload!==!1)return;const n=this.getPackageIdentity(t.source,e),r=s.find(i=>i.scope==="user"&&this.getPackageIdentity(this.getPackageSourceString(i.pkg),"user")===n);return r?{source:this.getPackageSourceString(r.pkg),scope:"user"}:void 0}resolveLocalExtensionSource(t,e,s,n,r){const i=this.resolvePathFromBase(t.path,r);if(f(i))try{const o=C(i);if(o.isFile()){n.baseDir=k(i),this.addResource(e.extensions,i,n,!0);return}o.isDirectory()&&(n.baseDir=i,this.collectPackageResources(i,e,s,n)||this.addResource(e.extensions,i,n,!0))}catch{return}}async installParsedSource(t,e){if(t.type==="npm"){await this.installNpm(t,e,e==="temporary");return}if(t.type==="git"){await this.installGit(t,e);return}}getPackageSourceString(t){return typeof t=="string"?t:t.source}getSourceMatchKeyForInput(t){const e=this.parseSource(t);return e.type==="npm"?`npm:${e.name}`:e.type==="git"?`git:${e.host}/${e.path}`:`local:${this.resolvePath(e.path)}`}getSourceMatchKeyForSettings(t,e){const s=this.parseSource(t);if(s.type==="npm")return`npm:${s.name}`;if(s.type==="git")return`git:${s.host}/${s.path}`;const n=this.getBaseDirForScope(e);return`local:${this.resolvePathFromBase(s.path,n)}`}buildNoMatchingPackageMessage(t,e){const s=this.findSuggestedConfiguredSource(t,e);return s?`No matching package found for ${t}. Did you mean ${s}?`:`No matching package found for ${t}`}findSuggestedConfiguredSource(t,e){const s=t.trim(),n=new Set;for(const r of e){const i=this.getPackageSourceString(r),o=this.parseSource(i);if(o.type==="npm"){(s===o.name||s===o.spec)&&n.add(i);continue}if(o.type==="git"){const a=`${o.host}/${o.path}`,l=o.ref?`${a}@${o.ref}`:void 0;(s===a||l&&s===l)&&n.add(i)}}return n.values().next().value}packageSourcesMatch(t,e,s){const n=this.getSourceMatchKeyForSettings(this.getPackageSourceString(t),s),r=this.getSourceMatchKeyForInput(e);return n===r}normalizePackageSourceForSettings(t,e){const s=this.parseSource(t);if(s.type!=="local")return t;const n=this.getBaseDirForScope(e),r=this.resolvePath(s.path);return S(n,r)||"."}parseSource(t){if(t.startsWith("npm:")){const s=t.slice(4).trim(),{name:n,version:r}=this.parseNpmSpec(s);return{type:"npm",spec:s,name:n,version:r,range:Dt(r),pinned:Rt(r)}}if(jt(t))return{type:"local",path:t};const e=Ft(t);return e||{type:"local",path:t}}async installedNpmMatchesConfiguredVersion(t,e){const s=this.getInstalledNpmVersion(e);return s?t.range?vt(s,t.range):!0:!1}async npmHasAvailableUpdate(t,e){if(N())return!1;const s=this.getInstalledNpmVersion(e);if(!s)return!1;try{const n=await this.getLatestNpmVersion(t.version?t.spec:t.name,t.range);return et(n,s)}catch{return!1}}getInstalledNpmVersion(t){const e=h(t,"package.json");if(f(e))try{const s=T(e,"utf-8");return JSON.parse(nt(s)).version}catch{return}}async getLatestNpmVersion(t,e){const s=this.getNpmCommand(),n=await this.applyNpmArgsHook(["view",t,"version","--json"],this.cwd),i=(await this.runCommandCapture(s.command,[...s.args,...n],{cwd:this.cwd,timeoutMs:M})).trim();if(!i)throw new Error("Empty response from npm view");const o=JSON.parse(i);if(typeof o=="string")return o;if(Array.isArray(o)){const a=o.filter(p=>typeof p=="string"&&p.length>0),l=e?kt(a,e):[...a].sort(St)[0];if(l)return l}throw new Error("Unexpected response from npm view")}async gitHasAvailableUpdate(t){if(N())return!1;try{const e=await this.runCommandCapture("git",["rev-parse","HEAD"],{cwd:t,timeoutMs:M}),s=await this.getRemoteGitHead(t);return e.trim()!==s.trim()}catch{return!1}}async getRemoteGitHead(t){const e=await this.getGitUpstreamRef(t);if(e){const i=(await this.runGitRemoteCommand(t,["ls-remote","origin",e])).match(/^([0-9a-f]{40})\s+/m);if(i?.[1])return i[1]}const n=(await this.runGitRemoteCommand(t,["ls-remote","origin","HEAD"])).match(/^([0-9a-f]{40})\s+HEAD$/m);if(!n?.[1])throw new Error("Failed to determine remote HEAD");return n[1]}async getLocalGitUpdateTarget(t){try{const s=(await this.runCommandCapture("git",["rev-parse","--abbrev-ref","@{upstream}"],{cwd:t,timeoutMs:M})).trim();if(!s.startsWith("origin/"))throw new Error(`Unsupported upstream remote: ${s}`);const n=s.slice(7);if(!n)throw new Error("Missing upstream branch name");return{ref:"@{upstream}",head:await this.runCommandCapture("git",["rev-parse","@{upstream}"],{cwd:t,timeoutMs:M}),fetchArgs:["fetch","--prune","--no-tags","origin",`+refs/heads/${n}:refs/remotes/origin/${n}`]}}catch{await this.runCommand("git",["remote","set-head","origin","-a"],{cwd:t}).catch(()=>{});const e=await this.runCommandCapture("git",["rev-parse","origin/HEAD"],{cwd:t,timeoutMs:M}),n=(await this.runCommandCapture("git",["symbolic-ref","refs/remotes/origin/HEAD"],{cwd:t,timeoutMs:M}).catch(()=>"")).trim().replace(/^refs\/remotes\/origin\//,"");return n?{ref:"origin/HEAD",head:e,fetchArgs:["fetch","--prune","--no-tags","origin",`+refs/heads/${n}:refs/remotes/origin/${n}`]}:{ref:"origin/HEAD",head:e,fetchArgs:["fetch","--prune","--no-tags","origin","+HEAD:refs/remotes/origin/HEAD"]}}}async getGitUpstreamRef(t){try{const s=(await this.runCommandCapture("git",["rev-parse","--abbrev-ref","@{upstream}"],{cwd:t,timeoutMs:M})).trim();if(!s.startsWith("origin/"))return;const n=s.slice(7);return n?`refs/heads/${n}`:void 0}catch{return}}runGitRemoteCommand(t,e){return this.runCommandCapture("git",e,{cwd:t,timeoutMs:M,env:{GIT_TERMINAL_PROMPT:"0"}})}async runWithConcurrency(t,e){if(t.length===0)return[];const s=new Array(t.length);let n=0;const r=Math.max(1,Math.min(e,t.length)),i=m(async()=>{for(;;){const o=n;if(n+=1,o>=t.length)return;s[o]=await t[o]()}},"worker");return await Promise.all(Array.from({length:r},()=>i())),s}getPackageIdentity(t,e){const s=this.parseSource(t);if(s.type==="npm")return`npm:${s.name}`;if(s.type==="git")return`git:${s.host}/${s.path}`;if(e){const n=this.getBaseDirForScope(e);return`local:${this.resolvePathFromBase(s.path,n)}`}return`local:${this.resolvePath(s.path)}`}dedupePackages(t){const e=[],s=new Map;for(const n of t){const r=this.getPackageIdentity(this.getPackageSourceString(n.pkg),n.scope),i=s.get(r);if(i===void 0){s.set(r,e.length),e.push(n);continue}const o=e[i];o?.scope==="project"&&n.scope==="user"?typeof o.pkg=="object"&&o.pkg.autoload===!1&&e.push(n):n.scope==="project"&&(e[i]=n)}return e}parseNpmSpec(t){const e=t.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);if(!e)return{name:t};const s=e[1]??t,n=e[2];return{name:s,version:n}}assertProjectTrustedForScope(t){if(t==="project"&&!this.settingsManager.isProjectTrusted())throw new Error("Project is not trusted; refusing to access project package storage")}getNpmCommand(){const t=this.settingsManager.getNpmCommand();if(!t||t.length===0)return{command:"npm",args:[]};const[e,...s]=t;if(!e)throw new Error("Invalid npmCommand: first array entry must be a non-empty command");return{command:e,args:s}}getPackageManagerName(){const t=this.getNpmCommand(),e=[t.command,...t.args],s=e.lastIndexOf("--"),n=s>=0?e[s+1]:t.command;return n?x(n).replace(/\.(cmd|exe)$/i,""):""}async runNpmCommand(t,e){const s=this.getNpmCommand(),n=await this.applyNpmArgsHook(t,e?.cwd);await this.runCommand(s.command,[...s.args,...n],e)}async applyNpmArgsHook(t,e){const s=globalThis[At];return typeof s!="function"?t:s(t,{cwd:e,packageManager:this.getPackageManagerName()})}getGitDependencyInstallArgs(){const t=this.settingsManager.getNpmCommand();return t&&t.length>0?["install"]:["install","--omit=dev"]}runNpmCommandSync(t){const e=this.getNpmCommand();return this.runCommandSync(e.command,[...e.args,...t])}getNpmInstallArgs(t,e){const s=this.getPackageManagerName();return s==="bun"?["install",...t,"--cwd",e,"--omit=peer"]:s==="pnpm"?["install",...t,"--prefix",e,"--config.auto-install-peers=false","--config.strict-peer-dependencies=false","--config.strict-dep-builds=false"]:["install",...t,"--prefix",e,"--legacy-peer-deps"]}async installNpm(t,e,s){const n=this.getNpmInstallRoot(e,s);this.ensureNpmProject(n),await this.runNpmCommand(this.getNpmInstallArgs([t.spec],n))}async uninstallNpm(t,e){const s=this.getNpmInstallRoot(e,!1);if(!f(s))return;const n=this.getPackageManagerName();if(n==="bun"){await this.runNpmCommand(["uninstall",t.name,"--cwd",s]);return}const r=["uninstall",t.name,"--prefix",s];n!=="pnpm"&&r.push("--legacy-peer-deps"),await this.runNpmCommand(r)}async installGit(t,e){const s=this.getGitInstallPath(t,e);if(f(s)){if(t.ref){await this.ensureGitRef(s,["fetch","origin",t.ref],"FETCH_HEAD");return}const r=await this.getLocalGitUpdateTarget(s);await this.ensureGitRef(s,r.fetchArgs,r.ref);return}const n=this.getGitInstallRoot(e);n&&this.ensureGitIgnore(n),D(k(s),{recursive:!0}),b(this.getGitUpdateMarkerPath(s),{force:!0});try{await this.runCommand("git",["clone",t.repo,s]),t.ref&&await this.runCommand("git",["checkout",t.ref],{cwd:s});const r=h(s,"package.json");f(r)&&await this.runNpmCommand(this.getGitDependencyInstallArgs(),{cwd:s})}catch(r){throw b(s,{recursive:!0,force:!0}),this.pruneEmptyGitParents(s,n),r}}async updateGit(t,e){const s=this.getGitInstallPath(t,e);if(!f(s)){await this.installGit(t,e);return}if(t.ref){await this.ensureGitRef(s,["fetch","origin",t.ref],"FETCH_HEAD");return}const n=await this.getLocalGitUpdateTarget(s);await this.ensureGitRef(s,n.fetchArgs,n.ref)}hasMissingGitDependencies(t){const e=h(t,"package.json");if(!f(e))return!1;try{const s=JSON.parse(nt(T(e,"utf-8")));if(!s.dependencies||typeof s.dependencies!="object"||Array.isArray(s.dependencies))return!1;const n=v(t,"node_modules");return Object.keys(s.dependencies).some(r=>{const i=v(n,r);return i.startsWith(`${n}${W}`)?!f(i):!1})}catch{return!1}}async repairMissingGitDependencies(t){this.hasMissingGitDependencies(t)&&await this.runNpmCommand(this.getGitDependencyInstallArgs(),{cwd:t})}getGitUpdateMarkerPath(t){return h(k(t),`.${x(t)}.pi-update-incomplete`)}async cleanAndInstallGitDependencies(t,e){try{await this.runCommand("git",["clean","-fdx"],{cwd:t})}catch(n){throw await this.repairMissingGitDependencies(t).catch(()=>{}),n}const s=h(t,"package.json");f(s)&&await this.runNpmCommand(this.getGitDependencyInstallArgs(),{cwd:t}),b(e,{force:!0})}async ensureGitRef(t,e,s){await this.runCommand("git",e,{cwd:t});const n=await this.runCommandCapture("git",["rev-parse","HEAD"],{cwd:t,timeoutMs:M}),r=`${s}^{commit}`,i=await this.runCommandCapture("git",["rev-parse",r],{cwd:t,timeoutMs:M}),o=this.getGitUpdateMarkerPath(t);if(n.trim()===i.trim()){f(o)?await this.cleanAndInstallGitDependencies(t,o):await this.repairMissingGitDependencies(t);return}z(o,"","utf-8"),await this.runCommand("git",["reset","--hard",r],{cwd:t}),await this.cleanAndInstallGitDependencies(t,o)}async refreshTemporaryGitSource(t,e){if(!N())try{await this.withProgress("pull",e,`Refreshing ${e}...`,async()=>{await this.updateGit(t,"temporary")})}catch{}}async removeGit(t,e){const s=this.getGitInstallPath(t,e);b(s,{recursive:!0,force:!0}),b(this.getGitUpdateMarkerPath(s),{force:!0}),this.pruneEmptyGitParents(s,this.getGitInstallRoot(e))}pruneEmptyGitParents(t,e){if(!e)return;const s=v(e);let n=k(t);for(;n.startsWith(s)&&n!==s;){if(!f(n)){n=k(n);continue}if(F(n).length>0)break;try{b(n,{recursive:!0,force:!0})}catch{break}n=k(n)}}ensureNpmProject(t){f(t)||D(t,{recursive:!0}),xt(t),this.ensureGitIgnore(t);const e=h(t,"package.json");f(e)||z(e,JSON.stringify({name:"pi-extensions",private:!0},null,2),"utf-8")}ensureGitIgnore(t){f(t)||D(t,{recursive:!0});const e=h(t,".gitignore");f(e)||z(e,`*
|
|
1
|
+
var gt=Object.defineProperty;var m=(c,t)=>gt(c,"name",{value:t,configurable:!0});import{createHash as dt}from"node:crypto";import{chmodSync as yt,existsSync as f,globSync as Pt,mkdirSync as W,readdirSync as I,readFileSync as H,rmSync as j,statSync as N,writeFileSync as z}from"node:fs";import{homedir as wt}from"node:os";function Y(){if(process.platform!=="linux"||Object.keys(process.env).length>0)return process.env;try{const c=H("/proc/self/environ","utf-8"),t={};for(const e of c.split("\0")){const s=e.indexOf("=");s>0&&(t[e.slice(0,s)]=e.slice(s+1))}return t}catch{return process.env}}m(Y,"getEnv");import{basename as A,dirname as w,join as h,relative as k,resolve as S,sep as U}from"node:path";import D from"ignore";import{minimatch as x}from"minimatch";import{gt as et,maxSatisfying as kt,rcompare as St,satisfies as vt,valid as Mt,validRange as Ct}from"semver";import{CONFIG_DIR_NAME as $,isOfficialExtensionsPackage as Nt,SHARED_SKILL_CONFIG_DIRS as st}from"../config.js";import{spawnProcess as nt,spawnProcessSync as Et}from"../utils/child-process.js";import{parseGitUrl as Ft}from"../utils/git.js";import{isOfflineModeEnabled as F}from"../utils/offline.js";import{canonicalizePath as bt,isLocalPath as It,markPathIgnoredByCloudSync as jt,resolvePath as L}from"../utils/paths.js";import{stripBom as rt}from"../utils/text.js";import{isStdoutTakenOver as xt}from"./output-guard.js";import{findNearestPiManifest as Gt,readPiManifest as _}from"./pi-manifest.js";const C=1e4,it=4,At=4,Dt=Symbol.for("dalcode.packageManager.npmArgsHook");function $t(c){return Mt(c??"")!==null}m($t,"isExactNpmVersion");function Rt(c){return c?Ct(c)??void 0:void 0}m(Rt,"getNpmVersionRange");function ot(c){return c.origin==="package"?4:(c.scope==="project"?0:2)+(c.source==="local"?0:1)}m(ot,"resourcePrecedenceRank");const O=["extensions","skills","prompts","themes"],Tt={extensions:/\.(ts|js)$/,skills:/\.md$/,prompts:/\.md$/,themes:/\.json$/},Wt=[".gitignore",".ignore",".fdignore"];function y(c){return c.split(U).join("/")}m(y,"toPosixPath");function q(){return process.env.HOME||wt()}m(q,"getHomeDir");function Ht(c){const t=h(c,"tmp","extensions");return W(t,{recursive:!0,mode:448}),yt(t,448),t}m(Ht,"getExtensionTempFolder");function Ut(c,t){const e=c.trim();if(!e||e.startsWith("#")&&!e.startsWith("\\#"))return null;let s=c,n=!1;s.startsWith("!")?(n=!0,s=s.slice(1)):s.startsWith("\\!")&&(s=s.slice(1)),s.startsWith("/")&&(s=s.slice(1));const r=t?`${t}${s}`:s;return n?`!${r}`:r}m(Ut,"prefixIgnorePattern");function R(c,t,e){const s=k(e,t),n=s?`${y(s)}/`:"";for(const r of Wt){const i=h(t,r);if(f(i))try{const a=H(i,"utf-8").split(/\r?\n/).map(l=>Ut(l,n)).filter(l=>!!l);a.length>0&&c.add(a)}catch{}}}m(R,"addIgnoreRules");function Lt(c){return c.startsWith("!")||c.startsWith("+")||c.startsWith("-")||c.includes("*")||c.includes("?")}m(Lt,"isPattern");function Q(c){return c.startsWith("!")||c.startsWith("+")||c.startsWith("-")}m(Q,"isOverridePattern");function _t(c){return c.includes("*")||c.includes("?")}m(_t,"hasGlobPattern");function Ot(c,t){return Pt(c,{cwd:t}).map(e=>S(t,e)).filter(e=>k(t,e).split(U).every(s=>s===".."||!s.startsWith("."))).sort((e,s)=>e<s?-1:e>s?1:0)}m(Ot,"expandPackageGlob");function Bt(c){const t=[],e=[];for(const s of c)Lt(s)?e.push(s):t.push(s);return{plain:t,patterns:e}}m(Bt,"splitPatterns");function at(c,t,e=!0,s,n){const r=[];if(!f(c))return r;const i=n??c,o=s??D();R(o,c,i);try{const a=I(c,{withFileTypes:!0});for(const l of a){if(l.name.startsWith(".")||e&&l.name==="node_modules")continue;const p=h(c,l.name);let u=l.isDirectory(),g=l.isFile();if(l.isSymbolicLink())try{const b=N(p);u=b.isDirectory(),g=b.isFile()}catch{continue}const P=y(k(i,p)),d=u?`${P}/`:P;o.ignores(d)||(u?r.push(...at(p,t,e,o,i)):g&&t.test(l.name)&&r.push(p))}}catch{}return r}m(at,"collectFiles");function X(c,t,e,s){const n=[];if(!f(c))return n;const r=s??c,i=e??D();R(i,c,r);try{const o=I(c,{withFileTypes:!0});for(const a of o){if(a.name!=="SKILL.md")continue;const l=h(c,a.name);let p=a.isFile();if(a.isSymbolicLink())try{p=N(l).isFile()}catch{continue}const u=y(k(r,l));if(p&&!i.ignores(u))return n.push(l),n}for(const a of o){if(a.name.startsWith(".")||a.name==="node_modules")continue;const l=h(c,a.name);let p=a.isDirectory(),u=a.isFile();if(a.isSymbolicLink())try{const d=N(l);p=d.isDirectory(),u=d.isFile()}catch{continue}const g=y(k(r,l));if(u&&a.name.endsWith(".md")&&!i.ignores(g)&&(t==="pi"&&c===r||t==="agents"&&c!==r)){n.push(l);continue}p&&(i.ignores(`${g}/`)||n.push(...X(l,t,i,r)))}}catch{}return n}m(X,"collectSkillEntries");function B(c,t){return X(c,t)}m(B,"collectAutoSkillEntries");function Vt(c){let t=S(c);for(;;){if(f(h(t,".git")))return t;const e=w(t);if(e===t)return null;t=e}}m(Vt,"findGitRepoRoot");function Kt(c=q()){return st.map(t=>h(c,t,"skills"))}m(Kt,"userSharedSkillDirs");function Jt(c){const t=[],e=S(c),s=Vt(e);let n=e;for(;;){for(const i of st)t.push(h(n,i,"skills"));if(s&&n===s)break;const r=w(n);if(r===n)break;n=r}return t}m(Jt,"collectAncestorAgentsSkillDirs");function ct(c){const t=[];if(!f(c))return t;const e=D();R(e,c,c);try{const s=I(c,{withFileTypes:!0});for(const n of s){if(n.name.startsWith(".")||n.name==="node_modules")continue;const r=h(c,n.name);let i=n.isFile();if(n.isSymbolicLink())try{i=N(r).isFile()}catch{continue}const o=y(k(c,r));e.ignores(o)||i&&n.name.endsWith(".md")&&t.push(r)}}catch{}return t}m(ct,"collectAutoPromptEntries");function lt(c){const t=[];if(!f(c))return t;const e=D();R(e,c,c);try{const s=I(c,{withFileTypes:!0});for(const n of s){if(n.name.startsWith(".")||n.name==="node_modules")continue;const r=h(c,n.name);let i=n.isFile();if(n.isSymbolicLink())try{i=N(r).isFile()}catch{continue}const o=y(k(c,r));e.ignores(o)||i&&n.name.endsWith(".json")&&t.push(r)}}catch{}return t}m(lt,"collectAutoThemeEntries");function ut(c){const t=h(c,"package.json");if(f(t)){const n=_(t);if(n?.extensions?.length){const r=[];for(const i of n.extensions){const o=S(c,i);f(o)&&r.push(o)}if(r.length>0)return r}}const e=h(c,"index.ts"),s=h(c,"index.js");return f(e)?[e]:f(s)?[s]:null}m(ut,"resolveExtensionEntries");function Z(c){const t=[];if(!f(c))return t;const e=ut(c);if(e)return e;const s=D();R(s,c,c);try{const n=I(c,{withFileTypes:!0});for(const r of n){if(r.name.startsWith(".")||r.name==="node_modules")continue;const i=h(c,r.name);let o=r.isDirectory(),a=r.isFile();if(r.isSymbolicLink())try{const u=N(i);o=u.isDirectory(),a=u.isFile()}catch{continue}const l=y(k(c,i)),p=o?`${l}/`:l;if(!s.ignores(p)){if(a&&(r.name.endsWith(".ts")||r.name.endsWith(".js")))t.push(i);else if(o){const u=ut(i);u&&t.push(...u)}}}}catch{}return t}m(Z,"collectAutoExtensionEntries");function V(c,t){return t==="skills"?X(c,"pi"):t==="extensions"?Z(c):at(c,Tt[t])}m(V,"collectResourceFiles");function K(c,t,e){const s=y(k(e,c)),n=A(c),r=y(c),i=n==="SKILL.md",o=i?w(c):void 0,a=i?y(k(e,o)):void 0,l=i?A(o):void 0,p=i?y(o):void 0;return t.some(u=>{const g=y(u);return x(s,g)||x(n,g)||x(r,g)?!0:i?x(a,g)||x(l,g)||x(p,g):!1})}m(K,"matchesAnyPattern");function zt(c){const t=c.startsWith("./")||c.startsWith(".\\")?c.slice(2):c;return y(t)}m(zt,"normalizeExactPattern");function T(c,t,e){if(t.length===0)return!1;const s=y(k(e,c)),n=A(c),r=y(c),i=n==="SKILL.md",o=i?w(c):void 0,a=i?y(k(e,o)):void 0,l=i?y(o):void 0;return t.some(p=>{const u=zt(p);return u===s||u===r?!0:i?u===a||u===l:!1})}m(T,"matchesAnyExactPattern");function Yt(c){return c.filter(t=>t.startsWith("!")||t.startsWith("+")||t.startsWith("-"))}m(Yt,"getOverridePatterns");function qt(c,t,e){const s=Yt(t),n=s.filter(a=>a.startsWith("!")).map(a=>a.slice(1)),r=s.filter(a=>a.startsWith("+")).map(a=>a.slice(1)),i=s.filter(a=>a.startsWith("-")).map(a=>a.slice(1));let o=!0;return n.length>0&&K(c,n,e)&&(o=!1),r.length>0&&T(c,r,e)&&(o=!0),i.length>0&&T(c,i,e)&&(o=!1),o}m(qt,"isEnabledByOverrides");function J(c,t,e){const s=[],n=[],r=[],i=[];for(const a of t)a.startsWith("+")?r.push(a.slice(1)):a.startsWith("-")?i.push(a.slice(1)):a.startsWith("!")?n.push(a.slice(1)):s.push(a);let o;if(s.length===0?o=[...c]:o=c.filter(a=>K(a,s,e)),n.length>0&&(o=o.filter(a=>!K(a,n,e))),r.length>0)for(const a of c)!o.includes(a)&&T(a,r,e)&&o.push(a);return i.length>0&&(o=o.filter(a=>!T(a,i,e))),new Set(o)}m(J,"applyPatterns");function Qt(c,t,e){const s=new Map;for(const n of t){const r=n.slice(n.startsWith("+")||n.startsWith("-")||n.startsWith("!")?1:0),i=!n.startsWith("-")&&!n.startsWith("!"),o=n.startsWith("+")||n.startsWith("-");for(const a of c)(o?T(a,[r],e):K(a,[r],e))&&s.set(a,i)}return s}m(Qt,"applyAutoloadDisabledPatterns");class me{static{m(this,"DefaultPackageManager")}cwd;agentDir;settingsManager;globalNpmRoot;globalNpmRootCommandKey;progressCallback;constructor(t){this.cwd=L(t.cwd),this.agentDir=L(t.agentDir),this.settingsManager=t.settingsManager}setProgressCallback(t){this.progressCallback=t}addSourceToSettings(t,e){const s=e?.local?"project":"user",r=(s==="project"?this.settingsManager.getProjectSettings():this.settingsManager.getGlobalSettings()).packages??[],i=this.normalizePackageSourceForSettings(t,s),o=m(p=>{const u=e?.resolvedCommit;return!u&&!p?i:typeof p=="string"||p===void 0?u?{source:i,resolvedCommit:u}:i:u?{...p,source:i,resolvedCommit:u}:{...p,source:i}},"toEntry"),a=r.findIndex(p=>this.packageSourcesMatch(p,t,s));if(a!==-1){const p=r[a];if(this.getPackageSourceString(p)===i&&!e?.resolvedCommit)return!1;const u=[...r];return u[a]=o(p),s==="project"?this.settingsManager.setProjectPackages(u):this.settingsManager.setPackages(u),!0}const l=[...r,o()];return s==="project"?this.settingsManager.setProjectPackages(l):this.settingsManager.setPackages(l),!0}removeSourceFromSettings(t,e){const s=e?.local?"project":"user",r=(s==="project"?this.settingsManager.getProjectSettings():this.settingsManager.getGlobalSettings()).packages??[],i=r.filter(a=>!this.packageSourcesMatch(a,t,s));return i.length!==r.length?(s==="project"?this.settingsManager.setProjectPackages(i):this.settingsManager.setPackages(i),!0):!1}getInstalledPath(t,e){const s=this.parseSource(t);if(s.type==="npm"){const n=this.getNpmInstallPath(s,e);return f(n)?n:void 0}if(s.type==="git"){const n=this.getGitInstallPath(s,e);return f(n)?n:void 0}if(s.type==="local"){const n=this.getBaseDirForScope(e),r=this.resolvePathFromBase(s.path,n);return f(r)?r:void 0}}readDeclaredPermissions(t){if(!t)return;const s=Gt(t)?.manifest.permissions;return s&&s.length>0?[...s]:void 0}async readGitHead(t){if(t)try{const s=(await this.runCommandCapture("git",["rev-parse","HEAD"],{cwd:t,timeoutMs:C})).trim();return/^[0-9a-f]{7,40}$/i.test(s)?s:void 0}catch{return}}getStoredResolvedCommit(t,e){const s=e==="project"?this.settingsManager.getProjectSettings().packages??[]:this.settingsManager.getGlobalSettings().packages??[];for(const n of s)if(typeof n!="string"&&this.packageSourcesMatch(n,t,e))return n.resolvedCommit}emitProgress(t){this.progressCallback?.(t)}async withProgress(t,e,s,n){this.emitProgress({type:"start",action:t,source:e,message:s});try{await n(),this.emitProgress({type:"complete",action:t,source:e})}catch(r){const i=r instanceof Error?r.message:String(r);throw this.emitProgress({type:"error",action:t,source:e,message:i}),r}}async resolve(t){const e=this.createAccumulator(),s=this.settingsManager.getGlobalSettings(),n=this.settingsManager.getProjectSettings(),r=[];for(const l of n.packages??[])r.push({pkg:l,scope:"project"});for(const l of s.packages??[])r.push({pkg:l,scope:"user"});const i=this.dedupePackages(r);await this.resolvePackageSources(i,e,t);const o=this.agentDir,a=h(this.cwd,$);for(const l of O){const p=this.getTargetMap(e,l),u=s[l]??[],g=n[l]??[];this.resolveLocalEntries(g,l,p,{source:"local",scope:"project",origin:"top-level"},a),this.resolveLocalEntries(u,l,p,{source:"local",scope:"user",origin:"top-level"},o)}return this.addAutoDiscoveredResources(e,s,n,o,a),this.toResolvedPaths(e)}async resolveExtensionSources(t,e){const s=this.createAccumulator(),n=e?.temporary?"temporary":e?.local?"project":"user",r=t.map(i=>({pkg:i,scope:n}));return await this.resolvePackageSources(r,s),this.toResolvedPaths(s)}listConfiguredPackages(){const t=this.settingsManager.getGlobalSettings(),e=this.settingsManager.getProjectSettings(),s=[];for(const n of t.packages??[]){const r=typeof n=="string"?n:n.source,i=this.getInstalledPath(r,"user");s.push({source:r,scope:"user",filtered:typeof n=="object",installedPath:i,resolvedCommit:typeof n=="object"?n.resolvedCommit:void 0,permissions:this.readDeclaredPermissions(i)})}for(const n of e.packages??[]){const r=typeof n=="string"?n:n.source,i=this.getInstalledPath(r,"project");s.push({source:r,scope:"project",filtered:typeof n=="object",installedPath:i,resolvedCommit:typeof n=="object"?n.resolvedCommit:void 0,permissions:this.readDeclaredPermissions(i)})}return s}async install(t,e){const s=this.parseSource(t),n=e?.local?"project":"user";this.assertProjectTrustedForScope(n),await this.withProgress("install",t,`Installing ${t}...`,async()=>{if(s.type==="npm"){await this.installNpm(s,n,!1);return}if(s.type==="git"){await this.installGit(s,n);return}if(s.type==="local"){const r=this.resolvePath(s.path);if(!f(r))throw new Error(`Path does not exist: ${r}`);return}throw new Error(`Unsupported install source: ${t}`)})}async installAndPersist(t,e){await this.install(t,e);const s=e?.local?"project":"user",n=this.getInstalledPath(t,s),r=await this.readGitHead(n);this.addSourceToSettings(t,{...e,resolvedCommit:r})}async remove(t,e){const s=this.parseSource(t),n=e?.local?"project":"user";this.assertProjectTrustedForScope(n),await this.withProgress("remove",t,`Removing ${t}...`,async()=>{if(s.type==="npm"){await this.uninstallNpm(s,n);return}if(s.type==="git"){await this.removeGit(s,n);return}if(s.type!=="local")throw new Error(`Unsupported remove source: ${t}`)})}async removeAndPersist(t,e){return await this.remove(t,e),this.removeSourceFromSettings(t,e)}async update(t,e){const s=e?.latest===!0,n=this.settingsManager.getGlobalSettings(),r=this.settingsManager.getProjectSettings(),i=t?this.getPackageIdentity(t):void 0;let o=!1;const a=[];for(const l of n.packages??[]){const p=typeof l=="string"?l:l.source;i&&this.getPackageIdentity(p,"user")!==i||(o=!0,a.push({source:p,scope:"user"}))}for(const l of r.packages??[]){const p=typeof l=="string"?l:l.source;i&&this.getPackageIdentity(p,"project")!==i||(o=!0,a.push({source:p,scope:"project"}))}if(t&&!o)throw new Error(this.buildNoMatchingPackageMessage(t,[...n.packages??[],...r.packages??[]]));await this.updateConfiguredSources(a,s)}async updateConfiguredSources(t,e=!1){if(F()||t.length===0)return;const s=[],n=[];for(const p of t){const u=this.parseSource(p.source);if(u.type==="npm")u.pinned||s.push({...p,parsed:u});else if(u.type==="git"){const g=this.getStoredResolvedCommit(p.source,p.scope);if(!u.ref&&g&&!e)continue;n.push({...p,parsed:u})}}const r=s.map(p=>async()=>({entry:p,shouldUpdate:await this.shouldUpdateNpmSource(p.parsed,p.scope)})),i=await this.runWithConcurrency(r,it),o=[],a=[];for(const p of i)p.shouldUpdate&&(p.entry.scope==="user"?o.push(p.entry):a.push(p.entry));const l=[];if(o.length>0&&l.push(this.updateNpmBatch(o,"user")),a.length>0&&l.push(this.updateNpmBatch(a,"project")),n.length>0){const p=n.map(u=>async()=>this.withProgress("update",u.source,`Updating ${u.source}...`,async()=>{if(await this.updateGit(u.parsed,u.scope),!this.getStoredResolvedCommit(u.source,u.scope))return;const P=this.getInstalledPath(u.source,u.scope),d=await this.readGitHead(P);d&&this.addSourceToSettings(u.source,{local:u.scope==="project",resolvedCommit:d})}));l.push(this.runWithConcurrency(p,At).then(()=>{}))}await Promise.all(l)}async shouldUpdateNpmSource(t,e){const s=this.getManagedNpmInstallPath(t,e),n=f(s)?this.getInstalledNpmVersion(s):void 0;if(!n)return!0;try{const r=await this.getLatestNpmVersion(t.version?t.spec:t.name,t.range);return et(r,n)}catch{return!0}}async updateNpmBatch(t,e){if(t.length===0)return;const s=t.length===1?t[0].source:`${e} npm packages`,n=t.length===1?`Updating ${t[0].source}...`:`Updating ${e} npm packages...`,r=t.map(i=>i.parsed.version?i.parsed.spec:`${i.parsed.name}@latest`);await this.withProgress("update",s,n,async()=>{await this.installNpmBatch(r,e)})}async installNpmBatch(t,e){const s=this.getNpmInstallRoot(e,!1);this.ensureNpmProject(s),await this.runNpmCommand(this.getNpmInstallArgs(t,s))}async checkForAvailableUpdates(){if(F())return[];const t=this.settingsManager.getGlobalSettings(),e=this.settingsManager.getProjectSettings(),s=[];for(const o of e.packages??[])s.push({pkg:o,scope:"project"});for(const o of t.packages??[])s.push({pkg:o,scope:"user"});const r=this.dedupePackages(s).filter(o=>o.scope!=="temporary").map(o=>async()=>{const a=typeof o.pkg=="string"?o.pkg:o.pkg.source,l=this.parseSource(a);if(l.type==="local"||l.pinned)return;if(l.type==="npm"){const g=this.getNpmInstallPath(l,o.scope);return!f(g)||!await this.npmHasAvailableUpdate(l,g)?void 0:{source:a,displayName:l.name,type:"npm",scope:o.scope}}const p=this.getGitInstallPath(l,o.scope);if(!(!f(p)||!await this.gitHasAvailableUpdate(p)))return{source:a,displayName:`${l.host}/${l.path}`,type:"git",scope:o.scope}});return(await this.runWithConcurrency(r,it)).filter(o=>o!==void 0)}async resolvePackageSources(t,e,s){for(const{pkg:n,scope:r}of t){const i=typeof n=="string"?n:n.source,o=typeof n=="object"?n:void 0,a=this.findAutoloadDeltaBase(n,r,t),l=a?.source??i,p=a?.scope??r,u=this.parseSource(l),g={source:i,scope:r,origin:"package"};if(u.type==="local"){const d=this.getBaseDirForScope(p);this.resolveLocalExtensionSource(u,e,o,g,d);continue}const P=m(async()=>{if(F())return!1;if(!s)return await this.installParsedSource(u,p),!0;const d=await s(l);if(d==="skip")return!1;if(d==="error")throw new Error(`Missing source: ${l}`);return await this.installParsedSource(u,p),!0},"installMissing");if(u.type==="npm"){let d=this.getNpmInstallPath(u,p);if(!f(d)||!await this.installedNpmMatchesConfiguredVersion(u,d)){if(!await P())continue;d=this.getNpmInstallPath(u,p)}g.baseDir=d,this.collectPackageResources(d,e,o,g);continue}if(u.type==="git"){const d=this.getGitInstallPath(u,p);if(f(d))p==="temporary"&&!u.pinned&&!F()&&await this.refreshTemporaryGitSource(u,l);else if(!await P())continue;g.baseDir=d,this.collectPackageResources(d,e,o,g)}}}findAutoloadDeltaBase(t,e,s){if(e!=="project"||typeof t!="object"||t.autoload!==!1)return;const n=this.getPackageIdentity(t.source,e),r=s.find(i=>i.scope==="user"&&this.getPackageIdentity(this.getPackageSourceString(i.pkg),"user")===n);return r?{source:this.getPackageSourceString(r.pkg),scope:"user"}:void 0}resolveLocalExtensionSource(t,e,s,n,r){const i=this.resolvePathFromBase(t.path,r);if(f(i))try{const o=N(i);if(o.isFile()){n.baseDir=w(i),this.addResource(e.extensions,i,n,!0);return}o.isDirectory()&&(n.baseDir=i,this.collectPackageResources(i,e,s,n)||this.addResource(e.extensions,i,n,!0))}catch{return}}async installParsedSource(t,e){if(t.type==="npm"){await this.installNpm(t,e,e==="temporary");return}if(t.type==="git"){await this.installGit(t,e);return}}getPackageSourceString(t){return typeof t=="string"?t:t.source}getSourceMatchKeyForInput(t){const e=this.parseSource(t);return e.type==="npm"?`npm:${e.name}`:e.type==="git"?`git:${e.host}/${e.path}`:`local:${this.resolvePath(e.path)}`}getSourceMatchKeyForSettings(t,e){const s=this.parseSource(t);if(s.type==="npm")return`npm:${s.name}`;if(s.type==="git")return`git:${s.host}/${s.path}`;const n=this.getBaseDirForScope(e);return`local:${this.resolvePathFromBase(s.path,n)}`}buildNoMatchingPackageMessage(t,e){const s=this.findSuggestedConfiguredSource(t,e);return s?`No matching package found for ${t}. Did you mean ${s}?`:`No matching package found for ${t}`}findSuggestedConfiguredSource(t,e){const s=t.trim(),n=new Set;for(const r of e){const i=this.getPackageSourceString(r),o=this.parseSource(i);if(o.type==="npm"){(s===o.name||s===o.spec)&&n.add(i);continue}if(o.type==="git"){const a=`${o.host}/${o.path}`,l=o.ref?`${a}@${o.ref}`:void 0;(s===a||l&&s===l)&&n.add(i)}}return n.values().next().value}packageSourcesMatch(t,e,s){const n=this.getSourceMatchKeyForSettings(this.getPackageSourceString(t),s),r=this.getSourceMatchKeyForInput(e);return n===r}normalizePackageSourceForSettings(t,e){const s=this.parseSource(t);if(s.type!=="local")return t;const n=this.getBaseDirForScope(e),r=this.resolvePath(s.path);return k(n,r)||"."}parseSource(t){if(t.startsWith("npm:")){const s=t.slice(4).trim(),{name:n,version:r}=this.parseNpmSpec(s);return{type:"npm",spec:s,name:n,version:r,range:Rt(r),pinned:$t(r)}}if(It(t))return{type:"local",path:t};const e=Ft(t);return e||{type:"local",path:t}}async installedNpmMatchesConfiguredVersion(t,e){const s=this.getInstalledNpmVersion(e);return s?t.range?vt(s,t.range):!0:!1}async npmHasAvailableUpdate(t,e){if(F())return!1;const s=this.getInstalledNpmVersion(e);if(!s)return!1;try{const n=await this.getLatestNpmVersion(t.version?t.spec:t.name,t.range);return et(n,s)}catch{return!1}}getInstalledNpmVersion(t){const e=h(t,"package.json");if(f(e))try{const s=H(e,"utf-8");return JSON.parse(rt(s)).version}catch{return}}async getLatestNpmVersion(t,e){const s=this.getNpmCommand(),n=await this.applyNpmArgsHook(["view",t,"version","--json"],this.cwd),i=(await this.runCommandCapture(s.command,[...s.args,...n],{cwd:this.cwd,timeoutMs:C})).trim();if(!i)throw new Error("Empty response from npm view");const o=JSON.parse(i);if(typeof o=="string")return o;if(Array.isArray(o)){const a=o.filter(p=>typeof p=="string"&&p.length>0),l=e?kt(a,e):[...a].sort(St)[0];if(l)return l}throw new Error("Unexpected response from npm view")}async gitHasAvailableUpdate(t){if(F())return!1;try{const e=await this.runCommandCapture("git",["rev-parse","HEAD"],{cwd:t,timeoutMs:C}),s=await this.getRemoteGitHead(t);return e.trim()!==s.trim()}catch{return!1}}async getRemoteGitHead(t){const e=await this.getGitUpstreamRef(t);if(e){const i=(await this.runGitRemoteCommand(t,["ls-remote","origin",e])).match(/^([0-9a-f]{40})\s+/m);if(i?.[1])return i[1]}const n=(await this.runGitRemoteCommand(t,["ls-remote","origin","HEAD"])).match(/^([0-9a-f]{40})\s+HEAD$/m);if(!n?.[1])throw new Error("Failed to determine remote HEAD");return n[1]}async getLocalGitUpdateTarget(t){try{const s=(await this.runCommandCapture("git",["rev-parse","--abbrev-ref","@{upstream}"],{cwd:t,timeoutMs:C})).trim();if(!s.startsWith("origin/"))throw new Error(`Unsupported upstream remote: ${s}`);const n=s.slice(7);if(!n)throw new Error("Missing upstream branch name");return{ref:"@{upstream}",head:await this.runCommandCapture("git",["rev-parse","@{upstream}"],{cwd:t,timeoutMs:C}),fetchArgs:["fetch","--prune","--no-tags","origin",`+refs/heads/${n}:refs/remotes/origin/${n}`]}}catch{await this.runCommand("git",["remote","set-head","origin","-a"],{cwd:t}).catch(()=>{});const e=await this.runCommandCapture("git",["rev-parse","origin/HEAD"],{cwd:t,timeoutMs:C}),n=(await this.runCommandCapture("git",["symbolic-ref","refs/remotes/origin/HEAD"],{cwd:t,timeoutMs:C}).catch(()=>"")).trim().replace(/^refs\/remotes\/origin\//,"");return n?{ref:"origin/HEAD",head:e,fetchArgs:["fetch","--prune","--no-tags","origin",`+refs/heads/${n}:refs/remotes/origin/${n}`]}:{ref:"origin/HEAD",head:e,fetchArgs:["fetch","--prune","--no-tags","origin","+HEAD:refs/remotes/origin/HEAD"]}}}async getGitUpstreamRef(t){try{const s=(await this.runCommandCapture("git",["rev-parse","--abbrev-ref","@{upstream}"],{cwd:t,timeoutMs:C})).trim();if(!s.startsWith("origin/"))return;const n=s.slice(7);return n?`refs/heads/${n}`:void 0}catch{return}}runGitRemoteCommand(t,e){return this.runCommandCapture("git",e,{cwd:t,timeoutMs:C,env:{GIT_TERMINAL_PROMPT:"0"}})}async runWithConcurrency(t,e){if(t.length===0)return[];const s=new Array(t.length);let n=0;const r=Math.max(1,Math.min(e,t.length)),i=m(async()=>{for(;;){const o=n;if(n+=1,o>=t.length)return;s[o]=await t[o]()}},"worker");return await Promise.all(Array.from({length:r},()=>i())),s}getPackageIdentity(t,e){const s=this.parseSource(t);if(s.type==="npm")return`npm:${s.name}`;if(s.type==="git")return`git:${s.host}/${s.path}`;if(e){const n=this.getBaseDirForScope(e);return`local:${this.resolvePathFromBase(s.path,n)}`}return`local:${this.resolvePath(s.path)}`}dedupePackages(t){const e=[],s=new Map;for(const n of t){const r=this.getPackageIdentity(this.getPackageSourceString(n.pkg),n.scope),i=s.get(r);if(i===void 0){s.set(r,e.length),e.push(n);continue}const o=e[i];o?.scope==="project"&&n.scope==="user"?typeof o.pkg=="object"&&o.pkg.autoload===!1&&e.push(n):n.scope==="project"&&(e[i]=n)}return e}parseNpmSpec(t){const e=t.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);if(!e)return{name:t};const s=e[1]??t,n=e[2];return{name:s,version:n}}assertProjectTrustedForScope(t){if(t==="project"&&!this.settingsManager.isProjectTrusted())throw new Error("Project is not trusted; refusing to access project package storage")}getNpmCommand(){const t=this.settingsManager.getNpmCommand();if(!t||t.length===0)return{command:"npm",args:[]};const[e,...s]=t;if(!e)throw new Error("Invalid npmCommand: first array entry must be a non-empty command");return{command:e,args:s}}getPackageManagerName(){const t=this.getNpmCommand(),e=[t.command,...t.args],s=e.lastIndexOf("--"),n=s>=0?e[s+1]:t.command;return n?A(n).replace(/\.(cmd|exe)$/i,""):""}async runNpmCommand(t,e){const s=this.getNpmCommand(),n=await this.applyNpmArgsHook(t,e?.cwd);await this.runCommand(s.command,[...s.args,...n],e)}async applyNpmArgsHook(t,e){const s=globalThis[Dt];return typeof s!="function"?t:s(t,{cwd:e,packageManager:this.getPackageManagerName()})}getGitDependencyInstallArgs(){const t=this.settingsManager.getNpmCommand();return t&&t.length>0?["install"]:["install","--omit=dev"]}runNpmCommandSync(t){const e=this.getNpmCommand();return this.runCommandSync(e.command,[...e.args,...t])}getNpmInstallArgs(t,e){const s=this.getPackageManagerName();return s==="bun"?["install",...t,"--cwd",e,"--omit=peer"]:s==="pnpm"?["install",...t,"--prefix",e,"--config.auto-install-peers=false","--config.strict-peer-dependencies=false","--config.strict-dep-builds=false"]:["install",...t,"--prefix",e,"--legacy-peer-deps"]}async installNpm(t,e,s){const n=this.getNpmInstallRoot(e,s);this.ensureNpmProject(n),await this.runNpmCommand(this.getNpmInstallArgs([t.spec],n))}async uninstallNpm(t,e){const s=this.getNpmInstallRoot(e,!1);if(!f(s))return;const n=this.getPackageManagerName();if(n==="bun"){await this.runNpmCommand(["uninstall",t.name,"--cwd",s]);return}const r=["uninstall",t.name,"--prefix",s];n!=="pnpm"&&r.push("--legacy-peer-deps"),await this.runNpmCommand(r)}async installGit(t,e){const s=this.getGitInstallPath(t,e);if(f(s)){if(t.ref){await this.ensureGitRef(s,["fetch","origin",t.ref],"FETCH_HEAD");return}const r=await this.getLocalGitUpdateTarget(s);await this.ensureGitRef(s,r.fetchArgs,r.ref);return}const n=this.getGitInstallRoot(e);n&&this.ensureGitIgnore(n),W(w(s),{recursive:!0}),j(this.getGitUpdateMarkerPath(s),{force:!0});try{await this.runCommand("git",["clone",t.repo,s]),t.ref&&await this.runCommand("git",["checkout",t.ref],{cwd:s});const r=h(s,"package.json");f(r)&&await this.runNpmCommand(this.getGitDependencyInstallArgs(),{cwd:s})}catch(r){throw j(s,{recursive:!0,force:!0}),this.pruneEmptyGitParents(s,n),r}}async updateGit(t,e){const s=this.getGitInstallPath(t,e);if(!f(s)){await this.installGit(t,e);return}if(t.ref){await this.ensureGitRef(s,["fetch","origin",t.ref],"FETCH_HEAD");return}const n=await this.getLocalGitUpdateTarget(s);await this.ensureGitRef(s,n.fetchArgs,n.ref)}hasMissingGitDependencies(t){const e=h(t,"package.json");if(!f(e))return!1;try{const s=JSON.parse(rt(H(e,"utf-8")));if(!s.dependencies||typeof s.dependencies!="object"||Array.isArray(s.dependencies))return!1;const n=S(t,"node_modules");return Object.keys(s.dependencies).some(r=>{const i=S(n,r);return i.startsWith(`${n}${U}`)?!f(i):!1})}catch{return!1}}async repairMissingGitDependencies(t){this.hasMissingGitDependencies(t)&&await this.runNpmCommand(this.getGitDependencyInstallArgs(),{cwd:t})}getGitUpdateMarkerPath(t){return h(w(t),`.${A(t)}.pi-update-incomplete`)}async cleanAndInstallGitDependencies(t,e){try{await this.runCommand("git",["clean","-fdx"],{cwd:t})}catch(n){throw await this.repairMissingGitDependencies(t).catch(()=>{}),n}const s=h(t,"package.json");f(s)&&await this.runNpmCommand(this.getGitDependencyInstallArgs(),{cwd:t}),j(e,{force:!0})}async ensureGitRef(t,e,s){await this.runCommand("git",e,{cwd:t});const n=await this.runCommandCapture("git",["rev-parse","HEAD"],{cwd:t,timeoutMs:C}),r=`${s}^{commit}`,i=await this.runCommandCapture("git",["rev-parse",r],{cwd:t,timeoutMs:C}),o=this.getGitUpdateMarkerPath(t);if(n.trim()===i.trim()){f(o)?await this.cleanAndInstallGitDependencies(t,o):await this.repairMissingGitDependencies(t);return}z(o,"","utf-8"),await this.runCommand("git",["reset","--hard",r],{cwd:t}),await this.cleanAndInstallGitDependencies(t,o)}async refreshTemporaryGitSource(t,e){if(!F())try{await this.withProgress("pull",e,`Refreshing ${e}...`,async()=>{await this.updateGit(t,"temporary")})}catch{}}async removeGit(t,e){const s=this.getGitInstallPath(t,e);j(s,{recursive:!0,force:!0}),j(this.getGitUpdateMarkerPath(s),{force:!0}),this.pruneEmptyGitParents(s,this.getGitInstallRoot(e))}pruneEmptyGitParents(t,e){if(!e)return;const s=S(e);let n=w(t);for(;n.startsWith(s)&&n!==s;){if(!f(n)){n=w(n);continue}if(I(n).length>0)break;try{j(n,{recursive:!0,force:!0})}catch{break}n=w(n)}}ensureNpmProject(t){f(t)||W(t,{recursive:!0}),jt(t),this.ensureGitIgnore(t);const e=h(t,"package.json");f(e)||z(e,JSON.stringify({name:"pi-extensions",private:!0},null,2),"utf-8")}ensureGitIgnore(t){f(t)||W(t,{recursive:!0});const e=h(t,".gitignore");f(e)||z(e,`*
|
|
2
2
|
!.gitignore
|
|
3
|
-
`,"utf-8")}getNpmInstallRoot(t,e){return e?this.getTemporaryDir("npm"):t==="project"?(this.assertProjectTrustedForScope(t),h(this.cwd
|
|
3
|
+
`,"utf-8")}getNpmInstallRoot(t,e){return e?this.getTemporaryDir("npm"):t==="project"?(this.assertProjectTrustedForScope(t),h(this.cwd,$,"npm")):h(this.agentDir,"npm")}getGlobalNpmRoot(){const t=this.getNpmCommand(),e=[t.command,...t.args].join("\0");if(this.globalNpmRoot&&this.globalNpmRootCommandKey===e)return this.globalNpmRoot;if(this.getPackageManagerName()==="bun"){const s=this.runNpmCommandSync(["pm","bin","-g"]).trim();this.globalNpmRoot=h(w(s),"install","global","node_modules")}else this.globalNpmRoot=this.runNpmCommandSync(["root","-g"]).trim();return this.globalNpmRootCommandKey=e,this.globalNpmRoot}getPnpmGlobalPackagePath(t){if(this.getPackageManagerName()!=="pnpm")return;const e=this.runNpmCommandSync(["list","-g","--depth","0","--json"]),s=JSON.parse(e);for(const n of s){const r=n.dependencies?.[t]?.path;if(r)return r}}getManagedNpmInstallPath(t,e){return e==="temporary"?h(this.getTemporaryDir("npm"),"node_modules",t.name):e==="project"?(this.assertProjectTrustedForScope(e),h(this.cwd,$,"npm","node_modules",t.name)):h(this.agentDir,"npm","node_modules",t.name)}getLegacyGlobalNpmInstallPath(t){try{return this.getPnpmGlobalPackagePath(t.name)??h(this.getGlobalNpmRoot(),t.name)}catch{return}}getNpmInstallPath(t,e){const s=this.getManagedNpmInstallPath(t,e);if(e!=="user"||f(s))return s;const n=this.getLegacyGlobalNpmInstallPath(t);return n&&f(n)?n:s}getGitInstallPath(t,e){if(e==="temporary")return this.getTemporaryDir(`git-${t.host}`,t.path);const s=this.getGitInstallRoot(e);if(!s)throw new Error("Missing git install root");return this.resolveManagedPath(s,t.host,t.path)}getGitInstallRoot(t){if(t!=="temporary")return t==="project"?(this.assertProjectTrustedForScope(t),h(this.cwd,$,"git")):h(this.agentDir,"git")}getTemporaryDir(t,e){const s=this.resolveManagedPath(Ht(this.agentDir),t),n=dt("sha256").update(`${t}-${e??""}`).digest("hex").slice(0,8);return this.resolveManagedPath(s,n,e??"")}resolveManagedPath(t,...e){const s=S(t),n=S(s,...e);if(n!==s&&!n.startsWith(`${s}${U}`))throw new Error(`Refusing to use path outside package install root: ${n}`);return n}getBaseDirForScope(t){return t==="project"?(this.assertProjectTrustedForScope(t),h(this.cwd,$)):t==="user"?this.agentDir:this.cwd}resolvePath(t){return L(t,this.cwd,{homeDir:q(),trim:!0})}resolvePathFromBase(t,e){return L(t,e,{homeDir:q(),trim:!0})}collectPackageResources(t,e,s,n){if(Nt(t))return!0;if(s){for(const o of O){const a=s[o],l=this.getTargetMap(e,o);s.autoload===!1?this.applyPackageDeltaFilter(t,a??[],o,l,n):a!==void 0?this.applyPackageFilter(t,a,o,l,n):this.collectDefaultResources(t,o,l,n)}return!0}const r=_(h(t,"package.json"));if(r){for(const o of O){const a=r[o];this.addManifestEntries(a,t,o,this.getTargetMap(e,o),n)}return!0}let i=!1;for(const o of O){const a=h(t,o);if(f(a)){const l=V(a,o);for(const p of l)this.addResource(this.getTargetMap(e,o),p,n,!0);i=!0}}return i}collectDefaultResources(t,e,s,n){const i=_(h(t,"package.json"))?.[e];if(i){this.addManifestEntries(i,t,e,s,n);return}const o=h(t,e);if(f(o)){const a=V(o,e);for(const l of a)this.addResource(s,l,n,!0)}}applyPackageFilter(t,e,s,n,r){const{allFiles:i}=this.collectManifestFiles(t,s);if(e.length===0){for(const a of i)this.addResource(n,a,r,!1);return}const o=J(i,e,t);for(const a of i){const l=o.has(a);this.addResource(n,a,r,l)}}applyPackageDeltaFilter(t,e,s,n,r){if(e.length===0)return;const{allFiles:i}=this.collectManifestFiles(t,s),o=Qt(i,e,t);for(const[a,l]of o)this.addResource(n,a,r,l)}collectManifestFiles(t,e){const n=_(h(t,"package.json"))?.[e];if(n&&n.length>0){const o=this.collectFilesFromManifestEntries(n,t,e),a=n.filter(Q),l=a.length>0?J(o,a,t):new Set(o);return{allFiles:Array.from(l),enabledByManifest:l}}const r=h(t,e);if(!f(r))return{allFiles:[],enabledByManifest:new Set};const i=V(r,e);return{allFiles:i,enabledByManifest:new Set(i)}}addManifestEntries(t,e,s,n,r){if(!t)return;const i=this.collectFilesFromManifestEntries(t,e,s),o=t.filter(Q),a=J(i,o,e);for(const l of i)a.has(l)&&this.addResource(n,l,r,!0)}collectFilesFromManifestEntries(t,e,s){const r=t.filter(i=>!Q(i)).flatMap(i=>_t(i)?Ot(i,e):[S(e,i)]);return this.collectFilesFromPaths(r,s)}resolveLocalEntries(t,e,s,n,r){if(t.length===0)return;const{plain:i,patterns:o}=Bt(t),a=i.map(u=>this.resolvePathFromBase(u,r)),l=this.collectFilesFromPaths(a,e),p=J(l,o,r);for(const u of l)this.addResource(s,u,n,p.has(u))}addAutoDiscoveredResources(t,e,s,n,r){const i={source:"auto",scope:"user",origin:"top-level",baseDir:n},o={source:"auto",scope:"project",origin:"top-level",baseDir:r},a={extensions:e.extensions??[],skills:e.skills??[],prompts:e.prompts??[],themes:e.themes??[]},l={extensions:s.extensions??[],skills:s.skills??[],prompts:s.prompts??[],themes:s.themes??[]},p={extensions:h(n,"extensions"),skills:h(n,"skills"),prompts:h(n,"prompts"),themes:h(n,"themes")},u={extensions:h(r,"extensions"),skills:h(r,"skills"),prompts:h(r,"prompts"),themes:h(r,"themes")},g=Kt(),P=new Set(g.map(M=>S(M))),d=this.settingsManager.isProjectTrusted(),b=d?Jt(this.cwd).filter(M=>!P.has(S(M))):[],v=m((M,E,G,pt,ht)=>{const ft=this.getTargetMap(t,M);for(const tt of E){const mt=qt(tt,pt,ht);this.addResource(ft,tt,G,mt)}},"addResources");d&&(v("extensions",Z(u.extensions),o,l.extensions,r),v("skills",B(u.skills,"pi"),o,l.skills,r));for(const M of b){const E=w(M),G={...o,baseDir:E};v("skills",B(M,"agents"),G,l.skills,E)}d&&(v("prompts",ct(u.prompts),o,l.prompts,r),v("themes",lt(u.themes),o,l.themes,r)),v("extensions",Z(p.extensions),i,a.extensions,n),v("skills",B(p.skills,"pi"),i,a.skills,n);for(const M of g){const E=w(M),G={...i,baseDir:E};v("skills",B(M,"agents"),G,a.skills,E)}v("prompts",ct(p.prompts),i,a.prompts,n),v("themes",lt(p.themes),i,a.themes,n)}collectFilesFromPaths(t,e){const s=[];for(const n of t)if(f(n))try{const r=N(n);r.isFile()?s.push(n):r.isDirectory()&&s.push(...V(n,e))}catch{}return s}getTargetMap(t,e){switch(e){case"extensions":return t.extensions;case"skills":return t.skills;case"prompts":return t.prompts;case"themes":return t.themes;default:throw new Error(`Unknown resource type: ${e}`)}}addResource(t,e,s,n){e&&(t.has(e)||t.set(e,{metadata:s,enabled:n}))}createAccumulator(){return{extensions:new Map,skills:new Map,prompts:new Map,themes:new Map}}toResolvedPaths(t){const e=m(s=>{const n=Array.from(s.entries()).map(([i,{metadata:o,enabled:a}])=>({path:i,enabled:a,metadata:o}));n.sort((i,o)=>ot(i.metadata)-ot(o.metadata));const r=new Set;return n.filter(i=>{const o=bt(i.path);return r.has(o)?!1:(r.add(o),!0)})},"mapToResolved");return{extensions:e(t.extensions),skills:e(t.skills),prompts:e(t.prompts),themes:e(t.themes)}}spawnCommand(t,e,s){const n=Y();return nt(t,e,{cwd:s?.cwd,stdio:xt()?["ignore",2,2]:"inherit",env:n})}spawnCaptureCommand(t,e,s){const n=Y(),r=s?.env?{...n,...s.env}:n;return nt(t,e,{cwd:s?.cwd,stdio:["ignore","pipe","pipe"],env:r})}runCommandCapture(t,e,s){return new Promise((n,r)=>{const i=this.spawnCaptureCommand(t,e,s);let o="",a="",l=!1;const p=typeof s?.timeoutMs=="number"?setTimeout(()=>{l=!0,i.kill()},s.timeoutMs):void 0;i.stdout?.on("data",u=>{o+=u.toString()}),i.stderr?.on("data",u=>{a+=u.toString()}),i.once("error",u=>{p&&clearTimeout(p),r(u)}),i.once("close",(u,g)=>{if(p&&clearTimeout(p),l){r(new Error(`${t} ${e.join(" ")} timed out after ${s?.timeoutMs}ms`));return}if(u===0){n(o.trim());return}const P=u===null?`signal ${g??"unknown"}`:`code ${u}`;r(new Error(`${t} ${e.join(" ")} failed with ${P}: ${a||o}`))})})}runCommand(t,e,s){return new Promise((n,r)=>{const i=this.spawnCommand(t,e,s);i.on("error",r),i.on("exit",o=>{o===0?n():r(new Error(`${t} ${e.join(" ")} failed with code ${o}`))})})}runCommandSync(t,e){const s=Y(),n=Et(t,e,{stdio:["ignore","pipe","pipe"],encoding:"utf-8",env:s});if(n.error||n.status!==0)throw new Error(`Failed to run ${t} ${e.join(" ")}: ${n.error?.message||n.stderr||n.stdout}`);return(n.stdout||n.stderr||"").trim()}}export{me as DefaultPackageManager,Dt as NPM_ARGS_HOOK_SLOT,Ht as getExtensionTempFolder};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const DEFAULT_MAP_MAX_DEPTH = 2;
|
|
2
|
+
export declare const DEFAULT_MAP_MAX_ENTRIES = 80;
|
|
3
|
+
export interface ProjectMapOptions {
|
|
4
|
+
maxDepth?: number;
|
|
5
|
+
maxEntries?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ProjectMap {
|
|
8
|
+
root: string;
|
|
9
|
+
directories: string[];
|
|
10
|
+
files: string[];
|
|
11
|
+
truncated: boolean;
|
|
12
|
+
maxDepth: number;
|
|
13
|
+
maxEntries: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function buildProjectMap(root: string, options?: ProjectMapOptions): ProjectMap;
|
|
16
|
+
export declare function formatProjectMapCollapsed(map: ProjectMap): string;
|
|
17
|
+
export declare function formatProjectMapExpanded(map: ProjectMap): string;
|
|
18
|
+
export declare function formatProjectMapPrompt(map: ProjectMap): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ResourceDiagnostic } from "./diagnostics.ts";
|
|
2
|
+
import { type SourceInfo } from "./source-info.ts";
|
|
3
|
+
export interface PromptTemplate {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
argumentHint?: string;
|
|
7
|
+
content: string;
|
|
8
|
+
sourceInfo: SourceInfo;
|
|
9
|
+
filePath: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function parseCommandArgs(argsString: string): string[];
|
|
12
|
+
export declare function substituteArgs(content: string, args: string[]): string;
|
|
13
|
+
export interface LoadPromptTemplatesOptions {
|
|
14
|
+
cwd: string;
|
|
15
|
+
agentDir: string;
|
|
16
|
+
promptPaths: string[];
|
|
17
|
+
includeDefaults: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface LoadPromptTemplatesResult {
|
|
20
|
+
templates: PromptTemplate[];
|
|
21
|
+
diagnostics: ResourceDiagnostic[];
|
|
22
|
+
}
|
|
23
|
+
export declare function loadPromptTemplates(options: LoadPromptTemplatesOptions): LoadPromptTemplatesResult;
|
|
24
|
+
export declare function expandPromptTemplate(text: string, templates: PromptTemplate[]): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type Api, type AssistantMessageEventStream, type Model, type OAuthCredentials, type OAuthLoginCallbacks, type Provider, type ProviderHeaders, type RefreshModelsContext, type SimpleStreamOptions, type TranscriptContext } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { ModelConfig, ModelsJsonProvider } from "./model-config.ts";
|
|
3
|
+
import { clearConfigValueCache } from "./resolve-config-value.ts";
|
|
4
|
+
export interface ExtensionOAuthConfig {
|
|
5
|
+
name: string;
|
|
6
|
+
isSubscription?: boolean;
|
|
7
|
+
usesCallbackServer?: boolean;
|
|
8
|
+
login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials>;
|
|
9
|
+
refreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise<OAuthCredentials>;
|
|
10
|
+
getApiKey(credentials: OAuthCredentials): string;
|
|
11
|
+
modifyModels?(models: Model<Api>[], credentials: OAuthCredentials): Model<Api>[];
|
|
12
|
+
}
|
|
13
|
+
export interface ProviderConfigInput {
|
|
14
|
+
name?: string;
|
|
15
|
+
baseUrl?: string;
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
api?: Api;
|
|
18
|
+
streamSimple?: (model: Model<Api>, context: TranscriptContext, options?: SimpleStreamOptions) => AssistantMessageEventStream;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
authHeader?: boolean;
|
|
21
|
+
oauth?: ExtensionOAuthConfig;
|
|
22
|
+
models?: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
api?: Api;
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
reasoning: boolean;
|
|
28
|
+
thinkingLevelMap?: Model<Api>["thinkingLevelMap"];
|
|
29
|
+
input: ("text" | "image")[];
|
|
30
|
+
inputLimits?: Model<Api>["inputLimits"];
|
|
31
|
+
cost: Model<Api>["cost"];
|
|
32
|
+
promptCache?: Model<Api>["promptCache"];
|
|
33
|
+
contextWindow: number;
|
|
34
|
+
maxTokens: number;
|
|
35
|
+
samplingParams?: Record<string, unknown>;
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
compat?: Model<Api>["compat"];
|
|
38
|
+
}>;
|
|
39
|
+
refreshModels?(context: RefreshModelsContext): Promise<NonNullable<ProviderConfigInput["models"]>>;
|
|
40
|
+
}
|
|
41
|
+
export type AuthStatus = {
|
|
42
|
+
configured: boolean;
|
|
43
|
+
source?: "stored" | "runtime" | "environment" | "fallback" | "models_json_key" | "models_json_command";
|
|
44
|
+
label?: string;
|
|
45
|
+
};
|
|
46
|
+
export declare const clearApiKeyCache: typeof clearConfigValueCache;
|
|
47
|
+
export declare function validateExtensionProvider(providerId: string, base: Provider | undefined, modelsConfig: ModelsJsonProvider | undefined, extension: ProviderConfigInput): void;
|
|
48
|
+
export declare function composeModelProvider(providerId: string, base: Provider | undefined, modelConfig: ModelConfig, extension: ProviderConfigInput | undefined, onRefreshedModels?: (models: NonNullable<ProviderConfigInput["models"]>) => void): Provider;
|
|
49
|
+
export declare function resolveConfiguredModelHeaders(model: Model<Api>, config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined, env?: Record<string, string>): Record<string, string> | undefined;
|
|
50
|
+
export interface CompatibilityRequestConfig {
|
|
51
|
+
headers?: ProviderHeaders;
|
|
52
|
+
authHeader: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function resolveCompatibilityRequestConfig(model: Model<Api>, config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): CompatibilityRequestConfig;
|
|
55
|
+
export declare function configuredRequestAuthStatus(config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): AuthStatus | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var A=Object.defineProperty;var d=(e,t)=>A(e,"name",{value:t,configurable:!0});import{APP_NAME as w,VERSION as E}from"../config.js";import{fetchWithRetry as b}from"../utils/management-http.js";import{getPiUserAgent as T}from"../utils/pi-user-agent.js";const _="https://pi.dev",R=4e3,O=14400*1e3;function U(e,t){const r=[...e];for(const i of t){const s=r.findIndex(o=>o.id===i.id);s>=0?r[s]=i:r.push(i)}return r}d(U,"mergeModels");function C(e,t){const r=Array.isArray(t)?t:typeof t=="object"&&t!==null&&"models"in t&&Array.isArray(t.models)?t.models:typeof t=="object"&&t!==null?Object.values(t):void 0;if(!r)throw new Error(`Invalid model catalog for provider "${e}"`);return r.filter(i=>typeof i=="object"&&i!==null&&"id"in i).map(i=>({...i,provider:e}))}d(C,"parseCatalog");function p(e,t){return e?t!==void 0&&(e.lastModified===void 0||e.lastModified<=t)?[]:e.models:[]}d(p,"remoteModels");function S(e=w){return e==="pi"?_:void 0}d(S,"getDefaultCatalogBaseUrl");function k(e,t,r){let i=[];return{...e,getModels:d(()=>U(e.getModels(),i),"getModels"),refreshModels:d(async s=>{const o=s.stored,c=p(o,r).filter(M=>M.provider===e.id);if(!await s.publish({update:d(()=>{i=c},"update")})||!s.allowNetwork||s.signal.aborted||!s.force&&o?.checkedAt!==void 0&&o.lastModified!==void 0&&Date.now()-o.checkedAt<O)return;const f=o?.models.length?o.etag:void 0,m=new URL(`/api/models/providers/${encodeURIComponent(e.id)}`,t),n=await b(m,{headers:{accept:"application/json","User-Agent":T(E),...f?{"if-none-match":f}:{}},signal:s.signal},{attemptTimeoutMs:R});if(s.signal.aborted)return;const a=Date.now();if(n.status===304&&o){await s.publish({persist:{...o,checkedAt:a}});return}if(n.status===404||n.status===501){await s.publish({persist:{...o??{models:[]},checkedAt:a,lastModified:0,etag:void 0}});return}if(!n.ok)throw await s.publish({persist:{...o??{models:[]},checkedAt:a}}),new Error(`Model catalog request failed for ${e.id}: ${n.status}`);const g=C(e.id,await n.json()),l=Date.parse(n.headers.get("last-modified")??"");if(s.signal.aborted)return;const u={models:g,checkedAt:a,lastModified:Number.isNaN(l)?0:l,etag:n.headers.get("etag")??void 0},h=p(u,r);await s.publish({persist:u,update:d(()=>{i=h},"update")})},"refreshModels")}}d(k,"withRemoteCatalog");export{O as REMOTE_CATALOG_REFRESH_INTERVAL_MS,S as getDefaultCatalogBaseUrl,k as withRemoteCatalog};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function getConfigValueEnvVarName(config: string): string | undefined;
|
|
2
|
+
export declare function getConfigValueEnvVarNames(config: string): string[];
|
|
3
|
+
export declare function getMissingConfigValueEnvVarNames(config: string, env?: Record<string, string>): string[];
|
|
4
|
+
export declare function isCommandConfigValue(config: string): boolean;
|
|
5
|
+
export declare function isConfigValueConfigured(config: string, env?: Record<string, string>): boolean;
|
|
6
|
+
export declare function resolveConfigValue(config: string, env?: Record<string, string>): string | undefined;
|
|
7
|
+
export declare function resolveConfigValueUncached(config: string, env?: Record<string, string>): string | undefined;
|
|
8
|
+
export declare function resolveConfigValueOrThrow(config: string, description: string, env?: Record<string, string>): string;
|
|
9
|
+
export declare function resolveHeaders(headers: Record<string, string> | undefined, env?: Record<string, string>): Record<string, string> | undefined;
|
|
10
|
+
export declare function resolveHeadersOrThrow(headers: Record<string, string> | undefined, description: string, env?: Record<string, string>): Record<string, string> | undefined;
|
|
11
|
+
export declare function clearConfigValueCache(): void;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { type Theme } from "../modes/interactive/theme/theme.ts";
|
|
2
|
+
import type { ResourceDiagnostic } from "./diagnostics.ts";
|
|
3
|
+
export type { ResourceCollision, ResourceDiagnostic } from "./diagnostics.ts";
|
|
4
|
+
import { type EventBus } from "./event-bus.ts";
|
|
5
|
+
import type { InlineExtension, LoadExtensionsResult } from "./extensions/types.ts";
|
|
6
|
+
import { type PathMetadata } from "./package-manager.ts";
|
|
7
|
+
import type { PromptTemplate } from "./prompt-templates.ts";
|
|
8
|
+
import { SettingsManager } from "./settings-manager.ts";
|
|
9
|
+
import type { Skill } from "./skills.ts";
|
|
10
|
+
export interface ResourceExtensionPaths {
|
|
11
|
+
skillPaths?: Array<{
|
|
12
|
+
path: string;
|
|
13
|
+
metadata: PathMetadata;
|
|
14
|
+
}>;
|
|
15
|
+
promptPaths?: Array<{
|
|
16
|
+
path: string;
|
|
17
|
+
metadata: PathMetadata;
|
|
18
|
+
}>;
|
|
19
|
+
themePaths?: Array<{
|
|
20
|
+
path: string;
|
|
21
|
+
metadata: PathMetadata;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
export interface ResourceLoaderReloadOptions {
|
|
25
|
+
resolveProjectTrust?: (input: {
|
|
26
|
+
extensionsResult: LoadExtensionsResult;
|
|
27
|
+
}) => Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
export interface ResourceLoader {
|
|
30
|
+
getExtensions(): LoadExtensionsResult;
|
|
31
|
+
getSkills(): {
|
|
32
|
+
skills: Skill[];
|
|
33
|
+
diagnostics: ResourceDiagnostic[];
|
|
34
|
+
};
|
|
35
|
+
getPrompts(): {
|
|
36
|
+
prompts: PromptTemplate[];
|
|
37
|
+
diagnostics: ResourceDiagnostic[];
|
|
38
|
+
};
|
|
39
|
+
getThemes(): {
|
|
40
|
+
themes: Theme[];
|
|
41
|
+
diagnostics: ResourceDiagnostic[];
|
|
42
|
+
};
|
|
43
|
+
getAgentsFiles(): {
|
|
44
|
+
agentsFiles: Array<{
|
|
45
|
+
path: string;
|
|
46
|
+
content: string;
|
|
47
|
+
}>;
|
|
48
|
+
};
|
|
49
|
+
getSystemPrompt(): string | undefined;
|
|
50
|
+
getSystemPromptSource(): {
|
|
51
|
+
path: string;
|
|
52
|
+
} | undefined;
|
|
53
|
+
getAppendSystemPrompt(): string[];
|
|
54
|
+
getAppendSystemPromptSources(): Array<{
|
|
55
|
+
path: string;
|
|
56
|
+
}>;
|
|
57
|
+
extendResources(paths: ResourceExtensionPaths): void;
|
|
58
|
+
reload(options?: ResourceLoaderReloadOptions): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
export declare function loadProjectContextFiles(options: {
|
|
61
|
+
cwd: string;
|
|
62
|
+
agentDir: string;
|
|
63
|
+
}): Array<{
|
|
64
|
+
path: string;
|
|
65
|
+
content: string;
|
|
66
|
+
}>;
|
|
67
|
+
export interface DefaultResourceLoaderOptions {
|
|
68
|
+
cwd: string;
|
|
69
|
+
agentDir: string;
|
|
70
|
+
settingsManager?: SettingsManager;
|
|
71
|
+
eventBus?: EventBus;
|
|
72
|
+
additionalExtensionPaths?: string[];
|
|
73
|
+
additionalSkillPaths?: string[];
|
|
74
|
+
additionalPromptTemplatePaths?: string[];
|
|
75
|
+
additionalThemePaths?: string[];
|
|
76
|
+
extensionFactories?: InlineExtension[];
|
|
77
|
+
noExtensions?: boolean;
|
|
78
|
+
noSkills?: boolean;
|
|
79
|
+
noPromptTemplates?: boolean;
|
|
80
|
+
noThemes?: boolean;
|
|
81
|
+
noContextFiles?: boolean;
|
|
82
|
+
systemPrompt?: string;
|
|
83
|
+
appendSystemPrompt?: string[];
|
|
84
|
+
extensionsOverride?: (base: LoadExtensionsResult) => LoadExtensionsResult;
|
|
85
|
+
skillsOverride?: (base: {
|
|
86
|
+
skills: Skill[];
|
|
87
|
+
diagnostics: ResourceDiagnostic[];
|
|
88
|
+
}) => {
|
|
89
|
+
skills: Skill[];
|
|
90
|
+
diagnostics: ResourceDiagnostic[];
|
|
91
|
+
};
|
|
92
|
+
promptsOverride?: (base: {
|
|
93
|
+
prompts: PromptTemplate[];
|
|
94
|
+
diagnostics: ResourceDiagnostic[];
|
|
95
|
+
}) => {
|
|
96
|
+
prompts: PromptTemplate[];
|
|
97
|
+
diagnostics: ResourceDiagnostic[];
|
|
98
|
+
};
|
|
99
|
+
themesOverride?: (base: {
|
|
100
|
+
themes: Theme[];
|
|
101
|
+
diagnostics: ResourceDiagnostic[];
|
|
102
|
+
}) => {
|
|
103
|
+
themes: Theme[];
|
|
104
|
+
diagnostics: ResourceDiagnostic[];
|
|
105
|
+
};
|
|
106
|
+
agentsFilesOverride?: (base: {
|
|
107
|
+
agentsFiles: Array<{
|
|
108
|
+
path: string;
|
|
109
|
+
content: string;
|
|
110
|
+
}>;
|
|
111
|
+
}) => {
|
|
112
|
+
agentsFiles: Array<{
|
|
113
|
+
path: string;
|
|
114
|
+
content: string;
|
|
115
|
+
}>;
|
|
116
|
+
};
|
|
117
|
+
systemPromptOverride?: (base: string | undefined) => string | undefined;
|
|
118
|
+
appendSystemPromptOverride?: (base: string[]) => string[];
|
|
119
|
+
}
|
|
120
|
+
export declare class DefaultResourceLoader implements ResourceLoader {
|
|
121
|
+
private cwd;
|
|
122
|
+
private agentDir;
|
|
123
|
+
private settingsManager;
|
|
124
|
+
private eventBus;
|
|
125
|
+
private packageManager;
|
|
126
|
+
private additionalExtensionPaths;
|
|
127
|
+
private additionalSkillPaths;
|
|
128
|
+
private additionalPromptTemplatePaths;
|
|
129
|
+
private additionalThemePaths;
|
|
130
|
+
private extensionFactories;
|
|
131
|
+
private noExtensions;
|
|
132
|
+
private noSkills;
|
|
133
|
+
private noPromptTemplates;
|
|
134
|
+
private noThemes;
|
|
135
|
+
private noContextFiles;
|
|
136
|
+
private systemPromptSource?;
|
|
137
|
+
private appendSystemPromptSource?;
|
|
138
|
+
private extensionsOverride?;
|
|
139
|
+
private skillsOverride?;
|
|
140
|
+
private promptsOverride?;
|
|
141
|
+
private themesOverride?;
|
|
142
|
+
private agentsFilesOverride?;
|
|
143
|
+
private systemPromptOverride?;
|
|
144
|
+
private appendSystemPromptOverride?;
|
|
145
|
+
private extensionsResult;
|
|
146
|
+
private skills;
|
|
147
|
+
private skillDiagnostics;
|
|
148
|
+
private prompts;
|
|
149
|
+
private promptDiagnostics;
|
|
150
|
+
private themes;
|
|
151
|
+
private themeDiagnostics;
|
|
152
|
+
private agentsFiles;
|
|
153
|
+
private systemPrompt?;
|
|
154
|
+
private systemPromptSourcePath?;
|
|
155
|
+
private appendSystemPrompt;
|
|
156
|
+
private appendSystemPromptSourcePaths;
|
|
157
|
+
private lastSkillPaths;
|
|
158
|
+
private extensionSkillSourceInfos;
|
|
159
|
+
private extensionPromptSourceInfos;
|
|
160
|
+
private extensionThemeSourceInfos;
|
|
161
|
+
private resourceMetadataByPath;
|
|
162
|
+
private lastPromptPaths;
|
|
163
|
+
private lastThemePaths;
|
|
164
|
+
private loaded;
|
|
165
|
+
constructor(options: DefaultResourceLoaderOptions);
|
|
166
|
+
getExtensions(): LoadExtensionsResult;
|
|
167
|
+
getSkills(): {
|
|
168
|
+
skills: Skill[];
|
|
169
|
+
diagnostics: ResourceDiagnostic[];
|
|
170
|
+
};
|
|
171
|
+
getPrompts(): {
|
|
172
|
+
prompts: PromptTemplate[];
|
|
173
|
+
diagnostics: ResourceDiagnostic[];
|
|
174
|
+
};
|
|
175
|
+
getThemes(): {
|
|
176
|
+
themes: Theme[];
|
|
177
|
+
diagnostics: ResourceDiagnostic[];
|
|
178
|
+
};
|
|
179
|
+
getAgentsFiles(): {
|
|
180
|
+
agentsFiles: Array<{
|
|
181
|
+
path: string;
|
|
182
|
+
content: string;
|
|
183
|
+
}>;
|
|
184
|
+
};
|
|
185
|
+
getSystemPrompt(): string | undefined;
|
|
186
|
+
getSystemPromptSource(): {
|
|
187
|
+
path: string;
|
|
188
|
+
} | undefined;
|
|
189
|
+
getAppendSystemPrompt(): string[];
|
|
190
|
+
getAppendSystemPromptSources(): Array<{
|
|
191
|
+
path: string;
|
|
192
|
+
}>;
|
|
193
|
+
extendResources(paths: ResourceExtensionPaths): void;
|
|
194
|
+
loadProjectTrustExtensions(): Promise<LoadExtensionsResult>;
|
|
195
|
+
reload(options?: ResourceLoaderReloadOptions): Promise<void>;
|
|
196
|
+
private loadCurrentExtensionSet;
|
|
197
|
+
private resolveExtensionLoadPath;
|
|
198
|
+
private loadFinalExtensionSet;
|
|
199
|
+
private addExtensionConflictDiagnostics;
|
|
200
|
+
private mapSkillPath;
|
|
201
|
+
private normalizeExtensionPaths;
|
|
202
|
+
private updateSkillsFromPaths;
|
|
203
|
+
private updatePromptsFromPaths;
|
|
204
|
+
private updateThemesFromPaths;
|
|
205
|
+
private applyExtensionSourceInfo;
|
|
206
|
+
private findSourceInfoForPath;
|
|
207
|
+
private getDefaultSourceInfoForPath;
|
|
208
|
+
private mergePaths;
|
|
209
|
+
private resolveResourcePath;
|
|
210
|
+
private loadThemes;
|
|
211
|
+
private loadThemesFromDir;
|
|
212
|
+
private loadThemeFromFile;
|
|
213
|
+
private loadExtensionFactories;
|
|
214
|
+
private dedupePrompts;
|
|
215
|
+
private dedupeThemes;
|
|
216
|
+
private discoverSystemPromptFile;
|
|
217
|
+
private discoverAppendSystemPromptFile;
|
|
218
|
+
private isUnderPath;
|
|
219
|
+
private detectExtensionConflicts;
|
|
220
|
+
}
|