@bastani/atomic 0.8.31-alpha.5 → 0.9.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -1
- package/dist/builtin/cursor/CHANGELOG.md +4 -1
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/cursor/src/proto/protobuf-codec-json.ts +44 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +271 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec-wire.ts +231 -0
- package/dist/builtin/cursor/src/proto/protobuf-codec.ts +5 -523
- package/dist/builtin/cursor/src/stream.ts +6 -70
- package/dist/builtin/cursor/src/transport-errors.ts +74 -0
- package/dist/builtin/cursor/src/transport-frame.ts +56 -0
- package/dist/builtin/cursor/src/transport-http2.ts +122 -0
- package/dist/builtin/cursor/src/transport-native-client.ts +161 -0
- package/dist/builtin/cursor/src/transport-run-stream.ts +188 -0
- package/dist/builtin/cursor/src/transport-timeouts.ts +87 -0
- package/dist/builtin/cursor/src/transport-types.ts +140 -0
- package/dist/builtin/cursor/src/transport.ts +24 -790
- package/dist/builtin/intercom/CHANGELOG.md +3 -0
- package/dist/builtin/intercom/broker/client.ts +0 -35
- package/dist/builtin/intercom/contact-supervisor-tool.ts +289 -0
- package/dist/builtin/intercom/index-heavy.ts +77 -1336
- package/dist/builtin/intercom/intercom-tool.ts +409 -0
- package/dist/builtin/intercom/intercom-utils.ts +401 -0
- package/dist/builtin/intercom/lifecycle.ts +133 -0
- package/dist/builtin/intercom/overlay.ts +96 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/intercom/subagent-relay.ts +137 -0
- package/dist/builtin/mcp/CHANGELOG.md +3 -0
- package/dist/builtin/mcp/config-write-utils.ts +104 -0
- package/dist/builtin/mcp/config.ts +4 -180
- package/dist/builtin/mcp/mcp-panel-renderer.ts +243 -0
- package/dist/builtin/mcp/mcp-panel-state.ts +227 -0
- package/dist/builtin/mcp/mcp-panel-types.ts +86 -0
- package/dist/builtin/mcp/mcp-panel.ts +145 -579
- package/dist/builtin/mcp/mcp-setup-panel.ts +4 -81
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/mcp/proxy-auth.ts +61 -0
- package/dist/builtin/mcp/proxy-call.ts +373 -0
- package/dist/builtin/mcp/proxy-connect.ts +58 -0
- package/dist/builtin/mcp/proxy-info-modes.ts +326 -0
- package/dist/builtin/mcp/proxy-modes.ts +3 -805
- package/dist/builtin/mcp/proxy-types.ts +3 -0
- package/dist/builtin/mcp/ui-server-http.ts +81 -0
- package/dist/builtin/mcp/ui-server.ts +2 -127
- package/dist/builtin/subagents/CHANGELOG.md +3 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/agents/agent-discovery.ts +127 -0
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +175 -0
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +310 -0
- package/dist/builtin/subagents/src/agents/agent-management.ts +3 -309
- package/dist/builtin/subagents/src/agents/agent-overrides.ts +397 -0
- package/dist/builtin/subagents/src/agents/agent-paths.ts +88 -0
- package/dist/builtin/subagents/src/agents/agent-types.ts +136 -0
- package/dist/builtin/subagents/src/agents/agents.ts +22 -895
- package/dist/builtin/subagents/src/agents/skills-paths.ts +333 -0
- package/dist/builtin/subagents/src/agents/skills.ts +3 -326
- package/dist/builtin/subagents/src/extension/index.ts +4 -118
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +13 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +401 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +131 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +213 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +84 -0
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +13 -795
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +215 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-finalize.ts +136 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-output.ts +105 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel-helpers.ts +112 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +159 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +127 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-state.ts +427 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +273 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +269 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +196 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-utils.ts +70 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +44 -2233
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-behavior.ts +75 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-component.ts +202 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-edit.ts +97 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-editor.ts +160 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-frame.ts +72 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-modes.ts +161 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-render-selectors.ts +203 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-selectors.ts +234 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-state.ts +103 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify-types.ts +29 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +4 -1328
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-clarify.ts +117 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-details.ts +35 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +194 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +183 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +185 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +229 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +194 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +94 -1043
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-control.ts +135 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +107 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-types.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +454 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +219 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-structured-retries.ts +77 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +34 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-utils.ts +56 -0
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +6 -1082
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +207 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +140 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +266 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +270 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +157 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +375 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +463 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +17 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +320 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +207 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +121 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +113 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +150 -2522
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +0 -16
- package/dist/builtin/subagents/src/runs/shared/nested-events-control.ts +167 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-core.ts +219 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-projection.ts +121 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-registry.ts +289 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events-sanitize.ts +201 -0
- package/dist/builtin/subagents/src/runs/shared/nested-events.ts +50 -935
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +0 -78
- package/dist/builtin/subagents/src/shared/types-async.ts +265 -0
- package/dist/builtin/subagents/src/shared/types-config.ts +125 -0
- package/dist/builtin/subagents/src/shared/types-depth.ts +121 -0
- package/dist/builtin/subagents/src/shared/types-output.ts +63 -0
- package/dist/builtin/subagents/src/shared/types-results.ts +318 -0
- package/dist/builtin/subagents/src/shared/types-runtime.ts +136 -0
- package/dist/builtin/subagents/src/shared/types.ts +10 -975
- package/dist/builtin/subagents/src/slash/slash-commands.ts +0 -12
- package/dist/builtin/subagents/src/tui/render-chain-graph.ts +247 -0
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +259 -0
- package/dist/builtin/subagents/src/tui/render-layout.ts +120 -0
- package/dist/builtin/subagents/src/tui/render-result-animation.ts +56 -0
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +154 -0
- package/dist/builtin/subagents/src/tui/render-result.ts +390 -0
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +83 -0
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +133 -0
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +166 -0
- package/dist/builtin/subagents/src/tui/render-widget.ts +273 -0
- package/dist/builtin/subagents/src/tui/render.ts +14 -1801
- package/dist/builtin/web-access/CHANGELOG.md +3 -0
- package/dist/builtin/web-access/content-tools.ts +348 -0
- package/dist/builtin/web-access/curator-page-assets/script-1.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-2.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-3.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-4.ts +400 -0
- package/dist/builtin/web-access/curator-page-assets/script-5.ts +398 -0
- package/dist/builtin/web-access/curator-page-assets/styles-1.ts +394 -0
- package/dist/builtin/web-access/curator-page-assets/styles-2.ts +394 -0
- package/dist/builtin/web-access/curator-page-assets/styles-3.ts +393 -0
- package/dist/builtin/web-access/curator-page.ts +17 -3180
- package/dist/builtin/web-access/curator-server-helpers.ts +115 -0
- package/dist/builtin/web-access/curator-server.ts +2 -113
- package/dist/builtin/web-access/exa-mcp.ts +218 -0
- package/dist/builtin/web-access/exa.ts +2 -207
- package/dist/builtin/web-access/extract-frames.ts +228 -0
- package/dist/builtin/web-access/extract.ts +13 -214
- package/dist/builtin/web-access/github-config.ts +156 -0
- package/dist/builtin/web-access/github-extract.ts +3 -154
- package/dist/builtin/web-access/index-heavy.ts +8 -1904
- package/dist/builtin/web-access/package.json +2 -1
- package/dist/builtin/web-access/web-search-activity.ts +102 -0
- package/dist/builtin/web-access/web-search-browser.ts +116 -0
- package/dist/builtin/web-access/web-search-command.ts +242 -0
- package/dist/builtin/web-access/web-search-config.ts +163 -0
- package/dist/builtin/web-access/web-search-curator.ts +214 -0
- package/dist/builtin/web-access/web-search-features.ts +165 -0
- package/dist/builtin/web-access/web-search-formatting.ts +117 -0
- package/dist/builtin/web-access/web-search-return.ts +136 -0
- package/dist/builtin/web-access/web-search-summary.ts +170 -0
- package/dist/builtin/web-access/web-search-tool.ts +290 -0
- package/dist/builtin/web-access/web-search-types.ts +50 -0
- package/dist/builtin/workflows/CHANGELOG.md +4 -1
- package/dist/builtin/workflows/builtin/deep-research-codebase-runner.ts +492 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +346 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +6 -822
- package/dist/builtin/workflows/builtin/goal-artifacts.ts +43 -0
- package/dist/builtin/workflows/builtin/goal-ledger.ts +54 -0
- package/dist/builtin/workflows/builtin/goal-prompts.ts +360 -0
- package/dist/builtin/workflows/builtin/goal-reducer.ts +141 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +56 -0
- package/dist/builtin/workflows/builtin/goal-review.ts +84 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +343 -0
- package/dist/builtin/workflows/builtin/goal-schemas.ts +60 -0
- package/dist/builtin/workflows/builtin/goal-types.ts +132 -0
- package/dist/builtin/workflows/builtin/goal.ts +4 -1160
- package/dist/builtin/workflows/builtin/open-claude-design-phases.ts +432 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +477 -0
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +312 -0
- package/dist/builtin/workflows/builtin/open-claude-design.ts +7 -1083
- package/dist/builtin/workflows/builtin/ralph-core.ts +408 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +123 -0
- package/dist/builtin/workflows/builtin/ralph-runner.ts +499 -0
- package/dist/builtin/workflows/builtin/ralph.ts +7 -979
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/detect-antipatterns-browser.js +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/engines/regex/detect-text.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/rules/checks.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/detector/shared/page.mjs +8 -1
- package/dist/builtin/workflows/skills/impeccable/scripts/live-accept.mjs +13 -15
- package/dist/builtin/workflows/skills/impeccable/scripts/live-manual-edit-evidence.mjs +2 -2
- package/dist/builtin/workflows/skills/impeccable/scripts/live-server.mjs +9 -0
- package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +186 -0
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +152 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +2 -167
- package/dist/builtin/workflows/src/extension/discovery-loaders.ts +115 -0
- package/dist/builtin/workflows/src/extension/discovery.ts +3 -117
- package/dist/builtin/workflows/src/extension/extension-factory.ts +120 -0
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +109 -0
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +270 -0
- package/dist/builtin/workflows/src/extension/index.ts +42 -4166
- package/dist/builtin/workflows/src/extension/public-types.ts +295 -0
- package/dist/builtin/workflows/src/extension/render-component.ts +14 -0
- package/dist/builtin/workflows/src/extension/runtime-direct.ts +96 -0
- package/dist/builtin/workflows/src/extension/runtime.ts +1 -92
- package/dist/builtin/workflows/src/extension/ui-surface.ts +286 -0
- package/dist/builtin/workflows/src/extension/wiring.ts +6 -475
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +111 -0
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +213 -0
- package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +81 -0
- package/dist/builtin/workflows/src/extension/workflow-command-utils.ts +181 -0
- package/dist/builtin/workflows/src/extension/workflow-policy.ts +15 -0
- package/dist/builtin/workflows/src/extension/workflow-ports.ts +41 -0
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +23 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +286 -0
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-stage-results.ts +264 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +181 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +175 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +205 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-helpers.ts +66 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +164 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-registration.ts +54 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +164 -0
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +102 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-abort.ts +431 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +232 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-child-helpers.ts +74 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-child-workflow.ts +158 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +167 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +450 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +233 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-exit-manager.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +368 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-inputs.ts +83 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +441 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-outputs.ts +160 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +274 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-run-finalizers.ts +122 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-run.ts +359 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +204 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +197 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +120 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +126 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +351 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +134 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +54 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-task-context.ts +132 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +293 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +109 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +19 -5354
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +219 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +500 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-messages.ts +129 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +53 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +146 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +55 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-structured-output.ts +82 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +141 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +13 -1355
- package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +453 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +442 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +2 -836
- package/dist/builtin/workflows/src/runs/shared/worktree-diff.ts +165 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +220 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +335 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +92 -0
- package/dist/builtin/workflows/src/runs/shared/worktree.ts +18 -791
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +365 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +425 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +236 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +354 -0
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +5 -598
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +428 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +9 -431
- package/dist/builtin/workflows/src/shared/store-factory.ts +16 -0
- package/dist/builtin/workflows/src/shared/store-internal.ts +219 -0
- package/dist/builtin/workflows/src/shared/store-prompt-methods.ts +219 -0
- package/dist/builtin/workflows/src/shared/store-public-types.ts +215 -0
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +223 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +305 -0
- package/dist/builtin/workflows/src/shared/store.ts +11 -1138
- package/dist/builtin/workflows/src/shared/workflow-failures-classifier.ts +266 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-contract.ts +75 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +477 -0
- package/dist/builtin/workflows/src/shared/workflow-failures-signals.ts +248 -0
- package/dist/builtin/workflows/src/shared/workflow-failures.ts +13 -1001
- package/dist/builtin/workflows/src/tui/chat-surface.ts +0 -66
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +45 -0
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +161 -0
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +333 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +336 -0
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +194 -0
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +306 -0
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +70 -0
- package/dist/builtin/workflows/src/tui/graph-view.ts +4 -1386
- package/dist/builtin/workflows/src/tui/inline-form-editor-text.ts +121 -0
- package/dist/builtin/workflows/src/tui/inline-form-editor.ts +11 -223
- package/dist/builtin/workflows/src/tui/inputs-picker-editing.ts +151 -0
- package/dist/builtin/workflows/src/tui/inputs-picker-input.ts +305 -0
- package/dist/builtin/workflows/src/tui/inputs-picker-render.ts +300 -0
- package/dist/builtin/workflows/src/tui/inputs-picker-types.ts +190 -0
- package/dist/builtin/workflows/src/tui/inputs-picker.ts +19 -997
- package/dist/builtin/workflows/src/tui/prompt-card-input.ts +226 -0
- package/dist/builtin/workflows/src/tui/prompt-card-render.ts +373 -0
- package/dist/builtin/workflows/src/tui/prompt-card-select.ts +116 -0
- package/dist/builtin/workflows/src/tui/prompt-card-state.ts +61 -0
- package/dist/builtin/workflows/src/tui/prompt-card-text.ts +129 -0
- package/dist/builtin/workflows/src/tui/prompt-card.ts +8 -910
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +315 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-custom-ui.ts +127 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +187 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +222 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +152 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +464 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-transcript.ts +242 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +151 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +141 -1777
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +85 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +1 -129
- package/dist/config-self-update.d.ts +21 -0
- package/dist/config-self-update.d.ts.map +1 -0
- package/dist/config-self-update.js +265 -0
- package/dist/config-self-update.js.map +1 -0
- package/dist/config.d.ts +3 -12
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -252
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-accessors.d.ts +3 -0
- package/dist/core/agent-session-accessors.d.ts.map +1 -0
- package/dist/core/agent-session-accessors.js +36 -0
- package/dist/core/agent-session-accessors.js.map +1 -0
- package/dist/core/agent-session-auto-compaction.d.ts +32 -0
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-auto-compaction.js +214 -0
- package/dist/core/agent-session-auto-compaction.js.map +1 -0
- package/dist/core/agent-session-bash.d.ts +30 -0
- package/dist/core/agent-session-bash.d.ts.map +1 -0
- package/dist/core/agent-session-bash.js +84 -0
- package/dist/core/agent-session-bash.js.map +1 -0
- package/dist/core/agent-session-compaction.d.ts +44 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-compaction.js +282 -0
- package/dist/core/agent-session-compaction.js.map +1 -0
- package/dist/core/agent-session-events.d.ts +65 -0
- package/dist/core/agent-session-events.d.ts.map +1 -0
- package/dist/core/agent-session-events.js +373 -0
- package/dist/core/agent-session-events.js.map +1 -0
- package/dist/core/agent-session-export.d.ts +42 -0
- package/dist/core/agent-session-export.d.ts.map +1 -0
- package/dist/core/agent-session-export.js +199 -0
- package/dist/core/agent-session-export.js.map +1 -0
- package/dist/core/agent-session-extension-bindings.d.ts +37 -0
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -0
- package/dist/core/agent-session-extension-bindings.js +231 -0
- package/dist/core/agent-session-extension-bindings.js.map +1 -0
- package/dist/core/agent-session-message-queue.d.ts +85 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -0
- package/dist/core/agent-session-message-queue.js +264 -0
- package/dist/core/agent-session-message-queue.js.map +1 -0
- package/dist/core/agent-session-methods.d.ts +302 -0
- package/dist/core/agent-session-methods.d.ts.map +1 -0
- package/dist/core/agent-session-methods.js +2 -0
- package/dist/core/agent-session-methods.js.map +1 -0
- package/dist/core/agent-session-models.d.ts +111 -0
- package/dist/core/agent-session-models.d.ts.map +1 -0
- package/dist/core/agent-session-models.js +368 -0
- package/dist/core/agent-session-models.js.map +1 -0
- package/dist/core/agent-session-prompt.d.ts +61 -0
- package/dist/core/agent-session-prompt.d.ts.map +1 -0
- package/dist/core/agent-session-prompt.js +330 -0
- package/dist/core/agent-session-prompt.js.map +1 -0
- package/dist/core/agent-session-retry.d.ts +62 -0
- package/dist/core/agent-session-retry.d.ts.map +1 -0
- package/dist/core/agent-session-retry.js +202 -0
- package/dist/core/agent-session-retry.js.map +1 -0
- package/dist/core/agent-session-skill-block.d.ts +13 -0
- package/dist/core/agent-session-skill-block.d.ts.map +1 -0
- package/dist/core/agent-session-skill-block.js +37 -0
- package/dist/core/agent-session-skill-block.js.map +1 -0
- package/dist/core/agent-session-state.d.ts +48 -0
- package/dist/core/agent-session-state.d.ts.map +1 -0
- package/dist/core/agent-session-state.js +129 -0
- package/dist/core/agent-session-state.js.map +1 -0
- package/dist/core/agent-session-tool-hooks.d.ts +7 -0
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -0
- package/dist/core/agent-session-tool-hooks.js +72 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -0
- package/dist/core/agent-session-tool-registry.d.ts +15 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -0
- package/dist/core/agent-session-tool-registry.js +151 -0
- package/dist/core/agent-session-tool-registry.js.map +1 -0
- package/dist/core/agent-session-tree.d.ts +46 -0
- package/dist/core/agent-session-tree.d.ts.map +1 -0
- package/dist/core/agent-session-tree.js +217 -0
- package/dist/core/agent-session-tree.js.map +1 -0
- package/dist/core/agent-session-types.d.ts +159 -0
- package/dist/core/agent-session-types.d.ts.map +1 -0
- package/dist/core/agent-session-types.js +41 -0
- package/dist/core/agent-session-types.js.map +1 -0
- package/dist/core/agent-session.d.ts +68 -688
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +26 -3152
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage-backends.d.ts +49 -0
- package/dist/core/auth-storage-backends.d.ts.map +1 -0
- package/dist/core/auth-storage-backends.js +185 -0
- package/dist/core/auth-storage-backends.js.map +1 -0
- package/dist/core/auth-storage.d.ts +2 -49
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -183
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/context-compaction-metrics.d.ts +16 -0
- package/dist/core/compaction/context-compaction-metrics.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-metrics.js +58 -0
- package/dist/core/compaction/context-compaction-metrics.js.map +1 -0
- package/dist/core/compaction/context-compaction-prompt.d.ts +9 -0
- package/dist/core/compaction/context-compaction-prompt.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-prompt.js +161 -0
- package/dist/core/compaction/context-compaction-prompt.js.map +1 -0
- package/dist/core/compaction/context-compaction-runner.d.ts +5 -0
- package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-runner.js +181 -0
- package/dist/core/compaction/context-compaction-runner.js.map +1 -0
- package/dist/core/compaction/context-compaction-strategy.d.ts +5 -0
- package/dist/core/compaction/context-compaction-strategy.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-strategy.js +27 -0
- package/dist/core/compaction/context-compaction-strategy.js.map +1 -0
- package/dist/core/compaction/context-compaction-types.d.ts +73 -0
- package/dist/core/compaction/context-compaction-types.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction-types.js +6 -0
- package/dist/core/compaction/context-compaction-types.js.map +1 -0
- package/dist/core/compaction/context-compaction.d.ts +9 -200
- package/dist/core/compaction/context-compaction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction.js +7 -1943
- package/dist/core/compaction/context-compaction.js.map +1 -1
- package/dist/core/compaction/context-deletion-application.d.ts +13 -0
- package/dist/core/compaction/context-deletion-application.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-application.js +259 -0
- package/dist/core/compaction/context-deletion-application.js.map +1 -0
- package/dist/core/compaction/context-deletion-store.d.ts +78 -0
- package/dist/core/compaction/context-deletion-store.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-store.js +162 -0
- package/dist/core/compaction/context-deletion-store.js.map +1 -0
- package/dist/core/compaction/context-deletion-targets.d.ts +40 -0
- package/dist/core/compaction/context-deletion-targets.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-targets.js +267 -0
- package/dist/core/compaction/context-deletion-targets.js.map +1 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts +187 -0
- package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-tool-definitions.js +98 -0
- package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -0
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts +19 -0
- package/dist/core/compaction/context-deletion-tool-helpers.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-tool-helpers.js +137 -0
- package/dist/core/compaction/context-deletion-tool-helpers.js.map +1 -0
- package/dist/core/compaction/context-deletion-tools.d.ts +4 -0
- package/dist/core/compaction/context-deletion-tools.d.ts.map +1 -0
- package/dist/core/compaction/context-deletion-tools.js +395 -0
- package/dist/core/compaction/context-deletion-tools.js.map +1 -0
- package/dist/core/compaction/context-transcript-analysis.d.ts +9 -0
- package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -0
- package/dist/core/compaction/context-transcript-analysis.js +234 -0
- package/dist/core/compaction/context-transcript-analysis.js.map +1 -0
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template-js/data-tree.js +287 -0
- package/dist/core/export-html/template-js/entries-navigation.js +424 -0
- package/dist/core/export-html/template-js/initialization.js +312 -0
- package/dist/core/export-html/template-js/message-tools.js +415 -0
- package/dist/core/export-html/template-js/tree-filter-render.js +421 -0
- package/dist/core/export-html/template-script.d.ts +3 -0
- package/dist/core/export-html/template-script.d.ts.map +1 -0
- package/dist/core/export-html/template-script.js +13 -0
- package/dist/core/export-html/template-script.js.map +1 -0
- package/dist/core/export-html/template.js +3 -1
- package/dist/core/extensions/agent-events.d.ts +159 -0
- package/dist/core/extensions/agent-events.d.ts.map +1 -0
- package/dist/core/extensions/agent-events.js +2 -0
- package/dist/core/extensions/agent-events.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +189 -0
- package/dist/core/extensions/api-types.d.ts.map +1 -0
- package/dist/core/extensions/api-types.js +2 -0
- package/dist/core/extensions/api-types.js.map +1 -0
- package/dist/core/extensions/command-types.d.ts +14 -0
- package/dist/core/extensions/command-types.d.ts.map +1 -0
- package/dist/core/extensions/command-types.js +2 -0
- package/dist/core/extensions/command-types.js.map +1 -0
- package/dist/core/extensions/context-types.d.ts +130 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -0
- package/dist/core/extensions/context-types.js +2 -0
- package/dist/core/extensions/context-types.js.map +1 -0
- package/dist/core/extensions/event-results.d.ts +61 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -0
- package/dist/core/extensions/event-results.js +2 -0
- package/dist/core/extensions/event-results.js.map +1 -0
- package/dist/core/extensions/event-types.d.ts +6 -0
- package/dist/core/extensions/event-types.d.ts.map +1 -0
- package/dist/core/extensions/event-types.js +2 -0
- package/dist/core/extensions/event-types.js.map +1 -0
- package/dist/core/extensions/loader-api.d.ts +10 -0
- package/dist/core/extensions/loader-api.d.ts.map +1 -0
- package/dist/core/extensions/loader-api.js +143 -0
- package/dist/core/extensions/loader-api.js.map +1 -0
- package/dist/core/extensions/loader-core.d.ts +12 -0
- package/dist/core/extensions/loader-core.d.ts.map +1 -0
- package/dist/core/extensions/loader-core.js +91 -0
- package/dist/core/extensions/loader-core.js.map +1 -0
- package/dist/core/extensions/loader-discovery.d.ts +7 -0
- package/dist/core/extensions/loader-discovery.d.ts.map +1 -0
- package/dist/core/extensions/loader-discovery.js +139 -0
- package/dist/core/extensions/loader-discovery.js.map +1 -0
- package/dist/core/extensions/loader-resources.d.ts +11 -0
- package/dist/core/extensions/loader-resources.d.ts.map +1 -0
- package/dist/core/extensions/loader-resources.js +10 -0
- package/dist/core/extensions/loader-resources.js.map +1 -0
- package/dist/core/extensions/loader-runtime.d.ts +7 -0
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -0
- package/dist/core/extensions/loader-runtime.js +51 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -0
- package/dist/core/extensions/loader-virtual-modules.d.ts +3 -0
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -0
- package/dist/core/extensions/loader-virtual-modules.js +92 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -0
- package/dist/core/extensions/loader.d.ts +4 -28
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -542
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +34 -0
- package/dist/core/extensions/message-types.d.ts.map +1 -0
- package/dist/core/extensions/message-types.js +2 -0
- package/dist/core/extensions/message-types.js.map +1 -0
- package/dist/core/extensions/provider-types.d.ts +71 -0
- package/dist/core/extensions/provider-types.d.ts.map +1 -0
- package/dist/core/extensions/provider-types.js +2 -0
- package/dist/core/extensions/provider-types.js.map +1 -0
- package/dist/core/extensions/runner-context.d.ts +42 -0
- package/dist/core/extensions/runner-context.d.ts.map +1 -0
- package/dist/core/extensions/runner-context.js +112 -0
- package/dist/core/extensions/runner-context.js.map +1 -0
- package/dist/core/extensions/runner-events.d.ts +47 -0
- package/dist/core/extensions/runner-events.d.ts.map +1 -0
- package/dist/core/extensions/runner-events.js +280 -0
- package/dist/core/extensions/runner-events.js.map +1 -0
- package/dist/core/extensions/runner-handlers.d.ts +32 -0
- package/dist/core/extensions/runner-handlers.d.ts.map +1 -0
- package/dist/core/extensions/runner-handlers.js +2 -0
- package/dist/core/extensions/runner-handlers.js.map +1 -0
- package/dist/core/extensions/runner-project-trust.d.ts +6 -0
- package/dist/core/extensions/runner-project-trust.d.ts.map +1 -0
- package/dist/core/extensions/runner-project-trust.js +27 -0
- package/dist/core/extensions/runner-project-trust.js.map +1 -0
- package/dist/core/extensions/runner-registries.d.ts +8 -0
- package/dist/core/extensions/runner-registries.d.ts.map +1 -0
- package/dist/core/extensions/runner-registries.js +76 -0
- package/dist/core/extensions/runner-registries.js.map +1 -0
- package/dist/core/extensions/runner-shortcuts.d.ts +10 -0
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -0
- package/dist/core/extensions/runner-shortcuts.js +71 -0
- package/dist/core/extensions/runner-shortcuts.js.map +1 -0
- package/dist/core/extensions/runner-ui.d.ts +3 -0
- package/dist/core/extensions/runner-ui.d.ts.map +1 -0
- package/dist/core/extensions/runner-ui.js +50 -0
- package/dist/core/extensions/runner-ui.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +7 -74
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +67 -673
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +179 -0
- package/dist/core/extensions/runtime-types.d.ts.map +1 -0
- package/dist/core/extensions/runtime-types.js +2 -0
- package/dist/core/extensions/runtime-types.js.map +1 -0
- package/dist/core/extensions/session-events.d.ts +89 -0
- package/dist/core/extensions/session-events.d.ts.map +1 -0
- package/dist/core/extensions/session-events.js +2 -0
- package/dist/core/extensions/session-events.js.map +1 -0
- package/dist/core/extensions/tool-events.d.ts +127 -0
- package/dist/core/extensions/tool-events.d.ts.map +1 -0
- package/dist/core/extensions/tool-events.js +26 -0
- package/dist/core/extensions/tool-events.js.map +1 -0
- package/dist/core/extensions/tool-types.d.ts +100 -0
- package/dist/core/extensions/tool-types.d.ts.map +1 -0
- package/dist/core/extensions/tool-types.js +11 -0
- package/dist/core/extensions/tool-types.js.map +1 -0
- package/dist/core/extensions/types.d.ts +20 -1288
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +4 -34
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +200 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -0
- package/dist/core/extensions/ui-types.js +2 -0
- package/dist/core/extensions/ui-types.js.map +1 -0
- package/dist/core/model-registry-auth.d.ts +7 -0
- package/dist/core/model-registry-auth.d.ts.map +1 -0
- package/dist/core/model-registry-auth.js +64 -0
- package/dist/core/model-registry-auth.js.map +1 -0
- package/dist/core/model-registry-builtins.d.ts +9 -0
- package/dist/core/model-registry-builtins.d.ts.map +1 -0
- package/dist/core/model-registry-builtins.js +120 -0
- package/dist/core/model-registry-builtins.js.map +1 -0
- package/dist/core/model-registry-custom-loader.d.ts +3 -0
- package/dist/core/model-registry-custom-loader.d.ts.map +1 -0
- package/dist/core/model-registry-custom-loader.js +213 -0
- package/dist/core/model-registry-custom-loader.js.map +1 -0
- package/dist/core/model-registry-dynamic.d.ts +6 -0
- package/dist/core/model-registry-dynamic.d.ts.map +1 -0
- package/dist/core/model-registry-dynamic.js +155 -0
- package/dist/core/model-registry-dynamic.js.map +1 -0
- package/dist/core/model-registry-loader.d.ts +4 -0
- package/dist/core/model-registry-loader.d.ts.map +1 -0
- package/dist/core/model-registry-loader.js +20 -0
- package/dist/core/model-registry-loader.js.map +1 -0
- package/dist/core/model-registry-schemas.d.ts +1084 -0
- package/dist/core/model-registry-schemas.d.ts.map +1 -0
- package/dist/core/model-registry-schemas.js +161 -0
- package/dist/core/model-registry-schemas.js.map +1 -0
- package/dist/core/model-registry-types.d.ts +74 -0
- package/dist/core/model-registry-types.d.ts.map +1 -0
- package/dist/core/model-registry-types.js +2 -0
- package/dist/core/model-registry-types.js.map +1 -0
- package/dist/core/model-registry.d.ts +3 -76
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +24 -733
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts +19 -0
- package/dist/core/model-resolver-cli.d.ts.map +1 -0
- package/dist/core/model-resolver-cli.js +118 -0
- package/dist/core/model-resolver-cli.js.map +1 -0
- package/dist/core/model-resolver-defaults.d.ts +5 -0
- package/dist/core/model-resolver-defaults.d.ts.map +1 -0
- package/dist/core/model-resolver-defaults.js +47 -0
- package/dist/core/model-resolver-defaults.js.map +1 -0
- package/dist/core/model-resolver-initial.d.ts +31 -0
- package/dist/core/model-resolver-initial.d.ts.map +1 -0
- package/dist/core/model-resolver-initial.js +116 -0
- package/dist/core/model-resolver-initial.js.map +1 -0
- package/dist/core/model-resolver-patterns.d.ts +26 -0
- package/dist/core/model-resolver-patterns.d.ts.map +1 -0
- package/dist/core/model-resolver-patterns.js +139 -0
- package/dist/core/model-resolver-patterns.js.map +1 -0
- package/dist/core/model-resolver-scope.d.ts +15 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -0
- package/dist/core/model-resolver-scope.js +66 -0
- package/dist/core/model-resolver-scope.js.map +1 -0
- package/dist/core/model-resolver-types.d.ts +29 -0
- package/dist/core/model-resolver-types.d.ts.map +1 -0
- package/dist/core/model-resolver-types.js +2 -0
- package/dist/core/model-resolver-types.js.map +1 -0
- package/dist/core/model-resolver.d.ts +6 -107
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +5 -549
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager-auto-resources.d.ts +5 -0
- package/dist/core/package-manager-auto-resources.d.ts.map +1 -0
- package/dist/core/package-manager-auto-resources.js +109 -0
- package/dist/core/package-manager-auto-resources.js.map +1 -0
- package/dist/core/package-manager-command.d.ts +11 -0
- package/dist/core/package-manager-command.d.ts.map +1 -0
- package/dist/core/package-manager-command.js +102 -0
- package/dist/core/package-manager-command.js.map +1 -0
- package/dist/core/package-manager-constants.d.ts +4 -0
- package/dist/core/package-manager-constants.d.ts.map +1 -0
- package/dist/core/package-manager-constants.js +4 -0
- package/dist/core/package-manager-constants.js.map +1 -0
- package/dist/core/package-manager-env.d.ts +4 -0
- package/dist/core/package-manager-env.d.ts.map +1 -0
- package/dist/core/package-manager-env.js +40 -0
- package/dist/core/package-manager-env.js.map +1 -0
- package/dist/core/package-manager-git.d.ts +10 -0
- package/dist/core/package-manager-git.d.ts.map +1 -0
- package/dist/core/package-manager-git.js +271 -0
- package/dist/core/package-manager-git.js.map +1 -0
- package/dist/core/package-manager-manifest.d.ts +7 -0
- package/dist/core/package-manager-manifest.d.ts.map +1 -0
- package/dist/core/package-manager-manifest.js +45 -0
- package/dist/core/package-manager-manifest.js.map +1 -0
- package/dist/core/package-manager-npm.d.ts +25 -0
- package/dist/core/package-manager-npm.d.ts.map +1 -0
- package/dist/core/package-manager-npm.js +252 -0
- package/dist/core/package-manager-npm.js.map +1 -0
- package/dist/core/package-manager-operations.d.ts +11 -0
- package/dist/core/package-manager-operations.d.ts.map +1 -0
- package/dist/core/package-manager-operations.js +196 -0
- package/dist/core/package-manager-operations.js.map +1 -0
- package/dist/core/package-manager-paths.d.ts +14 -0
- package/dist/core/package-manager-paths.d.ts.map +1 -0
- package/dist/core/package-manager-paths.js +61 -0
- package/dist/core/package-manager-paths.js.map +1 -0
- package/dist/core/package-manager-progress.d.ts +4 -0
- package/dist/core/package-manager-progress.d.ts.map +1 -0
- package/dist/core/package-manager-progress.js +16 -0
- package/dist/core/package-manager-progress.js.map +1 -0
- package/dist/core/package-manager-resolver.d.ts +5 -0
- package/dist/core/package-manager-resolver.d.ts.map +1 -0
- package/dist/core/package-manager-resolver.js +149 -0
- package/dist/core/package-manager-resolver.js.map +1 -0
- package/dist/core/package-manager-resource-accumulator.d.ts +6 -0
- package/dist/core/package-manager-resource-accumulator.d.ts.map +1 -0
- package/dist/core/package-manager-resource-accumulator.js +67 -0
- package/dist/core/package-manager-resource-accumulator.js.map +1 -0
- package/dist/core/package-manager-resource-collector.d.ts +5 -0
- package/dist/core/package-manager-resource-collector.d.ts.map +1 -0
- package/dist/core/package-manager-resource-collector.js +148 -0
- package/dist/core/package-manager-resource-collector.js.map +1 -0
- package/dist/core/package-manager-resource-files.d.ts +14 -0
- package/dist/core/package-manager-resource-files.d.ts.map +1 -0
- package/dist/core/package-manager-resource-files.js +265 -0
- package/dist/core/package-manager-resource-files.js.map +1 -0
- package/dist/core/package-manager-resource-patterns.d.ts +12 -0
- package/dist/core/package-manager-resource-patterns.d.ts.map +1 -0
- package/dist/core/package-manager-resource-patterns.js +136 -0
- package/dist/core/package-manager-resource-patterns.js.map +1 -0
- package/dist/core/package-manager-settings.d.ts +10 -0
- package/dist/core/package-manager-settings.d.ts.map +1 -0
- package/dist/core/package-manager-settings.js +91 -0
- package/dist/core/package-manager-settings.js.map +1 -0
- package/dist/core/package-manager-source.d.ts +21 -0
- package/dist/core/package-manager-source.d.ts.map +1 -0
- package/dist/core/package-manager-source.js +146 -0
- package/dist/core/package-manager-source.js.map +1 -0
- package/dist/core/package-manager-types.d.ts +169 -0
- package/dist/core/package-manager-types.d.ts.map +1 -0
- package/dist/core/package-manager-types.js +9 -0
- package/dist/core/package-manager-types.js.map +1 -0
- package/dist/core/package-manager.d.ts +9 -174
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +56 -2100
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader-assets.d.ts +6 -0
- package/dist/core/resource-loader-assets.d.ts.map +1 -0
- package/dist/core/resource-loader-assets.js +209 -0
- package/dist/core/resource-loader-assets.js.map +1 -0
- package/dist/core/resource-loader-context-files.d.ts +10 -0
- package/dist/core/resource-loader-context-files.d.ts.map +1 -0
- package/dist/core/resource-loader-context-files.js +74 -0
- package/dist/core/resource-loader-context-files.js.map +1 -0
- package/dist/core/resource-loader-core.d.ts +82 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -0
- package/dist/core/resource-loader-core.js +168 -0
- package/dist/core/resource-loader-core.js.map +1 -0
- package/dist/core/resource-loader-discovery.d.ts +4 -0
- package/dist/core/resource-loader-discovery.d.ts.map +1 -0
- package/dist/core/resource-loader-discovery.js +28 -0
- package/dist/core/resource-loader-discovery.js.map +1 -0
- package/dist/core/resource-loader-extensions.d.ts +13 -0
- package/dist/core/resource-loader-extensions.d.ts.map +1 -0
- package/dist/core/resource-loader-extensions.js +110 -0
- package/dist/core/resource-loader-extensions.js.map +1 -0
- package/dist/core/resource-loader-helpers.d.ts +4 -0
- package/dist/core/resource-loader-helpers.d.ts.map +1 -0
- package/dist/core/resource-loader-helpers.js +23 -0
- package/dist/core/resource-loader-helpers.js.map +1 -0
- package/dist/core/resource-loader-internals.d.ts +96 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -0
- package/dist/core/resource-loader-internals.js +4 -0
- package/dist/core/resource-loader-internals.js.map +1 -0
- package/dist/core/resource-loader-package-resources.d.ts +31 -0
- package/dist/core/resource-loader-package-resources.d.ts.map +1 -0
- package/dist/core/resource-loader-package-resources.js +112 -0
- package/dist/core/resource-loader-package-resources.js.map +1 -0
- package/dist/core/resource-loader-paths.d.ts +4 -0
- package/dist/core/resource-loader-paths.d.ts.map +1 -0
- package/dist/core/resource-loader-paths.js +22 -0
- package/dist/core/resource-loader-paths.js.map +1 -0
- package/dist/core/resource-loader-reload.d.ts +6 -0
- package/dist/core/resource-loader-reload.d.ts.map +1 -0
- package/dist/core/resource-loader-reload.js +226 -0
- package/dist/core/resource-loader-reload.js.map +1 -0
- package/dist/core/resource-loader-source-info.d.ts +9 -0
- package/dist/core/resource-loader-source-info.d.ts.map +1 -0
- package/dist/core/resource-loader-source-info.js +101 -0
- package/dist/core/resource-loader-source-info.js.map +1 -0
- package/dist/core/resource-loader-types.d.ts +130 -0
- package/dist/core/resource-loader-types.d.ts.map +1 -0
- package/dist/core/resource-loader-types.js +2 -0
- package/dist/core/resource-loader-types.js.map +1 -0
- package/dist/core/resource-loader.d.ts +3 -242
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +2 -976
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +7 -0
- package/dist/core/sdk-exports.d.ts.map +1 -0
- package/dist/core/sdk-exports.js +5 -0
- package/dist/core/sdk-exports.js.map +1 -0
- package/dist/core/sdk-types.d.ts +86 -0
- package/dist/core/sdk-types.d.ts.map +1 -0
- package/dist/core/sdk-types.js +2 -0
- package/dist/core/sdk-types.js.map +1 -0
- package/dist/core/sdk.d.ts +3 -91
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +2 -6
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-archive.d.ts +27 -0
- package/dist/core/session-manager-archive.d.ts.map +1 -0
- package/dist/core/session-manager-archive.js +114 -0
- package/dist/core/session-manager-archive.js.map +1 -0
- package/dist/core/session-manager-core.d.ts +104 -0
- package/dist/core/session-manager-core.d.ts.map +1 -0
- package/dist/core/session-manager-core.js +346 -0
- package/dist/core/session-manager-core.js.map +1 -0
- package/dist/core/session-manager-entries.d.ts +38 -0
- package/dist/core/session-manager-entries.d.ts.map +1 -0
- package/dist/core/session-manager-entries.js +124 -0
- package/dist/core/session-manager-entries.js.map +1 -0
- package/dist/core/session-manager-history.d.ts +38 -0
- package/dist/core/session-manager-history.d.ts.map +1 -0
- package/dist/core/session-manager-history.js +378 -0
- package/dist/core/session-manager-history.js.map +1 -0
- package/dist/core/session-manager-list.d.ts +5 -0
- package/dist/core/session-manager-list.d.ts.map +1 -0
- package/dist/core/session-manager-list.js +196 -0
- package/dist/core/session-manager-list.js.map +1 -0
- package/dist/core/session-manager-migrations.d.ts +11 -0
- package/dist/core/session-manager-migrations.d.ts.map +1 -0
- package/dist/core/session-manager-migrations.js +80 -0
- package/dist/core/session-manager-migrations.js.map +1 -0
- package/dist/core/session-manager-paths.d.ts +7 -0
- package/dist/core/session-manager-paths.d.ts.map +1 -0
- package/dist/core/session-manager-paths.js +22 -0
- package/dist/core/session-manager-paths.js.map +1 -0
- package/dist/core/session-manager-storage.d.ts +15 -0
- package/dist/core/session-manager-storage.d.ts.map +1 -0
- package/dist/core/session-manager-storage.js +127 -0
- package/dist/core/session-manager-storage.js.map +1 -0
- package/dist/core/session-manager-types.d.ts +172 -0
- package/dist/core/session-manager-types.d.ts.map +1 -0
- package/dist/core/session-manager-types.js +2 -0
- package/dist/core/session-manager-types.js.map +1 -0
- package/dist/core/session-manager-validation.d.ts +7 -0
- package/dist/core/session-manager-validation.d.ts.map +1 -0
- package/dist/core/session-manager-validation.js +34 -0
- package/dist/core/session-manager-validation.js.map +1 -0
- package/dist/core/session-manager.d.ts +8 -390
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +7 -1418
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +65 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -0
- package/dist/core/settings-manager-basic-accessors.js +253 -0
- package/dist/core/settings-manager-basic-accessors.js.map +1 -0
- package/dist/core/settings-manager-core.d.ts +57 -0
- package/dist/core/settings-manager-core.d.ts.map +1 -0
- package/dist/core/settings-manager-core.js +387 -0
- package/dist/core/settings-manager-core.js.map +1 -0
- package/dist/core/settings-manager-internals.d.ts +13 -0
- package/dist/core/settings-manager-internals.d.ts.map +1 -0
- package/dist/core/settings-manager-internals.js +4 -0
- package/dist/core/settings-manager-internals.js.map +1 -0
- package/dist/core/settings-manager-resource-accessors.d.ts +43 -0
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -0
- package/dist/core/settings-manager-resource-accessors.js +172 -0
- package/dist/core/settings-manager-resource-accessors.js.map +1 -0
- package/dist/core/settings-manager-ui-accessors.d.ts +44 -0
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -0
- package/dist/core/settings-manager-ui-accessors.js +208 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -0
- package/dist/core/settings-manager.d.ts +6 -321
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +5 -1060
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-merge.d.ts +4 -0
- package/dist/core/settings-merge.d.ts.map +1 -0
- package/dist/core/settings-merge.js +26 -0
- package/dist/core/settings-merge.js.map +1 -0
- package/dist/core/settings-storage.d.ts +20 -0
- package/dist/core/settings-storage.d.ts.map +1 -0
- package/dist/core/settings-storage.js +100 -0
- package/dist/core/settings-storage.js.map +1 -0
- package/dist/core/settings-types.d.ts +123 -0
- package/dist/core/settings-types.d.ts.map +1 -0
- package/dist/core/settings-types.js +2 -0
- package/dist/core/settings-types.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +7 -0
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash-policy-compile.d.ts +5 -0
- package/dist/core/tools/bash-policy-compile.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-compile.js +241 -0
- package/dist/core/tools/bash-policy-compile.js.map +1 -0
- package/dist/core/tools/bash-policy-evaluate.d.ts +3 -0
- package/dist/core/tools/bash-policy-evaluate.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-evaluate.js +92 -0
- package/dist/core/tools/bash-policy-evaluate.js.map +1 -0
- package/dist/core/tools/bash-policy-format.d.ts +5 -0
- package/dist/core/tools/bash-policy-format.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-format.js +49 -0
- package/dist/core/tools/bash-policy-format.js.map +1 -0
- package/dist/core/tools/bash-policy-parser.d.ts +4 -0
- package/dist/core/tools/bash-policy-parser.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-parser.js +155 -0
- package/dist/core/tools/bash-policy-parser.js.map +1 -0
- package/dist/core/tools/bash-policy-segment.d.ts +3 -0
- package/dist/core/tools/bash-policy-segment.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-segment.js +275 -0
- package/dist/core/tools/bash-policy-segment.js.map +1 -0
- package/dist/core/tools/bash-policy-shell.d.ts +11 -0
- package/dist/core/tools/bash-policy-shell.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-shell.js +267 -0
- package/dist/core/tools/bash-policy-shell.js.map +1 -0
- package/dist/core/tools/bash-policy-types.d.ts +146 -0
- package/dist/core/tools/bash-policy-types.d.ts.map +1 -0
- package/dist/core/tools/bash-policy-types.js +2 -0
- package/dist/core/tools/bash-policy-types.js.map +1 -0
- package/dist/core/tools/bash-policy.d.ts +5 -61
- package/dist/core/tools/bash-policy.d.ts.map +1 -1
- package/dist/core/tools/bash-policy.js +4 -1068
- package/dist/core/tools/bash-policy.js.map +1 -1
- package/dist/core/tools/todos-execute.d.ts +5 -0
- package/dist/core/tools/todos-execute.d.ts.map +1 -0
- package/dist/core/tools/todos-execute.js +200 -0
- package/dist/core/tools/todos-execute.js.map +1 -0
- package/dist/core/tools/todos-locks.d.ts +4 -0
- package/dist/core/tools/todos-locks.d.ts.map +1 -0
- package/dist/core/tools/todos-locks.js +80 -0
- package/dist/core/tools/todos-locks.js.map +1 -0
- package/dist/core/tools/todos-model.d.ts +21 -0
- package/dist/core/tools/todos-model.d.ts.map +1 -0
- package/dist/core/tools/todos-model.js +71 -0
- package/dist/core/tools/todos-model.js.map +1 -0
- package/dist/core/tools/todos-mutations.d.ts +6 -0
- package/dist/core/tools/todos-mutations.d.ts.map +1 -0
- package/dist/core/tools/todos-mutations.js +85 -0
- package/dist/core/tools/todos-mutations.js.map +1 -0
- package/dist/core/tools/todos-paths.d.ts +5 -0
- package/dist/core/tools/todos-paths.d.ts.map +1 -0
- package/dist/core/tools/todos-paths.js +25 -0
- package/dist/core/tools/todos-paths.js.map +1 -0
- package/dist/core/tools/todos-render.d.ts +10 -0
- package/dist/core/tools/todos-render.d.ts.map +1 -0
- package/dist/core/tools/todos-render.js +159 -0
- package/dist/core/tools/todos-render.js.map +1 -0
- package/dist/core/tools/todos-storage.d.ts +9 -0
- package/dist/core/tools/todos-storage.d.ts.map +1 -0
- package/dist/core/tools/todos-storage.js +183 -0
- package/dist/core/tools/todos-storage.js.map +1 -0
- package/dist/core/tools/todos-types.d.ts +46 -0
- package/dist/core/tools/todos-types.d.ts.map +1 -0
- package/dist/core/tools/todos-types.js +27 -0
- package/dist/core/tools/todos-types.js.map +1 -0
- package/dist/core/tools/todos.d.ts +12 -32
- package/dist/core/tools/todos.d.ts.map +1 -1
- package/dist/core/tools/todos.js +7 -893
- package/dist/core/tools/todos.js.map +1 -1
- package/dist/index-extensions.d.ts +3 -0
- package/dist/index-extensions.d.ts.map +1 -0
- package/dist/index-extensions.js +2 -0
- package/dist/index-extensions.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main-app-mode.d.ts +15 -0
- package/dist/main-app-mode.d.ts.map +1 -0
- package/dist/main-app-mode.js +51 -0
- package/dist/main-app-mode.js.map +1 -0
- package/dist/main-session-options.d.ts +12 -0
- package/dist/main-session-options.d.ts.map +1 -0
- package/dist/main-session-options.js +87 -0
- package/dist/main-session-options.js.map +1 -0
- package/dist/main-session.d.ts +9 -0
- package/dist/main-session.d.ts.map +1 -0
- package/dist/main-session.js +188 -0
- package/dist/main-session.js.map +1 -0
- package/dist/main-stdio.d.ts +12 -0
- package/dist/main-stdio.d.ts.map +1 -0
- package/dist/main-stdio.js +68 -0
- package/dist/main-stdio.js.map +1 -0
- package/dist/main.d.ts +2 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +11 -388
- package/dist/main.js.map +1 -1
- package/dist/migrations-config-values.d.ts +9 -0
- package/dist/migrations-config-values.d.ts.map +1 -0
- package/dist/migrations-config-values.js +298 -0
- package/dist/migrations-config-values.js.map +1 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -296
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +0 -7
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +9 -0
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-actions.js +244 -0
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts +18 -0
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-editor.js +165 -0
- package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-events.js +200 -0
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +13 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js +185 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +13 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.js +101 -0
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +53 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.js +42 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +63 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-types.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts +28 -0
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -0
- package/dist/modes/interactive/components/chat-session-host-utils.js +103 -0
- package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts +6 -129
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +50 -1022
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts +65 -0
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector-list.js +458 -0
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +3 -58
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +2 -457
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts +10 -0
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-delete.js +40 -0
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-header.d.ts +33 -0
- package/dist/modes/interactive/components/session-selector-header.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-header.js +117 -0
- package/dist/modes/interactive/components/session-selector-header.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-list.d.ts +49 -0
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-list.js +307 -0
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts +25 -0
- package/dist/modes/interactive/components/session-selector-tree.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-tree.js +53 -0
- package/dist/modes/interactive/components/session-selector-tree.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-types.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-types.js +2 -0
- package/dist/modes/interactive/components/session-selector-types.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-utils.d.ts +4 -0
- package/dist/modes/interactive/components/session-selector-utils.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-utils.js +37 -0
- package/dist/modes/interactive/components/session-selector-utils.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +3 -49
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +5 -542
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts +3 -0
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js +84 -0
- package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-items.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-items.js +211 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-options.d.ts +6 -0
- package/dist/modes/interactive/components/settings-selector-options.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-options.js +14 -0
- package/dist/modes/interactive/components/settings-selector-options.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +44 -0
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-submenus.js +228 -0
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts +67 -0
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector-types.js +2 -0
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +2 -63
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +5 -538
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +21 -0
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-component.js +80 -0
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-content.d.ts +8 -0
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-content.js +263 -0
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-help.d.ts +16 -0
- package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-help.js +103 -0
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts +16 -0
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-label-input.js +46 -0
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-list.d.ts +33 -0
- package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-list.js +336 -0
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-model.d.ts +7 -0
- package/dist/modes/interactive/components/tree-selector-model.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-model.js +358 -0
- package/dist/modes/interactive/components/tree-selector-model.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-types.d.ts +57 -0
- package/dist/modes/interactive/components/tree-selector-types.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-types.js +6 -0
- package/dist/modes/interactive/components/tree-selector-types.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector-viewport.d.ts +10 -0
- package/dist/modes/interactive/components/tree-selector-viewport.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector-viewport.js +32 -0
- package/dist/modes/interactive/components/tree-selector-viewport.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +2 -88
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +1 -1200
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.d.ts +2 -0
- package/dist/modes/interactive/interactive-agent-events.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-agent-events.js +370 -0
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-login.d.ts +2 -0
- package/dist/modes/interactive/interactive-auth-login.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-auth-login.js +214 -0
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts +2 -0
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-auth-routing.js +128 -0
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -0
- package/dist/modes/interactive/interactive-autocomplete.d.ts +2 -0
- package/dist/modes/interactive/interactive-autocomplete.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-autocomplete.js +140 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -0
- package/dist/modes/interactive/interactive-bash-compact.d.ts +2 -0
- package/dist/modes/interactive/interactive-bash-compact.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-bash-compact.js +112 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -0
- package/dist/modes/interactive/interactive-editor-actions.d.ts +2 -0
- package/dist/modes/interactive/interactive-editor-actions.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-editor-actions.js +131 -0
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-context.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-context.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-context.js +159 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js +208 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-dialogs.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-dialogs.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js +162 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-runtime.js +179 -0
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -0
- package/dist/modes/interactive/interactive-extension-widgets.d.ts +2 -0
- package/dist/modes/interactive/interactive-extension-widgets.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-extension-widgets.js +113 -0
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts +2 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js +186 -0
- package/dist/modes/interactive/interactive-hotkeys-debug.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.d.ts +2 -0
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.js +275 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts +103 -0
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-base.js +130 -0
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-deps.d.ts +81 -0
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-deps.js +74 -0
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +21 -0
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-helpers.js +77 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts +313 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-surface.js +2 -0
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts +29 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode-types.js +2 -0
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +30 -404
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +29 -5260
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.d.ts +2 -0
- package/dist/modes/interactive/interactive-model-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-model-routing.js +269 -0
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -0
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts +2 -0
- package/dist/modes/interactive/interactive-process-lifecycle.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-process-lifecycle.js +189 -0
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -0
- package/dist/modes/interactive/interactive-queueing.d.ts +2 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-queueing.js +163 -0
- package/dist/modes/interactive/interactive-queueing.js.map +1 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts +2 -0
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-render-chat.js +170 -0
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -0
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts +2 -0
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resource-disclosure.js +101 -0
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -0
- package/dist/modes/interactive/interactive-resource-paths.d.ts +2 -0
- package/dist/modes/interactive/interactive-resource-paths.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resource-paths.js +228 -0
- package/dist/modes/interactive/interactive-resource-paths.js.map +1 -0
- package/dist/modes/interactive/interactive-resource-rendering.d.ts +2 -0
- package/dist/modes/interactive/interactive-resource-rendering.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resource-rendering.js +181 -0
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -0
- package/dist/modes/interactive/interactive-selectors.d.ts +2 -0
- package/dist/modes/interactive/interactive-selectors.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-selectors.js +198 -0
- package/dist/modes/interactive/interactive-selectors.js.map +1 -0
- package/dist/modes/interactive/interactive-session-routing.d.ts +2 -0
- package/dist/modes/interactive/interactive-session-routing.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-session-routing.js +232 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -0
- package/dist/modes/interactive/interactive-session-runtime.d.ts +2 -0
- package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js +131 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -0
- package/dist/modes/interactive/interactive-slash-commands.d.ts +2 -0
- package/dist/modes/interactive/interactive-slash-commands.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-slash-commands.js +338 -0
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -0
- package/dist/modes/interactive/interactive-startup.d.ts +2 -0
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-startup.js +348 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -0
- package/dist/modes/interactive/theme/color-utils.d.ts +20 -0
- package/dist/modes/interactive/theme/color-utils.d.ts.map +1 -0
- package/dist/modes/interactive/theme/color-utils.js +204 -0
- package/dist/modes/interactive/theme/color-utils.js.map +1 -0
- package/dist/modes/interactive/theme/export-colors.d.ts +19 -0
- package/dist/modes/interactive/theme/export-colors.d.ts.map +1 -0
- package/dist/modes/interactive/theme/export-colors.js +69 -0
- package/dist/modes/interactive/theme/export-colors.js.map +1 -0
- package/dist/modes/interactive/theme/global-theme.d.ts +12 -0
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/global-theme.js +150 -0
- package/dist/modes/interactive/theme/global-theme.js.map +1 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts +30 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -0
- package/dist/modes/interactive/theme/terminal-detection.js +89 -0
- package/dist/modes/interactive/theme/terminal-detection.js.map +1 -0
- package/dist/modes/interactive/theme/theme-class.d.ts +30 -0
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-class.js +83 -0
- package/dist/modes/interactive/theme/theme-class.js.map +1 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts +17 -0
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-loading.js +155 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -0
- package/dist/modes/interactive/theme/theme-parse.d.ts +5 -0
- package/dist/modes/interactive/theme/theme-parse.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-parse.js +52 -0
- package/dist/modes/interactive/theme/theme-parse.js.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts +255 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-schema.js +78 -0
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
- package/dist/modes/interactive/theme/theme.d.ts +6 -108
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +6 -1065
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts +15 -0
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/tui-theme.js +199 -0
- package/dist/modes/interactive/theme/tui-theme.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +1 -61
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +1 -72
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +14 -0
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-command-handler.js +226 -0
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts +15 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.js +196 -0
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -0
- package/dist/modes/rpc/rpc-input.d.ts +12 -0
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-input.js +54 -0
- package/dist/modes/rpc/rpc-input.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +43 -607
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts +8 -0
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-responses.js +27 -0
- package/dist/modes/rpc/rpc-responses.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +25 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.js +70 -0
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -0
- package/dist/package-manager-cli-parser.d.ts +28 -0
- package/dist/package-manager-cli-parser.d.ts.map +1 -0
- package/dist/package-manager-cli-parser.js +269 -0
- package/dist/package-manager-cli-parser.js.map +1 -0
- package/dist/package-manager-cli.d.ts +0 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -267
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +10 -0
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/version-check.d.ts +1 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +17 -0
- package/dist/utils/version-check.js.map +1 -1
- package/docs/development.md +4 -0
- package/docs/workflows.md +8 -6
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -106
- package/examples/extensions/gondolin/index.ts +0 -23
- package/examples/extensions/overlay-qa-animation-components.ts +255 -0
- package/examples/extensions/overlay-qa-focus-components.ts +222 -0
- package/examples/extensions/overlay-qa-position-components.ts +433 -0
- package/examples/extensions/overlay-qa-shared.ts +37 -0
- package/examples/extensions/overlay-qa-streaming-input-components.ts +205 -0
- package/examples/extensions/overlay-qa-tests.ts +17 -1156
- package/examples/extensions/overlay-qa-toggle-passive-components.ts +169 -0
- package/examples/extensions/space-invaders.ts +0 -60
- package/examples/extensions/subagent/display.ts +148 -0
- package/examples/extensions/subagent/index.ts +11 -858
- package/examples/extensions/subagent/render.ts +383 -0
- package/examples/extensions/subagent/runner.ts +252 -0
- package/examples/extensions/subagent/schemas.ts +59 -0
- package/examples/extensions/subagent/types.ts +36 -0
- package/examples/extensions/tic-tac-toe-instructions.ts +65 -0
- package/examples/extensions/tic-tac-toe-rendering.ts +414 -0
- package/examples/extensions/tic-tac-toe-state.ts +158 -0
- package/examples/extensions/tic-tac-toe.ts +92 -754
- package/examples/rpc-extension-ui-components.ts +189 -0
- package/examples/rpc-extension-ui.ts +2 -179
- package/package.json +4 -4
|
@@ -1,2152 +1,108 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { homedir, tmpdir } from "node:os";
|
|
4
|
-
function getEnv() {
|
|
5
|
-
if (process.platform !== "linux" || Object.keys(process.env).length > 0) {
|
|
6
|
-
return process.env;
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
const data = readFileSync("/proc/self/environ", "utf-8");
|
|
10
|
-
const env = {};
|
|
11
|
-
for (const entry of data.split("\0")) {
|
|
12
|
-
const idx = entry.indexOf("=");
|
|
13
|
-
if (idx > 0) {
|
|
14
|
-
env[entry.slice(0, idx)] = entry.slice(idx + 1);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return env;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return process.env;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
24
|
-
import { globSync } from "glob";
|
|
25
|
-
import ignore from "ignore";
|
|
26
|
-
import { minimatch } from "minimatch";
|
|
27
|
-
import { maxSatisfying, rcompare, satisfies, valid, validRange } from "semver";
|
|
28
|
-
import { APP_NAME, CONFIG_DIR_NAME, ENV_OFFLINE, getAgentDir, getAgentDirs, getEnvValue, getProjectConfigDirs } from "../config.js";
|
|
29
1
|
import { spawnProcess, spawnProcessSync } from "../utils/child-process.js";
|
|
30
|
-
import {
|
|
31
|
-
import { parseGitUrl } from "../utils/git.js";
|
|
32
|
-
import { canonicalizePath, isLocalPath, markPathIgnoredByCloudSync, resolvePath } from "../utils/paths.js";
|
|
2
|
+
import { resolvePath as resolveAbsolutePath } from "../utils/paths.js";
|
|
33
3
|
import { isStdoutTakenOver } from "./output-guard.js";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
function isExactNpmVersion(version) {
|
|
44
|
-
return valid(version ?? "") !== null;
|
|
45
|
-
}
|
|
46
|
-
function getNpmVersionRange(version) {
|
|
47
|
-
return version ? (validRange(version) ?? undefined) : undefined;
|
|
48
|
-
}
|
|
49
|
-
function isGitCommand(command) {
|
|
50
|
-
const commandName = basename(command).toLowerCase();
|
|
51
|
-
return commandName === "git" || commandName === "git.exe";
|
|
52
|
-
}
|
|
53
|
-
function getCommandEnv(command, overrides) {
|
|
54
|
-
const baseEnv = getEnv();
|
|
55
|
-
if (isGitCommand(command))
|
|
56
|
-
return createGitEnvironment(overrides, baseEnv);
|
|
57
|
-
return overrides ? { ...baseEnv, ...overrides } : baseEnv;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Compute a numeric precedence rank for a resource based on its metadata.
|
|
61
|
-
* Lower rank = higher precedence. Used to sort resolved resources so that
|
|
62
|
-
* name-collision resolution ("first wins") produces the correct outcome.
|
|
63
|
-
*
|
|
64
|
-
* Precedence (highest to lowest):
|
|
65
|
-
* 0 project + settings entry (source: "local", scope: "project")
|
|
66
|
-
* 1 project + auto-discovered (source: "auto", scope: "project")
|
|
67
|
-
* 2 user + settings entry (source: "local", scope: "user")
|
|
68
|
-
* 3 user + auto-discovered (source: "auto", scope: "user")
|
|
69
|
-
* 4 package resource (origin: "package")
|
|
70
|
-
* 5 project-local resources borrowed from explicit temporary extension sources
|
|
71
|
-
*/
|
|
72
|
-
function resourcePrecedenceRank(m) {
|
|
73
|
-
if (m.origin === "package")
|
|
74
|
-
return 4;
|
|
75
|
-
if (m.borrowedProjectLocal)
|
|
76
|
-
return 5;
|
|
77
|
-
const scopeBase = m.scope === "project" ? 0 : 2;
|
|
78
|
-
return scopeBase + (m.source === "local" ? 0 : 1);
|
|
79
|
-
}
|
|
80
|
-
const RESOURCE_TYPES = ["extensions", "skills", "prompts", "themes", "workflows"];
|
|
81
|
-
const FILE_PATTERNS = {
|
|
82
|
-
extensions: /\.(ts|js)$/,
|
|
83
|
-
skills: /\.md$/,
|
|
84
|
-
prompts: /\.md$/,
|
|
85
|
-
themes: /\.json$/,
|
|
86
|
-
workflows: /\.(ts|js|mjs|cjs)$/,
|
|
87
|
-
};
|
|
88
|
-
const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
|
|
89
|
-
function toPosixPath(p) {
|
|
90
|
-
return p.split(sep).join("/");
|
|
91
|
-
}
|
|
92
|
-
function getHomeDir() {
|
|
93
|
-
return process.env.HOME || homedir();
|
|
94
|
-
}
|
|
95
|
-
function prefixIgnorePattern(line, prefix) {
|
|
96
|
-
const trimmed = line.trim();
|
|
97
|
-
if (!trimmed)
|
|
98
|
-
return null;
|
|
99
|
-
if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
|
|
100
|
-
return null;
|
|
101
|
-
let pattern = line;
|
|
102
|
-
let negated = false;
|
|
103
|
-
if (pattern.startsWith("!")) {
|
|
104
|
-
negated = true;
|
|
105
|
-
pattern = pattern.slice(1);
|
|
106
|
-
}
|
|
107
|
-
else if (pattern.startsWith("\\!")) {
|
|
108
|
-
pattern = pattern.slice(1);
|
|
109
|
-
}
|
|
110
|
-
if (pattern.startsWith("/")) {
|
|
111
|
-
pattern = pattern.slice(1);
|
|
112
|
-
}
|
|
113
|
-
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
114
|
-
return negated ? `!${prefixed}` : prefixed;
|
|
115
|
-
}
|
|
116
|
-
function addIgnoreRules(ig, dir, rootDir) {
|
|
117
|
-
const relativeDir = relative(rootDir, dir);
|
|
118
|
-
const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
|
|
119
|
-
for (const filename of IGNORE_FILE_NAMES) {
|
|
120
|
-
const ignorePath = join(dir, filename);
|
|
121
|
-
if (!existsSync(ignorePath))
|
|
122
|
-
continue;
|
|
123
|
-
try {
|
|
124
|
-
const content = readFileSync(ignorePath, "utf-8");
|
|
125
|
-
const patterns = content
|
|
126
|
-
.split(/\r?\n/)
|
|
127
|
-
.map((line) => prefixIgnorePattern(line, prefix))
|
|
128
|
-
.filter((line) => Boolean(line));
|
|
129
|
-
if (patterns.length > 0) {
|
|
130
|
-
ig.add(patterns);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch { }
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
function isPattern(s) {
|
|
137
|
-
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-") || s.includes("*") || s.includes("?");
|
|
138
|
-
}
|
|
139
|
-
function isOverridePattern(s) {
|
|
140
|
-
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-");
|
|
141
|
-
}
|
|
142
|
-
function hasGlobPattern(s) {
|
|
143
|
-
return s.includes("*") || s.includes("?");
|
|
144
|
-
}
|
|
145
|
-
function splitPatterns(entries) {
|
|
146
|
-
const plain = [];
|
|
147
|
-
const patterns = [];
|
|
148
|
-
for (const entry of entries) {
|
|
149
|
-
if (isPattern(entry)) {
|
|
150
|
-
patterns.push(entry);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
plain.push(entry);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return { plain, patterns };
|
|
157
|
-
}
|
|
158
|
-
function collectFiles(dir, filePattern, skipNodeModules = true, ignoreMatcher, rootDir) {
|
|
159
|
-
const files = [];
|
|
160
|
-
if (!existsSync(dir))
|
|
161
|
-
return files;
|
|
162
|
-
const root = rootDir ?? dir;
|
|
163
|
-
const ig = ignoreMatcher ?? ignore();
|
|
164
|
-
addIgnoreRules(ig, dir, root);
|
|
165
|
-
try {
|
|
166
|
-
const entries = readdirSync(dir, { withFileTypes: true });
|
|
167
|
-
for (const entry of entries) {
|
|
168
|
-
if (entry.name.startsWith("."))
|
|
169
|
-
continue;
|
|
170
|
-
if (skipNodeModules && entry.name === "node_modules")
|
|
171
|
-
continue;
|
|
172
|
-
const fullPath = join(dir, entry.name);
|
|
173
|
-
let isDir = entry.isDirectory();
|
|
174
|
-
let isFile = entry.isFile();
|
|
175
|
-
if (entry.isSymbolicLink()) {
|
|
176
|
-
try {
|
|
177
|
-
const stats = statSync(fullPath);
|
|
178
|
-
isDir = stats.isDirectory();
|
|
179
|
-
isFile = stats.isFile();
|
|
180
|
-
}
|
|
181
|
-
catch {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const relPath = toPosixPath(relative(root, fullPath));
|
|
186
|
-
const ignorePath = isDir ? `${relPath}/` : relPath;
|
|
187
|
-
if (ig.ignores(ignorePath))
|
|
188
|
-
continue;
|
|
189
|
-
if (isDir) {
|
|
190
|
-
files.push(...collectFiles(fullPath, filePattern, skipNodeModules, ig, root));
|
|
191
|
-
}
|
|
192
|
-
else if (isFile && filePattern.test(entry.name)) {
|
|
193
|
-
files.push(fullPath);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch {
|
|
198
|
-
// Ignore errors
|
|
199
|
-
}
|
|
200
|
-
return files;
|
|
201
|
-
}
|
|
202
|
-
function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
203
|
-
const entries = [];
|
|
204
|
-
if (!existsSync(dir))
|
|
205
|
-
return entries;
|
|
206
|
-
const root = rootDir ?? dir;
|
|
207
|
-
const ig = ignoreMatcher ?? ignore();
|
|
208
|
-
addIgnoreRules(ig, dir, root);
|
|
209
|
-
try {
|
|
210
|
-
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
211
|
-
for (const entry of dirEntries) {
|
|
212
|
-
if (entry.name !== "SKILL.md") {
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
const fullPath = join(dir, entry.name);
|
|
216
|
-
let isFile = entry.isFile();
|
|
217
|
-
if (entry.isSymbolicLink()) {
|
|
218
|
-
try {
|
|
219
|
-
isFile = statSync(fullPath).isFile();
|
|
220
|
-
}
|
|
221
|
-
catch {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const relPath = toPosixPath(relative(root, fullPath));
|
|
226
|
-
if (isFile && !ig.ignores(relPath)) {
|
|
227
|
-
entries.push(fullPath);
|
|
228
|
-
return entries;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
for (const entry of dirEntries) {
|
|
232
|
-
if (entry.name.startsWith("."))
|
|
233
|
-
continue;
|
|
234
|
-
if (entry.name === "node_modules")
|
|
235
|
-
continue;
|
|
236
|
-
const fullPath = join(dir, entry.name);
|
|
237
|
-
let isDir = entry.isDirectory();
|
|
238
|
-
let isFile = entry.isFile();
|
|
239
|
-
if (entry.isSymbolicLink()) {
|
|
240
|
-
try {
|
|
241
|
-
const stats = statSync(fullPath);
|
|
242
|
-
isDir = stats.isDirectory();
|
|
243
|
-
isFile = stats.isFile();
|
|
244
|
-
}
|
|
245
|
-
catch {
|
|
246
|
-
continue;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const relPath = toPosixPath(relative(root, fullPath));
|
|
250
|
-
if (mode === "pi" && dir === root && isFile && entry.name.endsWith(".md") && !ig.ignores(relPath)) {
|
|
251
|
-
entries.push(fullPath);
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
if (!isDir)
|
|
255
|
-
continue;
|
|
256
|
-
if (ig.ignores(`${relPath}/`))
|
|
257
|
-
continue;
|
|
258
|
-
entries.push(...collectSkillEntries(fullPath, mode, ig, root));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
catch {
|
|
262
|
-
// Ignore errors
|
|
263
|
-
}
|
|
264
|
-
return entries;
|
|
265
|
-
}
|
|
266
|
-
function collectAutoSkillEntries(dir, mode) {
|
|
267
|
-
return collectSkillEntries(dir, mode);
|
|
268
|
-
}
|
|
269
|
-
function findGitRepoRoot(startDir) {
|
|
270
|
-
let dir = resolve(startDir);
|
|
271
|
-
while (true) {
|
|
272
|
-
if (existsSync(join(dir, ".git"))) {
|
|
273
|
-
return dir;
|
|
274
|
-
}
|
|
275
|
-
const parent = dirname(dir);
|
|
276
|
-
if (parent === dir) {
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
dir = parent;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
function collectAncestorAgentsSkillDirs(startDir) {
|
|
283
|
-
const skillDirs = [];
|
|
284
|
-
const resolvedStartDir = resolve(startDir);
|
|
285
|
-
const gitRepoRoot = findGitRepoRoot(resolvedStartDir);
|
|
286
|
-
let dir = resolvedStartDir;
|
|
287
|
-
while (true) {
|
|
288
|
-
skillDirs.push(join(dir, ".agents", "skills"));
|
|
289
|
-
if (gitRepoRoot && dir === gitRepoRoot) {
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
const parent = dirname(dir);
|
|
293
|
-
if (parent === dir) {
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
dir = parent;
|
|
297
|
-
}
|
|
298
|
-
return skillDirs;
|
|
299
|
-
}
|
|
300
|
-
function collectAutoPromptEntries(dir) {
|
|
301
|
-
const entries = [];
|
|
302
|
-
if (!existsSync(dir))
|
|
303
|
-
return entries;
|
|
304
|
-
const ig = ignore();
|
|
305
|
-
addIgnoreRules(ig, dir, dir);
|
|
306
|
-
try {
|
|
307
|
-
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
308
|
-
for (const entry of dirEntries) {
|
|
309
|
-
if (entry.name.startsWith("."))
|
|
310
|
-
continue;
|
|
311
|
-
if (entry.name === "node_modules")
|
|
312
|
-
continue;
|
|
313
|
-
const fullPath = join(dir, entry.name);
|
|
314
|
-
let isFile = entry.isFile();
|
|
315
|
-
if (entry.isSymbolicLink()) {
|
|
316
|
-
try {
|
|
317
|
-
isFile = statSync(fullPath).isFile();
|
|
318
|
-
}
|
|
319
|
-
catch {
|
|
320
|
-
continue;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const relPath = toPosixPath(relative(dir, fullPath));
|
|
324
|
-
if (ig.ignores(relPath))
|
|
325
|
-
continue;
|
|
326
|
-
if (isFile && entry.name.endsWith(".md")) {
|
|
327
|
-
entries.push(fullPath);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
catch {
|
|
332
|
-
// Ignore errors
|
|
333
|
-
}
|
|
334
|
-
return entries;
|
|
335
|
-
}
|
|
336
|
-
function collectAutoThemeEntries(dir) {
|
|
337
|
-
const entries = [];
|
|
338
|
-
if (!existsSync(dir))
|
|
339
|
-
return entries;
|
|
340
|
-
const ig = ignore();
|
|
341
|
-
addIgnoreRules(ig, dir, dir);
|
|
342
|
-
try {
|
|
343
|
-
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
344
|
-
for (const entry of dirEntries) {
|
|
345
|
-
if (entry.name.startsWith("."))
|
|
346
|
-
continue;
|
|
347
|
-
if (entry.name === "node_modules")
|
|
348
|
-
continue;
|
|
349
|
-
const fullPath = join(dir, entry.name);
|
|
350
|
-
let isFile = entry.isFile();
|
|
351
|
-
if (entry.isSymbolicLink()) {
|
|
352
|
-
try {
|
|
353
|
-
isFile = statSync(fullPath).isFile();
|
|
354
|
-
}
|
|
355
|
-
catch {
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
const relPath = toPosixPath(relative(dir, fullPath));
|
|
360
|
-
if (ig.ignores(relPath))
|
|
361
|
-
continue;
|
|
362
|
-
if (isFile && entry.name.endsWith(".json")) {
|
|
363
|
-
entries.push(fullPath);
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
catch {
|
|
368
|
-
// Ignore errors
|
|
369
|
-
}
|
|
370
|
-
return entries;
|
|
371
|
-
}
|
|
372
|
-
function getManifestFromPackageJson(pkg) {
|
|
373
|
-
const appManifest = pkg[APP_NAME];
|
|
374
|
-
if (appManifest && typeof appManifest === "object" && !Array.isArray(appManifest)) {
|
|
375
|
-
return appManifest;
|
|
376
|
-
}
|
|
377
|
-
const legacyManifest = pkg.pi;
|
|
378
|
-
if (legacyManifest && typeof legacyManifest === "object" && !Array.isArray(legacyManifest)) {
|
|
379
|
-
return legacyManifest;
|
|
380
|
-
}
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
function readPiManifestFile(packageJsonPath) {
|
|
384
|
-
try {
|
|
385
|
-
const content = readFileSync(packageJsonPath, "utf-8");
|
|
386
|
-
const pkg = JSON.parse(content);
|
|
387
|
-
return getManifestFromPackageJson(pkg);
|
|
388
|
-
}
|
|
389
|
-
catch {
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
function resolveExtensionEntries(dir) {
|
|
394
|
-
const packageJsonPath = join(dir, "package.json");
|
|
395
|
-
if (existsSync(packageJsonPath)) {
|
|
396
|
-
const manifest = readPiManifestFile(packageJsonPath);
|
|
397
|
-
if (manifest?.extensions?.length) {
|
|
398
|
-
const entries = [];
|
|
399
|
-
for (const extPath of manifest.extensions) {
|
|
400
|
-
const resolvedExtPath = resolve(dir, extPath);
|
|
401
|
-
if (existsSync(resolvedExtPath)) {
|
|
402
|
-
entries.push(resolvedExtPath);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
if (entries.length > 0) {
|
|
406
|
-
return entries;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
const indexTs = join(dir, "index.ts");
|
|
411
|
-
const indexJs = join(dir, "index.js");
|
|
412
|
-
if (existsSync(indexTs)) {
|
|
413
|
-
return [indexTs];
|
|
414
|
-
}
|
|
415
|
-
if (existsSync(indexJs)) {
|
|
416
|
-
return [indexJs];
|
|
417
|
-
}
|
|
418
|
-
return null;
|
|
419
|
-
}
|
|
420
|
-
function collectAutoExtensionEntries(dir) {
|
|
421
|
-
const entries = [];
|
|
422
|
-
if (!existsSync(dir))
|
|
423
|
-
return entries;
|
|
424
|
-
// First check if this directory itself has explicit extension entries (package.json or index)
|
|
425
|
-
const rootEntries = resolveExtensionEntries(dir);
|
|
426
|
-
if (rootEntries) {
|
|
427
|
-
return rootEntries;
|
|
428
|
-
}
|
|
429
|
-
// Otherwise, discover extensions from directory contents
|
|
430
|
-
const ig = ignore();
|
|
431
|
-
addIgnoreRules(ig, dir, dir);
|
|
432
|
-
try {
|
|
433
|
-
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
434
|
-
for (const entry of dirEntries) {
|
|
435
|
-
if (entry.name.startsWith("."))
|
|
436
|
-
continue;
|
|
437
|
-
if (entry.name === "node_modules")
|
|
438
|
-
continue;
|
|
439
|
-
const fullPath = join(dir, entry.name);
|
|
440
|
-
let isDir = entry.isDirectory();
|
|
441
|
-
let isFile = entry.isFile();
|
|
442
|
-
if (entry.isSymbolicLink()) {
|
|
443
|
-
try {
|
|
444
|
-
const stats = statSync(fullPath);
|
|
445
|
-
isDir = stats.isDirectory();
|
|
446
|
-
isFile = stats.isFile();
|
|
447
|
-
}
|
|
448
|
-
catch {
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
const relPath = toPosixPath(relative(dir, fullPath));
|
|
453
|
-
const ignorePath = isDir ? `${relPath}/` : relPath;
|
|
454
|
-
if (ig.ignores(ignorePath))
|
|
455
|
-
continue;
|
|
456
|
-
if (isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) {
|
|
457
|
-
entries.push(fullPath);
|
|
458
|
-
}
|
|
459
|
-
else if (isDir) {
|
|
460
|
-
const resolvedEntries = resolveExtensionEntries(fullPath);
|
|
461
|
-
if (resolvedEntries) {
|
|
462
|
-
entries.push(...resolvedEntries);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
catch {
|
|
468
|
-
// Ignore errors
|
|
469
|
-
}
|
|
470
|
-
return entries;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Collect resource files from a directory based on resource type.
|
|
474
|
-
* Extensions use smart discovery (index.ts in subdirs), others use recursive collection.
|
|
475
|
-
*/
|
|
476
|
-
function collectResourceFiles(dir, resourceType) {
|
|
477
|
-
if (resourceType === "skills") {
|
|
478
|
-
return collectSkillEntries(dir, "pi");
|
|
479
|
-
}
|
|
480
|
-
if (resourceType === "extensions") {
|
|
481
|
-
return collectAutoExtensionEntries(dir);
|
|
482
|
-
}
|
|
483
|
-
return collectFiles(dir, FILE_PATTERNS[resourceType]);
|
|
484
|
-
}
|
|
485
|
-
function conventionDirsForResource(packageRoot, resourceType) {
|
|
486
|
-
if (resourceType === "workflows") {
|
|
487
|
-
return [join(packageRoot, "workflows"), join(packageRoot, "workflow")];
|
|
488
|
-
}
|
|
489
|
-
return [join(packageRoot, resourceType)];
|
|
490
|
-
}
|
|
491
|
-
function manifestEntriesForResource(manifest, resourceType) {
|
|
492
|
-
if (!manifest)
|
|
493
|
-
return undefined;
|
|
494
|
-
if (resourceType === "workflows")
|
|
495
|
-
return manifest.workflows ?? manifest.workflow;
|
|
496
|
-
return manifest[resourceType];
|
|
497
|
-
}
|
|
498
|
-
function matchesAnyPattern(filePath, patterns, baseDir) {
|
|
499
|
-
const rel = toPosixPath(relative(baseDir, filePath));
|
|
500
|
-
const name = basename(filePath);
|
|
501
|
-
const filePathPosix = toPosixPath(filePath);
|
|
502
|
-
const isSkillFile = name === "SKILL.md";
|
|
503
|
-
const parentDir = isSkillFile ? dirname(filePath) : undefined;
|
|
504
|
-
const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : undefined;
|
|
505
|
-
const parentName = isSkillFile ? basename(parentDir) : undefined;
|
|
506
|
-
const parentDirPosix = isSkillFile ? toPosixPath(parentDir) : undefined;
|
|
507
|
-
return patterns.some((pattern) => {
|
|
508
|
-
const normalizedPattern = toPosixPath(pattern);
|
|
509
|
-
if (minimatch(rel, normalizedPattern) ||
|
|
510
|
-
minimatch(name, normalizedPattern) ||
|
|
511
|
-
minimatch(filePathPosix, normalizedPattern)) {
|
|
512
|
-
return true;
|
|
513
|
-
}
|
|
514
|
-
if (!isSkillFile)
|
|
515
|
-
return false;
|
|
516
|
-
return (minimatch(parentRel, normalizedPattern) ||
|
|
517
|
-
minimatch(parentName, normalizedPattern) ||
|
|
518
|
-
minimatch(parentDirPosix, normalizedPattern));
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
function normalizeExactPattern(pattern) {
|
|
522
|
-
const normalized = pattern.startsWith("./") || pattern.startsWith(".\\") ? pattern.slice(2) : pattern;
|
|
523
|
-
return toPosixPath(normalized);
|
|
524
|
-
}
|
|
525
|
-
function matchesAnyExactPattern(filePath, patterns, baseDir) {
|
|
526
|
-
if (patterns.length === 0)
|
|
527
|
-
return false;
|
|
528
|
-
const rel = toPosixPath(relative(baseDir, filePath));
|
|
529
|
-
const name = basename(filePath);
|
|
530
|
-
const filePathPosix = toPosixPath(filePath);
|
|
531
|
-
const isSkillFile = name === "SKILL.md";
|
|
532
|
-
const parentDir = isSkillFile ? dirname(filePath) : undefined;
|
|
533
|
-
const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : undefined;
|
|
534
|
-
const parentDirPosix = isSkillFile ? toPosixPath(parentDir) : undefined;
|
|
535
|
-
return patterns.some((pattern) => {
|
|
536
|
-
const normalized = normalizeExactPattern(pattern);
|
|
537
|
-
if (normalized === rel || normalized === filePathPosix) {
|
|
538
|
-
return true;
|
|
539
|
-
}
|
|
540
|
-
if (!isSkillFile)
|
|
541
|
-
return false;
|
|
542
|
-
return normalized === parentRel || normalized === parentDirPosix;
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
function getOverridePatterns(entries) {
|
|
546
|
-
return entries.filter((pattern) => pattern.startsWith("!") || pattern.startsWith("+") || pattern.startsWith("-"));
|
|
547
|
-
}
|
|
548
|
-
function isEnabledByOverrides(filePath, patterns, baseDir) {
|
|
549
|
-
const overrides = getOverridePatterns(patterns);
|
|
550
|
-
const excludes = overrides.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
|
|
551
|
-
const forceIncludes = overrides.filter((pattern) => pattern.startsWith("+")).map((pattern) => pattern.slice(1));
|
|
552
|
-
const forceExcludes = overrides.filter((pattern) => pattern.startsWith("-")).map((pattern) => pattern.slice(1));
|
|
553
|
-
let enabled = true;
|
|
554
|
-
if (excludes.length > 0 && matchesAnyPattern(filePath, excludes, baseDir)) {
|
|
555
|
-
enabled = false;
|
|
556
|
-
}
|
|
557
|
-
if (forceIncludes.length > 0 && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
|
|
558
|
-
enabled = true;
|
|
559
|
-
}
|
|
560
|
-
if (forceExcludes.length > 0 && matchesAnyExactPattern(filePath, forceExcludes, baseDir)) {
|
|
561
|
-
enabled = false;
|
|
562
|
-
}
|
|
563
|
-
return enabled;
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* Apply patterns to paths and return a Set of enabled paths.
|
|
567
|
-
* Pattern types:
|
|
568
|
-
* - Plain patterns: include matching paths
|
|
569
|
-
* - `!pattern`: exclude matching paths
|
|
570
|
-
* - `+path`: force-include exact path (overrides exclusions)
|
|
571
|
-
* - `-path`: force-exclude exact path (overrides force-includes)
|
|
572
|
-
*/
|
|
573
|
-
function applyPatterns(allPaths, patterns, baseDir) {
|
|
574
|
-
const includes = [];
|
|
575
|
-
const excludes = [];
|
|
576
|
-
const forceIncludes = [];
|
|
577
|
-
const forceExcludes = [];
|
|
578
|
-
for (const p of patterns) {
|
|
579
|
-
if (p.startsWith("+")) {
|
|
580
|
-
forceIncludes.push(p.slice(1));
|
|
581
|
-
}
|
|
582
|
-
else if (p.startsWith("-")) {
|
|
583
|
-
forceExcludes.push(p.slice(1));
|
|
584
|
-
}
|
|
585
|
-
else if (p.startsWith("!")) {
|
|
586
|
-
excludes.push(p.slice(1));
|
|
587
|
-
}
|
|
588
|
-
else {
|
|
589
|
-
includes.push(p);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
// Step 1: Apply includes (or all if no includes)
|
|
593
|
-
let result;
|
|
594
|
-
if (includes.length === 0) {
|
|
595
|
-
result = [...allPaths];
|
|
596
|
-
}
|
|
597
|
-
else {
|
|
598
|
-
result = allPaths.filter((filePath) => matchesAnyPattern(filePath, includes, baseDir));
|
|
599
|
-
}
|
|
600
|
-
// Step 2: Apply excludes
|
|
601
|
-
if (excludes.length > 0) {
|
|
602
|
-
result = result.filter((filePath) => !matchesAnyPattern(filePath, excludes, baseDir));
|
|
603
|
-
}
|
|
604
|
-
// Step 3: Force-include (add back from allPaths, overriding exclusions)
|
|
605
|
-
if (forceIncludes.length > 0) {
|
|
606
|
-
for (const filePath of allPaths) {
|
|
607
|
-
if (!result.includes(filePath) && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
|
|
608
|
-
result.push(filePath);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
// Step 4: Force-exclude (remove even if included or force-included)
|
|
613
|
-
if (forceExcludes.length > 0) {
|
|
614
|
-
result = result.filter((filePath) => !matchesAnyExactPattern(filePath, forceExcludes, baseDir));
|
|
615
|
-
}
|
|
616
|
-
return new Set(result);
|
|
617
|
-
}
|
|
4
|
+
import { getCommandEnv } from "./package-manager-env.js";
|
|
5
|
+
import { getLocalGitUpdateTarget as getLocalGitUpdateTargetFromContext } from "./package-manager-git.js";
|
|
6
|
+
import { getGitInstallPath as getGitInstallPathFromContext, } from "./package-manager-paths.js";
|
|
7
|
+
import { getGlobalNpmRoot as getGlobalNpmRootFromContext, getLatestNpmVersion as getLatestNpmVersionFromContext, } from "./package-manager-npm.js";
|
|
8
|
+
import { checkForAvailableUpdates as checkForAvailableUpdatesFromContext, install as installFromContext, installParsedSource as installParsedSourceFromContext, remove as removeFromContext, update as updateFromContext, } from "./package-manager-operations.js";
|
|
9
|
+
import { resolveExtensionSources as resolveExtensionSourcesFromContext, resolvePackages, } from "./package-manager-resolver.js";
|
|
10
|
+
import { addSourceToSettings as addSourceToSettingsInContext, getInstalledPath as getInstalledPathFromContext, listConfiguredPackages as listConfiguredPackagesFromContext, removeSourceFromSettings as removeSourceFromSettingsInContext, } from "./package-manager-settings.js";
|
|
11
|
+
import { getPackageIdentity as getPackageIdentityFromContext, parseSource as parsePackageSource, } from "./package-manager-source.js";
|
|
12
|
+
import { gitHasAvailableUpdate as gitHasAvailableUpdateFromContext, refreshTemporaryGitSource as refreshTemporaryGitSourceFromContext, updateGit as updateGitFromContext, } from "./package-manager-git.js";
|
|
618
13
|
export class DefaultPackageManager {
|
|
619
14
|
constructor(options) {
|
|
620
|
-
this.
|
|
621
|
-
|
|
622
|
-
|
|
15
|
+
this.context = {
|
|
16
|
+
cwd: resolveAbsolutePath(options.cwd),
|
|
17
|
+
agentDir: resolveAbsolutePath(options.agentDir),
|
|
18
|
+
settingsManager: options.settingsManager,
|
|
19
|
+
};
|
|
20
|
+
this.context.driver = {
|
|
21
|
+
runCommand: (command, args, runOptions) => this.runCommand(command, args, runOptions),
|
|
22
|
+
runCommandCapture: (command, args, runOptions) => this.runCommandCapture(command, args, runOptions),
|
|
23
|
+
runCommandSync: (command, args) => this.runCommandSync(command, args),
|
|
24
|
+
installParsedSource: (parsed, scope) => this.installParsedSource(parsed, scope),
|
|
25
|
+
updateGit: (source, scope) => this.updateGit(source, scope),
|
|
26
|
+
gitHasAvailableUpdate: (installedPath) => this.gitHasAvailableUpdate(installedPath),
|
|
27
|
+
refreshTemporaryGitSource: (source, sourceStr) => this.refreshTemporaryGitSource(source, sourceStr),
|
|
28
|
+
getLocalGitUpdateTarget: (installedPath) => this.getLocalGitUpdateTarget(installedPath),
|
|
29
|
+
getGlobalNpmRoot: () => this.getGlobalNpmRoot(),
|
|
30
|
+
parseSource: (source) => this.parseSource(source),
|
|
31
|
+
getPackageIdentity: (source, scope) => this.getPackageIdentity(source, scope),
|
|
32
|
+
getGitInstallPath: (source, scope) => this.getGitInstallPath(source, scope),
|
|
33
|
+
getLatestNpmVersion: (packageSpec, range) => this.getLatestNpmVersion(packageSpec, range),
|
|
34
|
+
};
|
|
623
35
|
}
|
|
624
36
|
setProgressCallback(callback) {
|
|
625
|
-
this.progressCallback = callback;
|
|
37
|
+
this.context.progressCallback = callback;
|
|
626
38
|
}
|
|
627
39
|
addSourceToSettings(source, options) {
|
|
628
|
-
|
|
629
|
-
const currentSettings = scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
|
|
630
|
-
const currentPackages = currentSettings.packages ?? [];
|
|
631
|
-
const normalizedSource = this.normalizePackageSourceForSettings(source, scope);
|
|
632
|
-
const matchIndex = currentPackages.findIndex((existing) => this.packageSourcesMatch(existing, source, scope));
|
|
633
|
-
if (matchIndex !== -1) {
|
|
634
|
-
const existing = currentPackages[matchIndex];
|
|
635
|
-
if (this.getPackageSourceString(existing) === normalizedSource) {
|
|
636
|
-
return false;
|
|
637
|
-
}
|
|
638
|
-
const nextPackages = [...currentPackages];
|
|
639
|
-
nextPackages[matchIndex] =
|
|
640
|
-
typeof existing === "string" ? normalizedSource : { ...existing, source: normalizedSource };
|
|
641
|
-
if (scope === "project") {
|
|
642
|
-
this.settingsManager.setProjectPackages(nextPackages);
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
this.settingsManager.setPackages(nextPackages);
|
|
646
|
-
}
|
|
647
|
-
return true;
|
|
648
|
-
}
|
|
649
|
-
const nextPackages = [...currentPackages, normalizedSource];
|
|
650
|
-
if (scope === "project") {
|
|
651
|
-
this.settingsManager.setProjectPackages(nextPackages);
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
this.settingsManager.setPackages(nextPackages);
|
|
655
|
-
}
|
|
656
|
-
return true;
|
|
40
|
+
return addSourceToSettingsInContext(this.context, source, options);
|
|
657
41
|
}
|
|
658
42
|
removeSourceFromSettings(source, options) {
|
|
659
|
-
|
|
660
|
-
const currentSettings = scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
|
|
661
|
-
const currentPackages = currentSettings.packages ?? [];
|
|
662
|
-
const nextPackages = currentPackages.filter((existing) => !this.packageSourcesMatch(existing, source, scope));
|
|
663
|
-
const changed = nextPackages.length !== currentPackages.length;
|
|
664
|
-
if (!changed) {
|
|
665
|
-
return false;
|
|
666
|
-
}
|
|
667
|
-
if (scope === "project") {
|
|
668
|
-
this.settingsManager.setProjectPackages(nextPackages);
|
|
669
|
-
}
|
|
670
|
-
else {
|
|
671
|
-
this.settingsManager.setPackages(nextPackages);
|
|
672
|
-
}
|
|
673
|
-
return true;
|
|
43
|
+
return removeSourceFromSettingsInContext(this.context, source, options);
|
|
674
44
|
}
|
|
675
45
|
getInstalledPath(source, scope) {
|
|
676
|
-
|
|
677
|
-
if (parsed.type === "npm") {
|
|
678
|
-
return this.getExistingNpmInstallPath(parsed, scope);
|
|
679
|
-
}
|
|
680
|
-
if (parsed.type === "git") {
|
|
681
|
-
return this.getExistingGitInstallPath(parsed, scope);
|
|
682
|
-
}
|
|
683
|
-
if (parsed.type === "local") {
|
|
684
|
-
for (const baseDir of this.getBaseDirsForScope(scope)) {
|
|
685
|
-
const path = this.resolvePathFromBase(parsed.path, baseDir);
|
|
686
|
-
if (existsSync(path))
|
|
687
|
-
return path;
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
return undefined;
|
|
691
|
-
}
|
|
692
|
-
getExistingNpmInstallPath(source, scope) {
|
|
693
|
-
const candidates = [this.getNpmInstallPath(source, scope)];
|
|
694
|
-
if (scope === "project") {
|
|
695
|
-
for (const configDir of getProjectConfigDirs(this.cwd)) {
|
|
696
|
-
candidates.push(join(configDir, "npm", "node_modules", source.name));
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
for (const candidate of Array.from(new Set(candidates))) {
|
|
700
|
-
if (existsSync(candidate))
|
|
701
|
-
return candidate;
|
|
702
|
-
}
|
|
703
|
-
return undefined;
|
|
704
|
-
}
|
|
705
|
-
getExistingGitInstallPath(source, scope) {
|
|
706
|
-
const candidates = [this.getGitInstallPath(source, scope)];
|
|
707
|
-
if (scope === "project") {
|
|
708
|
-
for (const configDir of getProjectConfigDirs(this.cwd)) {
|
|
709
|
-
candidates.push(join(configDir, "git", source.host, source.path));
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
else if (scope === "user") {
|
|
713
|
-
for (const agentDir of this.getBaseDirsForScope("user")) {
|
|
714
|
-
candidates.push(join(agentDir, "git", source.host, source.path));
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
for (const candidate of Array.from(new Set(candidates))) {
|
|
718
|
-
if (existsSync(candidate))
|
|
719
|
-
return candidate;
|
|
720
|
-
}
|
|
721
|
-
return undefined;
|
|
722
|
-
}
|
|
723
|
-
emitProgress(event) {
|
|
724
|
-
this.progressCallback?.(event);
|
|
725
|
-
}
|
|
726
|
-
async withProgress(action, source, message, operation) {
|
|
727
|
-
this.emitProgress({ type: "start", action, source, message });
|
|
728
|
-
try {
|
|
729
|
-
await operation();
|
|
730
|
-
this.emitProgress({ type: "complete", action, source });
|
|
731
|
-
}
|
|
732
|
-
catch (error) {
|
|
733
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
734
|
-
this.emitProgress({ type: "error", action, source, message: errorMessage });
|
|
735
|
-
throw error;
|
|
736
|
-
}
|
|
46
|
+
return getInstalledPathFromContext(this.context, source, scope);
|
|
737
47
|
}
|
|
738
48
|
async resolve(onMissing) {
|
|
739
|
-
|
|
740
|
-
const globalSettings = this.settingsManager.getGlobalSettings();
|
|
741
|
-
const projectSettings = this.settingsManager.getProjectSettings();
|
|
742
|
-
// Collect all packages with scope (project first so cwd resources win collisions)
|
|
743
|
-
const allPackages = [];
|
|
744
|
-
for (const pkg of projectSettings.packages ?? []) {
|
|
745
|
-
allPackages.push({ pkg, scope: "project" });
|
|
746
|
-
}
|
|
747
|
-
for (const pkg of globalSettings.packages ?? []) {
|
|
748
|
-
allPackages.push({ pkg, scope: "user" });
|
|
749
|
-
}
|
|
750
|
-
// Dedupe: project scope wins over global for same package identity
|
|
751
|
-
const packageSources = this.dedupePackages(allPackages);
|
|
752
|
-
await this.resolvePackageSources(packageSources, accumulator, onMissing);
|
|
753
|
-
const globalBaseDir = this.agentDir;
|
|
754
|
-
const projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);
|
|
755
|
-
const globalBaseDirs = this.getBaseDirsForScope("user");
|
|
756
|
-
const projectBaseDirs = this.getBaseDirsForScope("project");
|
|
757
|
-
for (const resourceType of RESOURCE_TYPES) {
|
|
758
|
-
const target = this.getTargetMap(accumulator, resourceType);
|
|
759
|
-
const globalEntries = (globalSettings[resourceType] ?? []);
|
|
760
|
-
const projectEntries = (projectSettings[resourceType] ?? []);
|
|
761
|
-
for (const baseDir of projectBaseDirs) {
|
|
762
|
-
this.resolveLocalEntries(projectEntries, resourceType, target, {
|
|
763
|
-
source: "local",
|
|
764
|
-
scope: "project",
|
|
765
|
-
origin: "top-level",
|
|
766
|
-
baseDir,
|
|
767
|
-
}, baseDir);
|
|
768
|
-
}
|
|
769
|
-
for (const baseDir of globalBaseDirs) {
|
|
770
|
-
this.resolveLocalEntries(globalEntries, resourceType, target, {
|
|
771
|
-
source: "local",
|
|
772
|
-
scope: "user",
|
|
773
|
-
origin: "top-level",
|
|
774
|
-
baseDir,
|
|
775
|
-
}, baseDir);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
this.addAutoDiscoveredResources(accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir);
|
|
779
|
-
return this.toResolvedPaths(accumulator);
|
|
49
|
+
return resolvePackages(this.context, onMissing);
|
|
780
50
|
}
|
|
781
51
|
async resolveExtensionSources(sources, options) {
|
|
782
|
-
|
|
783
|
-
const scope = options?.temporary ? "temporary" : options?.local ? "project" : "user";
|
|
784
|
-
const packageSources = sources.map((source) => ({ pkg: source, scope }));
|
|
785
|
-
await this.resolvePackageSources(packageSources, accumulator, undefined, {
|
|
786
|
-
includeProjectLocalResources: options?.includeProjectLocalResources === true,
|
|
787
|
-
});
|
|
788
|
-
return this.toResolvedPaths(accumulator);
|
|
52
|
+
return resolveExtensionSourcesFromContext(this.context, sources, options);
|
|
789
53
|
}
|
|
790
54
|
listConfiguredPackages() {
|
|
791
|
-
|
|
792
|
-
const projectSettings = this.settingsManager.getProjectSettings();
|
|
793
|
-
const configuredPackages = [];
|
|
794
|
-
for (const pkg of globalSettings.packages ?? []) {
|
|
795
|
-
const source = typeof pkg === "string" ? pkg : pkg.source;
|
|
796
|
-
configuredPackages.push({
|
|
797
|
-
source,
|
|
798
|
-
scope: "user",
|
|
799
|
-
filtered: typeof pkg === "object",
|
|
800
|
-
installedPath: this.getInstalledPath(source, "user"),
|
|
801
|
-
});
|
|
802
|
-
}
|
|
803
|
-
for (const pkg of projectSettings.packages ?? []) {
|
|
804
|
-
const source = typeof pkg === "string" ? pkg : pkg.source;
|
|
805
|
-
configuredPackages.push({
|
|
806
|
-
source,
|
|
807
|
-
scope: "project",
|
|
808
|
-
filtered: typeof pkg === "object",
|
|
809
|
-
installedPath: this.getInstalledPath(source, "project"),
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
return configuredPackages;
|
|
55
|
+
return listConfiguredPackagesFromContext(this.context);
|
|
813
56
|
}
|
|
814
57
|
async install(source, options) {
|
|
815
|
-
|
|
816
|
-
const scope = options?.local ? "project" : "user";
|
|
817
|
-
this.assertProjectTrustedForScope(scope);
|
|
818
|
-
await this.withProgress("install", source, `Installing ${source}...`, async () => {
|
|
819
|
-
if (parsed.type === "npm") {
|
|
820
|
-
await this.installNpm(parsed, scope, false);
|
|
821
|
-
return;
|
|
822
|
-
}
|
|
823
|
-
if (parsed.type === "git") {
|
|
824
|
-
await this.installGit(parsed, scope);
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
if (parsed.type === "local") {
|
|
828
|
-
const resolved = this.resolvePath(parsed.path);
|
|
829
|
-
if (!existsSync(resolved)) {
|
|
830
|
-
throw new Error(`Path does not exist: ${resolved}`);
|
|
831
|
-
}
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
throw new Error(`Unsupported install source: ${source}`);
|
|
835
|
-
});
|
|
58
|
+
await installFromContext(this.context, source, options);
|
|
836
59
|
}
|
|
837
60
|
async installAndPersist(source, options) {
|
|
838
61
|
await this.install(source, options);
|
|
839
62
|
this.addSourceToSettings(source, options);
|
|
840
63
|
}
|
|
841
64
|
async remove(source, options) {
|
|
842
|
-
|
|
843
|
-
const scope = options?.local ? "project" : "user";
|
|
844
|
-
this.assertProjectTrustedForScope(scope);
|
|
845
|
-
await this.withProgress("remove", source, `Removing ${source}...`, async () => {
|
|
846
|
-
if (parsed.type === "npm") {
|
|
847
|
-
await this.uninstallNpm(parsed, scope);
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
if (parsed.type === "git") {
|
|
851
|
-
await this.removeGit(parsed, scope);
|
|
852
|
-
return;
|
|
853
|
-
}
|
|
854
|
-
if (parsed.type === "local") {
|
|
855
|
-
return;
|
|
856
|
-
}
|
|
857
|
-
throw new Error(`Unsupported remove source: ${source}`);
|
|
858
|
-
});
|
|
65
|
+
await removeFromContext(this.context, source, options);
|
|
859
66
|
}
|
|
860
67
|
async removeAndPersist(source, options) {
|
|
861
68
|
await this.remove(source, options);
|
|
862
69
|
return this.removeSourceFromSettings(source, options);
|
|
863
70
|
}
|
|
864
71
|
async update(source) {
|
|
865
|
-
|
|
866
|
-
const projectSettings = this.settingsManager.getProjectSettings();
|
|
867
|
-
const identity = source ? this.getPackageIdentity(source) : undefined;
|
|
868
|
-
let matched = false;
|
|
869
|
-
const updateSources = [];
|
|
870
|
-
for (const pkg of globalSettings.packages ?? []) {
|
|
871
|
-
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
872
|
-
if (identity && this.getPackageIdentity(sourceStr, "user") !== identity)
|
|
873
|
-
continue;
|
|
874
|
-
matched = true;
|
|
875
|
-
updateSources.push({ source: sourceStr, scope: "user" });
|
|
876
|
-
}
|
|
877
|
-
for (const pkg of projectSettings.packages ?? []) {
|
|
878
|
-
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
879
|
-
if (identity && this.getPackageIdentity(sourceStr, "project") !== identity)
|
|
880
|
-
continue;
|
|
881
|
-
matched = true;
|
|
882
|
-
updateSources.push({ source: sourceStr, scope: "project" });
|
|
883
|
-
}
|
|
884
|
-
if (source && !matched) {
|
|
885
|
-
throw new Error(this.buildNoMatchingPackageMessage(source, [
|
|
886
|
-
...(globalSettings.packages ?? []),
|
|
887
|
-
...(projectSettings.packages ?? []),
|
|
888
|
-
]));
|
|
889
|
-
}
|
|
890
|
-
await this.updateConfiguredSources(updateSources);
|
|
891
|
-
}
|
|
892
|
-
async updateConfiguredSources(sources) {
|
|
893
|
-
if (isOfflineModeEnabled() || sources.length === 0) {
|
|
894
|
-
return;
|
|
895
|
-
}
|
|
896
|
-
const npmCandidates = [];
|
|
897
|
-
const gitCandidates = [];
|
|
898
|
-
for (const entry of sources) {
|
|
899
|
-
const parsed = this.parseSource(entry.source);
|
|
900
|
-
// Pinned npm versions are fixed. Pinned git refs are configured checkout targets,
|
|
901
|
-
// so include them to reconcile an existing clone when the configured ref changes.
|
|
902
|
-
if (parsed.type === "npm") {
|
|
903
|
-
if (!parsed.pinned) {
|
|
904
|
-
npmCandidates.push({ ...entry, parsed });
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
else if (parsed.type === "git") {
|
|
908
|
-
gitCandidates.push({ ...entry, parsed });
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
const npmCheckTasks = npmCandidates.map((entry) => async () => ({
|
|
912
|
-
entry,
|
|
913
|
-
shouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),
|
|
914
|
-
}));
|
|
915
|
-
const npmCheckResults = await this.runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);
|
|
916
|
-
const userNpmUpdates = [];
|
|
917
|
-
const projectNpmUpdates = [];
|
|
918
|
-
for (const result of npmCheckResults) {
|
|
919
|
-
if (!result.shouldUpdate) {
|
|
920
|
-
continue;
|
|
921
|
-
}
|
|
922
|
-
if (result.entry.scope === "user") {
|
|
923
|
-
userNpmUpdates.push(result.entry);
|
|
924
|
-
}
|
|
925
|
-
else {
|
|
926
|
-
projectNpmUpdates.push(result.entry);
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
const tasks = [];
|
|
930
|
-
if (userNpmUpdates.length > 0) {
|
|
931
|
-
tasks.push(this.updateNpmBatch(userNpmUpdates, "user"));
|
|
932
|
-
}
|
|
933
|
-
if (projectNpmUpdates.length > 0) {
|
|
934
|
-
tasks.push(this.updateNpmBatch(projectNpmUpdates, "project"));
|
|
935
|
-
}
|
|
936
|
-
if (gitCandidates.length > 0) {
|
|
937
|
-
const gitTasks = gitCandidates.map((entry) => async () => this.withProgress("update", entry.source, `Updating ${entry.source}...`, async () => {
|
|
938
|
-
await this.updateGit(entry.parsed, entry.scope);
|
|
939
|
-
}));
|
|
940
|
-
tasks.push(this.runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => { }));
|
|
941
|
-
}
|
|
942
|
-
await Promise.all(tasks);
|
|
943
|
-
}
|
|
944
|
-
async shouldUpdateNpmSource(source, scope) {
|
|
945
|
-
const installedPath = this.getManagedNpmInstallPath(source, scope);
|
|
946
|
-
const installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;
|
|
947
|
-
if (!installedVersion) {
|
|
948
|
-
return true;
|
|
949
|
-
}
|
|
950
|
-
try {
|
|
951
|
-
const targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);
|
|
952
|
-
return targetVersion !== installedVersion;
|
|
953
|
-
}
|
|
954
|
-
catch {
|
|
955
|
-
// Preserve existing update behavior when version lookup fails.
|
|
956
|
-
return true;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
async updateNpmBatch(sources, scope) {
|
|
960
|
-
if (sources.length === 0) {
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
const sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;
|
|
964
|
-
const message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;
|
|
965
|
-
const specs = sources.map((entry) => (entry.parsed.version ? entry.parsed.spec : `${entry.parsed.name}@latest`));
|
|
966
|
-
await this.withProgress("update", sourceLabel, message, async () => {
|
|
967
|
-
await this.installNpmBatch(specs, scope);
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
async installNpmBatch(specs, scope) {
|
|
971
|
-
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
972
|
-
this.ensureNpmProject(installRoot);
|
|
973
|
-
await this.runNpmCommand(this.getNpmInstallArgs(specs, installRoot));
|
|
72
|
+
await updateFromContext(this.context, source);
|
|
974
73
|
}
|
|
975
74
|
async checkForAvailableUpdates() {
|
|
976
|
-
|
|
977
|
-
return [];
|
|
978
|
-
}
|
|
979
|
-
const globalSettings = this.settingsManager.getGlobalSettings();
|
|
980
|
-
const projectSettings = this.settingsManager.getProjectSettings();
|
|
981
|
-
const allPackages = [];
|
|
982
|
-
for (const pkg of projectSettings.packages ?? []) {
|
|
983
|
-
allPackages.push({ pkg, scope: "project" });
|
|
984
|
-
}
|
|
985
|
-
for (const pkg of globalSettings.packages ?? []) {
|
|
986
|
-
allPackages.push({ pkg, scope: "user" });
|
|
987
|
-
}
|
|
988
|
-
const packageSources = this.dedupePackages(allPackages);
|
|
989
|
-
const checks = packageSources
|
|
990
|
-
.filter((entry) => entry.scope !== "temporary")
|
|
991
|
-
.map((entry) => async () => {
|
|
992
|
-
const source = typeof entry.pkg === "string" ? entry.pkg : entry.pkg.source;
|
|
993
|
-
const parsed = this.parseSource(source);
|
|
994
|
-
if (parsed.type === "local" || parsed.pinned) {
|
|
995
|
-
return undefined;
|
|
996
|
-
}
|
|
997
|
-
if (parsed.type === "npm") {
|
|
998
|
-
const installedPath = this.getNpmInstallPath(parsed, entry.scope);
|
|
999
|
-
if (!existsSync(installedPath)) {
|
|
1000
|
-
return undefined;
|
|
1001
|
-
}
|
|
1002
|
-
const hasUpdate = await this.npmHasAvailableUpdate(parsed, installedPath);
|
|
1003
|
-
if (!hasUpdate) {
|
|
1004
|
-
return undefined;
|
|
1005
|
-
}
|
|
1006
|
-
return {
|
|
1007
|
-
source,
|
|
1008
|
-
displayName: parsed.name,
|
|
1009
|
-
type: "npm",
|
|
1010
|
-
scope: entry.scope,
|
|
1011
|
-
};
|
|
1012
|
-
}
|
|
1013
|
-
const installedPath = this.getExistingGitInstallPath(parsed, entry.scope);
|
|
1014
|
-
if (!installedPath) {
|
|
1015
|
-
return undefined;
|
|
1016
|
-
}
|
|
1017
|
-
const hasUpdate = await this.gitHasAvailableUpdate(installedPath);
|
|
1018
|
-
if (!hasUpdate) {
|
|
1019
|
-
return undefined;
|
|
1020
|
-
}
|
|
1021
|
-
return {
|
|
1022
|
-
source,
|
|
1023
|
-
displayName: `${parsed.host}/${parsed.path}`,
|
|
1024
|
-
type: "git",
|
|
1025
|
-
scope: entry.scope,
|
|
1026
|
-
};
|
|
1027
|
-
});
|
|
1028
|
-
const results = await this.runWithConcurrency(checks, UPDATE_CHECK_CONCURRENCY);
|
|
1029
|
-
return results.filter((result) => result !== undefined);
|
|
1030
|
-
}
|
|
1031
|
-
async resolvePackageSources(sources, accumulator, onMissing, options) {
|
|
1032
|
-
for (const { pkg, scope } of sources) {
|
|
1033
|
-
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
1034
|
-
const filter = typeof pkg === "object" ? pkg : undefined;
|
|
1035
|
-
const parsed = this.parseSource(sourceStr);
|
|
1036
|
-
const metadata = { source: sourceStr, scope, origin: "package" };
|
|
1037
|
-
if (parsed.type === "local") {
|
|
1038
|
-
for (const baseDir of this.getBaseDirsForScope(scope)) {
|
|
1039
|
-
this.resolveLocalExtensionSource(parsed, accumulator, filter, { ...metadata, baseDir }, baseDir, {
|
|
1040
|
-
includeProjectLocalResources: options?.includeProjectLocalResources === true,
|
|
1041
|
-
});
|
|
1042
|
-
}
|
|
1043
|
-
continue;
|
|
1044
|
-
}
|
|
1045
|
-
const installMissing = async () => {
|
|
1046
|
-
if (isOfflineModeEnabled()) {
|
|
1047
|
-
return false;
|
|
1048
|
-
}
|
|
1049
|
-
if (!onMissing) {
|
|
1050
|
-
await this.installParsedSource(parsed, scope);
|
|
1051
|
-
return true;
|
|
1052
|
-
}
|
|
1053
|
-
const action = await onMissing(sourceStr);
|
|
1054
|
-
if (action === "skip")
|
|
1055
|
-
return false;
|
|
1056
|
-
if (action === "error")
|
|
1057
|
-
throw new Error(`Missing source: ${sourceStr}`);
|
|
1058
|
-
await this.installParsedSource(parsed, scope);
|
|
1059
|
-
return true;
|
|
1060
|
-
};
|
|
1061
|
-
if (parsed.type === "npm") {
|
|
1062
|
-
let installedPath = this.getExistingNpmInstallPath(parsed, scope);
|
|
1063
|
-
const needsInstall = !installedPath || !(await this.installedNpmMatchesConfiguredVersion(parsed, installedPath));
|
|
1064
|
-
if (needsInstall) {
|
|
1065
|
-
const installed = await installMissing();
|
|
1066
|
-
if (!installed)
|
|
1067
|
-
continue;
|
|
1068
|
-
installedPath = this.getExistingNpmInstallPath(parsed, scope);
|
|
1069
|
-
if (!installedPath || !(await this.installedNpmMatchesConfiguredVersion(parsed, installedPath))) {
|
|
1070
|
-
continue;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
if (!installedPath)
|
|
1074
|
-
continue;
|
|
1075
|
-
metadata.baseDir = installedPath;
|
|
1076
|
-
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
1077
|
-
continue;
|
|
1078
|
-
}
|
|
1079
|
-
if (parsed.type === "git") {
|
|
1080
|
-
let installedPath = this.getExistingGitInstallPath(parsed, scope) ?? this.getGitInstallPath(parsed, scope);
|
|
1081
|
-
if (!existsSync(installedPath)) {
|
|
1082
|
-
const installed = await installMissing();
|
|
1083
|
-
if (!installed)
|
|
1084
|
-
continue;
|
|
1085
|
-
}
|
|
1086
|
-
else if (scope === "temporary" && !parsed.pinned && !isOfflineModeEnabled()) {
|
|
1087
|
-
await this.refreshTemporaryGitSource(parsed, sourceStr);
|
|
1088
|
-
}
|
|
1089
|
-
metadata.baseDir = installedPath;
|
|
1090
|
-
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
resolveLocalExtensionSource(source, accumulator, filter, metadata, baseDir, options) {
|
|
1095
|
-
const resolved = this.resolvePathFromBase(source.path, baseDir);
|
|
1096
|
-
if (!existsSync(resolved)) {
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
try {
|
|
1100
|
-
const stats = statSync(resolved);
|
|
1101
|
-
if (stats.isFile()) {
|
|
1102
|
-
this.addResource(accumulator.extensions, resolved, { ...metadata, baseDir: dirname(resolved) }, true);
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
if (stats.isDirectory()) {
|
|
1106
|
-
const packageMetadata = { ...metadata, baseDir: resolved };
|
|
1107
|
-
const packageResources = this.collectPackageResources(resolved, accumulator, filter, packageMetadata);
|
|
1108
|
-
const projectLocalResources = options?.includeProjectLocalResources
|
|
1109
|
-
? this.collectProjectLocalResources(resolved, accumulator, filter, packageMetadata)
|
|
1110
|
-
: false;
|
|
1111
|
-
const extensionEntries = resolveExtensionEntries(resolved);
|
|
1112
|
-
const shouldAddDirectoryFallback = extensionEntries !== null || (options?.includeProjectLocalResources === true && !projectLocalResources);
|
|
1113
|
-
if (!packageResources && shouldAddDirectoryFallback) {
|
|
1114
|
-
this.addResource(accumulator.extensions, resolved, packageMetadata, true);
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
catch {
|
|
1119
|
-
return;
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
async installParsedSource(parsed, scope) {
|
|
1123
|
-
if (parsed.type === "npm") {
|
|
1124
|
-
await this.installNpm(parsed, scope, scope === "temporary");
|
|
1125
|
-
return;
|
|
1126
|
-
}
|
|
1127
|
-
if (parsed.type === "git") {
|
|
1128
|
-
await this.installGit(parsed, scope);
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
getPackageSourceString(pkg) {
|
|
1133
|
-
return typeof pkg === "string" ? pkg : pkg.source;
|
|
1134
|
-
}
|
|
1135
|
-
getSourceMatchKeyForInput(source) {
|
|
1136
|
-
const parsed = this.parseSource(source);
|
|
1137
|
-
if (parsed.type === "npm") {
|
|
1138
|
-
return `npm:${parsed.name}`;
|
|
1139
|
-
}
|
|
1140
|
-
if (parsed.type === "git") {
|
|
1141
|
-
return `git:${parsed.host}/${parsed.path}`;
|
|
1142
|
-
}
|
|
1143
|
-
return `local:${this.resolvePath(parsed.path)}`;
|
|
1144
|
-
}
|
|
1145
|
-
getSourceMatchKeyForSettings(source, scope) {
|
|
1146
|
-
const parsed = this.parseSource(source);
|
|
1147
|
-
if (parsed.type === "npm") {
|
|
1148
|
-
return `npm:${parsed.name}`;
|
|
1149
|
-
}
|
|
1150
|
-
if (parsed.type === "git") {
|
|
1151
|
-
return `git:${parsed.host}/${parsed.path}`;
|
|
1152
|
-
}
|
|
1153
|
-
const baseDir = this.getBaseDirForScope(scope);
|
|
1154
|
-
return `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;
|
|
1155
|
-
}
|
|
1156
|
-
buildNoMatchingPackageMessage(source, configuredPackages) {
|
|
1157
|
-
const suggestion = this.findSuggestedConfiguredSource(source, configuredPackages);
|
|
1158
|
-
if (!suggestion) {
|
|
1159
|
-
return `No matching package found for ${source}`;
|
|
1160
|
-
}
|
|
1161
|
-
return `No matching package found for ${source}. Did you mean ${suggestion}?`;
|
|
1162
|
-
}
|
|
1163
|
-
findSuggestedConfiguredSource(source, configuredPackages) {
|
|
1164
|
-
const trimmedSource = source.trim();
|
|
1165
|
-
const suggestions = new Set();
|
|
1166
|
-
for (const pkg of configuredPackages) {
|
|
1167
|
-
const sourceStr = this.getPackageSourceString(pkg);
|
|
1168
|
-
const parsed = this.parseSource(sourceStr);
|
|
1169
|
-
if (parsed.type === "npm") {
|
|
1170
|
-
if (trimmedSource === parsed.name || trimmedSource === parsed.spec) {
|
|
1171
|
-
suggestions.add(sourceStr);
|
|
1172
|
-
}
|
|
1173
|
-
continue;
|
|
1174
|
-
}
|
|
1175
|
-
if (parsed.type === "git") {
|
|
1176
|
-
const shorthand = `${parsed.host}/${parsed.path}`;
|
|
1177
|
-
const shorthandWithRef = parsed.ref ? `${shorthand}@${parsed.ref}` : undefined;
|
|
1178
|
-
if (trimmedSource === shorthand || (shorthandWithRef && trimmedSource === shorthandWithRef)) {
|
|
1179
|
-
suggestions.add(sourceStr);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
return suggestions.values().next().value;
|
|
1184
|
-
}
|
|
1185
|
-
packageSourcesMatch(existing, inputSource, scope) {
|
|
1186
|
-
const left = this.getSourceMatchKeyForSettings(this.getPackageSourceString(existing), scope);
|
|
1187
|
-
const right = this.getSourceMatchKeyForInput(inputSource);
|
|
1188
|
-
return left === right;
|
|
1189
|
-
}
|
|
1190
|
-
normalizePackageSourceForSettings(source, scope) {
|
|
1191
|
-
const parsed = this.parseSource(source);
|
|
1192
|
-
if (parsed.type !== "local") {
|
|
1193
|
-
return source;
|
|
1194
|
-
}
|
|
1195
|
-
const baseDir = this.getBaseDirForScope(scope);
|
|
1196
|
-
const resolved = this.resolvePath(parsed.path);
|
|
1197
|
-
const rel = relative(baseDir, resolved);
|
|
1198
|
-
return rel || ".";
|
|
75
|
+
return checkForAvailableUpdatesFromContext(this.context);
|
|
1199
76
|
}
|
|
1200
77
|
parseSource(source) {
|
|
1201
|
-
|
|
1202
|
-
const spec = source.slice("npm:".length).trim();
|
|
1203
|
-
const { name, version } = this.parseNpmSpec(spec);
|
|
1204
|
-
return {
|
|
1205
|
-
type: "npm",
|
|
1206
|
-
spec,
|
|
1207
|
-
name,
|
|
1208
|
-
version,
|
|
1209
|
-
range: getNpmVersionRange(version),
|
|
1210
|
-
pinned: isExactNpmVersion(version),
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
if (isLocalPath(source)) {
|
|
1214
|
-
return { type: "local", path: source };
|
|
1215
|
-
}
|
|
1216
|
-
// Try parsing as git URL
|
|
1217
|
-
const gitParsed = parseGitUrl(source);
|
|
1218
|
-
if (gitParsed) {
|
|
1219
|
-
return gitParsed;
|
|
1220
|
-
}
|
|
1221
|
-
return { type: "local", path: source };
|
|
1222
|
-
}
|
|
1223
|
-
async installedNpmMatchesConfiguredVersion(source, installedPath) {
|
|
1224
|
-
const installedVersion = this.getInstalledNpmVersion(installedPath);
|
|
1225
|
-
if (!installedVersion) {
|
|
1226
|
-
return false;
|
|
1227
|
-
}
|
|
1228
|
-
if (source.range) {
|
|
1229
|
-
return satisfies(installedVersion, source.range);
|
|
1230
|
-
}
|
|
1231
|
-
if (source.version !== undefined) {
|
|
1232
|
-
if (isOfflineModeEnabled()) {
|
|
1233
|
-
// Non-semver selectors such as npm dist-tags are mutable, but offline mode cannot
|
|
1234
|
-
// resolve the current registry target. Keep an already-installed copy usable;
|
|
1235
|
-
// online resolution still verifies the exact tag target before accepting it.
|
|
1236
|
-
return true;
|
|
1237
|
-
}
|
|
1238
|
-
try {
|
|
1239
|
-
const targetVersion = await this.getLatestNpmVersion(source.spec);
|
|
1240
|
-
return installedVersion === targetVersion;
|
|
1241
|
-
}
|
|
1242
|
-
catch {
|
|
1243
|
-
return false;
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
return true;
|
|
1247
|
-
}
|
|
1248
|
-
async npmHasAvailableUpdate(source, installedPath) {
|
|
1249
|
-
if (isOfflineModeEnabled()) {
|
|
1250
|
-
return false;
|
|
1251
|
-
}
|
|
1252
|
-
const installedVersion = this.getInstalledNpmVersion(installedPath);
|
|
1253
|
-
if (!installedVersion) {
|
|
1254
|
-
return false;
|
|
1255
|
-
}
|
|
1256
|
-
try {
|
|
1257
|
-
const targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);
|
|
1258
|
-
return targetVersion !== installedVersion;
|
|
1259
|
-
}
|
|
1260
|
-
catch {
|
|
1261
|
-
return false;
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
getInstalledNpmVersion(installedPath) {
|
|
1265
|
-
const packageJsonPath = join(installedPath, "package.json");
|
|
1266
|
-
if (!existsSync(packageJsonPath))
|
|
1267
|
-
return undefined;
|
|
1268
|
-
try {
|
|
1269
|
-
const content = readFileSync(packageJsonPath, "utf-8");
|
|
1270
|
-
const pkg = JSON.parse(content);
|
|
1271
|
-
return pkg.version;
|
|
1272
|
-
}
|
|
1273
|
-
catch {
|
|
1274
|
-
return undefined;
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
async getLatestNpmVersion(packageSpec, range) {
|
|
1278
|
-
const npmCommand = this.getNpmCommand();
|
|
1279
|
-
const stdout = await this.runCommandCapture(npmCommand.command, [...npmCommand.args, "view", packageSpec, "version", "--json"], { cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS });
|
|
1280
|
-
const raw = stdout.trim();
|
|
1281
|
-
if (!raw)
|
|
1282
|
-
throw new Error("Empty response from npm view");
|
|
1283
|
-
const parsed = JSON.parse(raw);
|
|
1284
|
-
if (typeof parsed === "string") {
|
|
1285
|
-
return parsed;
|
|
1286
|
-
}
|
|
1287
|
-
if (Array.isArray(parsed)) {
|
|
1288
|
-
const versions = parsed.filter((value) => typeof value === "string" && value.length > 0);
|
|
1289
|
-
const latest = range ? maxSatisfying(versions, range) : [...versions].sort(rcompare)[0];
|
|
1290
|
-
if (latest)
|
|
1291
|
-
return latest;
|
|
1292
|
-
}
|
|
1293
|
-
throw new Error("Unexpected response from npm view");
|
|
1294
|
-
}
|
|
1295
|
-
async gitHasAvailableUpdate(installedPath) {
|
|
1296
|
-
if (isOfflineModeEnabled()) {
|
|
1297
|
-
return false;
|
|
1298
|
-
}
|
|
1299
|
-
try {
|
|
1300
|
-
const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
|
|
1301
|
-
cwd: installedPath,
|
|
1302
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1303
|
-
});
|
|
1304
|
-
const remoteHead = await this.getRemoteGitHead(installedPath);
|
|
1305
|
-
return localHead.trim() !== remoteHead.trim();
|
|
1306
|
-
}
|
|
1307
|
-
catch {
|
|
1308
|
-
return false;
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
async getRemoteGitHead(installedPath) {
|
|
1312
|
-
const upstreamRef = await this.getGitUpstreamRef(installedPath);
|
|
1313
|
-
if (upstreamRef) {
|
|
1314
|
-
const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", upstreamRef]);
|
|
1315
|
-
const match = remoteHead.match(/^([0-9a-f]{40})\s+/m);
|
|
1316
|
-
if (match?.[1]) {
|
|
1317
|
-
return match[1];
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", "HEAD"]);
|
|
1321
|
-
const match = remoteHead.match(/^([0-9a-f]{40})\s+HEAD$/m);
|
|
1322
|
-
if (!match?.[1]) {
|
|
1323
|
-
throw new Error("Failed to determine remote HEAD");
|
|
1324
|
-
}
|
|
1325
|
-
return match[1];
|
|
1326
|
-
}
|
|
1327
|
-
async getLocalGitUpdateTarget(installedPath) {
|
|
1328
|
-
try {
|
|
1329
|
-
const upstream = await this.runCommandCapture("git", ["rev-parse", "--abbrev-ref", "@{upstream}"], {
|
|
1330
|
-
cwd: installedPath,
|
|
1331
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1332
|
-
});
|
|
1333
|
-
const trimmedUpstream = upstream.trim();
|
|
1334
|
-
if (!trimmedUpstream.startsWith("origin/")) {
|
|
1335
|
-
throw new Error(`Unsupported upstream remote: ${trimmedUpstream}`);
|
|
1336
|
-
}
|
|
1337
|
-
const branch = trimmedUpstream.slice("origin/".length);
|
|
1338
|
-
if (!branch) {
|
|
1339
|
-
throw new Error("Missing upstream branch name");
|
|
1340
|
-
}
|
|
1341
|
-
const head = await this.runCommandCapture("git", ["rev-parse", "@{upstream}"], {
|
|
1342
|
-
cwd: installedPath,
|
|
1343
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1344
|
-
});
|
|
1345
|
-
return {
|
|
1346
|
-
ref: "@{upstream}",
|
|
1347
|
-
head,
|
|
1348
|
-
fetchArgs: [
|
|
1349
|
-
"fetch",
|
|
1350
|
-
"--prune",
|
|
1351
|
-
"--no-tags",
|
|
1352
|
-
"origin",
|
|
1353
|
-
`+refs/heads/${branch}:refs/remotes/origin/${branch}`,
|
|
1354
|
-
],
|
|
1355
|
-
};
|
|
1356
|
-
}
|
|
1357
|
-
catch {
|
|
1358
|
-
await this.runCommand("git", ["remote", "set-head", "origin", "-a"], { cwd: installedPath }).catch(() => { });
|
|
1359
|
-
const head = await this.runCommandCapture("git", ["rev-parse", "origin/HEAD"], {
|
|
1360
|
-
cwd: installedPath,
|
|
1361
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1362
|
-
});
|
|
1363
|
-
const originHeadRef = await this.runCommandCapture("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
|
|
1364
|
-
cwd: installedPath,
|
|
1365
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1366
|
-
}).catch(() => "");
|
|
1367
|
-
const branch = originHeadRef.trim().replace(/^refs\/remotes\/origin\//, "");
|
|
1368
|
-
if (branch) {
|
|
1369
|
-
return {
|
|
1370
|
-
ref: "origin/HEAD",
|
|
1371
|
-
head,
|
|
1372
|
-
fetchArgs: [
|
|
1373
|
-
"fetch",
|
|
1374
|
-
"--prune",
|
|
1375
|
-
"--no-tags",
|
|
1376
|
-
"origin",
|
|
1377
|
-
`+refs/heads/${branch}:refs/remotes/origin/${branch}`,
|
|
1378
|
-
],
|
|
1379
|
-
};
|
|
1380
|
-
}
|
|
1381
|
-
return {
|
|
1382
|
-
ref: "origin/HEAD",
|
|
1383
|
-
head,
|
|
1384
|
-
fetchArgs: ["fetch", "--prune", "--no-tags", "origin", "+HEAD:refs/remotes/origin/HEAD"],
|
|
1385
|
-
};
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
async getGitUpstreamRef(installedPath) {
|
|
1389
|
-
try {
|
|
1390
|
-
const upstream = await this.runCommandCapture("git", ["rev-parse", "--abbrev-ref", "@{upstream}"], {
|
|
1391
|
-
cwd: installedPath,
|
|
1392
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1393
|
-
});
|
|
1394
|
-
const trimmed = upstream.trim();
|
|
1395
|
-
if (!trimmed.startsWith("origin/")) {
|
|
1396
|
-
return undefined;
|
|
1397
|
-
}
|
|
1398
|
-
const branch = trimmed.slice("origin/".length);
|
|
1399
|
-
return branch ? `refs/heads/${branch}` : undefined;
|
|
1400
|
-
}
|
|
1401
|
-
catch {
|
|
1402
|
-
return undefined;
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
runGitRemoteCommand(installedPath, args) {
|
|
1406
|
-
return this.runCommandCapture("git", args, {
|
|
1407
|
-
cwd: installedPath,
|
|
1408
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1409
|
-
env: {
|
|
1410
|
-
GIT_TERMINAL_PROMPT: "0",
|
|
1411
|
-
},
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
async runWithConcurrency(tasks, limit) {
|
|
1415
|
-
if (tasks.length === 0) {
|
|
1416
|
-
return [];
|
|
1417
|
-
}
|
|
1418
|
-
const results = new Array(tasks.length);
|
|
1419
|
-
let nextIndex = 0;
|
|
1420
|
-
const workerCount = Math.max(1, Math.min(limit, tasks.length));
|
|
1421
|
-
const worker = async () => {
|
|
1422
|
-
while (true) {
|
|
1423
|
-
const index = nextIndex;
|
|
1424
|
-
nextIndex += 1;
|
|
1425
|
-
if (index >= tasks.length) {
|
|
1426
|
-
return;
|
|
1427
|
-
}
|
|
1428
|
-
results[index] = await tasks[index]();
|
|
1429
|
-
}
|
|
1430
|
-
};
|
|
1431
|
-
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
1432
|
-
return results;
|
|
78
|
+
return parsePackageSource(source);
|
|
1433
79
|
}
|
|
1434
|
-
/**
|
|
1435
|
-
* Get a unique identity for a package, ignoring version/ref.
|
|
1436
|
-
* Used to detect when the same package is in both global and project settings.
|
|
1437
|
-
* For git packages, uses normalized host/path to ensure SSH and HTTPS URLs
|
|
1438
|
-
* for the same repository are treated as identical.
|
|
1439
|
-
*/
|
|
1440
80
|
getPackageIdentity(source, scope) {
|
|
1441
|
-
|
|
1442
|
-
if (parsed.type === "npm") {
|
|
1443
|
-
return `npm:${parsed.name}`;
|
|
1444
|
-
}
|
|
1445
|
-
if (parsed.type === "git") {
|
|
1446
|
-
// Use host/path for identity to normalize SSH and HTTPS
|
|
1447
|
-
return `git:${parsed.host}/${parsed.path}`;
|
|
1448
|
-
}
|
|
1449
|
-
if (scope) {
|
|
1450
|
-
const baseDir = this.getBaseDirForScope(scope);
|
|
1451
|
-
return `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;
|
|
1452
|
-
}
|
|
1453
|
-
return `local:${this.resolvePath(parsed.path)}`;
|
|
1454
|
-
}
|
|
1455
|
-
/**
|
|
1456
|
-
* Dedupe packages: if same package identity appears in both global and project,
|
|
1457
|
-
* keep only the project one (project wins).
|
|
1458
|
-
*/
|
|
1459
|
-
dedupePackages(packages) {
|
|
1460
|
-
const seen = new Map();
|
|
1461
|
-
for (const entry of packages) {
|
|
1462
|
-
const sourceStr = typeof entry.pkg === "string" ? entry.pkg : entry.pkg.source;
|
|
1463
|
-
const identity = this.getPackageIdentity(sourceStr, entry.scope);
|
|
1464
|
-
const existing = seen.get(identity);
|
|
1465
|
-
if (!existing) {
|
|
1466
|
-
seen.set(identity, entry);
|
|
1467
|
-
}
|
|
1468
|
-
else if (entry.scope === "project" && existing.scope === "user") {
|
|
1469
|
-
// Project wins over user
|
|
1470
|
-
seen.set(identity, entry);
|
|
1471
|
-
}
|
|
1472
|
-
// If existing is project and new is global, keep existing (project)
|
|
1473
|
-
// If both are same scope, keep first one
|
|
1474
|
-
}
|
|
1475
|
-
return Array.from(seen.values());
|
|
1476
|
-
}
|
|
1477
|
-
parseNpmSpec(spec) {
|
|
1478
|
-
const versionSeparator = spec.startsWith("@") ? spec.indexOf("@", spec.indexOf("/") + 1) : spec.indexOf("@");
|
|
1479
|
-
if (versionSeparator <= 0) {
|
|
1480
|
-
return { name: spec };
|
|
1481
|
-
}
|
|
1482
|
-
return {
|
|
1483
|
-
name: spec.slice(0, versionSeparator),
|
|
1484
|
-
version: spec.slice(versionSeparator + 1),
|
|
1485
|
-
};
|
|
1486
|
-
}
|
|
1487
|
-
assertProjectTrustedForScope(scope) {
|
|
1488
|
-
if (scope === "project" && !this.settingsManager.isProjectTrusted()) {
|
|
1489
|
-
throw new Error("Project is not trusted; refusing to access project package storage");
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
getNpmCommand() {
|
|
1493
|
-
const configuredCommand = this.settingsManager.getNpmCommand();
|
|
1494
|
-
if (!configuredCommand || configuredCommand.length === 0) {
|
|
1495
|
-
return { command: "npm", args: [] };
|
|
1496
|
-
}
|
|
1497
|
-
const [command, ...args] = configuredCommand;
|
|
1498
|
-
if (!command) {
|
|
1499
|
-
throw new Error("Invalid npmCommand: first array entry must be a non-empty command");
|
|
1500
|
-
}
|
|
1501
|
-
return { command, args };
|
|
1502
|
-
}
|
|
1503
|
-
getPackageManagerName() {
|
|
1504
|
-
const npmCommand = this.getNpmCommand();
|
|
1505
|
-
const commandParts = [npmCommand.command, ...npmCommand.args];
|
|
1506
|
-
const separatorIndex = commandParts.lastIndexOf("--");
|
|
1507
|
-
const packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;
|
|
1508
|
-
return packageManagerCommand ? basename(packageManagerCommand).replace(/\.(cmd|exe)$/i, "") : "";
|
|
1509
|
-
}
|
|
1510
|
-
async runNpmCommand(args, options) {
|
|
1511
|
-
const npmCommand = this.getNpmCommand();
|
|
1512
|
-
await this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);
|
|
1513
|
-
}
|
|
1514
|
-
getGitDependencyInstallArgs() {
|
|
1515
|
-
const configuredCommand = this.settingsManager.getNpmCommand();
|
|
1516
|
-
if (configuredCommand && configuredCommand.length > 0) {
|
|
1517
|
-
return ["install"];
|
|
1518
|
-
}
|
|
1519
|
-
return ["install", "--omit=dev"];
|
|
1520
|
-
}
|
|
1521
|
-
runNpmCommandSync(args) {
|
|
1522
|
-
const npmCommand = this.getNpmCommand();
|
|
1523
|
-
return this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);
|
|
1524
|
-
}
|
|
1525
|
-
getNpmInstallArgs(specs, installRoot) {
|
|
1526
|
-
const packageManagerName = this.getPackageManagerName();
|
|
1527
|
-
// Extension packages run inside Atomic and resolve pi APIs through loader aliases/virtual modules.
|
|
1528
|
-
// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and
|
|
1529
|
-
// equivalent bun/pnpm settings) so package managers do not install or solve host-provided
|
|
1530
|
-
// @earendil-works/pi-* peers. Stale auto-installed pi peers can otherwise block updates.
|
|
1531
|
-
if (packageManagerName === "bun") {
|
|
1532
|
-
return ["install", ...specs, "--cwd", installRoot, "--omit=peer"];
|
|
1533
|
-
}
|
|
1534
|
-
if (packageManagerName === "pnpm") {
|
|
1535
|
-
return [
|
|
1536
|
-
"install",
|
|
1537
|
-
...specs,
|
|
1538
|
-
"--prefix",
|
|
1539
|
-
installRoot,
|
|
1540
|
-
"--config.auto-install-peers=false",
|
|
1541
|
-
"--config.strict-peer-dependencies=false",
|
|
1542
|
-
"--config.strict-dep-builds=false",
|
|
1543
|
-
];
|
|
1544
|
-
}
|
|
1545
|
-
return ["install", ...specs, "--prefix", installRoot, "--legacy-peer-deps"];
|
|
1546
|
-
}
|
|
1547
|
-
async installNpm(source, scope, temporary) {
|
|
1548
|
-
const installRoot = this.getNpmInstallRoot(scope, temporary);
|
|
1549
|
-
this.ensureNpmProject(installRoot);
|
|
1550
|
-
await this.runNpmCommand(this.getNpmInstallArgs([source.spec], installRoot));
|
|
81
|
+
return getPackageIdentityFromContext(this.context, source, scope);
|
|
1551
82
|
}
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
if (!existsSync(installRoot)) {
|
|
1555
|
-
return;
|
|
1556
|
-
}
|
|
1557
|
-
if (this.getPackageManagerName() === "bun") {
|
|
1558
|
-
await this.runNpmCommand(["uninstall", source.name, "--cwd", installRoot]);
|
|
1559
|
-
return;
|
|
1560
|
-
}
|
|
1561
|
-
await this.runNpmCommand(["uninstall", source.name, "--prefix", installRoot]);
|
|
1562
|
-
}
|
|
1563
|
-
getSafeGitRef(ref) {
|
|
1564
|
-
if (!this.isSafeGitRef(ref)) {
|
|
1565
|
-
throw new Error(`Invalid git ref: ${JSON.stringify(ref)}`);
|
|
1566
|
-
}
|
|
1567
|
-
return ref;
|
|
1568
|
-
}
|
|
1569
|
-
isSafeGitRef(ref) {
|
|
1570
|
-
if (!ref || ref === "@" || ref.startsWith("-") || ref.endsWith(".") || ref.endsWith("/")) {
|
|
1571
|
-
return false;
|
|
1572
|
-
}
|
|
1573
|
-
if (/[\x00-\x1f\x7f\s~^:?*\[\]\\]/u.test(ref)) {
|
|
1574
|
-
return false;
|
|
1575
|
-
}
|
|
1576
|
-
if (ref.includes("..") || ref.includes("@{") || ref.includes("//")) {
|
|
1577
|
-
return false;
|
|
1578
|
-
}
|
|
1579
|
-
return ref
|
|
1580
|
-
.split("/")
|
|
1581
|
-
.every((part) => part && part !== "." && part !== ".." && !part.startsWith(".") && !part.endsWith(".lock"));
|
|
83
|
+
getGitInstallPath(source, scope) {
|
|
84
|
+
return getGitInstallPathFromContext(this.context, source, scope);
|
|
1582
85
|
}
|
|
1583
|
-
async
|
|
1584
|
-
|
|
1585
|
-
const targetDir = this.getGitInstallPath(source, scope);
|
|
1586
|
-
if (existsSync(targetDir)) {
|
|
1587
|
-
if (safeRef) {
|
|
1588
|
-
await this.ensureGitRef(targetDir, ["fetch", "origin", "--", safeRef], "FETCH_HEAD");
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
const target = await this.getLocalGitUpdateTarget(targetDir);
|
|
1592
|
-
await this.ensureGitRef(targetDir, target.fetchArgs, target.ref);
|
|
1593
|
-
return;
|
|
1594
|
-
}
|
|
1595
|
-
const gitRoot = this.getGitInstallRoot(scope);
|
|
1596
|
-
if (gitRoot) {
|
|
1597
|
-
this.ensureGitIgnore(gitRoot);
|
|
1598
|
-
}
|
|
1599
|
-
mkdirSync(dirname(targetDir), { recursive: true });
|
|
1600
|
-
await this.runCommand("git", ["clone", "--", source.repo, targetDir]);
|
|
1601
|
-
if (safeRef) {
|
|
1602
|
-
await this.runCommand("git", ["checkout", safeRef], { cwd: targetDir });
|
|
1603
|
-
}
|
|
1604
|
-
const packageJsonPath = join(targetDir, "package.json");
|
|
1605
|
-
if (existsSync(packageJsonPath)) {
|
|
1606
|
-
await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
|
|
1607
|
-
}
|
|
86
|
+
async installParsedSource(parsed, scope) {
|
|
87
|
+
await installParsedSourceFromContext(this.context, parsed, scope);
|
|
1608
88
|
}
|
|
1609
89
|
async updateGit(source, scope) {
|
|
1610
|
-
|
|
1611
|
-
const targetDir = this.getExistingGitInstallPath(source, scope) ?? this.getGitInstallPath(source, scope);
|
|
1612
|
-
if (!existsSync(targetDir)) {
|
|
1613
|
-
await this.installGit(source, scope);
|
|
1614
|
-
return;
|
|
1615
|
-
}
|
|
1616
|
-
if (safeRef) {
|
|
1617
|
-
await this.ensureGitRef(targetDir, ["fetch", "origin", "--", safeRef], "FETCH_HEAD");
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
const target = await this.getLocalGitUpdateTarget(targetDir);
|
|
1621
|
-
await this.ensureGitRef(targetDir, target.fetchArgs, target.ref);
|
|
90
|
+
await updateGitFromContext(this.context, source, scope);
|
|
1622
91
|
}
|
|
1623
|
-
async
|
|
1624
|
-
|
|
1625
|
-
await this.runCommand("git", fetchArgs, { cwd: targetDir });
|
|
1626
|
-
const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
|
|
1627
|
-
cwd: targetDir,
|
|
1628
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1629
|
-
});
|
|
1630
|
-
const commitRef = `${ref}^{commit}`;
|
|
1631
|
-
const targetHead = await this.runCommandCapture("git", ["rev-parse", commitRef], {
|
|
1632
|
-
cwd: targetDir,
|
|
1633
|
-
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1634
|
-
});
|
|
1635
|
-
if (localHead.trim() === targetHead.trim()) {
|
|
1636
|
-
return;
|
|
1637
|
-
}
|
|
1638
|
-
await this.runCommand("git", ["reset", "--hard", commitRef], { cwd: targetDir });
|
|
1639
|
-
// Clean untracked files (extensions should be pristine)
|
|
1640
|
-
await this.runCommand("git", ["clean", "-fdx"], { cwd: targetDir });
|
|
1641
|
-
const packageJsonPath = join(targetDir, "package.json");
|
|
1642
|
-
if (existsSync(packageJsonPath)) {
|
|
1643
|
-
await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
|
|
1644
|
-
}
|
|
92
|
+
async gitHasAvailableUpdate(installedPath) {
|
|
93
|
+
return gitHasAvailableUpdateFromContext(this.context, installedPath);
|
|
1645
94
|
}
|
|
1646
95
|
async refreshTemporaryGitSource(source, sourceStr) {
|
|
1647
|
-
|
|
1648
|
-
return;
|
|
1649
|
-
}
|
|
1650
|
-
try {
|
|
1651
|
-
await this.withProgress("pull", sourceStr, `Refreshing ${sourceStr}...`, async () => {
|
|
1652
|
-
await this.updateGit(source, "temporary");
|
|
1653
|
-
});
|
|
1654
|
-
}
|
|
1655
|
-
catch {
|
|
1656
|
-
// Keep cached temporary checkout if refresh fails.
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
async removeGit(source, scope) {
|
|
1660
|
-
const targetDir = this.getGitInstallPath(source, scope);
|
|
1661
|
-
if (!existsSync(targetDir))
|
|
1662
|
-
return;
|
|
1663
|
-
rmSync(targetDir, { recursive: true, force: true });
|
|
1664
|
-
this.pruneEmptyGitParents(targetDir, this.getGitInstallRoot(scope));
|
|
1665
|
-
}
|
|
1666
|
-
pruneEmptyGitParents(targetDir, installRoot) {
|
|
1667
|
-
if (!installRoot)
|
|
1668
|
-
return;
|
|
1669
|
-
const resolvedRoot = resolve(installRoot);
|
|
1670
|
-
let current = dirname(targetDir);
|
|
1671
|
-
while (current.startsWith(resolvedRoot) && current !== resolvedRoot) {
|
|
1672
|
-
if (!existsSync(current)) {
|
|
1673
|
-
current = dirname(current);
|
|
1674
|
-
continue;
|
|
1675
|
-
}
|
|
1676
|
-
const entries = readdirSync(current);
|
|
1677
|
-
if (entries.length > 0) {
|
|
1678
|
-
break;
|
|
1679
|
-
}
|
|
1680
|
-
try {
|
|
1681
|
-
rmSync(current, { recursive: true, force: true });
|
|
1682
|
-
}
|
|
1683
|
-
catch {
|
|
1684
|
-
break;
|
|
1685
|
-
}
|
|
1686
|
-
current = dirname(current);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
ensureNpmProject(installRoot) {
|
|
1690
|
-
if (!existsSync(installRoot)) {
|
|
1691
|
-
mkdirSync(installRoot, { recursive: true });
|
|
1692
|
-
}
|
|
1693
|
-
markPathIgnoredByCloudSync(installRoot);
|
|
1694
|
-
this.ensureGitIgnore(installRoot);
|
|
1695
|
-
const packageJsonPath = join(installRoot, "package.json");
|
|
1696
|
-
if (!existsSync(packageJsonPath)) {
|
|
1697
|
-
const pkgJson = { name: `${APP_NAME}-extensions`, private: true };
|
|
1698
|
-
writeFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), "utf-8");
|
|
1699
|
-
}
|
|
96
|
+
await refreshTemporaryGitSourceFromContext(this.context, source, sourceStr);
|
|
1700
97
|
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
mkdirSync(dir, { recursive: true });
|
|
1704
|
-
}
|
|
1705
|
-
const ignorePath = join(dir, ".gitignore");
|
|
1706
|
-
if (!existsSync(ignorePath)) {
|
|
1707
|
-
writeFileSync(ignorePath, "*\n!.gitignore\n", "utf-8");
|
|
1708
|
-
}
|
|
1709
|
-
}
|
|
1710
|
-
getNpmInstallRoot(scope, temporary) {
|
|
1711
|
-
if (temporary) {
|
|
1712
|
-
return this.getTemporaryDir("npm");
|
|
1713
|
-
}
|
|
1714
|
-
if (scope === "project") {
|
|
1715
|
-
return join(this.cwd, CONFIG_DIR_NAME, "npm");
|
|
1716
|
-
}
|
|
1717
|
-
return join(this.agentDir, "npm");
|
|
98
|
+
async getLocalGitUpdateTarget(installedPath) {
|
|
99
|
+
return getLocalGitUpdateTargetFromContext(this.context, installedPath);
|
|
1718
100
|
}
|
|
1719
101
|
getGlobalNpmRoot() {
|
|
1720
|
-
|
|
1721
|
-
const commandKey = [npmCommand.command, ...npmCommand.args].join("\0");
|
|
1722
|
-
if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
|
|
1723
|
-
return this.globalNpmRoot;
|
|
1724
|
-
}
|
|
1725
|
-
if (this.getPackageManagerName() === "bun") {
|
|
1726
|
-
const binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
|
|
1727
|
-
this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
|
|
1728
|
-
}
|
|
1729
|
-
else {
|
|
1730
|
-
this.globalNpmRoot = this.runNpmCommandSync(["root", "-g"]).trim();
|
|
1731
|
-
}
|
|
1732
|
-
this.globalNpmRootCommandKey = commandKey;
|
|
1733
|
-
return this.globalNpmRoot;
|
|
1734
|
-
}
|
|
1735
|
-
getPnpmGlobalPackagePath(packageName) {
|
|
1736
|
-
if (this.getPackageManagerName() !== "pnpm") {
|
|
1737
|
-
return undefined;
|
|
1738
|
-
}
|
|
1739
|
-
const output = this.runNpmCommandSync(["list", "-g", "--depth", "0", "--json"]);
|
|
1740
|
-
const entries = JSON.parse(output);
|
|
1741
|
-
for (const entry of entries) {
|
|
1742
|
-
const path = entry.dependencies?.[packageName]?.path;
|
|
1743
|
-
if (path)
|
|
1744
|
-
return path;
|
|
1745
|
-
}
|
|
1746
|
-
return undefined;
|
|
1747
|
-
}
|
|
1748
|
-
getManagedNpmInstallPath(source, scope) {
|
|
1749
|
-
if (scope === "temporary") {
|
|
1750
|
-
return join(this.getTemporaryDir("npm"), "node_modules", source.name);
|
|
1751
|
-
}
|
|
1752
|
-
if (scope === "project") {
|
|
1753
|
-
return join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
|
|
1754
|
-
}
|
|
1755
|
-
return join(this.agentDir, "npm", "node_modules", source.name);
|
|
1756
|
-
}
|
|
1757
|
-
getLegacyGlobalNpmInstallPath(source) {
|
|
1758
|
-
try {
|
|
1759
|
-
return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
|
|
1760
|
-
}
|
|
1761
|
-
catch {
|
|
1762
|
-
return undefined;
|
|
1763
|
-
}
|
|
102
|
+
return getGlobalNpmRootFromContext(this.context);
|
|
1764
103
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
if (scope !== "user" || existsSync(managedPath)) {
|
|
1768
|
-
return managedPath;
|
|
1769
|
-
}
|
|
1770
|
-
const legacyPath = this.getLegacyGlobalNpmInstallPath(source);
|
|
1771
|
-
return legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;
|
|
1772
|
-
}
|
|
1773
|
-
getGitInstallPath(source, scope) {
|
|
1774
|
-
if (scope === "temporary") {
|
|
1775
|
-
return this.getTemporaryDir(`git-${source.host}`, source.path);
|
|
1776
|
-
}
|
|
1777
|
-
if (scope === "project") {
|
|
1778
|
-
return join(this.cwd, CONFIG_DIR_NAME, "git", source.host, source.path);
|
|
1779
|
-
}
|
|
1780
|
-
return join(this.agentDir, "git", source.host, source.path);
|
|
1781
|
-
}
|
|
1782
|
-
getGitInstallRoot(scope) {
|
|
1783
|
-
if (scope === "temporary") {
|
|
1784
|
-
return undefined;
|
|
1785
|
-
}
|
|
1786
|
-
if (scope === "project") {
|
|
1787
|
-
return join(this.cwd, CONFIG_DIR_NAME, "git");
|
|
1788
|
-
}
|
|
1789
|
-
return join(this.agentDir, "git");
|
|
1790
|
-
}
|
|
1791
|
-
getTemporaryDir(prefix, suffix) {
|
|
1792
|
-
const hash = createHash("sha256")
|
|
1793
|
-
.update(`${prefix}-${suffix ?? ""}`)
|
|
1794
|
-
.digest("hex")
|
|
1795
|
-
.slice(0, 8);
|
|
1796
|
-
return join(tmpdir(), `${APP_NAME}-extensions`, prefix, hash, suffix ?? "");
|
|
1797
|
-
}
|
|
1798
|
-
getBaseDirForScope(scope) {
|
|
1799
|
-
return this.getBaseDirsForScope(scope)[0];
|
|
1800
|
-
}
|
|
1801
|
-
getBaseDirsForScope(scope) {
|
|
1802
|
-
if (scope === "project") {
|
|
1803
|
-
return getProjectConfigDirs(this.cwd);
|
|
1804
|
-
}
|
|
1805
|
-
if (scope === "user") {
|
|
1806
|
-
return this.agentDir === getAgentDir() ? getAgentDirs() : [this.agentDir];
|
|
1807
|
-
}
|
|
1808
|
-
return [this.cwd];
|
|
1809
|
-
}
|
|
1810
|
-
resolvePath(input) {
|
|
1811
|
-
return resolvePath(input, this.cwd, { homeDir: getHomeDir(), trim: true });
|
|
1812
|
-
}
|
|
1813
|
-
resolvePathFromBase(input, baseDir) {
|
|
1814
|
-
return resolvePath(input, baseDir, { homeDir: getHomeDir(), trim: true });
|
|
1815
|
-
}
|
|
1816
|
-
collectPackageResources(packageRoot, accumulator, filter, metadata) {
|
|
1817
|
-
if (filter) {
|
|
1818
|
-
for (const resourceType of RESOURCE_TYPES) {
|
|
1819
|
-
const patterns = filter[resourceType];
|
|
1820
|
-
const target = this.getTargetMap(accumulator, resourceType);
|
|
1821
|
-
if (patterns !== undefined) {
|
|
1822
|
-
this.applyPackageFilter(packageRoot, patterns, resourceType, target, metadata);
|
|
1823
|
-
}
|
|
1824
|
-
else {
|
|
1825
|
-
this.collectDefaultResources(packageRoot, resourceType, target, metadata);
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
return true;
|
|
1829
|
-
}
|
|
1830
|
-
const manifest = this.readPiManifest(packageRoot);
|
|
1831
|
-
if (manifest) {
|
|
1832
|
-
for (const resourceType of RESOURCE_TYPES) {
|
|
1833
|
-
const entries = manifestEntriesForResource(manifest, resourceType);
|
|
1834
|
-
if (entries !== undefined) {
|
|
1835
|
-
this.addManifestEntries(entries, packageRoot, resourceType, this.getTargetMap(accumulator, resourceType), metadata);
|
|
1836
|
-
continue;
|
|
1837
|
-
}
|
|
1838
|
-
if (resourceType === "workflows") {
|
|
1839
|
-
this.collectDefaultResources(packageRoot, resourceType, this.getTargetMap(accumulator, resourceType), metadata);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
return true;
|
|
1843
|
-
}
|
|
1844
|
-
let hasAnyDir = false;
|
|
1845
|
-
for (const resourceType of RESOURCE_TYPES) {
|
|
1846
|
-
for (const dir of conventionDirsForResource(packageRoot, resourceType)) {
|
|
1847
|
-
if (existsSync(dir)) {
|
|
1848
|
-
// Collect all files from the directory (all enabled by default)
|
|
1849
|
-
const files = collectResourceFiles(dir, resourceType);
|
|
1850
|
-
for (const f of files) {
|
|
1851
|
-
this.addResource(this.getTargetMap(accumulator, resourceType), f, metadata, true);
|
|
1852
|
-
}
|
|
1853
|
-
hasAnyDir = true;
|
|
1854
|
-
}
|
|
1855
|
-
}
|
|
1856
|
-
}
|
|
1857
|
-
return hasAnyDir;
|
|
1858
|
-
}
|
|
1859
|
-
collectProjectLocalResources(sourceRoot, accumulator, filter, metadata) {
|
|
1860
|
-
let found = false;
|
|
1861
|
-
const projectMetadata = { ...metadata, origin: "top-level", borrowedProjectLocal: true };
|
|
1862
|
-
const addResources = (resourceType, paths, resourceMetadata, patterns) => {
|
|
1863
|
-
if (paths.length === 0)
|
|
1864
|
-
return;
|
|
1865
|
-
found = true;
|
|
1866
|
-
const target = this.getTargetMap(accumulator, resourceType);
|
|
1867
|
-
let enabledPaths;
|
|
1868
|
-
if (patterns === undefined) {
|
|
1869
|
-
enabledPaths = new Set(paths);
|
|
1870
|
-
}
|
|
1871
|
-
else if (patterns.length === 0) {
|
|
1872
|
-
enabledPaths = new Set();
|
|
1873
|
-
}
|
|
1874
|
-
else {
|
|
1875
|
-
enabledPaths = applyPatterns(paths, patterns, sourceRoot);
|
|
1876
|
-
}
|
|
1877
|
-
for (const path of paths) {
|
|
1878
|
-
this.addResource(target, path, resourceMetadata, enabledPaths.has(path));
|
|
1879
|
-
}
|
|
1880
|
-
};
|
|
1881
|
-
for (const configDir of getProjectConfigDirs(sourceRoot)) {
|
|
1882
|
-
const configMetadata = { ...projectMetadata, baseDir: configDir };
|
|
1883
|
-
addResources("extensions", collectAutoExtensionEntries(join(configDir, "extensions")), configMetadata, filter?.extensions);
|
|
1884
|
-
addResources("skills", collectAutoSkillEntries(join(configDir, "skills"), "pi"), configMetadata, filter?.skills);
|
|
1885
|
-
addResources("prompts", collectAutoPromptEntries(join(configDir, "prompts")), configMetadata, filter?.prompts);
|
|
1886
|
-
addResources("themes", collectAutoThemeEntries(join(configDir, "themes")), configMetadata, filter?.themes);
|
|
1887
|
-
addResources("workflows", collectResourceFiles(join(configDir, "workflows"), "workflows"), configMetadata, filter?.workflows);
|
|
1888
|
-
}
|
|
1889
|
-
const agentsSkillsDir = join(sourceRoot, ".agents", "skills");
|
|
1890
|
-
addResources("skills", collectAutoSkillEntries(agentsSkillsDir, "agents"), { ...projectMetadata, baseDir: dirname(agentsSkillsDir) }, filter?.skills);
|
|
1891
|
-
return found;
|
|
1892
|
-
}
|
|
1893
|
-
collectDefaultResources(packageRoot, resourceType, target, metadata) {
|
|
1894
|
-
const manifest = this.readPiManifest(packageRoot);
|
|
1895
|
-
const entries = manifestEntriesForResource(manifest, resourceType);
|
|
1896
|
-
if (entries !== undefined) {
|
|
1897
|
-
this.addManifestEntries(entries, packageRoot, resourceType, target, metadata);
|
|
1898
|
-
return;
|
|
1899
|
-
}
|
|
1900
|
-
for (const dir of conventionDirsForResource(packageRoot, resourceType)) {
|
|
1901
|
-
if (existsSync(dir)) {
|
|
1902
|
-
// Collect all files from the directory (all enabled by default)
|
|
1903
|
-
const files = collectResourceFiles(dir, resourceType);
|
|
1904
|
-
for (const f of files) {
|
|
1905
|
-
this.addResource(target, f, metadata, true);
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
applyPackageFilter(packageRoot, userPatterns, resourceType, target, metadata) {
|
|
1911
|
-
const { allFiles } = this.collectManifestFiles(packageRoot, resourceType);
|
|
1912
|
-
if (userPatterns.length === 0) {
|
|
1913
|
-
// Empty array explicitly disables all resources of this type
|
|
1914
|
-
for (const f of allFiles) {
|
|
1915
|
-
this.addResource(target, f, metadata, false);
|
|
1916
|
-
}
|
|
1917
|
-
return;
|
|
1918
|
-
}
|
|
1919
|
-
// Apply user patterns
|
|
1920
|
-
const enabledByUser = applyPatterns(allFiles, userPatterns, packageRoot);
|
|
1921
|
-
for (const f of allFiles) {
|
|
1922
|
-
const enabled = enabledByUser.has(f);
|
|
1923
|
-
this.addResource(target, f, metadata, enabled);
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
/**
|
|
1927
|
-
* Collect all files from a package for a resource type, applying manifest patterns.
|
|
1928
|
-
* Returns { allFiles, enabledByManifest } where enabledByManifest is the set of files
|
|
1929
|
-
* that pass the manifest's own patterns.
|
|
1930
|
-
*/
|
|
1931
|
-
collectManifestFiles(packageRoot, resourceType) {
|
|
1932
|
-
const manifest = this.readPiManifest(packageRoot);
|
|
1933
|
-
const entries = manifestEntriesForResource(manifest, resourceType);
|
|
1934
|
-
if (entries && entries.length > 0) {
|
|
1935
|
-
const allFiles = this.collectFilesFromManifestEntries(entries, packageRoot, resourceType);
|
|
1936
|
-
const manifestPatterns = entries.filter(isOverridePattern);
|
|
1937
|
-
const enabledByManifest = manifestPatterns.length > 0 ? applyPatterns(allFiles, manifestPatterns, packageRoot) : new Set(allFiles);
|
|
1938
|
-
return { allFiles: Array.from(enabledByManifest), enabledByManifest };
|
|
1939
|
-
}
|
|
1940
|
-
const allFiles = conventionDirsForResource(packageRoot, resourceType).flatMap((dir) => existsSync(dir) ? collectResourceFiles(dir, resourceType) : []);
|
|
1941
|
-
return { allFiles, enabledByManifest: new Set(allFiles) };
|
|
1942
|
-
}
|
|
1943
|
-
readPiManifest(packageRoot) {
|
|
1944
|
-
const packageJsonPath = join(packageRoot, "package.json");
|
|
1945
|
-
if (!existsSync(packageJsonPath)) {
|
|
1946
|
-
return null;
|
|
1947
|
-
}
|
|
1948
|
-
try {
|
|
1949
|
-
const content = readFileSync(packageJsonPath, "utf-8");
|
|
1950
|
-
const pkg = JSON.parse(content);
|
|
1951
|
-
return getManifestFromPackageJson(pkg);
|
|
1952
|
-
}
|
|
1953
|
-
catch {
|
|
1954
|
-
return null;
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
addManifestEntries(entries, root, resourceType, target, metadata) {
|
|
1958
|
-
if (!entries)
|
|
1959
|
-
return;
|
|
1960
|
-
const allFiles = this.collectFilesFromManifestEntries(entries, root, resourceType);
|
|
1961
|
-
const patterns = entries.filter(isOverridePattern);
|
|
1962
|
-
const enabledPaths = applyPatterns(allFiles, patterns, root);
|
|
1963
|
-
for (const f of allFiles) {
|
|
1964
|
-
if (enabledPaths.has(f)) {
|
|
1965
|
-
this.addResource(target, f, metadata, true);
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
collectFilesFromManifestEntries(entries, root, resourceType) {
|
|
1970
|
-
const sourceEntries = entries.filter((entry) => !isOverridePattern(entry));
|
|
1971
|
-
const resolved = sourceEntries.flatMap((entry) => {
|
|
1972
|
-
if (!hasGlobPattern(entry)) {
|
|
1973
|
-
return [resolve(root, entry)];
|
|
1974
|
-
}
|
|
1975
|
-
return globSync(entry, {
|
|
1976
|
-
cwd: root,
|
|
1977
|
-
absolute: true,
|
|
1978
|
-
dot: false,
|
|
1979
|
-
nodir: false,
|
|
1980
|
-
}).map((match) => resolve(match));
|
|
1981
|
-
});
|
|
1982
|
-
return this.collectFilesFromPaths(resolved, resourceType);
|
|
1983
|
-
}
|
|
1984
|
-
resolveLocalEntries(entries, resourceType, target, metadata, baseDir) {
|
|
1985
|
-
if (entries.length === 0)
|
|
1986
|
-
return;
|
|
1987
|
-
// Collect all files from plain entries (non-pattern entries)
|
|
1988
|
-
const { plain, patterns } = splitPatterns(entries);
|
|
1989
|
-
const resolvedPlain = plain.map((p) => this.resolvePathFromBase(p, baseDir));
|
|
1990
|
-
const allFiles = this.collectFilesFromPaths(resolvedPlain, resourceType);
|
|
1991
|
-
// Determine which files are enabled based on patterns
|
|
1992
|
-
const enabledPaths = applyPatterns(allFiles, patterns, baseDir);
|
|
1993
|
-
// Add all files with their enabled state
|
|
1994
|
-
for (const f of allFiles) {
|
|
1995
|
-
this.addResource(target, f, metadata, enabledPaths.has(f));
|
|
1996
|
-
}
|
|
1997
|
-
}
|
|
1998
|
-
addAutoDiscoveredResources(accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir) {
|
|
1999
|
-
const userMetadata = {
|
|
2000
|
-
source: "auto",
|
|
2001
|
-
scope: "user",
|
|
2002
|
-
origin: "top-level",
|
|
2003
|
-
baseDir: globalBaseDir,
|
|
2004
|
-
};
|
|
2005
|
-
const projectMetadata = {
|
|
2006
|
-
source: "auto",
|
|
2007
|
-
scope: "project",
|
|
2008
|
-
origin: "top-level",
|
|
2009
|
-
baseDir: projectBaseDir,
|
|
2010
|
-
};
|
|
2011
|
-
const userOverrides = {
|
|
2012
|
-
extensions: (globalSettings.extensions ?? []),
|
|
2013
|
-
skills: (globalSettings.skills ?? []),
|
|
2014
|
-
prompts: (globalSettings.prompts ?? []),
|
|
2015
|
-
themes: (globalSettings.themes ?? []),
|
|
2016
|
-
workflows: (globalSettings.workflows ?? []),
|
|
2017
|
-
};
|
|
2018
|
-
const projectOverrides = {
|
|
2019
|
-
extensions: (projectSettings.extensions ?? []),
|
|
2020
|
-
skills: (projectSettings.skills ?? []),
|
|
2021
|
-
prompts: (projectSettings.prompts ?? []),
|
|
2022
|
-
themes: (projectSettings.themes ?? []),
|
|
2023
|
-
workflows: (projectSettings.workflows ?? []),
|
|
2024
|
-
};
|
|
2025
|
-
const userConfigDirs = this.getBaseDirsForScope("user");
|
|
2026
|
-
const projectConfigDirs = this.getBaseDirsForScope("project");
|
|
2027
|
-
const userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills");
|
|
2028
|
-
const projectTrusted = this.settingsManager.isProjectTrusted();
|
|
2029
|
-
const projectAgentsSkillDirs = projectTrusted
|
|
2030
|
-
? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve(dir) !== resolve(userAgentsSkillsDir))
|
|
2031
|
-
: [];
|
|
2032
|
-
const addResources = (resourceType, paths, metadata, overrides, baseDir) => {
|
|
2033
|
-
const target = this.getTargetMap(accumulator, resourceType);
|
|
2034
|
-
for (const path of paths) {
|
|
2035
|
-
const enabled = isEnabledByOverrides(path, overrides, baseDir);
|
|
2036
|
-
this.addResource(target, path, metadata, enabled);
|
|
2037
|
-
}
|
|
2038
|
-
};
|
|
2039
|
-
if (projectTrusted) {
|
|
2040
|
-
for (const configDir of projectConfigDirs) {
|
|
2041
|
-
const metadata = { ...projectMetadata, baseDir: configDir };
|
|
2042
|
-
addResources("extensions", collectAutoExtensionEntries(join(configDir, "extensions")), metadata, projectOverrides.extensions, configDir);
|
|
2043
|
-
addResources("skills", collectAutoSkillEntries(join(configDir, "skills"), "pi"), metadata, projectOverrides.skills, configDir);
|
|
2044
|
-
addResources("prompts", collectAutoPromptEntries(join(configDir, "prompts")), metadata, projectOverrides.prompts, configDir);
|
|
2045
|
-
addResources("themes", collectAutoThemeEntries(join(configDir, "themes")), metadata, projectOverrides.themes, configDir);
|
|
2046
|
-
addResources("workflows", collectResourceFiles(join(configDir, "workflows"), "workflows"), metadata, projectOverrides.workflows, configDir);
|
|
2047
|
-
}
|
|
2048
|
-
}
|
|
2049
|
-
// Project skills from .agents/ (each with its own baseDir)
|
|
2050
|
-
for (const agentsSkillsDir of projectAgentsSkillDirs) {
|
|
2051
|
-
const agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory
|
|
2052
|
-
const agentsMetadata = {
|
|
2053
|
-
...projectMetadata,
|
|
2054
|
-
baseDir: agentsBaseDir,
|
|
2055
|
-
};
|
|
2056
|
-
addResources("skills", collectAutoSkillEntries(agentsSkillsDir, "agents"), agentsMetadata, projectOverrides.skills, agentsBaseDir);
|
|
2057
|
-
}
|
|
2058
|
-
for (const configDir of userConfigDirs) {
|
|
2059
|
-
const metadata = { ...userMetadata, baseDir: configDir };
|
|
2060
|
-
addResources("extensions", collectAutoExtensionEntries(join(configDir, "extensions")), metadata, userOverrides.extensions, configDir);
|
|
2061
|
-
addResources("skills", collectAutoSkillEntries(join(configDir, "skills"), "pi"), metadata, userOverrides.skills, configDir);
|
|
2062
|
-
addResources("prompts", collectAutoPromptEntries(join(configDir, "prompts")), metadata, userOverrides.prompts, configDir);
|
|
2063
|
-
addResources("themes", collectAutoThemeEntries(join(configDir, "themes")), metadata, userOverrides.themes, configDir);
|
|
2064
|
-
addResources("workflows", collectResourceFiles(join(configDir, "workflows"), "workflows"), metadata, userOverrides.workflows, configDir);
|
|
2065
|
-
}
|
|
2066
|
-
// User skills from ~/.agents/ (with its own baseDir)
|
|
2067
|
-
const userAgentsBaseDir = dirname(userAgentsSkillsDir);
|
|
2068
|
-
const userAgentsMetadata = {
|
|
2069
|
-
...userMetadata,
|
|
2070
|
-
baseDir: userAgentsBaseDir,
|
|
2071
|
-
};
|
|
2072
|
-
addResources("skills", collectAutoSkillEntries(userAgentsSkillsDir, "agents"), userAgentsMetadata, userOverrides.skills, userAgentsBaseDir);
|
|
2073
|
-
}
|
|
2074
|
-
collectFilesFromPaths(paths, resourceType) {
|
|
2075
|
-
const files = [];
|
|
2076
|
-
for (const p of paths) {
|
|
2077
|
-
if (!existsSync(p))
|
|
2078
|
-
continue;
|
|
2079
|
-
try {
|
|
2080
|
-
const stats = statSync(p);
|
|
2081
|
-
if (stats.isFile()) {
|
|
2082
|
-
files.push(p);
|
|
2083
|
-
}
|
|
2084
|
-
else if (stats.isDirectory()) {
|
|
2085
|
-
files.push(...collectResourceFiles(p, resourceType));
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
catch {
|
|
2089
|
-
// Ignore errors
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
return files;
|
|
2093
|
-
}
|
|
2094
|
-
getTargetMap(accumulator, resourceType) {
|
|
2095
|
-
switch (resourceType) {
|
|
2096
|
-
case "extensions":
|
|
2097
|
-
return accumulator.extensions;
|
|
2098
|
-
case "skills":
|
|
2099
|
-
return accumulator.skills;
|
|
2100
|
-
case "prompts":
|
|
2101
|
-
return accumulator.prompts;
|
|
2102
|
-
case "themes":
|
|
2103
|
-
return accumulator.themes;
|
|
2104
|
-
case "workflows":
|
|
2105
|
-
return accumulator.workflows;
|
|
2106
|
-
default:
|
|
2107
|
-
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
addResource(map, path, metadata, enabled) {
|
|
2111
|
-
if (!path)
|
|
2112
|
-
return;
|
|
2113
|
-
if (!map.has(path)) {
|
|
2114
|
-
map.set(path, { metadata, enabled });
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
createAccumulator() {
|
|
2118
|
-
return {
|
|
2119
|
-
extensions: new Map(),
|
|
2120
|
-
skills: new Map(),
|
|
2121
|
-
prompts: new Map(),
|
|
2122
|
-
themes: new Map(),
|
|
2123
|
-
workflows: new Map(),
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
2126
|
-
toResolvedPaths(accumulator) {
|
|
2127
|
-
const mapToResolved = (entries) => {
|
|
2128
|
-
const resolved = Array.from(entries.entries()).map(([path, { metadata, enabled }]) => ({
|
|
2129
|
-
path,
|
|
2130
|
-
enabled,
|
|
2131
|
-
metadata,
|
|
2132
|
-
}));
|
|
2133
|
-
resolved.sort((a, b) => resourcePrecedenceRank(a.metadata) - resourcePrecedenceRank(b.metadata));
|
|
2134
|
-
const seen = new Set();
|
|
2135
|
-
return resolved.filter((entry) => {
|
|
2136
|
-
const canonicalPath = canonicalizePath(entry.path);
|
|
2137
|
-
if (seen.has(canonicalPath))
|
|
2138
|
-
return false;
|
|
2139
|
-
seen.add(canonicalPath);
|
|
2140
|
-
return true;
|
|
2141
|
-
});
|
|
2142
|
-
};
|
|
2143
|
-
return {
|
|
2144
|
-
extensions: mapToResolved(accumulator.extensions),
|
|
2145
|
-
skills: mapToResolved(accumulator.skills),
|
|
2146
|
-
prompts: mapToResolved(accumulator.prompts),
|
|
2147
|
-
themes: mapToResolved(accumulator.themes),
|
|
2148
|
-
workflows: mapToResolved(accumulator.workflows),
|
|
2149
|
-
};
|
|
104
|
+
async getLatestNpmVersion(packageSpec, range) {
|
|
105
|
+
return getLatestNpmVersionFromContext(this.context, packageSpec, range);
|
|
2150
106
|
}
|
|
2151
107
|
spawnCommand(command, args, options) {
|
|
2152
108
|
return spawnProcess(command, args, {
|